LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update Pulse Generation

I am trying to continuously update a pulse generation without having to create a channel every for loop.  I calculate the required frequency and number of steps prior to running the pulse generator and I currently use a for loop to cycle through all of the information.  However, because I am creating a channel and starting the task every loop, my simulation is taking longer than I need it to.  Is there any way to create a channel outside of the for loop and then update the frequency and samples after the previous iteration has completed?

 

I need to cycle through a total of 11 sets of data (11 frequencies corresponding to 11 varying number of samples).  I now index each of these sets separately using a for loop and send each set to the counter independently of the other sets.

 

I have included portions of my code for further viewing, but please let me know if I can be of any help explaining my code.  The first image represents how I calculate the frequencies and number of samples.  This information is later indexed to the for loops.  The second image shows where the pulses begin based on these indexed values.  The third image shows basically the same as the second with the polarity of my stepper motor switched.

 

Thank you in advance,

 

Emily

 

 

Calculate_Freq_And_Steps.pngInhale_Portion.pngExhale_Portion.png

0 Kudos
Message 1 of 11
(5,365 Views)

Since you are doing a finite sample generation, your task would stop after it is done.  Try the following:

 

1. Pull the create channel outside of loop.

2. Don't delete the task or clear the task until all the loop iterations are completed

 

It will look like the following.

 

Create task --> Inside Loop(change parameter, start ask) --> clear task

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 2 of 11
(5,345 Views)

Thank you for the fast response.  I tried to bring the create channel outside of the loop and was unsuccessful.  I then brought the create channel and the timing outside of the loop.  I also put the clear task outside of loop.  I am able to run through the first values from the indexed array, but I receive the following error when trying to move to the second set of values.  I have also included an updated image of my block diagram.  Please let me know if you have other suggestions!

 

Regards,

 

Emily

 

 

UpdatedBD.pngError.png

0 Kudos
Message 3 of 11
(5,337 Views)

You have a wait task at the end.  You should try stop task instead and see what happen.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 4 of 11
(5,327 Views)

One more thing.  Use a shift register instead to pass in your DAQ reference.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 11
(5,324 Views)

I should delete the "Wait" and replace that with a "Stop" or replace the "Clear" with a "Stop"?

 

Also, I am confused about how to use a shift register to pass in my DAQ.  Are you referring to my initial 5V DO or the DAQ Assistant inside the for loop?

Emily
0 Kudos
Message 6 of 11
(5,312 Views)

1. Replace wait with stop.

2. The purple dot that goes into your for loop is your DAQ reference.  Right click on that dot and change it to a shift register instead.  You may have to do that for both input and output.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 7 of 11
(5,309 Views)

Hi Emily,

 

I didn't catch what hardware you are using but our newer STC-3 based devices (63xx, 9174, 9178) are capable of buffered counter outputs which could do what you are describing (see the Finite Implicit Buffered Pulse Train Generation section of the X Series User Manual page 7-35).

 

If you are using a board that supports clocked digital I/O you have another option--use the digital output subsystem to output the desired waveform.  You would need to generate a clock that is a rate that can be divided down to achieve all of your desired frequencies to use with the Digital Output Task.

 

 

Any of our non STC-3 based devices only allow for SW-timed updates to the counter output tasks so there is no way to guarantee an exact number of pulses at each frequency without restarting the counter task.  The third option would be to restart the task as you are currently doing (but you can make some improvements to your code to help this run faster which have already been mentioned--use Stop after the Wait to resolve the error, you still need both functions.  The Shift Register should not be necessary).

 

 

More information about what hardware you are using and what rates are desired would be helpful as well.

 

 

Best Regards,

Message Edited by John P on 03-02-2010 03:07 PM
Message Edited by John P on 03-02-2010 03:08 PM
John Passiak
0 Kudos
Message 8 of 11
(5,295 Views)

Hello John,

 

I am currently using a NI PCI-6025E DAQ.  If possible, I would like to try to get the current code running as I probably wouldnt have time to re-write the code.

 

Let me know if you have any further suggestions.

 

Emily

0 Kudos
Message 9 of 11
(5,291 Views)

The following represents the smallest steps and maximum frequencies that I require. I desire this to complete in 5 seconds, but my timers are saying it actually takes 6.02 seconds.  Could it be possible that with my harware I am actually getting 5 seconds worth of motor movement, but the delay in sending the pulses is accounting for the extra second?

 

Emily

 

 

Number of Steps Frequency (step/sec)
15 153.06
64 447.55
98 717.95
264 1068.83
653 1392.32
177 1187.92
139 942.37
105 724.14
115 547.62
48 376.47
10 119.05
26 268.04
79 637.10
177 949.06
524 1093.95
256 919.21
175 739.96
105 606.94
162 478.58
97 340.95
60 218.18
27 47.29

 

0 Kudos
Message 10 of 11
(5,290 Views)