Error message reading analog pins on Arduino boards in MATLAB R2023B - "Specified key type does not match the type expected for this container."

7 次查看(过去 30 天)
I have an Arduino Leonardo I'm trying to use with MATLAB R2023B. It seems to work fine with R2022B. See details below.
Is there an additional configuration step I'm missing with the newer MATLAB version?
Boards both seem to configure correctly and pass communication tests when using the Arduino Explorer GUI. Hardware support package installation seemed to go fine with no errors reported.
I'm running Windows 11 and connectng to the board via USB. I get the same errors whether I'm connected through a USB hub, or connected directly to a USB port on the computer motherboard.
When I'm using configurePin and readVoltage for analog pins using an Arduino Leonardo board I'm getting the following errors in R2023B:
"specified Key type does not exist" and "the first input must contain a multiple of 2 elements.." See code snippet below from R2023 command window.
>> a = arduino
Updating server code on board Leonardo (COM7). This may take a few minutes.
Arduino Leonardo detected.
This device is ready for use with MATLAB Support Package for Arduino Hardware. Get started with examples and other documentation.
To use this device with Simulink, install Simulink Support Package for Arduino Hardware.
a =
arduino with properties:
Port: 'COM7'
Board: 'Leonardo'
AvailablePins: {'D0-D13', 'A0-A5'}
AvailableDigitalPins: {'D0-D13', 'A0-A5'}
AvailablePWMPins: {'D3', 'D5-D6', 'D9-D11', 'D13'}
AvailableAnalogPins: {'A0-A5', 'D4', 'D6', 'D8-D10', 'D12'}
AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [1]
Libraries: {}
Show all properties
>> configurePin (a,'A0', 'AnalogInput')
Specified key type does not match the type expected for this container.
>> configurePin (a,'A0')
ans =
'AnalogInput'
>> readVoltage (a,'A0')
The first input must contain a multiple of 2 elements to convert from uint8 (8 bits) to uint16 (16 bits).
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2380103 (R2023b) Update 1
MATLAB License Number: 40640276
Operating System: Microsoft Windows 11 Pro Version 10.0 (Build 22621)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 23.2 (R2023b)
When performing these same commands in Matlab R2022B, no errors are returned and the output matches the examples provided in the Matlab support documentation. See code snippet from R2022B command window:
>> a=arduino
Updating server code on board Leonardo (COM7). This may take a few minutes.
Arduino Leonardo detected.
This device is ready for use with MATLAB Support Package for Arduino Hardware. Get started with examples and other documentation.
To use this device with Simulink, install Simulink Support Package for Arduino Hardware.
a =
arduino with properties:
Port: 'COM7'
Board: 'Leonardo'
AvailablePins: {'D0-D13', 'A0-A5'}
AvailableDigitalPins: {'D0-D13', 'A0-A5'}
AvailablePWMPins: {'D3', 'D5-D6', 'D9-D11', 'D13'}
AvailableAnalogPins: {'A0-A5', 'D4', 'D6', 'D8-D10', 'D12'}
AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [1]
Libraries: {}
Show all properties
>> readVoltage (a,'A0')
ans =
3.0156
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.13.0.2320565 (R2022b) Update 6
MATLAB License Number: 40640276
Operating System: Microsoft Windows 11 Pro Version 10.0 (Build 22621)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.13 (R2022b)

回答(2 个)

Camilo Vicente Gonzalez Pozo
Same issue ocurred with me , seems like the 2023b version is not working very well with the MATLAB and Simulink Supported package

MathWorks MATLAB Hardware Team
Hello,
Thank you for contacting us. We apologize for the inconvenience you are experiencing.
To resolve this issue, we kindly request that you reach out to our technical support team. They will be able to provide you with the necessary assistance.
https://www.mathworks.com/support/contact_us.html
Thanks,
MATLAB Hardware Team
MathWorks

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by