05-13-2013 02:50 PM
Hi,
I have an NI 9401 module with the NI 9174 chassis and Labview 8.6. I successfully adapted the single pulse output example to produce a single pulse output for every one rotation of my shaft encoder. Can someone help me with a similar example or modification to the code to generate a pulse train with 7 or 8 pulses for every one encoder revolution. SO instead of 1 output pulse for 1 revolution, I want 7 or 8 output pulses for 1 revolution. I have attached the code for the single pulse output example.
05-13-2013 05:12 PM - edited 05-13-2013 05:17 PM
Are you triggering the counter output off of the z index of the encoder? That will work for 1 pulse per revolution, but it isn't going to scale to N pulses per revolution (unless you don't care if the pulses are synchronized with the motion of your encoder).
Is it a quadrature encoder with A and B outputs? If so, you'll need to use the A and/or B signal to increment the count register. When the count register reaches terminal count, it will issue a pulse. You can then use this pulse to reset the count register back to a pre-defined value (and then continue counting, reaching terminal count, issue a pulse, etc.). I find it more intuitive to set the counter to the value you want then count down to 0 (direction is important in this implementation--if you need to change direction while running post back on what behavior you are looking for exactly and we can work from there).
So let's say your encoder is 1000 pulses per revolution. You would reset the value of the count register to (say) 125 (if you want 8 pulses per revolution). Note that you can only specify numbers that divide evenly into the number of ticks per revolution of your encoder (or if you used x4 decoding, the number of ticks per revolution x 4).
The code looks something like this:
Note that you can't specify the pulse width. It will be pretty short--if you want a longer pulse you can use the short pulse to trigger another counter to generate a single pulse of configurable width.
If the pulses need to be at the same position of your encoder every time you run the program, you should use the Z index signal from the encoder as an arm start trigger.
The "initial delay" of 2 in my example is the minimum the hardware supports--so your first pulse will occur 2 encoder ticks after the z index is received if using an arm start trigger (or you could make it the same as your reset value so it will be exactly in phase with the z index rather than having a 2 tick offset, but you'll have a longer delay before your first pulse is issued).
"A High B High" is what works for me on X Series. You might need to try changing this if the propagation delays are significantly different on the 9401/9174 combo (but I'd suspect you shouldn't have to change it).
An alternative implementation uses an edge count task instead of an encoder task, counts only one of the A or B signals, and uses the count reset functionality instead of the z index.
Best Regards,
05-14-2013 11:23 AM
Yes I am triggering using the z index of the encoder of the encoder. I do want the pulses to be synchronized withe the motion of the encoder. i do have a quadrature encoder with A and B output. My encoder is 2500 pulses per revolution. I want to generate 5 evenly spaced pulses per revolution with the intial pulse occuring when the z index is 0. I am trying to capture 5 spots evenly spaced around the circumference of my rotor and I want to capture those 5 spots every revolution so I need 5 pulses per revolution. I currently have one of the 5 spots aligned with the zero or z index of the encoder.
05-14-2013 01:13 PM
I also got the folllowing error message.
Source terminal to be routed could not be found on the device.
Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names.
Property: CI.Encoder.ZInputTerm
Source Device: cDAQ2Mod1
Source Terminal: ctr1Internal Output
Any advice on why I have this error.
05-14-2013 03:13 PM - edited 05-14-2013 03:14 PM
Oh sorry--I pulled that code from something I wrote for an X Series. cDAQ internal counters are named differently. For example: "/cDAQ2/Ctr1InternalOutput" (note the module name isn't used to specify the terminal since the counters are on the chassis backplane).
Best Regards,
05-15-2013 01:42 PM
Hi,
I tried this code and it doesn't work. Do you have any suggestions that would work for the Ni 9401, Ni 9174 combo with a quadrature encoder?
05-15-2013 03:03 PM - edited 05-15-2013 03:03 PM
This concept should work with the 9174/9401 combo if it is configured right (but if for some reason you can't use the counter output to reset itself via the z index terminal you can switch to an edge count task like I mentioned previously). Do you have your A and B connected so that the counter is counting down? What results are you getting?
Best Regards,
06-20-2013 09:22 AM - edited 06-20-2013 09:45 AM
Hi,
I am trying to acquire 1 pulse per rev (z pulse). I am a newbie, and can't figure this out, in this code. Can someone help me out?
I wish to have a boolean LED clicked on every Z pulse is sensed (and off everytime the z pulse is passed). I looked at the example.. but don't know what should be the output terminal?
I tried using MAX, but it isn't detecting the Z pulse, but it works well for A and B.
06-24-2013 07:58 AM
Hey Jango,
I think the first step here is to make sure we can acquire the signal from your Z pulse. It will likely be easiest to try to first acquire the signal in MAX before bringing it into LabVIEW. You will need to set up a counter test panel in MAX--have you already tried this?
What sort of DAQ card are you using to acquire the signals?
Andy C.
Applications Engineering
National Instruments
06-24-2013 09:10 AM - edited 06-24-2013 09:12 AM
Thanks for your reply,
Yes, I have looked it up on MAX, I can see the (in the Counter input tab) edge count increasing one per revolution.
I am using Cdaq 9178 and NI 9411 DI module.
(But on Digital input tab I/O I cannot see the Z LED going on and off. Do you know why?)