Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Wiring Hardware >> Tangible computing >> Balancing Robot (NEED HELP!)
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1202277622

Message started by arakourchians on 02/06/08 at 06:00:22

Title: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/06/08 at 06:00:22
Hello all!

I am currently making a robot that self balances. I wrote some drivers for the accelerometer I purchased and have that working just great! I have one problem that I can't seem to figure out. I bought an L293D H-Bridge. I want to control these motors to move backward and forward with controllable speed. I can't seem to wire this up right and when I used: http://wiring.org.co/learning/examples/dcmotor.html to figure out a way to make a motor controller it only spun one direction. Problem is, I can't get it to go backwards and forwards. The motor I am using is a regular DC motor. Someone please help!!

Thanks,
Ara

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/06/08 at 17:20:18
Dear Ara, well the effectiveness if regular DC motors depends on how you are using it (gears or pulleys), if the motor has load it will stop very fast and change direction very fast. Perhaps stepper motors are more suitable for this since they can be precisely controlled. Check this diagram: it uses a 74HC10 chip to control de direction of the two motors with the L293D.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/06/08 at 18:16:36
Awesome! This is exactly what I was trying to do, I can always run out to the store and buy a 74HC10, but I went through my collection of IC's first and found a 74HC00. It seems like it's a 2-input positive-NAND gate. In the diagram above it seems like all 3 inputs are connected together, looking at the both of the diagrams it seems like it would work even though it has 2 inputs. Would a 74HC00 work, or am I making a mistake here? Also is the 74HC10 a positive-NAND?

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/07/08 at 18:48:53
I tried the 74HC00 and it works just fine, the problem now is that if I use the USB as a power source the motor spins slowly (no matter what the input is), but it does go back and forward, and when I use the external battery it just spins in one direction and doesn't even follow the code. Whats going on?

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/08/08 at 00:02:09
Have you tried with an external power supply attached to the wiring board?, what voltage your motor use? how are you powering it?
Things can be erratic when something draws too much power from the wiring board, for example the wiring board can power up to 2 servos (it is possibe to connect up to 8), in such case an external or different power supply must be used for the servos or motors in general.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/08/08 at 06:51:55

barragan wrote on 02/08/08 at 00:02:09:
Have you tried with an external power supply attached to the wiring board?, what voltage your motor use? how are you powering it?
Things can be erratic when something draws too much power from the wiring board, for example the wiring board can power up to 2 servos (it is possibe to connect up to 8), in such case an external or different power supply must be used for the servos or motors in general.

I am using a regular 9V battery for the motors and another 9V battery to power the wiring board. Now I have it wired up and all, and when I run it, it runs great until the motors work to hard, or just likes to cut out. I have told LED (built in) 48 to turn on when the loop is running. During these cut outs the LED turns off, so I feel that I am tripping something.

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/08/08 at 17:47:09
yeah, that indicates the board is resetting, are the grounds of the two batteries tied together?

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/08/08 at 19:05:24
Yes they are grounded. I solved the problem by powering the L293D and 74HC00 using the positive power from one of the digital outs.

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/09/08 at 00:37:12
cool, it could be of great help if you post a tutorial about it, or maybe an example. I can help witht he diagrams etc. Let me know.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/09/08 at 03:33:20
Sure, I will be glad to post this up. I even wrote some drivers (it's a void method) for the memsic accelerometer, so I have accelerometer code that will take in the pulse from the accelerometer, and either export the true pulse or give a number in G's. I can also, when I am done, post the code to balance, plus the wiring.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/09/08 at 21:38:03
Well it turns out this shut off power issue still exists. The robot may balance for a while, then the pin 48 light will turn off indicating the loop stopped. About 5 seconds later it will turn back on and it will reset in a shorter amount of time than the previous reset. It seems exponential, and if I leave it alone for about 5 minutes it works for a longer time, then starts to do this. Now I am not sure what I am doing wrong, I would like a list of possibly things that are happening. My guess is that I am running to much current through the poor board, but nothing is heating up.

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/10/08 at 00:28:04
Please post an image/diagram of your connections, that would help.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/10/08 at 02:47:15
Great news! I figured out that this problem was caused by a simple mistake. I was using a 9 Volt battery to power the Wiring board and when I replaced it with 6 AA batteries the problem went away! I guess there may have been to much current being drawn (NOT sure) and it may have cut the connection, and reset. The bot stays on and what is even better is that it balances!!! I have very rough code on bot at the moment, but soon I will be revising it to be smoother. (I am afraid the poor thing will shake itself apart) :P

Title: Re: Balancing Robot (NEED HELP!)
Post by Vaccumdiode2 on 02/13/08 at 20:42:23
arakourchians,
          Would you be will to share your code and you basic set up.  I sounds like a fun project and I would like to play with it.

Rich

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/14/08 at 02:27:24
I will be glad to share my code, and I encourage improvements. I am currently refining the code to balance the robot more effectively. Within a week or so I will post:

-Code for the balancing
-Drivers for the Memsic accelerometer
-Wiring diagrams for the motor controller and the entire setup.

I talked with Mr. Barragan and I believe he is thinking about posting this up as a project and/or example.

-ara

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/14/08 at 18:23:37
Dear ara, please make it a project for the exhibition :)

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/14/08 at 18:47:47
Alright, sounds great thank you for this opportunity, I will make a webpage for this. Hopefully I can finish this in two weeks. I can send you a rough schematic of how it is wired, and the code will just make the robot balance in place. I am yet to make it move forward or backward.

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/19/08 at 23:03:02
I thought I might update you all. Well I have been working on and off this week on the bot. I caught the flu, and had more time at home to work on the bot so I guess something good came out of it. I have created a prototype code that uses position (angle) of the bot to power the motors. I would like to note that this is not how it is actually done, but I thought I might make a simple version of the code before I started adding more code. At the moment my code will work for a bot with very well balanced hardware. It will simply keep the robot standing.

I really didn't think this would be hard, and now ... I TOTALLY TAKE IT BACK!! This has been very challenge, and is not a project that can be done in a week. There is a lot of physics and math involved, and I am trying to write a new version of the code (almost from scratch *except the drivers I wrote*) that will account for rate of rotation of the bot, and more. There are many details behind this, and I am really working on trying to make the code compatible with all types of hardware. So that if your robots hardware is not well balanced the robot can compensate for that.

Mr. Barragan, it would be nice to get your email so that I can share my wiring diagrams and code(drivers and balance algorithm).

It would be nice for someone else with balancing robot hardware to test my code as well.  

Title: Re: Balancing Robot (NEED HELP!)
Post by barragan on 02/20/08 at 03:19:09
hey!, cool. my address is hbarragan [at] uniandes edu co

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 02/26/08 at 03:04:42

barragan wrote on 02/20/08 at 03:19:09:
hey!, cool. my address is hbarragan [at] uniandes edu co


I was wondering if you received my email with the code attachment. I have been testing my new code, that now accounts for angular rotation. It is still very buggy, but nothing that couldn't be fixed ;) I can already see that it works better though!

Title: Re: Balancing Robot (NEED HELP!)
Post by arakourchians on 03/15/08 at 17:26:57
Good news! The robot is finally balancing by itself with out any assistance or any major problems (previous code was terrible). Turns out we needed a gyroscope to return angular rotation. After running the gyro and accelerometer through a filter, and then through an algorithm (which I will later release), it balances pretty well. My previous code the balancing inputs were only based on the robots position. I ordered a gyroscope from SparkFun, and wrote drivers for it as well. This took a while and costed me about $200 all together. I plan to improve the code so that it is safe enough for me to blow up and make a life size one. :)

Title: Re: Balancing Robot (NEED HELP!)
Post by Titus on 03/15/08 at 19:00:13
Cool!

Keep us posted, and why not make an instructable(www.instructables.com) or post it on makezine blog

Titus

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.