Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW, Arduino, & SainSmart 16 Relay Controls & Error Handling question...

I've written a small VI that will control the SainSmart 16 Relay Module with a Arduino Mega 2650.  It's pretty basic, but it will switch the relays.  My question is how to handle errors in the VI.  Do they need to just be daisy chained or connected in some other way?  I have attached the VI for reference... If you have the hardware, open the "SainSmart16RelayExample.VI" first, this will give you a frontend to work with... the Arduino Relay Controls assumes you're using a Mega 2650 so the channels start at 22 and go through 37, these will need to be adjusted if you're using a different board.

 

Thanks!

Chad

Download All
Message 1 of 6
(6,298 Views)

Chad,

 

I do not have the hardware to test this VI, but I would recommend using the Merge Errors function to combine all of these error wires into a single error handler. This is common practice for LabVIEW VI's, so I would imagine it would work for your Arduino control program.

0 Kudos
Message 2 of 6
(6,272 Views)

Karl,

 

Thank you for the reply.  I'll give it a shot and see what happens.

 

Chad

0 Kudos
Message 3 of 6
(6,261 Views)

I had some time to refactor your code a bit. I don't have a mega so I didn't have a chance to test it.

A couple of comments:

Don't use the merge or split signals nodes as the convert to the dynamic data type, they are there for express vi's and hide the underlying data type. 

Since the communication bus between the arduino and the computer with LabVIEW is serial there is no advantage to place the write digital vi's in parallel.

 

 

Hope this helps

Now Using LabVIEW 2019SP1 and TestStand 2019
Download All
0 Kudos
Message 4 of 6
(6,258 Views)

Hello guys,

I found your example and tested with a mega2560 board and 4 relays and it works, but not quite as expected.

What I mean by this: when running the application I get all the channels active(leds are on) without even pressing any button to give a command, so I have all relays switched ON) 

Could someone explain what I need to modify inside the code to have all channels used in the code firstly OFF and only when pressing the button to switch ON. 

 

0 Kudos
Message 5 of 6
(6,098 Views)

Is the logic simply reversed? By this I mean, if all of the switches show as False on the front panel, the relays are on, and if the switches are True, the relays are off? If so, I would simply add a Boolean Not function to the output of each front panel control.

0 Kudos
Message 6 of 6
(6,064 Views)