Shop OBEX P1 Docs P2 Docs Learn Events
DanceBot Questions — Parallax Forums

DanceBot Questions

Rick BrooksRick Brooks Posts: 67
edited 2013-07-21 20:42 in Propeller 1
I've been reading "Programming and Customizing the Multicore Propeller Microcontroller" chapter 6 on the DanceBot.

It appears that the source code listed for chapter 6 is the same as is listed for chapter 7.· Specifically, on page 255 there is a bit of code that gives a command "bal.do(10,10,0)" and I don't see any spin programs listed that have a "bal" object reference.

It is obvious how the gyroscope is mounted from the photos.· On the other hand, mounting the accelerometer is not shown.· The code indicates that only the x axis is used.· I don't think that the accelerometer is mounted with the x axis straight up.· How should it be mounted?

For the encoders, both are wired and, I think, both are being read.· Which one (right or left side) is being used for the PID input?

Finally,·I have never used the LMD18200 motor controllers.· Do you just glue them to some surface and run short wires from the pins, or is there a better way of mounting them to the Proto Board?

That is enough questions for now.

········ Rick Brooks

Comments

  • HannoHanno Posts: 1,130
    edited 2010-03-09 06:28
    Hi Rick,
    Whew- lots of questions- let's see how I do..
    I'm going through the DanceBot code to add some comments and make it easier to use- should finish end of this week- I'll make a post here.
    You should mount the accelerometer so that it gives positive readings when you tilt the bot one way, and negative when you tilt it the other way. At rest, it should read close to 0. The Kalman Filter will fuse the output of this sensor with that from the gyroscope to get a good signal for balancing. Only the left motor's encoder is connected- I blew out the led on the right side early on- it ends up making the software a bit easier.
    I screwed the LMD18200 together and hot-melt glued them to the acrylic tube. I ran wires to the ProtoBoard. They're quite big, so I couldn't fit them onto the Protoboard.
    Good luck!
    Hanno

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Co-author of the official Propeller Guide- available at Amazon
    Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
    12Blocks, the block-based programming environment (thread here)
    and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer
  • Rick BrooksRick Brooks Posts: 67
    edited 2010-03-09 22:33
    Hanno,

    Thanks for the response.

    Studying DanceBot has presented interesting solutions to some problems that I had not previously anticipated.

    I look forward to seeing the rest of the code.

    ··········· Rick Brooks
  • HannoHanno Posts: 1,130
    edited 2010-03-16 20:50
    Hi Rick,
    I went through the code (good memories yeah.gif )
    I've added lots of comments and removed code that wasn't being used.
    The "do(speed,rotation)" function was in the "dancebot.spin"- it keeps the bot balanced while allowing you to specify its speed and rotation. The main loop of that file uses vision to find an item and then steers the bot there by continually calling the "do" function.
    I've updated the "conduit" file with the file from the latest ViewPort- other than that the code from the book works fine with the latest ViewPort.
    I'm working on getting the new code onto the book's ftp server, for now the archive containing all code is here:
    hannoware.com/dancebot/code.zip
    Hanno

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Co-author of the official Propeller Guide- available at Amazon
    Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
    12Blocks, the block-based programming environment (thread here)
    and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer
  • Rick BrooksRick Brooks Posts: 67
    edited 2010-03-17 00:04
    Hanno,

    Thanks for the update.· The dancebot.spin code is much easier to read, now.· I see where the "do"·method comes in and controls the robots movement.· I never got that far in the earlier dancebot code.

    I think that I have all of the parts to building a balancing robot, but I am more interested in·understanding the process of development, rather than building a finished robot.· The concept of a "hybrid fuzzy logic cascading PID controller" fascinates me.

    I'll keep you posted on my progress.

    ······· Rick Brooks

    ·
  • LarryPotterLarryPotter Posts: 8
    edited 2010-12-09 10:16
    I'm a bit late in this game, since I see some posts dating back to 2004. However...
    I have been using the Dancebot code as a learning aid. However, I am having a huge problem in understanding how the Kalman filter and the Fuzzy logic works. I have found some tutorials on the internet addressing these subjects, and I believe I sort of understand the Fuzzy logic. But, the Kalman filter is really throwing me for a loop. From what I have read about it on the internet, the Kalman Filter will get rid of "noise". However, Hanno Sandar is using it to "meld" the inputs of the accelerometer and the Gyro. Does anyone have any suggestions?
  • HannoHanno Posts: 1,130
    edited 2010-12-26 23:03
    Hi Larry,
    I wrote a bit about the control algorithm in 2 chapters of the Propeller book- see my signature. Getting a bot to balance in place for several minutes is comparatively easy and only requires a simple P, or PD filter. After months of experimenting and reading about other attempts I concluded I needed a full blown cascading pid controller- which I attempted to simplify using fuzzy logic. The Kalman Filter is separate from the controller- it fuses signals from two sensors (one of which is the derivative of the other) into a very accurate reading. Have a look at ViewPort- it includes a fuzzy logic visualizer, sample, documentation. Links in my signature...
    Hanno
  • LarryPotterLarryPotter Posts: 8
    edited 2011-01-27 11:37
    I constructed my dancebot and am now trying to "tune" it so that it maintains its balance. Just to keep things simple, I commented out all the vision code, and set the variables "tvel" and "trot" to zero whithin the main method. One thing I've noticed is that the fuzzy logic maps that appear at the bottom of dancebot.spin are not actually used in this application, i.e., there are no fuzzy reles set. I believe that Hanno added this so that one can see the maps in Viewport. However, fuzzy logic is used to the extent of "fuzzifying" a variable, and "defuzzifying" it into another.

    When I activate my robot, it acts as though it would balance on a curved surface (curved up like a smile). When placed on a flat surface, it will lean a little one way or the other, and the robot speeds towards the lean. However, the lean is always ahead of the robot's speed. So, it just travels faster and faster untill it falls over. I have experimented with every one of the variables within the "setmap" statements and have had no success. Does anyone have any suggestions? I am at my wits end.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-01-27 11:56
    I'm not sure how the fuzzy stuff factors in, but in a strict PID sense it sounds like your proportional response isn't high enough. You could also try setting your derivative response higher, but that's much harder to tune, and really sensitive to noise. You're better off getting the thing as close to "right" as possible with P, then adding D & I as necessary.
  • Rick BrooksRick Brooks Posts: 67
    edited 2011-01-27 14:27
    LarryPotter,

    I am not as far along as you. But, I did notice a variable "tiltOff" that may be what you are looking for.
    "tiltOff: offset in tilt- calibrated so tilt reads 0 when balanced"

    Rick Brooks
  • HannoHanno Posts: 1,130
    edited 2011-01-29 14:05
    Hi,
    As others pointed out, there may be multiple things going on:
    - "P" constant of PID controller set too low. Tuning this requires experimentation (or lots of math). Keep setting it higher until it oscillates.
    - "0" point not calibrated correctly. "tiltOff" should be set to a value so that "tilt" reads 0 when balanced straight up.
    - your bot is not fast enough. Are you using similar wheels, motor, batter, controller to mine?
    Hanno
  • LarryPotterLarryPotter Posts: 8
    edited 2011-02-04 15:39
    Thanks JasonDorie, Rick Brooks, and Hanno for your suggestions. As far as the constant “tiltOff”, I have set this to “0” since my accelerometer is level with respect to the robot. Incidentally, I am using Parallax’s Robot Control Board for my controller. I had to modify Motor.spin to accommodate this board. I also added the other wheel decoder, but had to rearrange the input pins within the code.
    I have tried varying both the proportional and integral values in an attempt to get this thing to balance, but it still acts like the speed is too slow. I am using all the parts listed in the book “Programming and Customizing the Multicore Propeller Microcontroller” with exception of the wheels. I don’t think Lynxmotion offers the 3.6 inch diameter wheels anymore, so I had to used the 2.75 inch wheels. I thought that the wheel size might be the cause of the problem, so I made a pair of 3.6 inch wheels out of plywood (with a rubber band for the thread) but it still acts the same.
    So, I will continue to experiment. I can appreciate how Hanno’s kid learned to balance before his robot did!
  • jpylejpyle Posts: 41
    edited 2013-07-20 17:28
    Hello, I would like to ask if anyone has the http://hannoware.com/dancebot/code.zip code , that Hanno had provided a link to?? I find it a dead link, now. (Not that I am a few YEARS off, here). Any help would be much appreciated. Thanks, John
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-20 18:12
    Here's the ftp site for the DanceBot chapter of the Official Guide. I'm not sure if these are the same files your looking for though.
  • jpylejpyle Posts: 41
    edited 2013-07-21 02:17
    Duane, Thank You, Thank You, Thank You!!!!! I believe that these files will allow me to (attempt) to continue with my balancing project. I may not have the results I hope for, But you have gotten me off of "High Center" with your kind reply. Thanks again---Sincerely, John Pyle OKC.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-21 07:41
    jpyle wrote: »
    Duane, Thank You, Thank You, Thank You!!!!! I believe that these files will allow me to (attempt) to continue with my balancing project. I may not have the results I hope for, But you have gotten me off of "High Center" with your kind reply. Thanks again---Sincerely, John Pyle OKC.

    You're very welcome.

    In case you or anyone else is interested, I adapted the original DanceBot code to use a Memsic2125 accelerometer.

    I personally haven't made a balancing robot but it's on my todo list.
  • jpylejpyle Posts: 41
    edited 2013-07-21 20:42
    Duane, I just thought that I was busy---You have to be in Georgia Overdrive!!! I Am Impressed!!!
Sign In or Register to comment.