Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How much pulses were sent

Hello

 

I have a small project with a stepper motor wich is controlled by a stepper drive. All I have to send is a pulsed signal to that drive in order to move the motor. In one part of the whole sequence I am programming, I have to move the motor until a load cell reach a certain value. For this I run the stepper motor by sending a pulse  with continouous samples until I reach the desired value on my load cell. Now, I would like to know how many pulses were sent in order to be able to reposition the motor to it's original position. I have tried to use the CO.Count property but it doesn't seems to return a usable value. Maybe I'm not using it the right way.

 

Thanks

0 Kudos
Message 1 of 4
(3,121 Views)

Hi JertoZ,

 

You are right that CO.Count is not what you are looking for.  That attribute actually returns the value of the hardware counter.  The hardware counter counts down and when it reaches 0 (TCs) the output of the counter toggles or pulses depending on what you set up.  Since we know the frequency that the counter is counting down, we can generate a known pulse train.

 

Anyways, the best way to do what you want is to use another counter on your device to count the output your pulse train.  That is, create a Counter Input Edge Count task that counts the output from your pulse train.  After you stop the pulse train, read the value of the CI task and that is how many pulses were generated.  A word of warning, though, that the way you are doing this is software timed.  In other words, when you tell the counter to stop generating pulses is not deterministic.  I'm not sure if this an issue with your application or not.

 

Zach

------
Zach Hindes
NI R&D
0 Kudos
Message 2 of 4
(3,087 Views)

Hi JertoZ,

 

The reason why this property node might not be returning the right values is because this node returns the actual count on the counter register rather than the number of pulses generated. This number will depend on the timebase used by your internal counter. I believe that what you need to do to for your application in order to get the number of pulse generated by your device is to have another counter task to count the edges coming from your signal. To do this, you will need to configure a pulse-train task for your first counter and configure your second counter to count edges. You will also need to wire the output of your first counter to the source of your second counter. I have written a simple example code which shows you how you can do this.

 

I hope this helps.

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 3 of 4
(3,076 Views)

Hello S_Hong

 

Thaks for your help, this is exaclty what I was looking for.

 

Have a nice day

 

JertoZ

0 Kudos
Message 4 of 4
(3,074 Views)