06-12-2014 11:38 AM
Hi all,
I'm trying to build this set up using labview.
I want to generate a PWM signal from labview to drive a solenoid valve. The signal should be driven out of a DAQ (NI USB-6211). The DAQ would be connected to solid-state relays and the relays will be connected to the valve. My primary problem at the moment is to generate a proper PWM signal from labview. Can anyone please help with that?
I've attached two VIs. The one titled submitis a very basic VI that shows a visualization of a square signal and a DAQ Assistant. But I'm not sure if this is working. How do I physically obtain the signal from the DAQ? What settings do I have to manipulate?
The second VI (DAqmx) is somewhat a replica to NI's PWM example, I don't particularly understand how it works and I'm not sure it's even working.
If anyone could offer any help/advice I'd be very grateful. I really need a reliable pwm signal to drive the valve. Thank you very much.
06-12-2014 12:39 PM
The example vi is exactly what you need though it should be in some type of case structure to control it. Best option there is to set up an AE (Action Engine) Best invention ever (after the code that selects an element from an array). It is using Dev1/ctr0 which should be correct unless you happen to have more than one daq. You could also use ctr1 if needed as the 6221 has two counters.
The connection is from the pin-out for ctr0 to drive the ssr. Not sure of the voltage out of the ctr right off though I think it is close to 5vdc. If it's not potent enough, you can use an external voltage and use the ctr as a sinking connection. Look up the pin-out diagram for your daq in MAX. It will be one of the DIO channels. Not sure why the d/c is set to a negative in the example. should be a positive value. If the vi turns it into an absolute then I guess it wouldn't matter but not best practice.
06-12-2014 01:07 PM
Hi Doug,
Thank you for your valuable advice. I'm not sure what an Action Engine is, I tried using the labview search button to find it but unfortunately no results. Can you please tell me where exactly would the AE be placed in the block diagram, I don't really get why would I need a case structure or an AE. When I start this program the DAQ will continuously be generating a PWM signal right until I halt right?
About the duty cycle, I really need a 50% duty cycle, but when I set it to 50, I get this error:
Error -200077 occurred at Property Node DAQmx Channel (arg 3) in DAQmx Create Channel (CO-Pulse Generation-Frequency).vi:1->Daqmx.vi,
It says that:
Requested Value: 50.0
Valid Values Begin with: 119.209297e-9
Valid Values End with: 999.999881e-3
That's why the d/c was set to a strange value of -5. If you can please edit the VI into what you see is best and send it back to me that would be terrific. Thank you very much!!
06-12-2014 01:38 PM
Do a search in the forum for Action Engine. You will get too many results to deal with. Look specifically for Ben's Nugget for Action Engine.
The reason you need this is so you can address the task and change the variables while it's running. You perform the various task functions in different states of the AE. The AE runs in a while loop so that it is available until you stop it.
Duty cycle is a percentage meaning that valid values will be from .01 to .999 (1.0 would be 100% and if you need that, it's not PWM any more)