LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial data to and from Arduino

Hi,

I have built a system in which an Arduino is connected to 40 relays. In LabView I have 40 Boolean switches which sent a certain message to the Arduino when they are switched to open/close the relay.

 

This all works but now I want Feedback from the relays back to my LabView. 

Every 5 seconds my Arduino prints in the serial monitor 1100...101 (1 relay ON, 0 relay OFF). 

Is it possible to create a system which receives this data and is connected to 40 leds so that when it receives 1 in the first byte, the first led illuminates and 0 in the second byte, the second led remains off?

 

Below I have placed a picture of what I currently have. 

The problem here is that Read buffer 3 sometimes works for the first 20 - 30 seconds and then it stops or only reacts when I flip a switch. The data received almost always has a big delay on it. 

The goal is to receive the message on the serial monitor everytime it gets posted in LabView and according to the message certain leds should light up.

 

Thanks in Advance 

0 Kudos
Message 1 of 3
(105 Views)

We can't really debug pictures, but your loop will only spin if an event occurs. (There is no event timeout wired).

 

Your code is way overcomplicated. Why not create a cluster of all the booleans, then check which one changed (one event instead of 40!). Your FOR loop that coverts a string to a byte array and then to an array of strings is pure Rube Goldberg.

 

RG.png

 

You could place the reading part inside the timeout case, for example. In your event cases, there is way too much duplicate code. If two cases of a case structure only differ by a string, the rest belongs outside the case structure.

 

Feel free to attach your VI (use "save fore previous", 2020 or below). For example we currently cannot tell what the display format of your string constants are or what's in any of the other cases.

 

 

 

0 Kudos
Message 2 of 3
(84 Views)

@altenbach wrote:

Your code is way overcomplicated. Why not create a cluster of all the booleans, then check which one changed (one event instead of 40!).


Here's how that could look like

 

relays.png

0 Kudos
Message 3 of 3
(62 Views)