Grove - I2C Motor Driver - information and source code

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

rberger
Pre-kindergarten
Pre-kindergarten
Posts: 3
Joined: Wed Dec 19, 2012 11:06 am

Re: Grove - I2C Motor Driver - information and source code

Post by rberger » Sun Dec 23, 2012 12:55 pm

vit346 wrote:
rberger wrote: Yes, that would be helpful. I'm interested in using this with the DFRobot Baron-4WD Mobile Platform which has optical encoders or possibly with the Trosson Budget Bot Chassis whose motors use Hall Effect Quadrature Encoders
Here is alternative firmware for the motor driver. I would be grateful to receive any report from you.

But how do you want to connect encoders? There are only 3 inputs available: MOSI, MISO, SCL. But 2 encoders require 4 inputs.
First: Thanks for responding

Second: I wish this forum would show hyperlinks better. I didn't see that you had one in your response and was going to ask where the firmware was!

On how to connect encoders: I hadn't realized there weren't enough inputs available. So that would be a real problem!

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Fri Jan 04, 2013 9:35 pm

Hi all,

I'm also having trouble getting this board up and running. When I connect power all 4 direction and the power led go on. Doesn't matter whether I2C is connected or not. Any ideas? How to check whether it's a DOA?

Also, my board has v1.0 printed on the back. Does that mean it's an outdated version?

And lastly, anyone got stepper motor code for it? That's what I bought it for but the sample code is only for DC motors.

I'm trying to operate it from an Arduino Uno with several other devices on the I2C bus.


Thanks for any help, Dieter

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Fri Jan 04, 2013 9:40 pm

dtr.vndrn wrote:Hi all,

I'm also having trouble getting this board up and running. When I connect power all 4 direction and the power led go on. Doesn't matter whether I2C is connected or not. Any ideas? How to check whether it's a DOA?

Also, my board has v1.0 printed on the back. Does that mean it's an outdated version?

And lastly, anyone got stepper motor code for it? That's what I bought it for but the sample code is only for DC motors.

I'm trying to operate it from an Arduino Uno with several other devices on the I2C bus.


Thanks for any help, Dieter
Ok scrap the all-leds on issue.. I was being stupid mixing up 5 and 3.3V VCC...

All help on the other questions still very welcome though!

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Sat Jan 05, 2013 3:34 am

Looks like an outdated board indeed, it doesn't have the address dipswitch... Any know if other things have changed as well?

Apart from that, I was able to run the DC motor sample code successfully. I'm now trying to integrate it with my main application which involves other devices on the bus (ADXL345, MPR121). Now all power and direction led's light again and the board doesn't respond. Is this a signal for a certain error state that can help me debugging?

Still would like stepper motor action instead of DC, too.

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Sat Jan 05, 2013 4:03 am

I'll just keep logging my progress here. Perhaps it'll help someone at some point...

Turns out my older version board has address 0x28 instead of the current one's 0x0f.

Looks like my board is the same as the one in the link posted earlier in this thread: salviusrobot.blogspot.nl/2012/03/grove-i2c-motor-driver-setup-and.html (forum doesn't let me post links)

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Mon Jan 07, 2013 1:32 am

I found a basic stepper library for the Grove/Twig I2C driver here: https://github.com/mariolukas/TwigMotor-Library
Mind you, serial addresses are set for the older version boards. Change them for newer versions.
The code is also pre-arduino-1.0. I've patched 2 files in the repository for 1.0+ compatibility.

Actually the stepper mode is really not complicated, just badly documented in the wiki. What you need to do is set the 'channel set' / 'direction set' registry alternatingly for your motor's 2/4/6/8 steps.

When I got TwigMotor working I started merging its I2C functionality with the AccelStepper library: http://www.open.com.au/mikem/arduino/Ac ... index.html
It's a great arduino stepper library with non-blocking code, acceleration/deceleration, etc.
I now have an alpha version of AccelStepper with an additional mode for I2C control of the Grove board (and potentially other I2C stepper drivers). I'll publish it once it's cleaned and tested.

vit346
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Sun Dec 16, 2012 12:33 am

Re: Grove - I2C Motor Driver - information and source code

Post by vit346 » Thu Jan 10, 2013 5:29 am

dtr.vndrn wrote: Actually the stepper mode is really not complicated, just badly documented in the wiki. What you need to do is set the 'channel set' / 'direction set' registry alternatingly for your motor's 2/4/6/8 steps.
1) Maybe (this picture) will help you
2) Usually stepper motor is driven by constant current, not voltage. But this board doesn't allow you to measure the current.
3) I think it would be better to implement all logic inside the board. I have posted the message about alternative open-source firmware. Please, consider implementing stepper-motor mode in this firmware.

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Thu Jan 10, 2013 8:14 am

vit346 wrote:
dtr.vndrn wrote: Actually the stepper mode is really not complicated, just badly documented in the wiki. What you need to do is set the 'channel set' / 'direction set' registry alternatingly for your motor's 2/4/6/8 steps.
1) Maybe (this picture) will help you
2) Usually stepper motor is driven by constant current, not voltage. But this board doesn't allow you to measure the current.
3) I think it would be better to implement all logic inside the board. I have posted the message about alternative open-source firmware. Please, consider implementing stepper-motor mode in this firmware.
Thanks for chiming in!

I'm not sure what the implications of #2 are. Can you elaborate? Is there going to be issues because of it?
The TwigStepper library sets PWM to 255 before doing the channel switching. Is that related?

As for #3, I don't have a programmer to upload firmware to my board...

vit346
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Sun Dec 16, 2012 12:33 am

Re: Grove - I2C Motor Driver - information and source code

Post by vit346 » Fri Jan 11, 2013 3:34 am

I have some experience in making driver for 12W stepper motors for CNC router.
The classical scheme is the following:
Image
L298 is used with L297, which implements all logic, and controls the current. To control the drive current It compares voltage at SEN1/SEN2 with voltage at VREF.

My stepper motor works at 1.5A. It have resistance about 2 Ohms. So, if you want to run it at constant voltage, maximum voltage is 3V. It is unreal!
If you control the current, you can run it at any input voltage.

I don't know anything about small stepper motors, maybe there are motors, which can be run at constant voltage 5V or 12V.

L298 have inputs to connect current-sense resistors, but I have never seen an I2C board with this resistors.

dtr.vndrn
Pre-kindergarten
Pre-kindergarten
Posts: 8
Joined: Fri Jan 04, 2013 8:27 pm

Re: Grove - I2C Motor Driver - information and source code

Post by dtr.vndrn » Fri Jan 11, 2013 4:17 am

I have this motor: https://www.sparkfun.com/products/9238

I've ran it for a couple of hours and it seemed fine, though it got quite hot. I'm not sure if that's ok as it's my first time working with steppers.

Post Reply