I2C Motor Driver V1.2

Grove is a modulated, ready-to-use tool set.
Much like Lego, it takes a building block approach to assembling electronics.

Moderators: lily.li, violet, jeremy882, crail.lyu969

Post Reply
morind
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed Jan 16, 2013 9:21 pm

I2C Motor Driver V1.2

Post by morind » Wed Jan 16, 2013 9:23 pm

Hi all,

I just get this board, but I would like to have more information : what is this switch for ?
I trie to have a look at the wiki and also schematic, but seems there is no information on this.
Can you please help ?

Thank you

Best regards,

Denis

morind
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed Jan 16, 2013 9:21 pm

Re: I2C Motor Driver V1.2

Post by morind » Thu Jan 17, 2013 3:49 pm

Hi,

Replying to myself, I found the information on another post :

http://www.seeedstudio.com/wiki/Grove_- ... river_V1.2

But still, when I plug the module all LED are light up, and it seems the I2C bus is in short as I detect no I2C...
Want can be the issue ?

Best regards,

Denis

User avatar
Jacket Chen
Staff
Staff
Posts: 659
Joined: Thu Jun 21, 2012 4:25 pm
Are you a staff member of seeedstudio?: yes
Which products/projects are your favorite?: Seeeduino Shields
Location: China

Re: I2C Motor Driver V1.2

Post by Jacket Chen » Mon Jan 21, 2013 4:36 pm

Hi, please confirm that your I2C address is right.

such as:If your switch is 1011, your I2C address is 0x0b.
Love little, love long.

morind
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed Jan 16, 2013 9:21 pm

Re: I2C Motor Driver V1.2

Post by morind » Mon Jan 21, 2013 4:43 pm

Hi,

I will test as soon as I will program the firmware on the Atmega, seems there is no firmware yet.

Best regards,

Denis

User avatar
Jacket Chen
Staff
Staff
Posts: 659
Joined: Thu Jun 21, 2012 4:25 pm
Are you a staff member of seeedstudio?: yes
Which products/projects are your favorite?: Seeeduino Shields
Location: China

Re: I2C Motor Driver V1.2

Post by Jacket Chen » Mon Jan 21, 2013 5:23 pm

Hi,there is firmware of I2C motor driver 1.2
Love little, love long.

morind
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed Jan 16, 2013 9:21 pm

Re: I2C Motor Driver V1.2

Post by morind » Mon Jan 21, 2013 6:43 pm

I do not have the AVR ISP programmer yet, bought it and I should receive it soon.
Cross fingers :-)

Br,
Denis

User avatar
Jacket Chen
Staff
Staff
Posts: 659
Joined: Thu Jun 21, 2012 4:25 pm
Are you a staff member of seeedstudio?: yes
Which products/projects are your favorite?: Seeeduino Shields
Location: China

Re: I2C Motor Driver V1.2

Post by Jacket Chen » Wed Jan 23, 2013 9:22 am

Enjoy yourself. Have a nice day.
Love little, love long.

morind
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed Jan 16, 2013 9:21 pm

Re: I2C Motor Driver V1.2

Post by morind » Sat Jan 26, 2013 12:40 am

Hi,

I have programmed it using ATmega8 (and not ATMega8L as I do not have it in the list) and i have exactly the same issue.
All LED are on. Maybe i am doing something wrong ?
I have programmed Flash memory and not EEPROM. Also before programming something I saved the program from this flash, editing data, this is something completely different.
I do not know what to do.

Best regards

Denis

User avatar
Jacket Chen
Staff
Staff
Posts: 659
Joined: Thu Jun 21, 2012 4:25 pm
Are you a staff member of seeedstudio?: yes
Which products/projects are your favorite?: Seeeduino Shields
Location: China

Re: I2C Motor Driver V1.2

Post by Jacket Chen » Mon Jan 28, 2013 3:21 pm

hey, does you use 0023 to driver it?

And if all leds are lighted , maybe you need modify its' code

maybe you could try these code

Code: Select all

#include <Wire.h>
 
//#define MOTORSHIELDaddr   0x0f
#define SETPWMAB          0x82
#define SETFREQ           0x84
#define CHANGEADDR        0x83
#define CHANNELSET        0xaa
#define MOTOR1            0xa1
#define MOTOR2            0xa5
#define SAVEADDR          'S'
#define NOTSAVEADDR       'N'
 
static unsigned char MOTORSHIELDaddr = 0x28;
 
void speedAB(unsigned char spda , unsigned char spdb)
{
  Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
  Wire.send(SETPWMAB);        //set pwm header 
  Wire.send(spda);              // send pwma 
  Wire.send(spdb);              // send pwmb    
  Wire.endTransmission();    // stop transmitting
  delayMicroseconds(100);
}
 
void fre_pre(unsigned char pres)
{    
  Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
  Wire.send(SETFREQ);        // set frequence header
  Wire.send(pres);              //  send prescale 
  Wire.send(0);              //  need to send this byte as the third byte(no meaning)  
  Wire.endTransmission();    // 
  delayMicroseconds(100);
}
 
void change_adr(unsigned char new_adr, unsigned char save_or_not)
{
  Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
  Wire.send(CHANGEADDR);        // change address header
  Wire.send(new_adr);              //  send new address
  Wire.send(save_or_not);              //   save the new address or not  
  Wire.endTransmission();    // 
  delayMicroseconds(100); //this command needs at least 6 us
}
 
void channel(unsigned char i4) //0b 0000 I4 I3 I2 I1 
{
//  delayMicroseconds(4);
  Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
  Wire.send(CHANNELSET);        // channel control header
  Wire.send(i4);              // send channel control information
  Wire.send(0);              // need to send this byte as the third byte(no meaning)  
  Wire.endTransmission();    // 
}
void motorAndspd( unsigned char motor_s,unsigned char Mstatus, unsigned char spd)
{
  Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
  Wire.send(motor_s);        // motor select information
  Wire.send(Mstatus);        // motor satus information
  Wire.send(spd);            //  motor speed information
  Wire.endTransmission();    // 
  delayMicroseconds(100);
}
 
void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  delayMicroseconds(10); //wait for motor driver to initialization
}
 
void loop()
{
 
  motorAndspd(0xa1,0b01,225);
  motorAndspd(0xa5,0b01,30);
  delay(2000);  
 
  motorAndspd(0xa5,0b10,225);
  motorAndspd(0xa1,0b10,30);
  delay(2000);
 
  change_adr(0x12, NOTSAVEADDR );
  MOTORSHIELDaddr = 0x12;
 
  for( int i = 0;i< 16;i++)
  { 
    fre_pre(i); 
    channel(i);
    delay(100);
  }
  speedAB(0 , 0);
  change_adr(0x28,NOTSAVEADDR );
  MOTORSHIELDaddr = 0x28;
 
}
Love little, love long.

Post Reply