LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting an analog input to a digital output

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. 

0 Kudos
Message 1 of 15
(1,627 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(1,623 Views)

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.

0 Kudos
Message 3 of 15
(1,585 Views)

Hi dmarios,

 

I'm preferring LV2019… (File->Save for previous)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(1,568 Views)

Hi,

 

I hope this works.

 

Thank you.

0 Kudos
Message 5 of 15
(1,559 Views)

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:

  • Do you get any errors from your tasks?
  • Does your AI module support this "Force bridge" measurement mode?
  • Which hardware do you use? What is "cDAQ1Mod2" and "dev1"?

 

I recommend to put a small wait into the loop:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(1,549 Views)

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.

0 Kudos
Message 7 of 15
(1,536 Views)

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.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 8 of 15
(1,499 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 15
(1,492 Views)

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.

0 Kudos
Message 10 of 15
(1,446 Views)