Well it’s certianly been a long since my last post, sorry! Between getting married and christmas (all on the same day lol), and the kids going back to school, my geeking (as my wife likes to call it) has been taking a back seat lately i.e. not a whole lot happening. However I have managed to squeeze in bit of learning. The first getting myself familiarilised with PIC micros, the picaxe although brilliant for small jobs, I have found to be limited, i.e. no timers etc. so I have been playing around with their big brothers. The fist learning project was a serial LCD using the 16F84, I’m using the brilliant Sourceboost BoostC Compiler ( http://www.sourceboost.com/ )
Also came across a brilliant DSP guide in an easy to understand language and not heaps if heavy maths , and its FREE for the online book http://www.dspguide.com/, this really made the light go on, ding! with the Ahh I get it in the smoke and mirrors world of DSP. I’m definately looking at purchasing a hard cover version.
I came across an interesting article yesterday on Hack-A-Day about using a LED as a Photo Sensor and cheap communictaion device. This is achieved by using some physical properties of the LED for both Transmit and Receive. The article also links to a cool video clip demonstrating this. Original Article can be found here http://www.hackaday.com/entry/1234000873073550/
Anyway this sparked my interest and I soon had a PICAXE-08M hooked up to test if it-in fact it works (I also made sure that the date was not 1st April LOL). After about an hour I had it working, this code requires 3 LEDs, One acts as the Light Source and is always on (not really necessary, you can use anything as a light source, the brighter the better), the Second LED acts as the Sensor and is connected to two outputs along with the current limiting resistor, this is really the heart of the concept. The third LED is a status Indicator and gets switched on and off depending on the reading of the LED Sensor.
This idea, as simple as it is, makes for some interesting sensor ideas.
Here’s the PICAXE code – LEDSwitch.zip
I have to make some decisions on what direction I need to go with my buzzbot project, basically I have been frustrated with some short comings of the PICAXE microcontroller. The main being lack of any onboard timers and having only one common interrupt available. Also I think that I’m trying to fit too much onto one of these babies.
Don’t get me wrong I love these little guys, they are fantastic if all I need is polled I/O, which for the majority of the time is what I’m after, however everytime I want to do something time critical I hit a dead end.
Main issues so far:
PID Motor / Differential steering Control – No timer interrupts and PICAXE not being fast enough to update PID Calculation base on each wheel velocity. I have no real way of getting around this so I think my options are to move to an actual PIC (as opposed to PICAXE) and program the PID Differential Steering in C / Assembler.
PWM Motor Control – Limited to 2 pwm output pins on the picaxe28, (btw this in itself is not an issue, just trying to get it working on the existing H-Bridge which has 4 wires – and I didn’t really want to use any external logic), I have tried coding a PWM using picbasic, but does not have the resolution, so I may have to add some external “glue” hardware to allow my h-bridge to be driven from onboad pwm and forward/reverse direction. I’m also cosidering replacing the existing H-Bridge that was part of the R/C buggy with a L293 Dual H-Bridge chip, this in itself will solve my issues with PWM motor control, but still need to resolve the PID issue for my differential steering.
IR Detectors – I have moved the IR Detector Circuit offchip while playing with PWM / PID control. This I have implemented using a picaxe08M, also having some issues here, although I think I can get around these. The 08M only has one PWM onboard, and I’m using this to modulate one of the IR TX LEDS. I would love to have 2 PWM onchip as the PWM/IRTX/IRRX Combo works really well in detecting objects, I have moved to a proper IR Receiver rather than just an IR Opto Switch. I had issues with sensitivity, and using a proper IR modulated Receiver has cut these out. I guess it was ambient IR causing the problems. The only problm I have now is as there is only one PWM I need to modulate another IR TX (The right) at approx 40Khz. I have tried it in code but no go as the picaxe is not fast enough, So I have been playing around with the “infraout” commands of the 08M, this in conjunction with the PWM seems to be causing alot of noise on the RX, if I disable the infraout then all works aok, so some more things to look at, it may be that the same onboard timer is being used as with the PWM, or the infraout is spot on 38Khz, as I have found by detuning the PWM down I decreased my falses. Anyway will look into this a bit more.
I started testing last night after finishing initial motor and wheel sensor hookups to my development board. Couple of minor issues so far.
I’m using a pic based board from Modtronics. These are great and reasonably priced, along with the prototyping daughterboard. However I have since found that the onboard RS232 is not on the same pin as the PICAXE28X, so I had to wire in an additional programming circuit, no biggy. The other issues so far were the wheel sensors. From my initial design I had used 10K resistors to bias the output of the opto-transistor, this was not tested and when testing the logic probe was picking things up ok, but not the PICAXE, after much stuffing around and not being able to find my multimeter (it was still packed away from shifting house) I ended up prototyping the same circuit, still had some issues, so I went hunting for my multimeter and of course it was on the bottom box lol. Luckily thanks to my trusty multimeter I found that the sensor was just dropping down to 3.8v when interrupted, anyway the solution to the problem was a larger resistor, a 22K on the output, this tested AOK, now getting ttl levels when switched, I also noted that the distance of the sensor to the reflective object (paper in this case) was fairly critical. I modded the breadboard and then found one side was working fine, the other was not being seen. Checked and found that the sensor was slightly further away than the one that was working. So out with the hot glue gun and moved the sensor. Both side are now giving me a reading on the PICAXE.
Next I adapted some motor control routines on Hippys PICAXE site to test my motor circuit. First I tested without my motor control board plugged in, didnt’ want any smoke to escape, and all logic tested aok, then came big crunch of running motors live. I can gladly say that all tests worked A1 with no issues. Motor was tested though a range of 3 speeds in FWD, REV, Turn right FWD , Turn Left FWD, Turn Right Rev, Turn Left Rev, Spin Left and finally Spin Right. While Testing the FWD and REV, I checked the Pulses from the wheel encoders to see how much the same each drive was over 100 counts from the wheel encoders and it looks like the Right side is slightly stronger than the left, no real surprise here as no two motor/gearbox combinations are the same. I had thought about this a few days ago and knew that with any differential drive system I will encounter this type of problem.
Motor Control Algorithm
This then leads me onto my motor control algorithm. Over the last few days I have been researching PID Controller and their application to motor control for robots, as I want Buzzbot to drive in a straight line, also been looking at fuzzy logic, but I think will give that a miss at the moment. I have been thinking of using and adaptation of the PI Proportional controller from the book “Robots – Inspiration to Implementation” however so far I’m not 100% happy with the PWM and the way it is from the code I adapted, while it is very simple and works, I would really like to use the onboard PWMout routines, but as I mentioned in an earlier entry it is only limited to two PWM and to two physical pins on the PICAXE – Bummer!!!! I also thought I can use the old PWM command. This command requires it to be refreshed, much like what is happening in my test code, except with a agreater resolution, unlike the PWMOUT that runs in the background, perfect I thought!, but when I went to test it I found it’s only available on the 08 series…double Bummer!!!!! So now may have to look at teh PulseOut command.
While the existing configuration does give me three speeds, the lowest is time critical and I notice that when I add a debug routine the slowest speed does start pulsing, also I don’t think it will give me the fine control needed on each of the wheel speed controllers. I’m going to have to think about this a bit deeper.
All in all everything is working as expected, with a couple of minor hicups along the way. Biggest issue will be PWM resolution and time of my routines. I think I’ll need to come up with another way of doing what I want simply and without too much additional hardware if I want a closed loop control system. While I ponder on this I’ll test the IR Sensor circuits. These I’ll prototype first before I hardwire in. Once I finish these I can then start working on behaviour. I would like to look at using some sort of subsumption model, but will look at it deeper as I get closer.
Last night I did some brain storming asto what the I/O requirements will be. During this requirements phase I came across a bit of a delima with the PWM requirements for the motor controller. The motor controller requires two outputs per motor, so this rules out using the onboard PWMout command of the PICAXE, as there are only two dedicated PWM pins on the chip that I’m using. Although I could do it with some additional glue logic in hardware, I don’t really want to do that (as I’m lazy), so now I will be doing it all within the software, this should free up the servo command within the PICAXE, so I can now use this to drive the servo for the sonar unit.
I’m going to be using the PICAXE 28X. With my I/O current configuration of the 22 available I/O on chip, I have 2 Inputs/Outputs and 4 Analogue Inputs Available for future expansion (or and additional 4 inputs if I don’t want to use the analogue inputs). It will be interesting to see if the processor will be fast enough process everything in a timely manner, especially with the motor control and encoders. Well I guess I’m about to find out.
I’m now going to actually get my hands dirty with the PICAXE as I still haven’t plugged the development board into my PC yet 🙂
Now that the Motor Drive Controller has been worked out, (but yet untested) I needed to make up some encoders for the Left and right Wheels. After a bit of research I found an excellent program for creating encoders and quickly made two and have just glued them to the inside of the wheels for some rough and ready testing. I really think I will need to make them more durable, but for the time being they should surfice. Once I have the encoders and the sensors mounted I will start some testing on the drive system and the PicAxe.
Some quick calculations to see what I get:
Wheel Diameter (D)=50mm
wheel Circumference (C)= D * 3.14 = 157mm
Encoder Resolution (Res)= 16
Distance Travelled Per between encoder Pulses = C/Res = 9.81mm
So per encoder output pulse width = 4.9mm (~5mm) – Remember the encoder has a resolution of 16 (50% black and 50% white) therefore I need to divide by 50% to get the per pulse distance assuming a nice neat square wave.
I’ve also placed the encoders in the top cover, filed out some slots and hotglued to suit.
Today I reversed engineered the control board of the RC Buggy and the results are the schematic attached. I was only interested in the Motor Drive CCT so thats all that is drawn. It looks fairly straight forward to hook up the PICAXE to this board, although the main Driver Transistors are TO-92L type packages, so I suspect the duty cycle of the drive will not be continuous as there are no heat sinks etc.
While I was at it I removed the RF Receiver Daughterboard and the decoder chip (U1 in the schematics), so now the board is all ready to go.
The Buzzbot idea came to me when i was trying to think what can i do to learn the picaxe uController, something practical, well rather than just flashing Leds and buzz buzzers anyway. What I wanted to do was something robotic that is cheap and easy as I don’t have much of a workshop facility available to me just yet to assemble any bases.
We had just moved house and whilst doing the spring clean of some toy boxes and throwing alot of my childrens toys into thte “garage sale” box I came across the Buzz Lightyear Remote control buggy. Basically a 6 wheel buggy with a psycho looking buzz with missile launchers as hands that raises and releases the missiles. Well the missiles were long lost and what interested me was in using it as the base for my “buzzbot” is that most of the work is already done for me. i.e. I don’t have to build a base and look for motors etc. I just want to get down to the nitty gritty of interfacing the PICAXE into something and playing around with it. Another thing that I think will work in my favour is that the Left and right wheel drives seem to be independant of each other as this thing from memory could turn on a dime, so therefore there must at least two motors, and the necessary driver circuits in place for me to use.
Upon dissasembly it looks as though I was right, a gearbox and motor for the left and right drives (front two wheels on each side are geared , while the rear is free wheeling) also a circuit board with a simple RF Receiver and a heap of transistors, which after some initial tracing leads me to suspect are the H-Bridge Drive implementation for the motors, Left, right and the psycho buzz torso aka Missle launcher (he raises up to fire) woohoo, most of the work is already done.
Man he must be on crack!
Ok since I have now dissected the Buzzbuggy it will now be re-assembled back into the “buzzbot” minus the psycho buzz torso, as I just want to use the base as my test platform for the PicAxe. I now need to trace through the circuit and see where I can tap into for the motor control, and also add some sensors.
First post to christen the new site……
Personal Projects underway.
1) Learn the PICAXE, a fantastic little uController, http://www.rev-ed.co.uk/picaxe/ I have just got my hands on the PICAXE 18X, so in attempt to learn to use this little beast I am looking at interfacing it with a few sensors and turn my sons discarded “Buzz Buggy” into a little 6 wheeled autonomous “buzzbot”.
2) Also getting pissed off mowing the lawn at home every week, especially now it’s summer in Australia, so have now decided to look at some sort of mowbot. After some research found someone who has actually implement one over the last few years with some great drawings and details, so will be using this as a starting point http://www.mowbot.org.