Error message reading analog pins on Arduino boards in MATLAB R2023B - "Specified key type does not match the type expected for this container."
6 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Camilo Vicente Gonzalez Pozo
on 18 Oct 2023
Same issue ocurred with me , seems like the 2023b version is not working very well with the MATLAB and Simulink Supported package
0 Comments
MathWorks MATLAB Hardware Team
on 26 Oct 2023
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
0 Comments
See Also
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!