Page 1 sur 1

[solved] Make rotoshield work 2

Message non luPosté: Sam 23 Juil 2011 15:48
de erik
Hi,

I've just gotten a fully assembled rotoshield and connected it to my Arduino Mega 2560 Board. I've also connected 4 small DC motors and a ca. 7 V battery pack to the external power supply.

When I turn on the power to the main board (mega 2560) the blue LED lights up. But nothing happens when I upload a simple sketch like this:
#include <Wire.h>
#include <snootor.h>

SnootorDC M1;
SnootorDC M2;
SnootorDC M3;
SnootorDC M4;

void setup(){
  Serial.begin(9600);
  Serial.println("Motor test!");
  Wire.begin();
  M1.init(1);
  M2.init(2);
  M3.init(3);
  M4.init(4);
  M1.setSpeed(200);
  M2.setSpeed(200);
  M3.setSpeed(200);
  M4.setSpeed(200);
  M1.run(FORWARD);
  M2.run(FORWARD);
  M3.run(FORWARD);
  M4.run(FORWARD);
}

void loop(){
  Serial.println("forward...");
  delay(2000);
}



I do see the "println" stuff when running the serial monitor.

REMARK: The blue LED does not light up when I turn on the external power supply (even though the polarity is right), but it does turn on when I turn on the power supply for the main board!

Furthermore, when I check the voltage differences it looks like there is a missing link somewhere. It's like the circuit is broken, but I don't know enough electronics to find out where :(

Do you think you'll be able to help?

Thanks,
Erik

Re: Make rotoshield work 2

Message non luPosté: Sam 23 Juil 2011 20:20
de Lionel
Hi Erik,

Sure we'll help you !!

I'll try asap your config and sketch,
We plan to update the library, very soon and we'll release an update at the beginning of the coming week,

Just a detail, a super simple sketch is like that
(sure it's working on uno & duemillanove, I'll check tomorrow on a mega)

Code: Tout sélectionner
// Snootlab Max 7313 Motor shield library
// Based on Adafruit Motor shield library
// https://github.com/adafruit/Adafruit-Motor-Shield-library
// copyleft Snootlab, 2011
// this code is public domain, enjoy!


#include <Wire.h>
#include <snootor.h>

SnootorDC M1;
SnootorDC M2;

void setup(){
  Wire.begin();
  M1.init(1);
  M2.init(2);
}

void loop(){
  M1.setSpeed(255);
  M1.run(FORWARD);
  M2.setSpeed(255);
  M2.run(FORWARD);
  delay(2000);
  M1.setSpeed(255);
  M1.run(BACKWARD);
  M2.setSpeed(255);
  M2.run(BACKWARD);
  delay(2000);
 }


Thank's for your feedback, i'll keep you in touch super quickly

Re: Make rotoshield work 2

Message non luPosté: Sam 23 Juil 2011 22:04
de erik
Hi Lionel,

Thanks for the quick response.

I tried your sketch, but still no response from the motors.

I've attached a couple of photos so you can see my setup.

Cheers,
Erik

Re: Make rotoshield work 2

Message non luPosté: Lun 25 Juil 2011 14:59
de Lionel
Hi Erik,

I try with an arduino Mega 2560 and here are the things to have it up and running:

I²C signal re-mapping :

At this moment, the library did not map the I²C pins from rotoshield to arduino Mega so you've to bridge them like this :

Rotoshield -> Arduino Mega
Pin 4 -> Pin 20 (SDA)
Pin 5 -> Pin 21 (SCL)

Here is a photo :

mega_rotoshield.png
mega_rotoshield.png (494.45 Kio) Vu 9373 fois


Power supply

I strongly suggest you use two differents power supplies (split supply) one for arduino and one for the motors.

Motors are big parasitic sources when running, sending noise on power line.
This noise is able to disturb the microcontroller causing unexpected behavior

Moreover, suddent direction changes or several motor simultaneous start can take lot of energy from source causing unexpected reset on the microcontroller if the same power source is shared.

I suggest you use a big Lead Acid or NiMH battery pack (As suggested in the photo above), or other sources like LiPo... but splitting is highly recommended...

Here is the super simple test sketch I used for 4 DC motors.

Code: Tout sélectionner
// Snootlab Max 7313 Motor shield library
// Based on Adafruit Motor shield library
// https://github.com/adafruit/Adafruit-Motor-Shield-library
// copyleft Snootlab, 2011
// this code is public domain, enjoy!


#include <Wire.h>
#include <snootor.h>

SnootorDC M1;
SnootorDC M2;
SnootorDC M3;
SnootorDC M4;

void setup(){
  Wire.begin();
  M1.init(1);
  M2.init(2);
  M3.init(3);
  M4.init(4);
}

void loop(){
  M1.setSpeed(255);
  M1.run(FORWARD);
  M2.setSpeed(255);
  M2.run(FORWARD);
  M3.setSpeed(255);
  M3.run(FORWARD);
  M4.setSpeed(255);
  M4.run(FORWARD);
  delay(2000);
 
  M1.setSpeed(255);
  M1.run(BACKWARD);
  M2.setSpeed(255);
  M2.run(BACKWARD);
  M3.setSpeed(255);
  M3.run(BACKWARD);
  M4.setSpeed(255);
  M4.run(BACKWARD);
  delay(2000);
 
 }



Hope it'll help

Re: Make rotoshield work 2

Message non luPosté: Lun 25 Juil 2011 17:04
de erik
Hi,

Before I try your setup I'd like to clarify two things:

1. I did use an external power supply for the motors, but just a pack of batteries.

2. Is it correct that there is no light in the blue LED when the external power is connected to the Rotoshield card? (and the rotoshield card is not connected to the main board)

Thanks again,
Erik

Re: Make rotoshield work 2

Message non luPosté: Lun 25 Juil 2011 17:32
de Lionel
Hi,

It's my fault, there is one thing that is not clear on the Rotoshield use.

The M+ power line for motors is totally independant (for noise consideration)

If you put power only on M+, your logic board (arduino) is not powered.

If M+ is in the arduino power in range (6 to 10V) you can use M+ to power your arduino board. To do that, you have to link M+ and Vin (you can use wire jumper between M+ and Vin)
Vin will be regulated by the arduino board and the 5V regulated by the arduino board will be used for its own power.
But, doing that is not splitting the power sources, and as I said in my previous post, you can expect weird behavior with this use (but it can work...)


erik a écrit:1. I did use an external power supply for the motors, but just a pack of batteries.

Ok, it's good for motors, but you have to power on your Arduino
(see above)

erik a écrit:2. Is it correct that there is no light in the blue LED when the external power is connected to the Rotoshield card? (and the rotoshield card is not connected to the main board)

Yes, because the blue light is only indicating the 5V logic (arduino regulated 5V on)

Re: Make rotoshield work 2

Message non luPosté: Lun 25 Juil 2011 18:40
de erik
Hi Lionel,

It's working now - great, awesome! Thanks! Merci!

Re: Make rotoshield work 2

Message non luPosté: Lun 25 Juil 2011 19:23
de Lionel
Thank's for your feedback,
Image

I'm glad it's ok now,
have fun !!