Shop OBEX P1 Docs P2 Docs Learn Events
2 wheel balancing robot — Parallax Forums

2 wheel balancing robot

Mark PepperMark Pepper Posts: 14
edited 2006-10-06 11:52 in Propeller 1
Hi

I am having fun trying to get a 2 wheeled balancing robot to work (as per Robot Wagoner's article in Robot magazine) and was wondering if anyone else had given it a stab too?

Apart from the fact that I can't get it to balance I have been trying to change the code to not use the video output (I only have the house TV as a monitor) but to use the BS2 debug serial out commands. I have found that I can send serial data from the PUB start object but cannot get any output from any of the other objects that are started on a new cog or in another PUB object. See the section of code below:

PUB Start | x

·· BS2.start (31,30)··········· ' Initialize BS2 Object, Rx and Tx pins for DEBUG
·· waitcnt(50_000_000+cnt)
·· BS2.Debug_str(string("···· Just testing!",13))····· ' some test text
......code removed for clarity

PUB Kbd
'
· bs2.debug_str(string("Kbd Cog",13,10))··

The string "Just Testing" outputs to serial but "Kbd Cog" does not. Anyone any ideas why?

If I use Roberts code the basic functionality of the bot works but any servo movement is just too slow to counteract any off balancing. Any ideas why so here too please?

Oh and just for good measure I can't get the keyboard to have any effect at all. The routine doesn't seem to run.

The code I am using (appart from the video to serial mods) is available here http://www.botmag.com/issue4/index.shtml

Mark

Post Edited (Mark Pepper) : 10/4/2006 11:00:34 PM GMT

Comments

  • ALIBEALIBE Posts: 299
    edited 2006-10-05 13:43
    a related work here:
    http://forums.parallax.com/forums/default.aspx?f=21&m=109179

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://fstop.crosscity.com/
    http://icar.crosscity.com/
    ·
  • Mark PepperMark Pepper Posts: 14
    edited 2006-10-05 14:42
    Yep, I read that posting last night but it doesn't help with my Spin code problems I am afraid.

    Mark
  • HarleyHarley Posts: 997
    edited 2006-10-05 17:40
    Sounds like the 'inverted pendulum' or 'Segway' problem of keeping an device balanced. Need quick response and considerable power to achieve that.

    I'm wondering if Spin is even fast enough to handle it? Hopefully so.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • AImanAIman Posts: 531
    edited 2006-10-05 17:47
    Yes, the Propeller is absolutly capable of handling the problem. I think its the robotics forum where a guy from Greece made a two wheeled robot and posted the code. He used a BS2. I will try to find the place and post it for you.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-05 17:53
    Regarding the debug output ... Each cog has its own I/O registers and these are combined in the hardware to produce the actual I/O pin state. When you only initialize one cog's debug pin registers, the others effectively function as inputs. It still would not work for two cogs to try to produce debug information since they might both try to send at the same time. If you can afford to devote a cog to debug output, you might use the FullDuplexSerial object for the serial channel (has a separate cog for the serial I/O), increase the buffer size to 128 bytes and use a semaphore/lock so that only one cog can use the transmit routines at a time. With the larger buffer, you'll be able to insert complete messages without waiting all the time for the serial channel unless there's just too much debug output.
  • AImanAIman Posts: 531
    edited 2006-10-05 17:56
    Here is the link from the completed projects forum showing a two wheeled robot balancing.

    http://forums.parallax.com/showthread.php?p=570699
  • Mark PepperMark Pepper Posts: 14
    edited 2006-10-05 19:46
    Mike
    Mike Green said...
    Regarding the debug output ... Each cog has its own I/O registers and these are combined in the hardware to produce the actual I/O pin state. When you only initialize one cog's debug pin registers, the others effectively function as inputs. It still would not work for two cogs to try to produce debug information since they might both try to send at the same time. If you can afford to devote a cog to debug output, you might use the FullDuplexSerial object for the serial channel (has a separate cog for the serial I/O), increase the buffer size to 128 bytes and use a semaphore/lock so that only one cog can use the transmit routines at a time. With the larger buffer, you'll be able to insert complete messages without waiting all the time for the serial channel unless there's just too much debug output.
    I'm not quite with you I'm afraid when you say "you only initialise one cog's debug pin registers. Say I want to launch 2 cogs, the first one being the initial cog that launches the other and·that just does some debug serial outputing then stops in a loop. The second cog is launched by the first but then wants to send some serial output. Do I just need to do a BS2.start (31,30) at the beginning of that cogs code? I note that the "balancing" code I have from Robert doesn't setup the TV_terminal object for each cog. It uses I/O and does work, why would that be?

    Essentially the problem is that I don't have (yet) a simple monitor so am trying to use a serial output stream to send text to my PC so I can check code progress.

    I have plenty of cogs left to use too.
    Mark
  • simonlsimonl Posts: 866
    edited 2006-10-06 11:34
    You'll find an article and code for a PChip controlled balance-bot here: http://www.parallax.com/dl/docs/article/ROBOT-Fall06-BalancingBot.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon
  • Mark PepperMark Pepper Posts: 14
    edited 2006-10-06 11:52
    Soryy but this is the article I am refering to at the beginning of this posting. The code is marked as experimental and in my case at least doesn't do what it says on the tin.

    Mark
Sign In or Register to comment.