06 May 2010

One Step Forward, One Step Back

Tonight's goal was to get that motor driver board fired up and turn some motors. Well ... things didn't quite progress that far. But progress was made nonetheless.

The 298 driver board has six opto-isolated inputs, three for each H-bridge in the 298. First step was to tweak the arduino to operate three digital outputs, so at least the 298 board could be tested one half at a time. This was easy enough, just using digitalWrite() on pins 2, 3 and 4. Not having a lot of instrumentation, it would be hard to tell if the 298 board would even be getting any input, so before wiring to that, I connected pins 2, 3, and 4 each to a regular LED in series with 470 ohms to ground. This gave visible confirmation that the test sequence in the arduino was working correctly. The test sequence was just a cycle through all 8 combinations of the 3 bits to control half the 298, sitting about 1.25 seconds in each state, just about long enough to get stable readings on the DVM.

Next came the 12V smoke test on the 298 driver board, in isolation from the logic of course. The concern here was whether the board was wired up correctly. So I connected the return side of the driver to the battery, put the DVM across the battery to monitor that, and momentarily made contact to the positive battery terminal with the board's Vcc line. Open circuit this battery was showing 13.25V, a little low but not abnormally so for this kind of battery. A couple of quick taps with no exploding capacitors later, I noticed that with the driver board connected, the battery dropped to 10.5V. Not good. The driver board wasn't even driving anything, should be pulling maybe 50mA at most, and the battery should be good for 10 times that current.

So now for a reality check, I hooked the battery to my r/c plane starter motor and hit the switch. Absolutely nothing. This battery was on the charger all last week in preparation for this, and here it was, dead. Well, it was on the shelf for about four years before this last week. Then I noticed, amongst the other things printed on the battery, there at the bottom, "Replace every 3-5 years". Oh well, that's the step backwards. Did I mention my r/c plane starter? Yeah, it came with its own 12V sealed battery, about five times bigger than the one depicted last post. A quick spin of the starter motor confirmed *that* one was not dead. Back in business!

The size of the plane battery was a bit worrisome. If something shorted, this battery would make the event just that much more exciting. So, for a current limiter, I used that plane starter motor. It's practically a piece of wire, compared to the L298 driver setup, and it has a switch, and even if the 298 board totally shorted out, the most energy that would be involved would be no worse than that from hooking the starter to the battery directly and hitting the switch, which is the normal operation for those two things. OK, so the circuit under test is now L298 board return connected to battery (-), battery (+) to the starter-motor with integrated switch red clip, start motor black clip to L298 board +V line. DVM across the battery. Brief contacts with the starter switch resulted in (1) virtually non-existent droop on the battery voltage (2) a complete lack of the start motor spinning madly and (3) No Smoke. Time to connect the 298 and the arduino!

But wait - what to use for a load for the L298 board? The chassis with the motors is too big for the coffee table I have taken over for a lab bench. Instead of using a motor, I put two LEDs back to back, then a 2K-ohm in series with the LEDs, and put that across one of the H-bridge sections. Using two LEDs like this, each one protects the other from reverse voltage excursions. One is biased backwards, but only by the forward voltage drop of the one that's lit. This way it's easy to see which way the current is flowing. Using 2K-ohms with a nominal 12V and figuring 1.5V for diode drop would put about 5mA through the LEDs, just about right for easy visibility.

Fortunately the 298 driver was working according to the design, there were only a few moments of confidence-shaking loose breadboard wires (typical), and once the wonky wires were tamed I had confirmation from the LED setup that (1) code in the arduino was producing the test sequence, (2) the arduino was in fact driving the opto-isolator inputs hard enough, (3) the opto-isolator outputs were driving the L298N well enough, and (4) the L298 H-bridge was gating the motor-output leads to +12V and ground as controlled by the test sequence. Success! Well, with lights standing in for motors. For half the board at least. I didn't solder enough leads onto the 298 board last night to test the other section.

And there's tomorrow's plan: get the setup off the breadboard, get some nice soldering done and hook up actual motors. If I get that far, then cable up those archaic game paddles and maybe do some test driving. I mean, load testing. Yeah.

05 May 2010

Fired up the soldering iron

Not letting this robot thing fizzle out, I pushed for more progress tonight. The immediate goal is to put the Arduino Duemillanove on the chassis, tie it through the L298N motor driver to the motors, and try to drive it around with tethered controls.

Sounds simple enough, until you try it. Tonight's free time was consumed entirely by trying to get that 'tethered controller' part operational. The result? I do now have two potentiometers, in relatively nice hand-held cases, hooked to the arduino, and the arduino producing two channels of PWM, which currently just operate LEDs. The rest of the post is just the gruesome details.

The controllers started life as Apple 2 paddle controllers, probably dating to about 1978 by the look of them. Just one of those weird sorts things you end up with in your electronics re-purposing bin. Anyway, after no doubt being used for some truly epic Pong sessions back in 1978, then gathering dust for a while, they are now going to be reincarnated as a low-tec robot control input device.

There are two 'paddles', each one having a potentiometer and a momentary switch, and they are Y-cabled to a 16pin DIP header. (Funny what passed for a consumer product connector back in those days.) Some re-wiring was required. Not sure how the Apple2 dealt with them, don't even need to know, just suffice it to say that the wiring in there was strange, some kind of rheostat/270ohm thing. Whatever. I re-wired them to provide a 0 to +Vcc output, and while in there, rigged the switch to be normally open with contact to ground. The DIP connector plugs nicely into a breadboard, too.

So with two analog inputs of the arduino, a quick 'sketch' (honestly, that's what the arduino IDE calls a project) to copy AIN0 to PWM pin 9 and AIN1 to PWM pin 10, and there's a demonstration of a system that should be able to provide PWM to actual motors, just as soon as that L298N can be rigged up.

Here's the arduino, skating around loose on top of the breadboard but jumpered to a pair of LEDs, standing in for the motors, and to the controller input. The 16pin controller input is that large black boxy thing in the bottom center.


and here's the L298N driver board, and the battery for motive power. That tangle of stuff on the left is the L298N, some bypass caps, and you can just make out the TO-220 case of the 7805 and 330uF bulk cap that will provide isolated logic power to the L298. Motors connect on the left side, and that entire right half of the board is six opto-isolators. Told you it was ugly!

Anyway, that chewed up a couple of hours, but tomorrow, that 298 is going to trade electrons with that battery, and with any luck at all, the smoke will stay inside the little plasticky things.

Labels: ,

04 May 2010

robot tinkering

Over the last week or so I have been resurrecting my from-scratch robot project. I had gathered a number of pieces but for various reasons all this stuff was neglected for a while. After considering where it was left off, a few design changes were in order.

For example, the previous design was to be differential drive, with motors left and right, and passive support (casters) front and back. I had a 12 inch square piece of 3/4" plywood more or less drilled out to support the motors and casters that way, but was never quite happy with it. Finally figured out why. Imagine what happens when the robot comes to the base of a ramp. The front caster goes up a bit, and suddenly one or both drive wheels is off the ground. In other words, said configuration can't climb a ramp. I didn't want to just re-invent the car either, and besides, implementing a pair of articulated steering wheels is probably more than my rudimentary mechanical skills are up for. So here's how it's turned out: the differential drive remains, but the wheels are now moved to the forward edge, and a single caster at the trailing edge completes the setup.

Also dusted off was an L298N dual H-bridge motor controller board I had cobbled together. I wasn't happy with the way that turned out either, which no doubt contributed to the entire project being shelved for too long. Mainly the breadboard-shaped proto-board, with six opto-isolator chips on it, takes up too much room for the amount of functionality provided. After so long on the back burner, I decided that if it removes an obstacle to getting something rolling (it does) then it's good enough.

And in the control department, the ultimate goal is to have wireless operation. I think the way to do this may be to stick an 802.11g wireless router on the robot, and use an SBC to operate the robot hardware. Finding an SBC with built-in wireless is proving difficult, and besides, anything built into the board will be hard to modify, whereas if the SBC just provides a standard RJ45, then eventually replacing the 802.11g with an 802.11n wouldn't be such a big deal. The other advantage of using a wireless router, rather than a simple wireless nic, is that I can follow the robot around with the netbook; if the robot and netbook both were just wireless endpoints, both would have to stay in range of some fixed router. So the robot-as-router simplifies the system. So now the battery is going to have to get bigger, but it's probably worth it. (Unless someone can tell me that it's a piece of cake to get two wireless endpoints talking to one-another *without* a router)

However, before committing resources like a wireless router and an SBC, it seems prudent to target an intermediate stage of development. So for the time being, the plan is to operate in tethered mode with an arduino to provide PWM to the motors. This will be valuable to check out the dynamics of the platform and prove whether that rat's-nest ugly L298N driver board can handle the load. Well, I would be remiss as an engineer if I weren't about 99% certain it would, but it's always reassuring to see a design put through its paces, isn't it? Anyway, this will require getting the arduino to produce PWM outputs. For a tethered controller, a couple of potentiometers will provide analog inputs to the arduino, which will just turn around and drive the PWM with the values from the pots.

And good progress on the arduino front -- tonight I proved out enough code to drive one of the two drive motors. Hooked one potentiometer into the arduino, and an LED on a PWM output, and could vary the LED brightness with the pot. This should easily extend to running a 2nd channel (for the other motor), then it's just a matter of securing the chassis, motor drive board, arduino, and the 1.2A-Hr, 12V sealed lead-acid battery, and seeing how it handles.