01-02-2017 02:25 PM - edited 01-02-2017 02:26 PM
Hi, I have incremental encoder with 360 pulses per revolution (max. 3000 rpm) attached to NI9401 and analog input connected to NI9212 (both in cDAQ-9172).My goal is measure combustion engine pV diagram. I found this document
(http://www.ni.com/pdf/csma/us/361574a1.pdf) but unfortunately there is no example how to....
How to synchronize and connect Position and Voltage together and get array with Voltage coresponding with each degree (Position 0-360°) ?
Thank for your help and your patience
Solved! Go to Solution.
01-02-2017 02:32 PM
01-02-2017 03:21 PM
Thank you for your advice, GerdW !
I added Start Digital Edge connected to Z channel of encoder (initial value set to -360) to ensure beginning of measurement at 0° and changed to 1D Analog 1Chan 360Samp but now this array contains only 336 items. When I turn encoder slowly with my hand I see every steps form 0 to 360 degrees.
01-02-2017 09:24 PM
Your code for data acquisition is very odd. You want one sample for every Encoder pulse, set up the DAQmx Read for one channel, N (=360) samples, set the sampling rate to 10KHz (which has nothing to do with the rate of encoder pulses). So every degree, you try to acquire 360 points (continuously) which, at 10KHz, will take 360/10000 = 36 ms. So each "bunch of 360 points" comes in at about 1000/36 = (roughly) 30 Hz. What? Weird!
So how many samples do you want for every Encoder pulse? One? Then set Single Sample mode, and every Encoder Pulse, you'll get one sample. Simple. A Simple Sample.
Or do you want something else?
Bob Schor
01-03-2017 01:37 AM - edited 01-03-2017 01:39 AM
Hi Bob,
I use the same approach to measure exactly the same phenomenon:
Setting up an AI DAQmx task by configurating some AI channels with scaling, then setting an external pulse input as sample clock.
The sample rate given to DAQmxTiming IS related to the encoder pulse frequency! It has to be higher than the max expected pulse frequency - otherwise you get DAQmx errors (something in the line of "ADC not ready for new conversion").
This is how I read the samples: I read as many samples as the encoder gives pulse per revolution!
01-03-2017 08:23 AM - edited 01-03-2017 08:31 AM
Hello Bob,
I agree that my code is odd, But I think that 10kHz rate was fine, when I moved encoder axis only by hand (very slow rate).
Help says that if you use an external sample clock (my case), set Rate to maximum expected rate of that clock (it will be 50hz*360pulses =18kHz in real conditions). GerdW says simillar.
Anyway, thank you.
CUA
01-03-2017 08:30 AM
Thank you GerdW,
You give me new hope 🙂
I will tray it this way and let you know...
CUA
01-03-2017 09:29 AM
I stand corrected. I didn't realize you could set the Sample Clock to a Pulse Source that was "semi-random", like an encoder pulse (I've never done this kind of sampling). It's not intuitive (to me) what the Sampling Rate (10KHz) means in a case like this, as you aren't using the A/D's "clock" for triggering samples. I think that is what got me confused ...
Bob Schor
01-03-2017 01:30 PM
Hi Bob,
the sample rate is used to "prepare" the ADC in terms of settling rate, conversion time settings and similar.
DAQmx handles such things internally whenever you set a sampling rate (depending on device capabilities)…
01-08-2017 01:26 PM
Hi GerdW,
I'm still not able to get all encoder posititions while shaft is running at higher speeds (50Hz). I hope that this is causing my problems with analog read.
I tested encoder outupt with logic analyser and all pulses was ok (359 rising edges per revolution) at speed of 50 Hz.
I supposed that my loops are slower that data aquisition, so I used queue to catch all data, but with same results.
Any idea why i'm loosing encoder positions ?
Thank you !
CUA