From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measure

cancel
Showing results for 
Search instead for 
Did you mean: 

How I can get and plot the incremental encoder outputs A, B, and Z in MATLAB?

Hello,

 

I am working in MATLAB 2012a and using E60H incremental encoder (see Attached file 'E60HCatalog') with NI 9411 module

 

so I am acquiring data from the encoder and I could plot it. the plot is on the attached file (see Encoder_output) using this code:

 

daq.getVendors();   
daq.getDevices();
s = daq.createSession('ni');
s.Rate=16000;
s.DurationInSeconds = 1.0
s.addAnalogInputChannel('cDAQ1Mod2','ai0','Voltage'); % NI 9234 vibration signal_1
s.addAnalogInputChannel('cDAQ1Mod2','ai1','Voltage'); % NI 9234 vibration signal_2
s.addCounterInputChannel('cDAQ1Mod1','ctr0','Position');  % NI 9411 Speed signal
[data,time] = s.startForeground();
%[data1,time1] = s.startForeground();
figure(1);plot(time) % ploting time
figure(2);plot(data(:,1)) % ploting vibration signal_1
figure(3);plot(data(:,2)) % ploting vibration signal_2
figure(4); plot(data(:,1)); hold on; plot(data(:,2),'r') % ploting both vibration signal_1 and vibration signal_2
figure(5);plot(data(:,3)) % ploting Speed signal

 

1- Really I am not sure what this output represent? (is it output A , B or Z).

and why the pules are increasing with the time and looking as stairs?

 

2- the most important is that I want to get and plot all encoder outputs, A, B, and Z. so how can I get and plot all of them?

 

3- how I can find the speed?

 

I really appreciate your help

 

thank you

Download All
0 Kudos
Message 1 of 1
(5,950 Views)