01-09-2020 11:24 AM
Hello,
I am trying to turn on a heater and a fan but when I turn them on, they pulse on and off very quickly. I need to be able to press the button and have them stay on. I'm sure I'm missing something very basic but can someone point me in the right direction? I have attached the code.
Thanks.
01-09-2020 12:24 PM - edited 01-09-2020 12:25 PM
Hi Nic,
on your VI:
Why do you use a local variable of "stop"? Why not use the terminal directly?
Why do you need to delete from array twice to get two elements? Why not use IndexArray just once?
Why do you need to convert to DDT before comparing a value with a constant???
Where do you initialize your DAQmx tasks? Have you examined all those DAQmx example VIs coming with LabVIEW?
Why is there no wait statement in your loop?
@Nic123 wrote:
I am trying to turn on a heater and a fan but when I turn them on, they pulse on and off very quickly. I need to be able to press the button and have them stay on.
Your buttons are set to "switch" mode, so they should stay TRUE when pressed once. When your fans don't rotate continuously then I have to ask: how are the fans connected and powered?
Which DAQ device do you use?
01-09-2020 02:08 PM
I am using a local "stop" because this is a small part of a vi. I am new to LabVIEW so I just found a few functions that "worked". I tried to wire the local stop button directly to the main stop button but it didn't work for some reason. I am modifying a code that someone else wrote years ago and they used "delete from array". It seemed to work so that's why I used that. I got an error when I tried wiring the oil pressure directly so that's why I used the DDT. The tasks are initialized on the front panel. I looked for examples but I must have missed the ones relevant to this. The fan is an oil cooler. The cooler and heater are wired to a NI-9472 module. The oil pressure and temps are wired to a NI-9219 module. I can turn on the oil cooler (fan) and heater from NI Max with no problems so I'm assuming it has to be my code. Thanks for your help.
01-09-2020 02:37 PM
You can't wire an array (left over from the Delete From Array) to a scalar indicator. The reason the DDT worked for you is it turned the array into that "magical" blue DDT wire, and then that can connect and be coerced from the underlying 1-D array it is holding (which you don't know because the blue wires are evil and hide that fact) to a scalar.
If you used Index Array, to get the pressure, you'd be fine.
So we know there are problems with your code.
Can you run Gerd's version okay?
01-09-2020 02:56 PM
Oh ok that makes more sense. Thanks! I was able to run the code Gerd's code but the heater and fan still flash on and off. The entire code probably needs redone but I am just trying to get it to work until I learn more about LabVIEW.
01-09-2020 03:41 PM
I just realized that I had two tasks set for my heater in NI Max. I deleted one of them and it all works like its suppose to. Thanks for your help guys!
01-10-2020 12:53 AM
Hi Nic,
@Nic123 wrote:
The entire code probably needs redone but I am just trying to get it to work until I learn more about LabVIEW.
Usually you should do that the other way around: first learn the (programming) language, then do the work with it…