A self balancing robot with IOIO

858 views
Skip to first unread message

Ytai Ben-Tsvi

unread,
May 13, 2012, 8:39:59 PM5/13/12
to ioio-...@googlegroups.com

To those who aren't on my G+:
I've built a self-balancing robot (segway-style) powered by IOIO and Android.
The nice thing here is that the Android's internal sensors (accelerometer and gyro) and used for feedback.
It was questionable whether they would be accurate and fast enough, and whether the IOIO connection latency would low enough. It is not longer questionable :D

The setup uses two stepper motors with A4988 drivers. A new feature (soon to be released) in IOIO enables sending pulses with varying frequency for controlling them, thus achieving very precise speed control. A 5000mAh, 2-cell Lipo provides enough juice for hours of operation. The box has been built with scissors and tape and can be taken apart and back within 3 minutes (so I can easily show the internals).

This robot has a secondary function: you can take the phone out, connect a Bluetooth dongle to the IOIO instead, lay it on its back, where there's a ball caster, and use the phone to drive it remotely. It goes quite fast, thanks to the slightly over-spec'ed steppers...


Claire Delaunay

unread,
May 14, 2012, 1:44:55 AM5/14/12
to ioio-...@googlegroups.com
Ha !
Totally awesome,
Congrats Ytai :-)

Corebots www.corebots.net
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.

Anish Mohammed

unread,
May 14, 2012, 2:20:14 AM5/14/12
to ioio-...@googlegroups.com
Hi Ytai,
 That is cool :)
Regards
Anish

Anish Mohammed
Twitter: anishmohammed
http://uk.linkedin.com/in/anishmohammed

ZHANG Yan

unread,
May 14, 2012, 2:25:10 AM5/14/12
to ioio-...@googlegroups.com

wow I tried this last year with ioio and two servos but failed to make it self-balanced. Many appreciation! Do you have a list of specs? Can you make it move forward while balancing itself?

Ytai Ben-Tsvi

unread,
May 14, 2012, 3:06:37 AM5/14/12
to ioio-...@googlegroups.com
It should be able to move forward and backwards and turn. I haven't yet played around with it enough, but just did some preliminary tests and I'm pretty confident it is easy.
I had a previous attempt for a self-balancer based on continuous standard hobby servos. I found that the backlash in the gears is problematic. This time around I chose steppers and I'm very pleased with that. They have 200 steps / rev times 16 microsteps = 3200 positions / rev. They are very torquey without needing gears, so I can direct drive these big 90mm wheels with no problem and get high torque and precision. I initially used smaller steppers that didn't deliver. Then I bought these two beasts with these drivers. The important thing was that their voltage rating is low and their current rating is high. That means I can connect them to higher voltage and let the driver do current limiting, which is what also allows for microstepping.
Other than that - no specs - that's all the robot: steppers, drivers, 2-cell Lipo, IOIO, Nexus S and a kid-size Keens shoe box :)

Rajan Gupta

unread,
May 14, 2012, 4:09:26 AM5/14/12
to ioio-...@googlegroups.com
Hey Ytai,

I have recently made a similar robot as my undergraduate degree final year project. My initial plan was to achieve exactly what you have done using IOIO but then was faced with problems like latency in the sensor output and correspondingly actuating the motors.

Here is the video of what I have so far achieved.
Balancing Platform

Happy to know something similar done by you.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.



--
Regards,
Rajan Gupta
Undergraduate
Department of Electrical Engineering
Indian Institute of Technology Madras
India
+91 9884310421

Ytai Ben-Tsvi

unread,
May 14, 2012, 4:17:26 AM5/14/12
to ioio-...@googlegroups.com
Nice build!
Why is it jumping intermittently? Also, where did you get high latency? Which sensors have your used? Which Android device? Which connectivity to the IOIO?

John Schmotzer

unread,
May 14, 2012, 8:33:53 AM5/14/12
to ioio-...@googlegroups.com
Ytai, Rajan,

Nice projects!
John W. Schmotzer
Electrical Engineering: Systems
MSAE Exec Board
HKN Active
University of Michigan

mark gross

unread,
May 14, 2012, 9:07:34 AM5/14/12
to ioio-...@googlegroups.com
using stepper motors is an interesting implementation.  That may be what is giving extra stability.  I expect that using a couple of H-bridge drivers, driving 2 DC motors, connected to 2 pwm pins on the IOIO would need lower latencies to work well.

Its very cool Ytai!

--mark
create interesting things.

Ed Young

unread,
May 14, 2012, 2:48:47 PM5/14/12
to ioio-...@googlegroups.com
That's very, very cool. I hope to see it (and lots of other cool stuff)  in June at your the Sparkfun "Android Development with IOIO" class.

Ed

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.



--
- Ed

Ytai Ben-Tsvi

unread,
May 15, 2012, 1:33:18 AM5/15/12
to ioio-...@googlegroups.com
I'll bring it along if they don't throw me off the plane...

Joseph Swanson

unread,
May 15, 2012, 11:09:42 AM5/15/12
to ioio-...@googlegroups.com
Awesome...

miky

unread,
May 18, 2012, 10:55:25 AM5/18/12
to ioio-...@googlegroups.com

Hi Yati, what control you used for balancing robot, PID or Linear quadratic regulator or another control?

Ytai Ben-Tsvi

unread,
May 18, 2012, 2:27:20 PM5/18/12
to ioio-...@googlegroups.com
PID where the input is the angle and the output is the motor speed.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/9o1wUPXMurUJ.

Al B

unread,
Jun 18, 2013, 2:08:15 PM6/18/13
to ioio-...@googlegroups.com
Hi Ytai,

Do you think I can use this Stepper motor instead?

https://www.sparkfun.com/products/10846

I'll need to change the code since this one is a 400 steps/rev though.

Thanks, and best regards!

Ytai Ben-Tsvi

unread,
Jun 20, 2013, 2:00:24 AM6/20/13
to ioio-...@googlegroups.com
I believe I've used a similar one.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.

To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Al B

unread,
Jun 20, 2013, 3:37:37 AM6/20/13
to ioio-...@googlegroups.com
Ytai,

Does the latest firmware for the IOIO-OTG support the variable-frequency pulses?  Or do I still have to build the special firmware from the pwm-improvements branch (oio/firmware/app_layer_v1) and upload into the IOIO-OTG?

Thanks!

Ytai Ben-Tsvi

unread,
Jun 20, 2013, 3:54:12 AM6/20/13
to ioio-...@googlegroups.com

This hasn't been merged yet. The pwm-improvement brach doesn't currently support the ioio-otg. The shortest path is probably to carefully rebase this branch on master.

--

Al B

unread,
Jun 20, 2013, 10:49:59 AM6/20/13
to ioio-...@googlegroups.com
Ytai,

I already made the changes to the Java library locally (e.g. PwmOutput::setPeriod(), PwmOutput:setFrequency(), IOIOProtocol::setPwmRunningPeriod(), etc., etc.) so I can try to do same with the firmware code, but do you remember the exact .h and .c files that contain the support for the variable-frequency pulses?

Also, can one now build the firmware using eclipse or do I need to use MPLAB and C30?

TIA!

Ytai Ben-Tsvi

unread,
Jun 20, 2013, 11:49:05 AM6/20/13
to ioio-...@googlegroups.com
Use git show or git diff to see exactly what's changed in pwm-improvements since it forked from master.
Also note that you should fix the command numbers assigned in the protocol (firmware/.../protocol.c and software/.../IOIOProtocol) to not collide with features added on master (e.g. CapSense).


Al B

unread,
Jun 20, 2013, 12:40:57 PM6/20/13
to ioio-...@googlegroups.com
It's been more than a year since you created the branch so there are a lot of changes.  However, I'm only interested on the changes to support the variable-frequency pulses; which seems to be contained under the /app_layer_v1 folder with the comment "Initial implementation of setting the frequency."

If you think that is the case, then I am only need to merge my local OTF firmware code with the changes in these files:

protocol.c
protocol.h
protocol_defs.h
pwm.c
pwm.h

Otherwise, it might be "cheaper" just to purchase a V1 board.

Do you have any plans to enhance the OTG firmware to support variable-frequency pulses in the near future?

BTW, I'm extremely impressed with the amount of effort and dedication you have put to support and enhance the IOIO endeavor so thank you so much for that.

Cheers!

Ytai Ben-Tsvi

unread,
Jun 20, 2013, 1:16:04 PM6/20/13
to ioio-...@googlegroups.com
Don't diff against master, diff against the point where pwm-improvements diverged from master and you should see a rather small diff.
The motor control library will have this functionality when merged. It is possible, however, that I'll push the pwm-improvements style of doing things for simplicity sake.


Al B

unread,
Mar 3, 2014, 2:59:05 PM3/3/14
to ioio-...@googlegroups.com
Regarding the 2-cell Lipo battery.

Did you use a 40C continuous
discharge or / 50C?

I ask since I's thinking about buying this one:

http://www.hobbypartz.com/98p-40c-5000-2s1p-hardcase-direct.html

Ytai Ben-Tsvi

unread,
Mar 3, 2014, 5:01:21 PM3/3/14
to ioio-...@googlegroups.com
Doesn't matter. In either case we're talking about insane amounts of current which are way way higher than what we'd ever need for this application.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.

Al B

unread,
Mar 3, 2014, 5:20:51 PM3/3/14
to ioio-...@googlegroups.com
So are you saying that 5000mAh are not really required and 2200mAh battery will probably be sufficient?

http://www.hobbypartz.com/98p-25c-2200-2s1p.html

Ytai Ben-Tsvi

unread,
Mar 3, 2014, 5:28:17 PM3/3/14
to ioio-...@googlegroups.com
Ha?
Your previous question was about the "C" rating (maximum current), to which I've answered "doesn't matter".
This is a completely different question (capacity), to which the answer is "depending how long you want it to last between charges".


On Mon, Mar 3, 2014 at 2:20 PM, Al B <cagi...@gmail.com> wrote:
So are you saying that 5000mAh are not really required and 2200mAh battery will probably be sufficient?

http://www.hobbypartz.com/98p-25c-2200-2s1p.html

--

Al B

unread,
Mar 11, 2014, 8:09:11 PM3/11/14
to ioio-...@googlegroups.com
Hey Ytai,,

Your description below says that you used two(2) A4988 Stepper Motor Driver.  You also indicate that you are using a 2-cell Lipo battery.  However, the stepper driver requires an minimum operating voltage of 8V so how are you powering those drivers?  Would it be better to use the DRV8834 Low-Voltage Stepper Motor Driver instead?

Ytai Ben-Tsvi

unread,
Mar 12, 2014, 11:38:44 AM3/12/14
to ioio-...@googlegroups.com
Agreed.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Al B

unread,
Mar 12, 2014, 12:07:41 PM3/12/14
to ioio-...@googlegroups.com
I assUme that you agree with using the DRV8834 Low-Voltage drivers.  However, would you mind clarifying how you powered the A4988 driver for your project?

I just wonder since I followed your original instructions and bought 2 of those A4988 driver, but now it seems that I have eat them with ketchup and buy the low-voltage ones since Pololu return policy sucks!

"We will accept returns of un-opened items in their original packaging within 30 days of the order date, but you will have to pay for the return shipping and a $3 + 15% restocking fee. The initial shipping charge is not refundable either."

Ytai Ben-Tsvi

unread,
Mar 12, 2014, 8:19:25 PM3/12/14
to ioio-...@googlegroups.com
I powered by connecting IOIO Vin <-> Driver Vmot.
Despite the specs, I can verify that 2-cell works OK even when the battery is low. In hindsight, since you've pointed out the out-of-spec usage, I would probably do things differently.

If I were you, I'd probably just use the drivers as is, and if there's a problem, move to a 3S LiPo (make sure the power lines are short-as-possible).

Don't be too hard on Pololu, they're offering good products at great prices and dealing with returns is probably a conscious compromise they've made, which is reasonable in the vast majority of cases. Just my $0.02...


--

clay_shooter

unread,
Apr 30, 2014, 10:03:54 PM4/30/14
to ioio-...@googlegroups.com
Did the IOIO code for this ever get put into an official release?

Ytai Ben-Tsvi

unread,
Apr 30, 2014, 10:22:21 PM4/30/14
to ioio-...@googlegroups.com

No

On Apr 30, 2014 7:03 PM, "clay_shooter" <jfre...@freemansoft.com> wrote:
Did the IOIO code for this ever get put into an official release?

--
Reply all
Reply to author
Forward
0 new messages