Jump to content

Continuously generate pulse train with variable frequency


Recommended Posts

Hi all,

I am trying to use NI-USB 6259(BNC) to send Pulse signal to conduct position control of a servo motor with labview. The position control of servo motor follows these rules:

1. The number of the pulse train determines how many degrees the motor rotate ;( e.g. the angular position of motor)

2. The frequency of pulses determines how fast the motor rotate; (e.g. the speed of motor rotating)

3. The digital determines the direction of rotation of motor e.g. clockwise or counterclockwise)

 

My question comes when I need to generate continuously a finite plus train signal in a period of time. Below is a sample:

 

gallery_53429_117_154830.jpg

 
 

Here is the explanation of this table, the motor keep rotating in clockwise direction during 0~1s. When the time reaches 1s, the motor just complete the rotation of 923 pulse signals. And then the motor starts to rotate in counterclockwise direction during 1s~2s. When the time reaches 2s, the motor just complete the rotation of 3540 pulse signals. So we can see that the rotating speed of motor in 0~1s is different from the speed in 1s~2s. Namely, the frequency of pulse signal in 0~1s is different from the frequency in 1s~2s.

 

I have already use the counter output of DAQmx, it just can generate pulse signal with certain numbers and certain frequency in one time. The attachment is the vi which demonstrates how to generate a finite digital pulse train from a Counter Output Channel and the Frequency, Duty Cycle, Initial Delay, and Idle State are all configurable.

 

How can I generate a series of pulse signal with varying numbers and frequencies during a certain period of time.

 

Thanks a lot!

post-53429-0-25873600-1430135483_thumb.p

Counter - Finite Output.vi

Edited by RaymondTeng
Link to comment

Here's a fun little project I had.  It was to make a frequency sweep on a counter.  This particular project used the BNC connector on a cDAQ-9188, and no c-series cards, just the chassis.  It does this by generating the array of frequency/duty cycle pair.  It will output that frequency and duty cycle for one cycle of the wave, then do the next frequency duty cycle pair.

 

At the time I had no idea that a counter could have a buffer of finite samples.  In my mind this means it has two hardware timers, one for the frequency and duty cycle, the other to handle when the next frequency duty cycle needs to be.  If your counter supports this type of buffered write of N samples this shouldn't be a problem.  You just need to do a decent amount of math to come up with the array of frequency and duty cycles that you want the card to play.

 

https://decibel.ni.com/content/docs/DOC-32352

 

This example isn't meant to be a drop in solution, but just a way of showing that it is possible to control the time at which a new frequency and duty cycle occur.

  • Like 1
Link to comment

Here's a fun little project I had.  It was to make a frequency sweep on a counter.  This particular project used the BNC connector on a cDAQ-9188, and no c-series cards, just the chassis.  It does this by generating the array of frequency/duty cycle pair.  It will output that frequency and duty cycle for one cycle of the wave, then do the next frequency duty cycle pair.

 

At the time I had no idea that a counter could have a buffer of finite samples.  In my mind this means it has two hardware timers, one for the frequency and duty cycle, the other to handle when the next frequency duty cycle needs to be.  If your counter supports this type of buffered write of N samples this shouldn't be a problem.  You just need to do a decent amount of math to come up with the array of frequency and duty cycles that you want the card to play.

 

https://decibel.ni.com/content/docs/DOC-32352

 

This example isn't meant to be a drop in solution, but just a way of showing that it is possible to control the time at which a new frequency and duty cycle occur.

Hi hooovahh ,

 

Thank you for your help!

 

My friend has an NI cDAQ 9178 with NI 9401, NI9215 and NI 9263.  I found that the specification of cDAQ 9178 have below explanation:

gallery_53429_117_154119.jpg

Is that the buffer I can use ?  If I have buffer, does  it mean that I can generate different number of pules at each sample time ?  Because I can use the controlling of number of pules instead of changing frequency.

 

Thank you very much.

Link to comment

If you want to use an analog out for generating you setup you can.  You'll have other limitations that might get in the way making that difficult.  Like the fact that when a new buffer is put down, you'll either need to stop your task, which will drive the output to 0 while for some time, or you can replace the buffer values but you can't resize the buffer.

 

So say you want to generate a waveform that is a PWM at 100hz and 50% duty cycle.  Using an analog out you can generate a single cycle of this wave and tell it to repeat.  But if you want to change to 50hz and 50% duty cycle you'll need to stop the current task, create the new buffer, put that buffer down, and start the new task.  This will mean that for a few milliseconds your output will be 0v.  

 

A counter output gives you more some features that an analog out can't, and an analog out has some features a counter can't.  Some tasks can use either.  Your 9178 chassis has two BNC connectors on the front that can be used as counters.  And my example was designed and the 9188 which I'm guessing has very similar features.  If you can get my example working, then it shouldn't be too difficult to replace the array of frequency duty cycle pairs with your own and have it work.

  • Like 1
Link to comment

If you want to use an analog out for generating you setup you can.  You'll have other limitations that might get in the way making that difficult.  Like the fact that when a new buffer is put down, you'll either need to stop your task, which will drive the output to 0 while for some time, or you can replace the buffer values but you can't resize the buffer.

 

So say you want to generate a waveform that is a PWM at 100hz and 50% duty cycle.  Using an analog out you can generate a single cycle of this wave and tell it to repeat.  But if you want to change to 50hz and 50% duty cycle you'll need to stop the current task, create the new buffer, put that buffer down, and start the new task.  This will mean that for a few milliseconds your output will be 0v.  

 

A counter output gives you more some features that an analog out can't, and an analog out has some features a counter can't.  Some tasks can use either.  Your 9178 chassis has two BNC connectors on the front that can be used as counters.  And my example was designed and the 9188 which I'm guessing has very similar features.  If you can get my example working, then it shouldn't be too difficult to replace the array of frequency duty cycle pairs with your own and have it work.

Thanks for your valuable suggestion!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.