Shop OBEX P1 Docs P2 Docs Learn Events
PEKBot — Parallax Forums

PEKBot

JohnBFJohnBF Posts: 107
edited 2009-05-27 06:33 in Propeller 1
I was going to re-make a BoeBot with the Propeller Proto Board - the holes match up and all. But at the last minute I changed my mind. Who wants to solder everything in? All the fun is configuring, and re-configuring, and then changing everything all over again, particularly with the huge possibilities of the propeller chip. So I used the PE Kit instead.·I added a 9-volt battery to keep the chip power separate from the servos, added power switches and voila:·a PEKBot!·The PE Kit breadboards are held in place by friction·with a balsa enclosure, so I can reuse them again eventually.

Terrific fun with all kinds of different things going on at once!

/John
3008 x 2000 - 228K
«1

Comments

  • crgwbrcrgwbr Posts: 614
    edited 2007-03-01 19:03
    great job. simalar to my Mars rover bot.

    http://forums.parallax.com/forums/default.aspx?m=174955&f=21&p=1#m175109

    What kind of sensors do you plan on using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    NerdMaster
    For
    Life
  • RsadeikaRsadeika Posts: 3,837
    edited 2007-03-01 19:13
    Nice job. Now if you add a remote control with a random move or controlled move selection, that would make it even more interesting.
  • edited 2007-03-01 19:21
    Hey, John, that looks great!

    Would you like some object following code for it? It's got some useful Spin objects for speaker, servos, IR detection, and PID.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • rokickirokicki Posts: 1,000
    edited 2007-03-01 19:40
    I sure would like that code! Please post!
  • edited 2007-03-01 19:59
    Cool, it's attached along with a video clip that shows the Boe-Bot using P control and·a PE Kit Bot using PID control.· Sorry about the sparse comments; it's been kind of a side project (in progress), and free time has been a little sparse lately.· I'll post some extra notes shortly.

    Andy

    <Edit>
    Modified source code was moved two posts down - here is the link: PE Kit Following Bot Source.
    Vidoe clip is still here.
    </Edit>


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 3/1/2007 9:05:21 PM GMT
  • JohnBFJohnBF Posts: 107
    edited 2007-03-01 20:30
    Thanks for the code, Andy. What a treasure chest of great stuff! I also want to incorporate IR remote control. So far I've built a very simple Sony IR decoder object, which I posted on the object exchange the other day. I'm sure there will be more sophisticated ones soon.

    Now I need to avoid the temptation to just download your code to the Bot, adjust the pin constants and circuits and have fun with it. I've found that when I do that I'm just renting the ideas. I don't really own the concepts until I build things from scratch. Well, maybe I'll do it the easy way just for a bit.

    /John
  • edited 2007-03-01 20:51
    John,

    Yeah, I know what you mean about owning the concept. You'll undoubtedly start working from the ground up after taking it for a spin. Also, a lot of the cog counter module techniques the objects use will be introduced in the forthcoming PE Kit Counters labs.

    IMPORTANT: I posted a copy of the source code here with some more comments. The top file is "PID Following Propeller Bot.spin". Open·it and start reading the comments·from the beginning of the file. The top file's PUB init block also has comments on how each object gets initialized, and the main block has comments that explain the relation ship between the distance measurements and the servo outputs.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 3/1/2007 9:04:51 PM GMT
  • Stan671Stan671 Posts: 103
    edited 2007-03-02 00:10
    Andy, thank you so much for posting those beautiful gems of code for the PID robot control.· I have been hesitant to tackle PID for my bot because it just seems way too complicated.· Your code will be studied and borrowed and tweaked.

    And the video very clearly·demonstrates·the difference in quality and smoothness of control with the PID.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stan Dobrowski

    Post Edited (Stan671) : 3/2/2007 2:44:38 AM GMT
  • Bryan K.Bryan K. Posts: 47
    edited 2007-03-02 15:27
    Have any of you used the PID with a balancing robot? There was an article in Nuts and Volts, the Oct. issue, the "Build a Balancing Bot, Part 1" I am thinking of using the Prop to build a balancing bot using PID control.
  • BergamotBergamot Posts: 185
    edited 2007-03-02 16:53
    Bryan K. said...
    Have any of you used the PID with a balancing robot? There was an article in Nuts and Volts, the Oct. issue, the "Build a Balancing Bot, Part 1" I am thinking of using the Prop to build a balancing bot using PID control.
    Hey, me too! I wonder how many people here are working on the same project.
  • Bryan K.Bryan K. Posts: 47
    edited 2007-03-02 17:02
    Bergamot,
    I am trying to come up with something based on the Nuts and Volts Balancing Bot article, but using linear accelerometers instead of the angular tilt sensors. I am thinking if its possible to use the ADC program from the object exchange to read an analog voltage from the accelerometer. Any luck? It is just a project on the side for now. How far are you with the PID control, and/or the rest of the robot?
  • BergamotBergamot Posts: 185
    edited 2007-03-02 20:16
    Bryan K. said...
    How far are you with the PID control, and/or the rest of the robot?
    Probably about as far as you are; I just finished basic design, and ordered my first round of parts. When they get here, I'll start working on interfacing the propeller with the sensors.
    Bryan K. said...
    I am trying to come up with something based on the Nuts and Volts Balancing Bot article, but using linear accelerometers instead of the angular tilt sensors.
    Well I won't know until I start building, but as far as I've been able to tell, hobbyist-level accelerometers have too much of a lag to keep the body stable.

    The 'right' way seems to be to use an accelerometer to get a normal force vector, use atan2 to turn that into an angle, and combine that with angular velocity readings off a gyroscope. The most popular way to do that is a Kalman filter. While I understand how to use one, I won't claim that I have a firm grasp on what it's actually doing.

    Once you figure out the angle, you compare it to what it "should" be, and use the PID control to minimize the difference. PIDs are way easier than they sound; the only hard part should be doing it without floating point math.
    Bryan K. said...
    I am thinking if its possible to use the ADC program from the object exchange to read an analog voltage from the accelerometer.
    That's my plan too. It's made very easy by the low sample rates we're talking about (most of the people doing ADC are taking thousands of samples per second, and I only need a couple hundred.)

    Since I'm prototyping it all on a solderless breadboard, I'm interested to know whether i can get decent ADC readings with that. Someone in an old analog thread mentioned getting it to work, but was a little hazy on the details.

    After I get the darn thing to stand up, then I get to have fun adding a remote control, collision sensors, etc. It's a hobby and a learning process
  • Bryan K.Bryan K. Posts: 47
    edited 2007-03-28 04:01
    I think the gyro is a must, now that I have researched the concept further. I am starting to develop some basic outlines for coding, trying to use the PID object from the PEKbot ( the program above) to actually compute the output from the error in a few lines of code. I also looked into driving servos from the output versus an H bridge, requiring different PWM signals to do so. I also thought of using an external ADC (8 or 12 bit) to measure the signal voltages from the gyro, as this does not take up more processing than running the ADC object. If you are still going to use the ADC object, let me know how it goes.
  • rjo_rjo_ Posts: 1,825
    edited 2007-03-28 13:48
    ++Acronym Alert^^

    PID has two generally accepted meanings: 1) Pelvic Inflammatory Disease-- not a fit subject for this forum, as in "Copper Seven"- IUD.
    2) "Proportional band - Integral - Derivative" http://www.expertune.com/tutor.html
  • LitefireLitefire Posts: 108
    edited 2007-03-28 20:22
    when you say that PID is way easier than it sounds, can you show me some sample code for PID that would work for the propeller?

    ~~Brian
  • edited 2007-03-28 20:25
    Brian,

    There's an example in·a post in this thread with the timestamp: Posted 3/1/2007 12:59 PM (GMT -7).

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • LitefireLitefire Posts: 108
    edited 2007-03-28 20:42
    oh duh. sorry about that.

    ~~Brian
  • LitefireLitefire Posts: 108
    edited 2007-03-28 20:47
    andy, just looked at this code and it looks really interesting. what i'm wondering is if it is possible to have an updatable setpoint. for instance, if i have the loop controlling velocity, i'd like to be able to change the velocity that it strives to attain. right now, it'd only be able to get to a certain speed, not good for my application. would you happen to know what i would have to change to do such a thing...?

    ~~Brian
  • edited 2007-03-28 22:28
    Hi Brian,

    This method aught to do it (below).· Just add it to the PID object, maybe as the second method.· The object calling the method could use a command like pid.spNew(26.5) to update the set point.· Or, substitute a variable that·stores a floating point value in place of the 26.5 floating point constant.

    PUB spUpdate (newSetPoint)
      '' Update Set Point
      sp := newSetPoint 
    
    


    BTW, what this does is copies the·method's·newSetPoint parameter (a local variable) to the PID object's sp global variable that gets used in the PID calculations.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 3/28/2007 10:40:46 PM GMT
  • LitefireLitefire Posts: 108
    edited 2007-03-28 22:48
    great, thanks so much!

    ~~Brian
  • JohnBFJohnBF Posts: 107
    edited 2007-03-29 01:38
    In addition to the PEKBot that started this thread, I am also working on propellerizing the BS2-based balancing robot I reported in January at
    http://forums.parallax.com/forums/default.aspx?f=21&m=162898

    I replaced the BS2 with a propeller protoboard and very quickly got the bot to balance using the Ping))) sensor just like it did with the BS2. I then added two memsic 2125 accelerometers (one at the top and one at the bottom of the chassis) and an ADXRS300 rate gyro.

    I then took the Parallax mini USB cable out of it's housing to make a very thin, very flexible wired connection to my PC and I am using PLX-DAQ to dump sensor readings to an Excel spreadsheet.

    My strategy is to look at the accelerometer and gyro readings while the bot is actually balancing to develop strategies for getting the bot to balance with an accelerometer and gyro.

    So far the data is interesting and I've got some ideas, but I have not tried to implement them yet. I'm trying to be patient and collect really good data first.

    I'd be happy to post the spin code I'm using if anyone would like to take a look, but this is still very much a work in progress.

    /John
  • BergamotBergamot Posts: 185
    edited 2007-03-29 17:40
    John: Are you using an external ADC chip for the gyro, or the propeller's counter-based solution?

    I really wish someone would make a memsic-2125-style breakout board for the new generation of serial gyros; it would save me a ton of complexity.
  • JohnBFJohnBF Posts: 107
    edited 2007-03-29 18:38
    I'm using an ADC 0831 chip. Nothing fancy, but quick and simple and it works fine. /John
  • edited 2007-03-29 21:30
    The attached Propeller Following PEKbot v0.90.zip has an updated PID object that uses Cam Thompson's Float32 object from the Propeller Object Exchange to do the floating point calculations.· In terms of sampling rate, the previous PID object was only good up to about 100 Hz.· The version in this zip is good up to a little over 1 kHz, which should be fine for the apps discussed so far in this thread.··I haven't started on an assembly language version yet.··When it's ready, I'm guessing it'll be good for least 100 kHz, probably more.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 8/24/2010 6:40:26 PM GMT
  • edited 2007-03-29 21:39
    litefire...
    what i'm wondering is if it is possible to have an updatable setpoint. for instance, if i have the loop controlling velocity, i'd like to be able to change the velocity that it strives to attain.

    Andy Lindsay said...
    Brian,


    This method aught to do it (below)....·
    Brian,

    I noticed while updating the PID·object that it already has an update method.· You can use that to update any of the parameters you initialize (including set point).· Best thing to do is open the PID object, then view it in documentation mode by clicking Propeller Tool's Documentation button.· The info for that method will be visible.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • Jim ColemanJim Coleman Posts: 52
    edited 2007-05-09 21:54
    Andy

    Please show by picture or drawing how the prop circuit board is attached to the Boe-Bot robot chassis and also the lay-out of the wiring so I can duplicate the design shown in the clip. I have just purchased two Bot’s to use with the prop.

    Thanks Jim
  • edited 2007-05-10 21:05
    Jim,

    For mounting the board, you will need a rectangle the size of the PE Platform with counter sinked holes for four 4-40 3/8" flathead screws. Use the material of your choice (I prefer 3/16" plexiglass.) The outline of the square will depend on whether you want two or three breadboards. Two breadboards would be 4 4/10" X 3 2/10", three would be 6 4/10" X 3 2/10". Drill 4 holes in the center per the Board of Education Manual's mechanical drawing. That's four .125" holes with centers on 3.7" X 2.75".

    For the wiring not covered by the schematic in the object example code, see the PE Kit Packaging, which is available from the Propeller Education Kit product page.

    Make sure to put the 4/40 screws through your mounting board before removing the waxpaper from the adhesive under the breadbaords and affixing them.

    Andy

    P.S. If this is a 1-off and you want to use two breadboards, I can arrange to send you a scrap Board of Education PCB. That's what I use on my PEKbot (see attached).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 5/10/2007 9:14:30 PM GMT
    1408 x 1056 - 353K
    1408 x 1056 - 432K
    1408 x 1056 - 358K
  • Jim ColemanJim Coleman Posts: 52
    edited 2007-05-11 04:27
    Andy,

    Thank you so much. I can’t wait to get started. I have compiled all of your PE documentation as well as many of the books you have written. I am truly a fan of your work. I don’t know where you find the time to produce the quantity of work that you do.
    I was going to skip the Boe-Bot after the Prop came into existence because the Prop is more challenging than the Stamp but now I will be able to do both the Bot and the Prop.
    Thank you for the offer of the circuit board, but I have collected so much Parallax hardware that I should be OK.
    Final thought: If I mount a stuffed animal on the Boe-Bot, what will our miniature Australian Shepherd think of the robot’s behavior. Time will tell.

    Thanks again, Jim
  • inserviinservi Posts: 113
    edited 2007-05-11 08:15
    Hello,
    What do you mean about PID ?

    dro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
  • edited 2007-05-11 18:10
    Jim,

    Wow, thank you, those are high compliments indeed!

    We shall look forward to a clip your Aussi Shepherd herding the PEKbot. Our cats get rather indignant whenever my PEKbot starts to follow them around.


    inservi,

    PID means Proportional, Integral, Derivative control. Here's a link to an explanation:

    http://forums.parallax.com/showthread.php?p=529609

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 8/24/2010 6:40:59 PM GMT
Sign In or Register to comment.