LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Powering an electromechanical relay with an NI-9481 module.

Alright so I have my state machine and now I'm trying to implement my code to output a digital signal to the relays, but I can't get them to fire with the timing sequence. I went over the tutorials for state machines and checked out a few examples on this forum, but I am still a bit confused as to what I am doing wrong and what my next step should be. Anyone have any pointers?
Download All
0 Kudos
Message 11 of 32
(2,076 Views)
Try tying the boolean array "Relays" to your DAQ.mx Write function. That should fire the desired relays.

Now, you may not want to send the command to the relays every 50ms. If you want to only send the command to turn the relays if the Relays changes, you could put in another Case Stucture to handle that. Link the Relays to another Shift Register, bring it back thru the Timeout Event, and compare the previous status with the current status. If the current status is different than the previous, THEN change the output. Otherwise, don't do anything. That way, the DAQmx Write.vi only happens once for each cycle. And of course, make sure all event cases carry the current value for Relays thru.

Did I clearly confuse you?

B-)
0 Kudos
Message 12 of 32
(2,062 Views)
Alright, I attempted to connect the "relays" boolean array to the DAQ.mx write function with no luck. None of the relays fired at all. So then I attempted to create a new case structure for the relays, but am veyr confused as to what you are suggesting that I do. When you say "link the relays to another shift register," what are you referring to? How do I make sure that the current values carry through?
0 Kudos
Message 13 of 32
(2,054 Views)
Alright, so I've been experimenting with case structures within my code that I am adding to the state machine. I can get relays to turn on for each cycle, but I cannot get them to shut off at the end of each cycle before a new cycle begins and the next relay is fired. Any recommendations?
0 Kudos
Message 14 of 32
(2,030 Views)
Sorry you are having trouble. Without seeing your code, I can't be sure what is wrong (also, I don't have the same hardware you are working with).

However, you said that you "cannot get them to shut off at the end of each cycle before a new cycle begins". If you want the relays to all turn OFF after the cycle is complete, before starting the next cycle, then you can simply "Add Case After" each cycle and include a constant for the boolean array with all FALSE, and that should go to the DAQmx Write.

You will have to either add another item to the RelaySequence ctl (right-click on the Beginning State and select Open Type Def. That will bring up the control editor, where you can then Edit Items) or you can use the Stop or Initialize case that already exists.

I hope that helps!

B-)
0 Kudos
Message 15 of 32
(2,021 Views)

Quick-tip

When adding another state to an enum driven state machine, I will add the new state to the enum BEFORE adding the new case so that the new case will automatically pick-up the proper name.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 16 of 32
(2,019 Views)
Thanks again for the help!. I'm really not sure exactly what I did, but after playing around for a bit I got the relay to function exactly as I need it to. Attached is the vi. Some of the coding may be sloppy, so if you have any suggestions on how it could improve, they would be welcome. Now it's time to work on temperature control functions, so I'm sure I'll be posting again relatively soon!

Nick
Download All
0 Kudos
Message 17 of 32
(2,005 Views)
If its working, that's great. I did see some things that I would do differently.

1) Try to keep all data flow from Left to Right. Having the output connected to something before it makes debugging more difficult.
2) Try to keep all wires visible, without going behind other objects. That also makes following the data flow more challenging.
2) Your comparisons for which relays are ON is more complicated than necessary. I'm attaching a slightly modified version of your code. Please test it to see if it works as you expected.

You said that your board has 4 relays, so originally I had the Relays array contain 4 booleans, but if you are only using 3 of them, then perhaps that is why you were having trouble. I've made the change where you can only control 3 of the 4 relays. Maybe that makes things easier.

Let us know if you need more help.

B-)
0 Kudos
Message 18 of 32
(1,993 Views)
Oops. Forgot to set the Cycle 1 Relays, etc. to only have 3 elements by default. That would cause trouble! That is fixed in this vi.

B-)




Message Edited by LabViewGuruWannabe on 12-05-2007 06:59 PM
0 Kudos
Message 19 of 32
(1,990 Views)
Could you convert those to the labVIEW 8.0 format, or is there a way in which I can do it myself?
0 Kudos
Message 20 of 32
(1,974 Views)