Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Square wave generation with variable On and OFF time

I am trying to develop a VI for controlling the pump actuation. I am not sure if you have seen it, but the task is to generate a square waveform with both positive and negative values.
I have attached a plot of voltage versus time for your reference (cycle.jpg)
 
Here is how I plan to generate the waveform. I am trying to use the "Gen voltage update.vi" to generate the voltage signal.
And then a logic to generate the desired voltage level depending on what time of cycle we are on.
I have modified this VI by running it continuously using a 'While loop'.
(This VI is an example in LabVIEW example finder.--> [hardware input/output/ gen voltage update.vi])

Right now, I dont have a facility to see if output voltage can be changed when the slider in VI is adjusted to a different value at run time.

 
Also, here is a MATLAB code I came up with to decide the value of signal

%Assumptions:
%Amplitude A : 5V
%ON time t : 10ms
%OFF time t: 10 ms

t_on=10;
t_off=10;
ct=2*t_on+2*t_off;           %cycle time
for t=0:100
       rem=mod(t,ct)
        if(rem<t_on)
            A=5;
        end
        if (rem>=t_on & rem<t_off)
            A=0;
        end
        if (rem>=(t_on+t_off) & rem<(2*t_on+t_off))
           A=-5;
        end
        if (rem>=(2*t_on+t_off))
            A=0;
        end
        plot(t,A,'o');
        hold on;
end 
 
I am looking for some direction to develop the logic to generate this in LabVIEW.
Any other methods to approach this problem are welcome.
I am eagerly waiting for some useful response(s).

 


Regards,

 

Anupam

Download All
0 Kudos
Message 1 of 17
(5,871 Views)

Hi Anupam,

 

From looking at your post on the other thread, I noticed that you're using a 6216.  This board has Clocked AO lines which I would highly recommend using instead of SW-timing.

 

If you set the clock to 1 kHz, then every sample in your array would correspond to 1 ms of time.  There are many ways to generate such an array in LabVIEW--here is the one that I came up with:

 

21039i0C7D24F79AD7B958         21041iB1598557BE1E7308

 


I hope this helps!

 

 

Best Regards,

John Passiak
Message 2 of 17
(5,854 Views)

Thanks John,

 

That was a great help.

 

I am trying to hook up a NI 6216 board to run this VI.

You think that should work right? Let me know and I will place all the orders immediately.

 

Also, I did set up a simulated 6216 device to check the output. It is not working though.

 

Regards,

 

Anupam

0 Kudos
Message 3 of 17
(5,819 Views)

Hi Anupam,

 

Yes, this should work with the 6216 since the board has buffered Analog Output.  The one question that you'll need to ask is how much current do you need to source/sink?  The 6216 AO lines can handle up to 2 mA.

 

 

What isn't working with the simulated device?  Did you make sure the device name (e.g. "Dev1/ao0") matches with the device name of your simulated 6216 (can be checked in Measurement and Automation Explorer)?  Are you receiving a specific error?

 

I'm running the example with a simulated 6216 right now with no problems.  The program is not set up to allow you to adjust the voltage and on/off time on-the-fly but it could be modified to do so (see Continuously Generate Voltage Non-Regeneration example).

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 17
(5,808 Views)

Hey John,

 

I need current much more than that. Anything from 50 to 300 mA. Can you suggets some other board or technique to go around this constraint.

 

Regarding simulated device, Yes, the example is able to run without any problem. Also, the ports, 'Dev1/ao0' does match. I also do not need facility to change magnitude on the fly.

However, I dont know how to check the output generated by example on the test panel of the simulated device.

 

Regards,

 

Anupam.

0 Kudos
Message 5 of 17
(5,802 Views)

Hi Anupam,

 

A unity gain buffer should do the trick with the AO code mentioned previously (you will need to shop around for an op-amp with the slew rate and current drive that you require).

 

In general the Analog Output lines on NI DAQ boards are intended to connect to high-impedance loads and don't source or sink much current.  Digital lines usually have much higher current specs, but typically range from 0-5 Volts (TTL logic levels) and are either ON or OFF.

 

There are multiple solutions to this, but without spending too much on unnecessary hardware your best bet is to implement some sort of low-cost external circuit to provide enough current.

 

 

 

Unfortunately there is no way to check the output generated by the example on the test panel of the simulated device.  This idea has actually been proposed on our Idea Exchange, feel free to vote it up if this is a feature you would like NI to consider it for a future release.  For now you can simply look at the waveform graph to get a good idea of what will be generated.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 17
(5,795 Views)

Hey John,

 

Thanks for your patience with this project.

 

I am planning to use a H type bridge instead of an unity gain buffer beacuse, in this way I minimise the external ciruitry to the minimum.

 

According to the control_signal VI,

I have modified it a little bit to generate two control signals instead of one.

 

I have attached the screen shot of the VI. This VI will be further modified. Instead of the negative pulse, that too will be positive and will have appropriate timing delays. Right now they are all manually set to zero.

 

Can you please have a look at the circuit and suggest me if it is must to have NI 6216 or can I use NI 9263 instead.

Also to measure the current, about 7.5 V and 500 mA, will NI 9227 work efficiently or do I have to approach this problem in a diferent manner.

 

Regards,

 

Anupam

 

Download All
0 Kudos
Message 7 of 17
(5,746 Views)

Hi Anupam,

 

The requirements to control the H Bridge are much simpler than to control the pump directly.  It looks like the control signal uses TTL voltage threshholds, so you should be able to use any clocked Analog Output or Digital Output that meets these requirements.  For AO this could be the 9263 or the 6216 that you presumably already have.  You could also use the 9401 or 9402 digital C-Series modules if desired (assuming you are using a Compact DAQ Chassis).

 

The VI that you have attached won't quite work, you can only have a single HW-Timed AO task for a given device.  Instead of breaking the code up into two tasks, you should instead use the Multi-Channel instance of DAQmx Write and build the data into a 2D array.

 

 

As far as the current measurement goes, is this a current source or a voltage source?  The 9227 is designed to measure current sources and uses a shunt resistor to perform the measurement.  To say your circuit always outputs 7.5 V and 500 mA is misleading since one of these values will change depending on what circuit you are connected to.

 

 

Best Regards,

John Passiak
0 Kudos
Message 8 of 17
(5,740 Views)

John,

 

So, if I use NI 9401, do I still need to use DAQmx operations or Can I split the output signal from logic and make it go to waveform and one of the channel on 9401

and so it similarly with other waveform and other channel ?

 

With 9227, yes, Maximum current is 500 mA and maximum current is 7.5 V, not togehter . Max power however is 1W

 

So I can I use 9227 directly like an ammeter or I need any modifications.

 


@John P wrote:

Hi Anupam,

 

The requirements to control the H Bridge are much simpler than to control the pump directly.  It looks like the control signal uses TTL voltage threshholds, so you should be able to use any clocked Analog Output or Digital Output that meets these requirements.  For AO this could be the 9263 or the 6216 that you presumably already have.  You could also use the 9401 or 9402 digital C-Series modules if desired (assuming you are using a Compact DAQ Chassis).

 

The VI that you have attached won't quite work, you can only have a single HW-Timed AO task for a given device.  Instead of breaking the code up into two tasks, you should instead use the Multi-Channel instance of DAQmx Write and build the data into a 2D array.

 

 

As far as the current measurement goes, is this a current source or a voltage source?  The 9227 is designed to measure current sources and uses a shunt resistor to perform the measurement.  To say your circuit always outputs 7.5 V and 500 mA is misleading since one of these values will change depending on what circuit you are connected to.

 

 

Best Regards,


 

Thanks,

 

Anupam


@John P wrote:

Hi Anupam,

 


@John P wrote:

Hi Anupam,

 

The requirements to control the H Bridge are much simpler than to control the pump directly.  It looks like the control signal uses TTL voltage threshholds, so you should be able to use any clocked Analog Output or Digital Output that meets these requirements.  For AO this could be the 9263 or the 6216 that you presumably already have.  You could also use the 9401 or 9402 digital C-Series modules if desired (assuming you are using a Compact DAQ Chassis).

 

The VI that you have attached won't quite work, you can only have a single HW-Timed AO task for a given device.  Instead of breaking the code up into two tasks, you should instead use the Multi-Channel instance of DAQmx Write and build the data into a 2D array.

 

 

As far as the current measurement goes, is this a current source or a voltage source?  The 9227 is designed to measure current sources and uses a shunt resistor to perform the measurement.  To say your circuit always outputs 7.5 V and 500 mA is misleading since one of these values will change depending on what circuit you are connected to.

 

 

Best Regards,


 

The requirements to control the H Bridge are much simpler than to control the pump directly.  It looks like the control signal uses TTL voltage threshholds, so you should be able to use any clocked Analog Output or Digital Output that meets these requirements.  For AO this could be the 9263 or the 6216 that you presumably already have.  You could also use the 9401 or 9402 digital C-Series modules if desired (assuming you are using a Compact DAQ Chassis).

 

The VI that you have attached won't quite work, you can only have a single HW-Timed AO task for a given device.  Instead of breaking the code up into two tasks, you should instead use the Multi-Channel instance of DAQmx Write and build the data into a 2D array.

 

 

As far as the current measurement goes, is this a current source or a voltage source?  The 9227 is designed to measure current sources and uses a shunt resistor to perform the measurement.  To say your circuit always outputs 7.5 V and 500 mA is misleading since one of these values will change depending on what circuit you are connected to.

 

 

Best Regards,


 

0 Kudos
Message 9 of 17
(5,734 Views)

The 9401 uses DAQmx.  You would use two lines on the 9401 to control the two inputs of your H Bridge.  Both lines need to be written to in the same HW-timed task.  Which cDAQ chassis are you using?

 

The 9227 is similar to most digital ammeters, in that it uses a shunt resistor to convert current to voltage, and measures the voltage directly with an ADC.  The 9227 is specced to measure 5A rms maximum, so your 500 mA shouldn't be a problem.  The input impedance of this device is 12 mOhm.

 

 

Best Regards,

John Passiak
0 Kudos
Message 10 of 17
(5,731 Views)