Balancing bot?
I am trying to figure out some code to build a system similar to your balancing bots. The·components·I·am using are a Memsic 2125 two axis accelerometer,·HB-25 motor controller, and a linear actuator.·I am trying to code the stamp so that the motor controller will control the actuator so that a zero angle on the accelerometer is maintained.·I was told by a tech at Parallax that some your code for balancing bots is very similar to what·I am doing. I think he said that it was like a "porportional drive".·I am very new to this stuff and·only have enough coding ability to slightly modify programs or build very simple ones. Any help you guys could give me is greatly appreciated!
thanks,
Sean
thanks,
Sean
Comments
·· With the linear actuator I don't know if the same concets apply.· Typically in a balancing bot, the motor drive will be proportional to the angle of tilt of the bot.· The more it's tilted the more drive you apply in that direction to attempt to upright itself.· Perhaps there are some users on here wo can post their balancing bot code to give you an idea?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
If that is the case, the same concepts should apply. The further from vertical the pendulum leans, the faster the actuator needs to move to "get under" it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
http://forums.parallax.com/forums/default.aspx?f=21&m=109179
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Living on the planet Earth might be expensive but it includes a free trip around the sun every year...
/Bamse
That's exactly what i'm trying to do.·My project·is basically a self leveling seat. The actuator is going to adjust the angle of the seat (from below the axis of rotation) to keep the seat level. The code for the IR sensor helps but·I don't know if I have the programming capability to adapt that code to my memsic accelerometer and motor controllers. Does anyone know of any bots that at least use the accelerometer with servos or IR with HB-25s? I may be able to figure out the code if·I have one of the elements, but not having either, is going to be hard. Thanks again!
I hope to figure it out soon to update the balancing project.
Thanos
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greekbotics: Greek Robotics Forum
My thought was to sample the angle then move the actuator in or out to return to zero degrees. The hard part for me to program are the different elements required for the HB-25. It needs code for final speed, turn motor forward or backward, and ramp up and ramp down. The way the code works, the motor will turn on (in a given direction), ramping up to a set speed, until the code turns it off.
Does this help or make sense?
I·have attached a modified version of Parallax's code for the HB-25.
Thanks
You better do some datalogging measurments of the output of the accelerometer to see for yourself.
If its output is linear on the boat it might work, otherwise you better use a gyro.
Thanos
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greekbotics: Greek Robotics Forum
I haven't really followed this thread, but let me offer the following. Generally speaking balancing bots need to sense tilt and respond to it quickly when it's outside of acceptable limits. This can be done by using an accelerometer as a tilt sensor, or by use of a gyro. Generally, the accelerometer is the more practical and less expensive solution.
The key to the entire thing is having the sensor as NEAR to the center of rotation as possible. That way it will see the tilt as it is occurring, and not by some possible secondary means, if it's hung out on an edge of the platform, away from the center of rotation.
The tilt sensor will offer two types of readings, depending on whether there is a positive tilt (forward) or negative tilt (backwards). One must respond quickly and appropriately to re-center the center of gravity (move the platform back under the center of gravity). Moving it too quicjly will cause "overshoot" and casue a secondary response in the opposite direction. Too little movement will cause "undershoot" which calls for more center-seeking movement, NOT NECESSARILY FASTER MOVEMENT. Faster movement may well cause overshoot, which only compounds the problem.
I hope those general thoughts are helpful.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 4/12/2006 10:17:13 AM GMT
The part I don't really know how to do is to program it for the motor controller (HB-25). So far I have put the accleleromter into a subroutine and I think the motor controller should go into a subroutine also. There are essentially three elements that I have to code for: direction, max motor speed, and start and stop. Now since the program is trying to keep the seat at 0 degrees, it should never really get outside of a few degrees in either direction before the program starts controlling the actuator moving the seat back to zero.·And since the actuator should be able to move the seat a couple of degrees within·one·second, the actuator will never really get up to full speed before being shut off (spin down should be minimal). So, my first question is, do I just go with a static max speed setting (knowing that just a portion of the ramp up of the actuator will be enough to get back to zero) or do i need to use a variable that gets set by something else (what and how to do this, I don't know)? Next question, for the HB-25 controller, will the code "PULSOUT HB25, 750" (I found this line in the initialization section) stop the motor no matter what direction it was moving (in program section of the sample code from Parallax it shows a "PULSOUT HB25, 750 + or - index" to slow the motor)? If I can just use "PULSOUT HB25, 750" then·I think I know how to use that in my code. For the direction, I think I can just use simple IF statements to compare to the direction of the tilt. Is any of this helping? I know the accelerometer will work good enough for what·I am doing, I think I just need help programming that to work with the moor controllers (I think the controller is the hardest to code right now.
Also, I think I just figured out how the code for the controller works, can someone please validate this for me? I think it is working like a servo or a two way potentiometer. Here's the sample code that Parallax uses:
FOR index = 0 TO 250··············· ' Ramp Up To Full Speed
··· PULSOUT HB25, 750·+ index········· ' Motor 1 Forward
this looks very similar to a servo, 750 is·center (or off for a speed control) and the index from 0 to 250 ramps the movement of the servo to 1000 or the extent in one direction (or full speed for a speed control). Using a negative index will be full in the other direction. So, using this logic in my application, I can use a scalar with the angle to set index then just use "PULSOUT HB25, 750·+ or - index" and get rid of the FOR line. This would set the speed and give me a way to adjust the overshoot.
Does this sound correct? Keep in mind that I don't know much about these devices or coding, so what I am proposing may not make sense, I don't know...
Anyway, I'd appreciate your feedback.
Thanks,
Sean
·
OK, so·I think I figured out a few things, but I'm not getting the results that·I should. I have attached the in-progress program. I haven't yet added any code for scaling the motor controller output based on the angle. The problem·I have is that·I get full controller output (15V) when I use just that section of code by itself, but when I include it into the program, it only puts out about .4V and jumps around even at that. It does though respond to the angle like it should, negative voltage for negative angles and positive voltage for pos angles, but still only about .4 V (again it should be about 15V). Can you guys please take a look at my code and see what may be wrong? What I want it to do at this point is put out 15V (like it does with just that section of code)·at a constant angle of tilt and not change voltage until I either rotate back to zero degrees or go over to negative angles (then it should be -15V). I'd really apreciate some help here, I feel like I may be close to getting something working.
Thanks!
Update: I loaded the new code with the Pause 10s and debug line. The debug window shows exactly what I expect. It displays the correct dialog ("push actuator out", etc.) for the correct IF statement. And, at 0 angle it displays "stop actuator" until I change the angle. So, as far as the debug window goes, it's perfect.
For the purpose of the system, the motor, it still doesn't work. I connected a small fan to the motor controller and it works perfect when I use the controller code (attached: HB-25 test - forward then backward), like you suggested to make sure everything works. It still doesn't really do anything when I use the code with the accelerometer. For the most part, it just bounces around 0V and the fan twiches. So, as far as the code I added while we talked, it didn't do anything. I attached the new code so that you can verify (seat computer-b). If anyone else has any suggestions, please post them. Thanks!
Sean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· I found what was causing the erratic behavior of the motor.·· You're trying to SEROUT to the same pin (PIN15) that the HB-25 gets its PULSOUT from.· This is being done in the Calcs routine.· It's garbage that keeps shutting the HB-25 down due to out of range pulse values associated with true serial communication.· Once that is corrected everything works great as far as moving the motor in a given direction when tilted that way.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
What·number did you change it to?
Thank you so much, I really appreciate it!
Sean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Thanks again!
I have a secondary question about the MEMSIC angle program, why does it not show 1 degree. The first angle it shows is 2 degrees, so it goes negative whatever, -2, 0, 2, positive whatever. It would be helpful for me to get that 1 degree angle so I can slow down the actuator and make the balance more accurate. And, it would be even better if I could get decimal angles, to the tenth of a degree anyway.
Thanks.
·
Now I'm having an issue where the HB25 controllers are not wokring properly when I switch the Stamp and the HB25s on at the same time. I am trying to use 1 switch to power on the HB25s and the Stamp so that they don't consume power while they aren't being used. I left a message at Tech Support, so hopefuly I can get it figured out soon. I know that there is probably an issue with the HB25s not initializing before the Stamp sees them. I have added a pause to the first line of the program, but that didn't work.
Thanks,
Sean