analog Encoder in Matlab and arduino

12 ビュー (過去 30 日間)
john white
john white 2019 年 1 月 17 日
コメント済み: john white 2019 年 1 月 18 日
Hi
I have an encoder which it's channels are analog require, I mean these channels must be connected to the analog pins of the arduino board so, for reading this encoder I have a problem in Matlab, I know that there is a library for encoders in the Matlab and it should be written as:
a=arduino('com7','uno','Libraries','RotaryEncoder');
encoder=rotaryEncoder(a,'D2','D3',12)
but, as I said my encoder channels must be connected to the analog pins and I write this code:
a=arduino('com7','uno','Libraries','RotaryEncoder');
encoder=rotaryEncoder(a,'A0','A1',12)
and it could not be accepted and it shows an error that these pins are not correct for rotary encoder library
my question is how I could read my analog encoder pulses?

採用された回答

Madhu Govindarajan
Madhu Govindarajan 2019 年 1 月 18 日
Just go ahead and connect the encoder outs to digital pins that you have access to. Then use rotaryEncoder function on those digital pins while spinning the encoder by hand and use readCount to see if it shows results appropriately.
This should work just fine.
  3 件のコメント
john white
john white 2019 年 1 月 18 日
ok thanks a lot

サインインしてコメントする。

その他の回答 (1 件)

Madhu Govindarajan
Madhu Govindarajan 2019 年 1 月 17 日
The rotaryEncoder function is only going to work with quadrature encoders as noted in the documentation.
It seems to me like that analog encoders are usually potentiometers that have some sort of linear relationship between output voltage and degrees moved. You willl need to read the tech specification sheet or do your own testing to understand what the analog output voltages means with regards to the degree of the shaft. You can use the readVoltage function in MATLAB to bring in the voltages and establish the relationship.
Best bet for more help from community users - share existing arduino code to bring in data from this encoder or the spec sheet of the encoder itself.
  9 件のコメント
john white
john white 2019 年 1 月 18 日
I have the data sheet of the encoder, I attached it

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by