Matlab error when reading analogVoltage from Arduino "The first input must contain a multiple of 2 elements to convert from uint8 (8 bits) to uint16 (16 bits)."

14 ビュー (過去 30 日間)
D S
D S 2019 年 4 月 6 日
編集済み: Tim Darrah 2020 年 10 月 25 日
Hello,
I would like to control the position of a linear motor by reading the output from a linear potentiometer connected to it using the Matlab GUI.
I am sending the signal to run the motor until a certain value of voltage is received by Matlab, however when I run the code I get the following error:
"The first input must contain a multiple of 2 elements to convert from uint8 (8 bits) to uint16 (16 bits)."
Does anyone know how to get rid of this error?
my code looks like this
%FORWARD
b = readVoltage(a,'A2')
while b > 0.57
writePWMVoltage(a,'D3',5);
writeDigitalPin(a,'D12',1);
writeDigitalPin(a,'D9',0);
if b < 0.56
break
end
end
  1 件のコメント
Tim Darrah
Tim Darrah 2020 年 10 月 25 日
編集済み: Tim Darrah 2020 年 10 月 25 日
I also started getting this error when calling readVoltage from a function, then I just cleared the arduino object and it worked again. weird.

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

回答 (1 件)

Lipi Vora
Lipi Vora 2019 年 4 月 12 日
Hi, what exact line are you getting the error at? Also, I understand that you are reading voltage from a potentiometer and then writing to the motor pins, is that correct?
  3 件のコメント
Lipi Vora
Lipi Vora 2019 年 4 月 17 日
Could you provide details of the Arduino model that you are using?
Oliver Shorthose
Oliver Shorthose 2020 年 4 月 27 日
Hi, I get this issue as well but using an AnalogInput block on Simulink. When I run the model as it is, it works fine and the model works. However, when I use that model inside another model I get the response '
  • The first input must contain a multiple of 2 elements to convert from uint8 (8 bits) to uint16 (16 bits). '
The Arduino is attached to a pneumatic chamber to be inflated/deflated accordingly. Why might it be that it fails when called from the parent?
Parent use of the model:
The error:

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

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by