LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help

Solved!
Go to solution

Can anyone help. I'm creating a VI to control and test a display. My VI will look like the display and when the tester presses the Brightness Up or Down keys, the corresponding keys in the VI will turn on and off. Which I've managed to do. The key presses are send across RS232 and I get a pressed string and a released string. This I've managed OK. (might not be the best way, but it works)

The problem I have is when the Brightness up key is pressed I have to write 'B' followed by a value to the display. The default value will be 64, so firstly I need to store that value, then depending on which key is pressed, that value will need to be incremented or decremented by 1, then sent out.

So if I receive a Brightness up. I need to sent 'B65'. Also I need to store that value for the next key press. Which may be up or down so would result in me sending B66 or B64 depending on which key was pressed.

Secondly the brightness range is 0 - 255, so when my stored value reaches one of those, it should not go any further.

0 Kudos
Message 1 of 7
(2,472 Views)

Sorry forgot to attach the VI

0 Kudos
Message 2 of 7
(2,471 Views)

From How To Ask Questions The Smart Way:

Use meaningful, specific subject headers

On mailing lists, newsgroups or Web forums, the subject header is your golden opportunity to attract qualified experts' attention in around 50 characters or fewer. Don't waste it on babble like "Please help me" (let alone "PLEASE HELP ME!!!!" messages with subjects like that get discarded by reflex). Don't try to impress us with the depth of your anguish; use the space for a super-concise problem description instead.

One good convention for subject headers, used by many tech support organizations, is "object - deviation". The "object" part specifies what thing or group of things is having a problem, and the "deviation" part describes the deviation from expected behavior.

 

Conclusion: "Help" is a meaningless subject.

 

In order to keep track of the brightness level you need a shift register on the while loop, not the for-loop, whose purpose escapes me. When you receive the brightness up/down you increment/decrement the shift register value accordingly, and you can use the In Range and Coerce function to set limits on it. Of course, the real issue is how do you know what brightness level to start at? Is there some command that you can use to determine the current brightness level so you know what value to initialize the shift register to?

Message 3 of 7
(2,461 Views)

Forgot to add this part before the edit time expired: For the code that's used to specify the case item, use integers - don't use floats since that's unnecessary. An alternative is to create an array from the two Booleans and use the Boolen Array to Numeric to get a bit-weighted value.

0 Kudos
Message 4 of 7
(2,457 Views)

The default value of the brightness is 64. This is set in the display and does not get passed out the RS232. It's down to the VI to adjust the brightness, which is controlled by the receiving of brightness up or down commands and the VI sending the new value.

Everytime the power is cycled on the display it will set back to that default brightness (value 64).

 

Sorry about the header, I'll remember for next time. It was just the frustration, I've been on this for a few days and haven't used LabView for months, which I'm very new too.

0 Kudos
Message 5 of 7
(2,451 Views)
Solution
Accepted by NewWorldMan
  • Since there are 5 received bytes, I assume that the three letter codes are followed by crlf. In this case you could just use search array to get the command.
  • There is no need to hide the indicators inside the cases and write to locals in other cases. The indicator needs to be after the case, no locals needed.
  • You only need to write to the serial if the value has changed. Writing an empty string seems useless.
  • Make the value U8, to keep it automatically in the valid range
  • You only need one case structure to handle all possible states
  • ...

Here's a quick draft that might give you some ideas. Modify as needed.

Message 6 of 7
(2,442 Views)

Thank you for that. It looks much better and a more logical way of do it.

0 Kudos
Message 7 of 7
(2,427 Views)