LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control of a DC solenoid

Hello,

 

I am trying to control a 12V DC solenoid using LabVIEW and a microcontroller with trigger i/o and a relay.  The goal is to have the solenoid powered for 2 seconds and then shut off so I've been using a signal with a frequency of 0.5 to accomplish this.  The signal should be output from an analog output channel however I'm getting an error in my VI and don't know where it is coming from.  I think it may have to do with the physical channel input but I'm not sure.  Since the program runs without saying that an error is ocurring, any incite into where the error is generated would be greatly appreciated.  The VI is attached below.  

 

Thanks! 

0 Kudos
Message 1 of 16
(4,689 Views)

There are a bazillion potential errors, it is hard to determine what your error is without more details.  What does your error say?  Does it have an error code number?  How do you know you have an error if "the program runs without saying that an error is ocurring".

 

Your settings on the Express VI don't make sense.  You say you want a 0.5 Hz signal, but your Express VI is configured for 0.001 Hz.

 

Message Edited by Ravens Fan on 04-03-2009 03:03 PM
0 Kudos
Message 2 of 16
(4,686 Views)

As for your error, I can't answer your question directly.  Sorry, I have little experience with the Analog Output.

 

I do have 2 thoughts:

 

1.  Seems like a digital output would be more appropriate for the task.

2. What does the microcontroller do for you?  Why not run the solenoid from LabVIEW?

 

I usually have my setup kind of like:

 

Digital Output --->  5VDC TTL in/ 12VDC out Solid-State-Relay --->12VDC Solenoid

 

If your DIO is "Open Collector", and can sink the amount of current required by your 12VDC Solenoid then you may not even seed the solid-state-relay.  Although, it is probably still good to have the SSR because solenoids have this habit of creating voltage spikes when switched on and off.  Something about V = L di/dt.  Those voltage spikes might kill your DIO if connected directly.  Lots of SSRs out there have built in snubber features (as they are designed to switch solenoids).  The Opto-22 style are my favorite.  Omega has some nice knock-offs called DCO5.

0 Kudos
Message 3 of 16
(4,683 Views)

Hello Ravens Fan,

 

The error code is: -200077 and the hex code is: FFFCF273.  The error explanation window says this:

Error -200077 occurred at Property Node DAQmx Channel (arg 2) in DAQmx Create Channel (AO-Voltage-Basic).vi:1->solenoid.vi

Possible reason(s):

Requested value is not a supported value for this property.

Property: AO.Voltage.Units
You Have Requested:
You Can Select: Volts, From Custom Scale

Channel Name: Dev1/ao0

Task Name: Solenoid Voltage 2

 

I know I have an error because my error function is not equal on either side of the vi.  I input 0 and it outputs the error code; it should be the same if my vi is functioning the way I want it, right?

 

As for the signal I was playing around with things and forgot I had changed it to 0.001.  Thank you for noticing that.  And thanks for your time!

0 Kudos
Message 4 of 16
(4,631 Views)

Hello,

 

1. I'm using an analog output instead of a digital because I was under the impression that an AO will have rgeater accuracy and reliability than a DO and the timing of the solenoid firing must be as exact as possible.  

 

2.  The microcontroller acts as the middle man that will bridge the voltage generation in labview and the relay that will supply power to the solenoid.  We're using a relay because we don't want to fry our NI DAQ or the USB port.  Is that not an issue for us?

 

Thank you!

0 Kudos
Message 5 of 16
(4,628 Views)

leanee,

 

Error caused by constant wired to units terminal of Create Channel.  What DAQmx hardware are you using? 

 

 

 

 

 

 

 

Message Edited by Wayne.C on 04-06-2009 02:24 PM
0 Kudos
Message 6 of 16
(4,620 Views)

Thank you Wayne.C!

 

Do I also not need to create a global channel?  I want to generate a 5 volt signal that lasts for 2 seconds that comes out of the AO/0 port of my USB6008.  Do I just need the data into the DAQmx create channel to be a physical channel (the AO/0 line?) and can remove the global channel?  Could you please explain why the answer is what it is?

 

Thank you 

0 Kudos
Message 7 of 16
(4,609 Views)

Leannee,

 

Global Virtual Channels and Tasks created in MAX are an easy way to get going with DAQmx hardware.  The downside is that when your application is deployed to another PC, the DAQmx settings must be exported from the development machine and then imported on the target machine.  I personally prefer to define all my tasks and channels in my vi's.  I believe this also makes my code easier to troubleshoot and maintain.  That means a bit more work on the front end but can make deploying an application much easier. 

 

I would suggest you do a couple of things.  One is read the section in the DAQmx manual that describes the Task State Model.  The next is look at the DAQmx examples that ship with LV. 

 

Since the USB6008 does not have a counter that can be used to generate a pulse, using a AO will be the most accurate method of controlling the on time.  Is this pulse output meant to be a steady stream of pulses that happen at regular intervals or something that happens every once in a while?

0 Kudos
Message 8 of 16
(4,592 Views)

leanee,

 

Spent a little time trying to come up with an example vi to demonstrate setting everything up from scratch.  Realized that the USB6008 does not have an internal timebase.  This means that when outputing a waveform, the sampling rate is software timed.  This is a potential problem if you are looking for a very accurate pulsewidth.  How accurate do you need to be?

0 Kudos
Message 9 of 16
(4,563 Views)
You are probably right about the timing, unless your hardware supports buffered digital output.  Otherwise your output timing is more dependent on your computer than your DAQ hardware.  I'm still unclear why you need the microcontroller to bridge the voltage between your DAQ device and the relay driving the solenoid.  If it works for you then, :).
0 Kudos
Message 10 of 16
(4,550 Views)