Monday, December 04, 2006

December 4, 2006 update:

Well, I received the gears and wheels that I ordered. The wheels from www.budgetrobotics.com are great.

I used to be fairly proficient with my Taig microlathe, but not Sunday. The gears are bored for .25” (1/4”) but the shaft diameter on the motors is .234”. I decide to make an adapter that would fit better on the shaft and integrate with the wheels and gears. I tried to use some Fortal aluminum, but it wasn’t cutting as well as I had remembered. It took my quite an effort to hacksaw a chunk to chuck in the lathe, and then it kept bogging down on anything but light cuts. It would have taken a day for one adapter to whittle 1.5” down to .375”. So I switched to nylon. All told it took 5 hours to crank out one adapter.

The good news is it works great; the bad news is I have 1 more to make. I’ll post a photo tonight.


Onwards,
Jay

Tuesday, November 28, 2006

11/28/2006 update:

This past weekend I did indeed get some “me” time to work on my bot. I spent most of Friday making the cables and soldering the interface board. I decided to use ribbon cable (old IDE cables) for the point to point wiring versus wire wrap. I really like the way it worked out and can recommend other give it a try too.

I decided against creating four 8-pin cables from the port headers on the MAVRIC to my interface board. Instead, I designed it so that I used all of PortB for one cable and a combination of PortF, PortE and PortD for the other. In other words, I went the wiring harness route.

From left to right, simple switcher power supply, MAVRIC, interface board, encoder, DC gearmotor

I also decided against reusing my tank base for this bot. The vacuum cleaner belts were starting to dry rot and I really wanted to redo the mechanics of the drive. I spent the rest of my weekend looking for solutions to couple the motors, wheels, and encoders. When I finally settled on gears I then began the search for affordable gears. www.servocity.com have a nice selection, but they are very proud of their gears. $4.95 for 1 gear and it doesn’t even have a set screw not is it bored for the ¼” shaft. Instead they want to sell you a hub for another $4.95. I have a micro lathe and can make my own hubs, but $4 is too much for a single gear IMHO. I found Stock Drive after trying www.servolink.com (great prices but $30 minimum order) and MSC (no details on the gears). They hit me with a $3.95 handling charge for using the online store and then another $6.18 for UPS for 4 freaking gears. The gears were reasonably priced at $2.10 a piece. If they had offered USPS I would have picked that. It’s a major pet peeve of mine getting overcharged for shipping. But I digress.

Oh, and I also ordered some wheels ($10 minimum order) from www.budgetrobotics.com . After deciding on the gears, I was able to knock up a model in CAD. The silver motors will be aligned with the center of the 9" diameter disk platform. The red encoders will be linked via the gears. The wheels will be attached to the gear on the motor shaft via 4 screws. I am planning for the gears to be a press fit, but if not, the hubs on the gears or thick enough to drill and tap for a set screw. Failing that, I'll bore out the hub and make a sleeve hub out of aluminum.

Onward,

Jay





This iso wireframe shows how the gears come into play. The base is made from 6mm pvc.


Wednesday, November 15, 2006

11/15/2006 progress:


What have I been up to? Well mainly I have been thinking about how to physically interface my sensors and peripherals to the MAVRIC. The MAVRIC has 6 8-pin headers (he offers screw terminals too) for each port of the ATMega128 cpu. I am being playing with my pin layout to consolidate as many pins on a port as I can. Some pins are too specialized for this (A2D, UART) and thus I have it down to 4 ports.

Also I have three serial devices but only two serial ports. I need to play with bit-banging to one of them (most likely the voice module).

I have not touched the bot in over a week, but I did place an order to www.sparkfun.com for some odds and ends. This weekend I am testing for level three in Krav and then I’ll work on a interface board. But then I’m still in a circle. Do I need an interface board, or do I create custom wiring harness with 5 8-pin connectors on one end and sensor connectors on the other. Or do I create 4 8-pin bus connectors to a connector board and tie the port pins to their connectors using wire wrapping or point to point soldering and then run another connector from the board to the sensor. I like the second method better but it’s more connectors and thus more to screw up.

Here is what my connector board looked like on a previous robot: http://www.geocities.com/jaydmdigital/ieee/jamaica.html 3rd picture.

After I get the whole connector thing decided, I can work on the PID, line sensors, IR sensor, etc… so you see it really is a key decision.

Hmmmmm…

Jay

Thursday, November 02, 2006

11/2/2006 progress:

I tested my PWM code (and corrected a typo in my blog) tonight. I’m happy to report that locked anti-phase is working. The “sings” at the locked position but I can live with that (I think). Hopefully it won’t be louder than the voice chip speaker. Also, using my RC wattmeter my motor never goes above 1A even with a locked rotor (i.e. my stopping it by hand) with a 12V motor source.

So next on the agenda is PID testing. Then onward to line following.

Onward,

Jay

Wednesday, November 01, 2006

11/1/2006 update:

Things have slowed a bit. I decided that the best way to test the line following was to have a moving platform. Therefore I decided to rebuild my H-Bridge circuit. I decided to compare the circuit I built nearly a decade ago with the reference design. Wow, not sure what I was thinking but my component values for the RC blanking circuit were way not right, and my current sense resistor wasn’t even connected.

Locked anti-phase
Previously I was using PWM of the enable pin for speed control and the phase pin for direction. Recently I read about PWM of the phase call locked anti-phase control. At 50% the motor is locked and thus neither moves forward or backward. If the PWM is less than 50% then it moves backward, greater than 50% forward. How much greater or less than 50% controls the speed. So now you get speed and direction with one control line.

New circuit
I soldered up my new circuit with more correct values except the current sense resistor. RS doesn’t carry a .5ohm resistor and paying $5 for a resistor is nuts. Long story short 10ohms was too big and I ended up removing the current sensing and blanking components from the circuit to make it work. Also I need to get a smaller tip for my iron as I had a short (or two) that I had to trace down too. Once I’m sure on my circuits, drafting a PCB seems like a good idea.

Testing
To test my circuit I first tried it as a servo. I must have been high from solder fumes because I knew that PWM of a servo doesn’t use a duty cycle it uses pulse timing (1.5ms for center, 1ms for 0 degrees, 2ms for 180 degrees roughly). So as a quick and dirty I bit banged a 500ms 50% duty square wave. The motor was locked alright but it was singing too. So I tried smaller periods and settled on 50ms. I’m hoping that using the built in phase correct PWM of Timern that I can get a nice smooth 127 steps in both directions with little wasted power at “stop”. I am thinking that I’ll need to add a brake line for each motor to de-energize the motors at 0 speed (50% duty).

PWM
There are 4 timers on the ATMega128 Timer 0 and 2 are 8-bit and Timer 1 and 3 are 16 bit. All are capable of PWM using output compares. If I only need/want 127 steps then and 8 bit timer is enough, but I can see no penalty in using a 16 bit timer either. So here is the scenario. Using the phase-correct mode of operation the period of the waveform is set by the WGMn3:0 bits. Either 0x00FF, 0X01FF or 0x03FF. For 8-bit 0x00FF is what I’ll use. TCNTn will count up to 0x00FF and then count down to zero. If OCRnx == 0 then the output will be zero. Similarly if it is 0x00FF (or TOP) then output will be 1. So first step is to decide the actual period and set the prescaler to get close. The CPU clock is 16MHz. A prescaler of 64 will give us a 4us timer clock source. This means our period will be roughly 2ms (2 * 255 * 4us) or 500Hz. Now we need to configure the Output Compare bits in TCCRnA. We will configure them to 2 (10b) to clear the output bit on up counting match and set it on down counting match. Finally we need to set the DDRx bits for our output pins.

void timer1PWMInit (void)
{
// Set prescaler
TCCR1B = 0x03; // Timer clocked at F_CPU/64

// Init to 8bit phase correct mode 1
TCCR1A = _BV(WGMA0);

// Configure Output compares for A and B mode 2
// output bit will be cleared on match while up counting and set on match while down counting
TCCR1A = _BV(COMA1) _BV(COMB1); ;

// Set DDRB pins 5 and 6 for output
DDRB = _BV(OC1A) _BV(OC1B);

// set motors to 0 or 50% duty for locked anti-phase controller
OCR1A = 0x7F;
OCR1B = 0x7F;

// Enable timer1 overflows
TIMSK = _BV(TOIE1); // enable TCNT1 overflow

}

Onward,
Jay

Wednesday, October 25, 2006

10/25/2006 progress:

What a good day it turned out to be yesterday. I went home at lunch to fix the serial cable connector. I booted it up and tried the Soundgin software. YEEHA it works! I spent some time playing with the vocabulary by adding my own words to the listing. So now I move on to the line following sensor.

I have decided that each sensor will be individually mounted and wired. I will use 6’ servo leads. I am leaning towards the QRD 1114 part for ease of mounting. I will try analog first.

Still need to get some proto PCB. I’d rather use the solder mask plated thru hole material vesus the RS stuff, but it’s hard to tell what you get if you order it from a B&W photo. Anyone have any part numbers for me to use. I am thinking 4”x 6” or 2”x 3” .1” PTH with solder mask and mounting holes in each corner.

Onward,
Jay

Tuesday, October 24, 2006

10/24/2006 update:

I decided to take a break form programming and build my audio/voice circuit for the Soundgin. I spent about 2 hours Sunday laying out and soldering the circuit provided by the manufacturer. I didn’t get a chance to test it until that night and it didn’t work … well it did make noise, but not what I was expecting. So I had to wait till lunch Monday to do some debugging. Rather than look at the schematic and trace the line, I draw the schematic based on my soldered circuit. I used that link to creating your own graphing paper to generate PCB graph paper (i.e. dots versus lines) spaced at .2” so I could see what I had. Everything was correct but I had forgotten one connection from the low pass filter to ground. I added it after dinner last night and bingo, I get the demo with plays all the allophones to work.

This morning before leaving for work I added a header to allow me to jumper the demo input to ground, and either use 5V for the LM386 or a 9V lead if I need/want more volume. I also plan to play with adding capacitance to the gain pins.

I had hoped to test the Soundgin software with an RS232 to TTL cable I made ages ago for an HC11 Botboard. Unfortunately, I made a guess as to which pins should RX and TX when I soldered my circuit to the header and I guessed wrong ;) Oh well, with my new crimps I’ll be able to redo the cable in no time. You see, I tried to fix it in the field and ended up pulling one of the wires out ... doh!

Well, back to my list. I think I’ll work on #3 next. That’s the line sensor circuit. That will also require #2. Then I’ll tackle #5. I have 5 of the 3252SB chips in my inventory.

Onward,
Jay

Sunday, October 22, 2006

10/21/2006 update:

Progress has been either stopped or else moving backwards. I’ve been down the very dark street of the TWI on an Atmel device. Long story short, I can’t trust the TWI not to freeze and thus block in my code. So I’m dumping it, the I2C LCD (which I think I may have shorted out too L ), and the last few days of my life. Yeah it’s been bad, but on the the good side, I now have a good handle on how to use the debugger.

So, now I’m dropping back to serial for my LCD (only 16x2 and 9600baud versus the 20x4 and 100KHz). I also grabbed a copy of FreeRTOS which has an AVR port though I’ve had to do some work to port it to mega128 versus the mega232. I need to get my srf04 and encoder code (I intend to pull it out of AVRLib to keep it simple) and get a basic system to have the display updating 5Hz, the sonar measuring (pinging) 10Hz using an external interrupt, and the encoder as an interrupt.

Oh, and all my parts for making wires came in as well as my sound chip and components to get that circuit built … too bad I fried my brain (and nerves) on the $^%^* I2C first.

Onward,
Jay

Monday, October 16, 2006

October 16, 2006 to-do list:

Things are starting to get a bit overwhelming for me. I tend to get ahead of myself and end up second-guessing, blue-skying, and just plain day-dreaming. In other words, I stall out until I can procrastinate no longer and I end up doing marathon sessions. In an effort to prevent that from occurring this time, I have decided to create a to-do list and try to link any dependencies so I can see the forest and the trees.

Note not listed by priority.

1. Build some cables and a break out board.
Status: The parts for the cables has been ordered and should be here by Wednesday. I have a PCB protoboard from Radio Shack but it may be too small.

2. Make a sample of the contest board and line for testing.
Status: Not started. Not a high priority but will need it when I test line sensors.

3. Make a line sensor and test different parts and configurations.
Status: I have QRD1114 and QRB1114 parts and can either feed them into the A2D or to digital I/O via an inverter. I have used both and am leaning towards the A2D.
Dependency: Maybe on wire making parts … but not required for prototypes

4. Make a terminal serial cable for debugging with AvrX
Status: Need to get a surplus serial cable. Then just connect the wires to the MAVRIC. I’ll search for one at lunch.

5. Rebuild/build H-bridge circuit.
Status: I have my original (5 years old now) Allegro Micro A3952SB circuit board and some of the newer A3959SB parts. I need to redo the circuit with cleaner wiring.
Dependency: Wire making parts

6. Design the shape and size of the robot.
Status: I found this link to a website that let’s you print your own graph paper. Will start sketching some designs for the wheel layout and base shapes

7. Design the motor mounts and encoder mounting
Status: Currently I have a tank-based mobile platform with the encoders serving as the other end of the tank tread. I will need to design a way to transfer the shaft motion to the encoders without interfering with the wheels. Also, I’d like the make the motor/encoder mount as a module that can be removed/installed as a component incase I ever want to change the base shape/layout.

8. Prototype a circuit that will decode the 1200Baud I/R signal.
Status: No started but do plan to use one of the UARTs on the MAVRIC. Have not decided on photodiode or phototransistor and will need to do some prototyping.

9. Add sound/speech.
Status: Have ordered components but am backordered on actual voice chip. No ETA. Will call manufacturer to get their opinion and may switch to competing product depending on timeline.

10. Build ball launcher.
Status: I have a pretty good idea for the design using a PVC elbow, a brushless DC motor (because I have one), and BLDC controller using a servo output. At this point I don’t have any real size constraints. The module should be sell contained and thus make it easy for me to change position and angle of it. At this point I am looking for the launcher to sit on one side of the robot.

Onward,
Jay

Sunday, October 15, 2006

October 15, 2006 progress:

One step back, two steps forward. I became obvious to me once I started trying to put a few sensors together and control the rate at which they scanned and displayed their data that I need some sort of task scheduler or RTOS. A quick search on Google and it brought up one I had read about but never used AvrX.

So I have sent the last day reading about AvrX and experimenting with shoehorning my existing sensor drivers into it. After some initial issues with the makefile I was using I have successfully grafted the encoder, i2c, and matrixglcd functions onto some example code Larry provides. I love quick wins it just boosts my morale.

So now that the quick and dirty is out of the way, I am reading everything I can about how and when to use the AvrX api. I have joined the Yahoo Groups support group as well. I hope to have the SRF04 code added by tomorrow. However, it looks like I may want/need to make a serial cable to enable debugging first.

Onward,
Jay