MATLAB Answers

Arduino UNO, Adafruit Motor Shield, and OWI Robotic Arm Edge -- Issues with Connectivity

2 views (last 30 days)
Sarah Malik
Sarah Malik on 30 Nov 2017
Answered: Arpita Agrawal on 23 Feb 2018
Hello! I'm working on a project where I want to be able to program a robotic arm in Arduino using MatLab. I've used the Arduino UNO with an Adafruit Motor Shield V2.3 and the OWI Robotic Arm Edge kit. The arm is perfectly assembled and works just fine with the standard remote it comes with. All of the connections with the Adafruit Motor Shield are correctly placed, and the shield has been soldered onto pins that connect to the UNO.
I am absolutely positive that the physical and electronic setup is correct, however whenever I try to move the motors attached to the shield, none of them register. Below is my code:
a = arduino('COM3', 'Uno', 'Libraries', 'Adafruit\MotorShieldV2')
shield = addon(a, 'Adafruit\MotorShieldV2')
addrs = scanI2CBus(a,0);
dcm = dcmotor(shield, 1);
dcm.Speed = 0.01;
dcm2 = dcmotor(shield, 2);
dcm2.Speed = 0.2;
dcm3 = dcmotor(shield, 3);
dcm3.Speed = 0.2;
dcm4 = dcmotor(shield, 4);
dcm4.Speed = 0.2;
I believe the issue is with the third line:
addrs = scanI2CBus(a,0);
When I run the code, the shield has the following properties:
shield =
motorshieldv2 with properties:
Pins: A4(SDA), A5(SCL)
I2CAddress: 96 (0x60)
PWMFrequency: 1600 (Hz)
So while the IC2 address should be 0x60, the actual value of the variable addrs is a 2x1 cell instead of 0x60, as the project demands/specifies as seen in the workspace: </matlabcentral/answers/uploaded_files/96809/workspace.png> **I realized the picture doesn't work, so I've attached the screencap at the top.
I'm almost certain that this is the reason behind why none of the motors are being registered, but how can I fix it?
Thanks in advance for any assistance! Please let me know if I need to supply more information.

Answers (1)

Arpita Agrawal
Arpita Agrawal on 23 Feb 2018
The command scanI2CBus returning a 2x1 cell when the Adafruit Motor Shield is connected to Uno is the expected behavior
ans = 2×1 cell array
This command returns 2 device addresses. The address 0x70 is returned because that is the all call address for PCA9685 which is the I2C based PWM controller present on the Adafruit Motor Shield. The device address 0x60 is the default address to use this shield in normal operation mode to controller motors using this shield.

Community Treasure Hunt

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

Start Hunting!