08-10-2023 06:33 AM
Hi,
I want to control a solenoid valve (digital output) using a continuous logical comparison using an analog input (force) and a constant. I am trying to use the structures as an if/else statement but I haven't managed to do this yet. I don't know what I am doing wrong. I am attaching what I have done so far.
Thank you very much.
08-10-2023 06:37 AM - edited 08-10-2023 06:38 AM
Hi dmarios,
@dmarios24 wrote:
I want to control a solenoid valve (digital output) using a continuous logical comparison using an analog input (force) and a constant.
It sounds you need something simple like this:
You can replace the control/indicator by DAQmxRead/Write functions…
08-10-2023 08:04 AM - edited 08-10-2023 08:06 AM
Thank you very much. However, I have a problem with the channels/tasks I need to use. Should I use any specific task for the load cell (analog input) or the solenoid valve (digital output) because it does not actually measure the force continuously in order to get to the logical comparison.
I have attached the code again.
08-10-2023 08:29 AM
08-10-2023 08:37 AM
Hi,
I hope this works.
Thank you.
08-10-2023 08:48 AM - edited 08-10-2023 08:50 AM
Hi dmarios,
@dmarios24 wrote:
I have a problem with the channels/tasks I need to use. Should I use any specific task for the load cell (analog input) or the solenoid valve (digital output) because it does not actually measure the force continuously in order to get to the logical comparison.
You don't need any "specific" task as the CreateVirtualChannel will create a new one when called.
Questions:
I recommend to put a small wait into the loop:
08-10-2023 09:00 AM
I tried the small delay but it didn't change anything. I am using the NI 9237 (cDAQ1Mod2/ai0) for the load cells and the USB6008 for the solenoid valve (with a MOSFET). Even if the force exceeds the threshold, it doesn't trigger the solenoid valve (digital output) (Dev1). I am not sure if I need anything else, like a boolean or if/else structure to activate it. When I try to change the settings in the virtual channel for the load cells, that's when I get errors. If i create an individual task only for the analog input though, everything works okay.
08-10-2023 12:58 PM
Did you probe the output of the AI Read to be sure it goes over 10 Volts and toggles the boolean signal?
If so, can you see the digital signal change state on Port1/Line0?
If so, is that digital signal powerful enough to trigger your MOSFET?
If you are seeing all the correct signals, post a diagram of your circuit. You may need at least a pull-up resistor to get enough current to drive your MOSFET.
08-10-2023 01:27 PM
Hi dmarios,
@dmarios24 wrote:
Even if the force exceeds the threshold, it doesn't trigger the solenoid valve (digital output) (Dev1).
Did you probe the boolean wire to make sure your VI outputs TRUE/FALSE?
What happens when you replace your solenoid valve by a (low power) LED with a suitable current limiting resistor? Does the LED blink when you cross the threshold?
08-11-2023 08:11 AM
Hi,
I thought the load cells are measuring force when I am taking waveforms. But you are saying that in the logical comparison the constant is volts? If that is the case, how can I convert the output of the load cells from units of Newton into volts?
Thank you very much again.