LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequential testing help

Hello,

 

Problem: I am trying to run a sequential test that allows me to open and close relays. I am able to get it working the way I want with flat sequences but as everyone knows those are not really acceptable. I have been searching the forums and I believe I need a state machine or producer/consumer but, I am not sure how to incorporate that into what I have.

 

Requirements:

  • Able to stop the test at any moment
  • scalable (from 1 relay at a time to up to 32)
  • only 1 relay can be active at 1 given time
  • eventually be able to have redundancy in case a relay fails.
  • Total elapsed time the test has been running
  • visual representation that the relay is active
  •  cycle number each relay is on

Equipment:

  • Arduino Uno
  • 5v relay module
  • LabView 2012 (hopefully 2017 in the coming month)
  • Makerhub - LINX to communicate LabView and arduino together

Any help would be greatly appreciated. I have completed a Labview class but it was mostly about what each function can do not how to put them together and create programs other than simple data collection graphs and analysis. Please ask any questions that would help you understand my gibberish.

 

Thanks

0 Kudos
Message 1 of 10
(3,483 Views)

Hi Collin,

 

I believe I need a state machine or producer/consumer but, I am not sure how to incorporate that into what I have.

I also recommend state machines and p/c schemes, they will help you a lot!

But I don't recommend to "incorporate that into what you have"…

 

Start from scratch - after looking at the example implementations coming with LabVIEW: open the "New…" from the file menu to open one of those predefined example projects!

 

To handle more than one relay you should think about better data structures. One way could be an array to hold your relay data with such data put into a type-defined cluster…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,457 Views)

Collin,

 

Although your question has a lot more info than most I see on the forum, I am still not entirely sure what you are trying to achieve.

 

How fast to do you need to cycle the relays?

When you say scale, do you mean more arduinos or just more relays on a single arduino?

 

How vital is it that the LabVIEW display shows each relay state change? Is a total count for each relay acceptable? Would physical LEDs connected such that they light when the relay is energised work?

 

The reason I ask, is that I expect the speed to limited by the serial over USB comms to the Uno, so it might be wiser to abandon Linx and make a state machine on the Uno that is responsible for toggling the relays, you can update some setpoints (variables) on it from LabVIEW when required, such as number of relays / on time / off time and also have it periodically return the count for each relay.

 

It requires more work at the arduino end, but you would have something more reliable in the end.

 

0 Kudos
Message 3 of 10
(3,453 Views)

The times for the relays will be on/off will vary depending on the test we run. ( example 4 seconds on 250 ms off, 500ms on 10 ms off)

 

When I say scale I mean more relays on 1 arduino. (For the tests where we run more then 8 relays I will be using an arduino mega.)

 

The reason I have to know if the relay is on is because of safety reasons. That is why eventually I will have a current sensor at the output of the relay for redundancy. We cant use physical LED's because the tests are in a sealed safety room once the test is running.

 

Thanks

- Collin

 

0 Kudos
Message 4 of 10
(3,426 Views)

Hi,

 

When I guess "incorporate" was a bad word choice. I fully anticipated starting from scratch. What I meant was change what I have into something new that would be faster and had the features I need. But I think you understood.

 

I have been looking around in the examples and not sure which one to mess around with. I have opened some examples and watched  queued message handler and State Machine Test sequencer with highlight exaction to understand what is happening.

 

I'll do some trial and error with the predefined projects. (I didn't know NI had them. Thanks for telling me that, saves a lot of time for simple programs)

 

I was also thinking about doing some type of cluster for structuring a single relay. Can you have indicators and controls in a single array cluster?

 

Thanks 

- Collin

0 Kudos
Message 5 of 10
(3,422 Views)

Hi Collin,

 

Can you have indicators and controls in a single array cluster?

Bad news: No, you can't have controls and indicators within the very same cluster. The whole cluster is either a control or indicator…

Good news: you can set some of your controls in the cluster to "disabled" (in their context menu). This way the user cannot change them at runtime, only "enabled" controls can be edited.

 

As you are a beginner in LabVIEW I don't recommend to mix inputs and outputs in clusters. You easily get into trouble when updating values in the cluster concurrently to user input - on the other hand you might learn about efficient data structures and handling much faster … 😄

 

Recommendation: when you answer to specific messages in your thread you should explicitely name the participant you address (or even note the message number) instead of writing just "you"… 😉

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,416 Views)

Hi GerdW,

(Message 6)

 

I didn't think it was possible to have such an cluster but as you said I am a beginner and I don't know all of the tricks yet. 

 

As I am looking through this State Machine template I am confused on where I open and close the arduino. Do I replace the Data Cluster or start a new data line in the initialize state? Or should it go somewhere else? Once I some of the first steps working like being able to turn on/off 1 relay I believe I can reason out the scaling I need to do.

 

- Collin

0 Kudos
Message 7 of 10
(3,406 Views)

 


and I believe I need a state machine or producer/consumer but, I am not sure how to incorporate that into what I have.

Requirements:

  • Able to stop the test at any moment
  • scalable (from 1 relay at a time to up to 32)
  • only 1 relay can be active at 1 given time

Look at the Queued Message Handler (QMH project template) included with LabVIEW.  Create a single state for each type of "TEST".  You can Queue all of the tests at the start.  If you need to stop/abort test, you can enqueue a "Stop Test" state at the beginning of the Queue (flush the Queue to clear remaining tests.)

 

Since you want to be able to stop at any time, avoid loops.

0 Kudos
Message 8 of 10
(3,392 Views)

Hi Collin,

 

I am confused on where I open and close the arduino.

Sounds like you need two additional states for "open" and "close" the arduino communication…

 

Do I replace the Data Cluster or start a new data line in the initialize state?

Well, in the example project NI wrote "replace" at all items in the data cluster. There might be a reason for… 😄

And additionally you could create more shift registers to hold (and group) even more data!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(3,390 Views)

GerdW,

(message 9)

 

Okay, I think I understand the basics of of the state machine. I am still not sure how to go about the multiple relays. I have yet to try and implement some of the writing to the arduino board. I'll upload what I have so far maybe you or someone could steer me in the right direction. I am also wondering how I get the serial port to not error out right away and instead wait for someone to put in an input before initializing the arduino. 

 

Thanks

- Collin

0 Kudos
Message 10 of 10
(3,379 Views)