Go Down

Topic: Arduino Uno I2C with (motorshield) in Matlab (Read 1 time) previous topic - next topic



Little background:
I am working on a project to run 2 stepper motors simultaneously using Matlab. I was able to run the 2 motors in Matlab using an Uno and a motorshield (after uploading the srv.pde. The srv.pde is required for the shield to work in my case.), but I wasn't able to run the motors simultaneously.

I tried I2C with an another Uno and using the Wire library (http://arduino.cc/en/Tutorial/MasterWriter) in addition to the AccelStepper library, I was able to run the motors simultaneously using the Arduino 1.0.2 software.

My question is:
Is there a way of adding the Wire and AccelStepper libraries to the srv.pde so that I can use I2C and AccelStepper in Matlab? Is there another way of running 2 motors simultaneously using Matlab?

Thank you.


after uploading the srv.pde

Which you aren't going to show us. Fine. Be that way.

Is there another way of running 2 motors simultaneously using Matlab?

Could be. I can't see what code you are using, though, so I can't help.


Dec 14, 2012, 08:20 am Last Edit: Dec 14, 2012, 06:39 pm by ejri Reason: 1
Attached is the srv.pde code (MATLAB Support Package for Arduino (aka ArduinoIO Package)).


You might try attaching your code. Click on 'Additional Options...' under the text input box.


Code: [Select]
Servo servo[70];
An array of 70 servo objects. Why? You can't possibly connect 70 servos to one Arduino.


I have tried to add the Wire library to the srv.pde to establish an I2C,

The slave code:

#include <Wire.h>

void setup()

void loop()

void receiveEvent( int howMany)
while (Wire.available())

The master code, is the srv.pde and I added:
#include <Wire.h>
#include <AccelStepper.h>

and to the void loop(), I added

Wire.beginTransmission (100);

Do I need to end the transmission (I mean add Wire.endTransmission() to the code)? Or the transmission should automatically end when I disconnect the arduino?

Adding #include <AccelStepper.h> to the code didn't seem to have an effect, the 2 motors still don't run simultaneously. What do I have to do to fix this?


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131