Monday, June 2, 2008

Trackbot part 3


Trackbot top shot showing main board

For the main board I used the same IR emitter/detector circuit used for Squarebot. I also added a PIC microcontroller to be the brains as I wanted a bit more that just avoidance in the design. All my original design work was done on a breadboard that stayed setup until the design was finished. I find this makes if very easy to go back and test things (like the flyback diodes described later) and when wiring up the boards it helps also. Also to push myself a little I used a PC board a third the size
of the board used for Squarebot. It was tight but worth the effort. The output from the detector circut went to the microcontroller. I also had a bump switch on the front of Trackbot as an input. The bump switch was mounted quite low in case an object was missed by the detectors and run into. The outputs from the microcontroller couldn't directly power the relays. Instead they switched a transistor which turned on the relays. I had also missed putting in a flyback diode over the relay contacts. As a result everytime the relays turned off a huge spike went through the circuit causing the IR detectors to "flutter" and false detect. Some small signal diodes fixed that, plus they fitted in the rather tight board as I hadn't originally allowed space for them.

The reason I choose a PIC microcontroller was primarily based on the programmer board I could buy. The board I purchased (details) was only $50 AUS and included a $9 microcontroller. There were few other cheap programmer boards available and not know how much I would be using it I didn't want to spend $300+ on a professional programmer to only use it once. For this project the PIC16F84 was more than adequate for what I wanted. Plenty of memory space and IO pins for my simple design. I had done some assember programming at Uni but I found an excellent PIC16F84 tutorial which meant I could get the most out of the chip with the least trial and error. The only other doco I used was the datasheet from Motorolla. The actual program will be in a later post. I did consider a DIY progarmmer board but didn't want the frustration of getting it working as most of the designs were very specific to certain computer hardware setups.

I found out a few things with the programmer/design. The first was that the watchdog reset was enabled by default. The result was the program was reset every few milliseconds. Strangely it wasn't till I was testing the bump switch that I noticed. The bump switch would send both motors into reverse for a short time then turn (ie one motor reverse). This was to get Trackbot out of the situation of hitting something full on and avoiding the "both detectors sense something, full reverse, nothing detected, full forward, repeat" situation. With the watchdog reset occuring this wasn't happening. The other thing that took some tinkering was the time delays on turning on the relays to control the turning of Trackbot. Since there is always a delay when a motor changes direction I needed to wait long enough for the motor have time to reverse and long enough for some actual "turning" to take place. This took a bit of trial and error as expected.

Next time the first test run...

No comments: