Open Arduino

Enter Your Project for a chance to win a grand prize for the most innovative use of Arduino or a $200 shopping cart! The Birthday Special: Arduino Projects for Arduino Day!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Arduino in Test Instrumentation

 

To celebrate Project 14's birthday, I made a programmable switch with an Arduino UNO.

This final post shows a complete LabVIEW example with the instrument.

 

The LabView Example

 

This example runs a continuous loop that switches the relays on and off. It also shows the status on a dashboard.

You can set the speed of the switching, and can choose which of the two relays is switched.

The LabVIEW driver, including this example, is available on the first blog post of this series.

 

 

The settings can be changed at runtime. When you enter a new switch delay value, it becomes active immediately.

The same for the Channel selection. You can real-time switch between relay 1 and 2.

The LED shows the status that the Arduino reports for the selected channel.

Pushing the STOP button exits the loop and lets the workflow execute the closing sequence, where resources are cleaned up.

 

The LabVIEW process

 

You'll recognise the controls of the dashboard above as inputs and outputs in the workflow. You'll also see the driver blocks made for this instrument.

 

 

The left side shows the initialisation parameters for the device, such as COM port, do you want to reset the status at the start, how long the device should wait by default between sending a SCPI command and reading the reply from the Arduino.

Then the initialize block is called. It establishes the serial communication and, because we asked it, resets the status.

 

The remainder is a loop, with 3 activities on each run: set the status, read and show the status, wait for a given time.

The loop runs until the STOP button is pushed or an error happens (e.g. the device stops replying, USB cable removed).

The loop counter is used to toggle the status between ON and OFF. If the counter is even, we turn the switch OFF. If it's uneven, the switch is set on.

The above construct is used for this. It's a modulus 2 calculation. i is the loop counter and given as the numerator, and the constant 2 is given as the denominator.

The remainder is then compared for equality to 1.  The result of that comparison is a boolean, true when the remainder is 1, else false.

 

Because the Channel, Switch Delay and LED controls are inside the loop, they are polled and set at each loop cycle.

That's why you can change the channel and switching speed at runtime, and the status change is reflected at each cycle.

This is different than the controls for the initial setup. They are placed outside of the loop. They are read once when the flow is started.

 

When the STOP button is clicked, the loop exits. The closing part of the flow is now run.

I placed a reset block to take care that both relays are switched off. Then the communication link with the Arduino is closed.

 

And with that, I'm also closing this blog series. Thank you for reading.

 

Related Blog
Arduino in Test Instrumentation - Intro: SCPI Programmable Switch
Arduino in Test Instrumentation - Part 1: SCPI Lib
Arduino in Test Instrumentation - Part 2: Firmware
Arduino in Test Instrumentation - Part 3a: LabVIEW Driver Intitialisation Block
Arduino in Test Instrumentation - Part 3b: LabVIEW Driver Switch Control Block
Arduino in Test Instrumentation - Part 3c: LabVIEW Driver Read Status Block
Arduino in Test Instrumentation - Outro: LabVIEW Example