## Sunday, September 30, 2012

### AFRON announces winners!

Congrats to the winners of the African Robotics Network "10 Dollar" Robotics Design Challenge! Some very clever designs put forth!!

## Friday, September 28, 2012

### Eagle CAD: Copying Between Schematics

Here's how to copy between schematics in Eagle CAD 6.1.0.

First of all, where is the CUT tool?! It's been replaced by the copy tool. You can now use that to copy between schematics.
• Open one instance of Eagle CAD with your target schematic (TARGET)
• Open another instance of Eagle CAD with the source schematic you're copying from (SOURCE)
• SOURCE: In the source instance, use the Group tool to select what you want to copy
• SOURCE: Click the copy tool
• SOURCE: Right-click on one of the parts and select Copy: Group from the contextual menu
• TARGET: click the Paste tool and paste your group wherever you want.
Took me awhile to find this information so I thought I'd try to spread the word.

## Friday, September 14, 2012

### Entry for AFRON "10 Dollar Robot" Design Challenge

 "Carve" - Bot Thoughts prototype for the AFRON "10 Dollar" Robot Design Challenge

Awarded Honorable Mention

## Overview

"Carve" is the Bot Thoughts entry for The AFRON "10 Dollar Robot" Design Challenge, Traditional Category, an educational robot system with flexibility to provide students and hobbyists around the world with an extremely affordable, capable, expandable, flexible, reliable learning tool.

The name "Carve" comes from a skateboarding term and is a nod to a rather distinctive component on the rear of the robot, as well as a description of its turning radius...

Mass produced cost is estimated at $12.73 for 1000 units, not including per-classroom accessories (approximately$27). Prototype cost is estimated at just over $28 including battery, and around$55 including required accessories (one each per classroom).

The base model provides a fully autonomous robot line follower to the student. The robot can be expanded with small, low-cost shields that provide extra capability.

Shields could contain anything that will fit within the 1" x 1.5" form factor, such as charging, programming, additional sensors, wireless communication, machine vision, data logging, IMU, basically

### Features

• Power supply: 500mAH and up 1S 3.7V LiPo, can be converted to 3 alkaline cells (AAA)
• Sensors: infrared line follower sensors
• ATmega328P is Arduino IDE compatible and MiniBloq compatible
• Expandable with 'shields' making additional, a la carte capabilities affordable
Two working prototypes have been constructed. The first was built to prove out physical assembly, motor control, and steering. The second prototype, pictured here, verifies circuit designs including motor driver selection, and provides a platform for fine tuning performance.

### Programmable

The robot is autonomous, and programmable using a widely supported, very available ATmega328P that can be programmed either using the Arduino IDE or, at a future date, the MiniBloq graphical programming environment.

MiniBloq is an open source, Kickstarter project used for education and it runs on Windows and the One Laptop Per Child machine, bringing robotics within reach of more students. Future revisions of MiniBloq are expected to make it possible to configure it to support this robot.

Despite the extra cost of the mainstream microcontroller, its ubiquity in the hobbyist community pays dividends such as:

• excellent usability with Arduino, MiniBloq, and AVR IDEs,
• support from a very large worldwide Arduino an community,
• easy adaptation of Arduino shields onto smaller, cheaper form factor,
• wide array of drivers for sensors,
• an extremely large collection of libraries, and
• a plethora of code examples across the internet.

### Robot Kit

The robot is primarily intended to be mass produced in the form of a kit with soldering and assembly to be completed by the teacher or students. The robot is comprised of

• a single motor with dual axle stubs,
• two drive wheels and axles,
• servo-based steering,
• steering wheels,
• all necessary brackets,
• and a circuit board with an ATmega328P processor and motor driver ICs
The kit provides an unpopulated circuit board with through hole components. Two SOIC-8 motor driver chips can be hand-soldered or alternatively, pre-assembled at additional cost. The estimated mass produced price assumes pre-populated motor ICs.

### Easy to Reproduce

The robot is designed to be extremely easy to reproduce by beginning electronics hobbyists using commonly available components and tools. The end result would be similar to the prototype at similar cost, provided hobbyists had access to a professionally fabricated boards through batch PCB fabrication, like OSHPark.com, or through sales of bare boards produced at high enough volume to reduce costs.

Physical assembly is accomplished with nothing more sophisticated than hot melt glue, a cheap and readily available adhesive. Fabrication of the single hardware bracket involves cutting and bending a brass strip with pliers or using an alternative.

Intermediate hobbyists can etch and drill the single-side board design at home as was done for the prototype.

## Design

The robot is designed with cost as a priority, while carefully balancing capability, expandability, flexibility, reliability, and ease of assembly. To control cost, simplify assembly, and sustain reasonable reliability, the robot is designed to use popular, easily available, inexpensive, mass-produced parts and tools that are easily assembled into a functional robot. There's no need for 3d printers, laser cutters, advanced tools, or anything of the kind.

### Locomotion and Steering

The design is based on a single drive motor with two drive wheels and rear steering. Traditional wheeled, motor driven robots are believed to be the most flexible and useful in educational settings.

The single motor, rear servo steering design cannot execute tight radius turns or spins as with differential steering; however, turning radius is minimized by using weight transfer to allow the inner drive wheel to slip during turns.

Weight transfer is accomplished by placing the turning wheels at the end of the servo horn, and by slightly tilting the servo from vertical. As the turning angle increases, the center of gravity of the robot shifts and more weight is transferred off the inner drive wheel (see the experiments section for data). The design was proven by an early Bot Thoughts robot, Sparky several years ago.

Students can clearly observe the rotational speed and slip of each of the drive wheels, and the design offers material for interesting discussions about physics, geometry, and automotive axle differentials.

#### The Single Motor vs. Differential Steering Designs

• Fewer driver components, simpler, lower cost
• Smaller chassis, lower PCB fabrication cost
• Addition of a servo, subtraction of motor, low cost at higher volume
• Increase in turning radius; cannot spin in place
• Line follower sensors must be located further forward, slightly added cost
Overall the cost is estimated to be lower with a single motor design.

### Sensors

The base model includes infrared sensors in the form of very low cost IR LED and phototransistor pairs. These devices excel at close range obstacle detection (within ~10cm) or line-follower applications and provide a basis for lessons in physics and electronics. For example, the effect of natural sunlight can be explored giving rise to problem solving opportunities. Students can find ways to adapt the robot to different ambient lighting.

The base model includes a line sensor board. Taking a cue from the design of the Microrobot Cruiser, this board is (semi) modular and could be swapped for an obstacle detection board (yet to be designed) with some soldering (or the design could be altered with a small cost impact to permit swapping without additional solder work)

### Motor Driver

The motor driver circuit design was inspired by that of the Pololu Orangutan LV-168 which featured a low voltage motor driver, capable of running from as few as three 1.5V AA cells.

 Motor driver section of the main board schematic

This design featured two Fairchild FDS9934C dual complimentary MOSFET arrays arranged as an H-Bridge. These ICs, in 8-SOIC packages, were used in the prototype design. The preferred prototype ICs were Diodes, Inc., DMC2020-USD but were swapped after a mistake that may have damaged them.

Unlike the Pololu circuit, PTC resettable fuses were omitted in the design to keep costs to a bare minimum, relying on software and overrated MOSFETs to avoid failure.

Also unlike the Pololu circuit, this design provides MCU access to all four MOSFET gates. The MCU can precisely control MOSFET on and off timing, to eliminate shoot through.

The MCU can also command all possible operational modes: brake, coast, forward, and reverse.
Pull up and pull down resistors are in place to ensure default-off operation of the H-Bridge.

The mass produced version is intended to use the Vishay Si1563 ICs. These come in a SOT-363 package. Time did not permit testing these chips, but they appear to meet the requirements well, and cost less than the Fairchild and Diodes ICs.

### Main Board

The main board also serves as the robot's chassis, with cost reduction in mind. It features all through-hole components making it easier for beginning hobbyists, students, and teachers to assemble the robots.

The design is single-sided and can be etched at home as proven by the prototype board.

The design incorporates headers that permit shields to be stacked, much like the Arduino board. However, the form factor is smaller (boards are cheaper to produce), and aligned to 0.1" spacing. The pins break out all the digital and analog microcontroller pins as well as supply pins and the reset pin.

 Main board, Eagle rendering

 Main board, top, SketchUp/EagleUp

 Main board, bottom , SketchUp/EagleUp

### Line Sensor Board

The line sensor board connects to the main board so the robot can act as a line follower. It features 4 pairs of IR LED and Phototransistor in 3mm form factor. Again, through hole parts are used for easy beginner soldering. The line sensor board is attached to the main board by soldered pin headers and two sets of optional screw, nut, and standoff hardware.

 Line sensor board, Eagle rendering

 Line sensor board, top, SketchUp/EagleUp

 Line sensor board, bottom, SketchUp/EagleUp

### Chassis

As stated, the main board is the chassis of the robot. The main board and motor are affixed together with hot glue. A rubber band, electrical tape, or any number of materials could be used instead.

Additionally, a single bracket mounts the servo to the main board. The prototype version uses a small strip of brass sheet metal, affixed with hot glue. The mass produced version would repurpose a mass produced bracket that will reduce cost considerably.

 SketchUp rendering of robot without line sensor board
 SketcUp rendering of robot with line sensor board

### Power Supply

A 3.7V, 1S 500mAH LiPo battery is the source of power for the robot. These batteries are relatively low cost, long-lived, small, light, and relatively common, used in micro RC helicopters.

Any larger 1S LiPo will reliably power the robot as well. Time did not permit analysis of typical current draw to evaluate use of smaller batteries. Field testing of the robot with the 500mAH battery showed reasonable battery life and reliable operation.

The batteries can be charged using a Sparkfun USB charger ($9.95) using a 2-pin header adapter or connection adapter. The production version could use: • the Sparkfun charger, • a purpose-built shield for charging, • a purpose-built shield for charging and programming, • a custom-designed charger board, Expected lifetime of these type of batteries is difficult to ascertain. Many online forum posts indicate 100-200 cycles. To maximize flexibility, the robot is designed to run from 3, readily available, 1.5V alkaline or NiMH cells such as AAA. Any set of three 1.5V cells with enough current capacity could run the robot with no other changes required. The robot was tested at various voltages and found to operate well from approximately 2.2V and up, well within the range of 3 cells. Two-cell operation is possible with caveats. The servo stops operating properly at around 2V and the CPU requires a lower frequency crystal below 2.4V (2-cell would require 5MHz), in turn requiring IDE configuration. The robot prototype was tested with a 4MHz resonator and the Arduino IDE was successfully configured to support 4MHz operation. MiniBloq does not yet support 4MHz, ATmega328P boards. ## Educational Applications This robot design provides a number of educational applications. The robot offers the flexibility to be used as a simple line follower using a line follower board, or a micro mouse, using a object detection board. It can be further expanded with shields to offer myriad additional capabilities. A list of some of the potential learning topics follows; these topics would have to be tailored to the level of education: primary, secondary, college. ### Basic Electronics: Circuit Diagrams, Components • Batteries • Resistors • Capacitors • LEDs • Soldering (optional) • Demo: blink LED ### Physics: Light, Forces • Motors and gears • Torque: Force and distance • Gear reduction, speed reduction, torque multiplication • Demo: run motor out of gearbox, inside gearbox • Electromagnetic spectrum, visible light, Infrared light • IR LED and Phototransistors • Demo: blink LED when reflected IR detected • Turning geometry • Vehicle axle differentials • Center of gravity and balance • Servo turning system design ### Computer Science: Programming C or MiniBloq • Arduino/MiniBloq introduction, blink LED • Arduino/MiniBloq: control servo, motors • Arduino/MiniBloq: read phototransistor voltages • Arduino/MiniBloq: create line follower ### Problem Solving, Logic • Breaking down problems • Computer algorithms (line following, etc.) • Troubleshooting robot misbehavior ## Bill of Materials (Prototype/Single) The prototype Bill of Materials is found on the following Google Docs spreadsheet, under the Prototype tab. AFRON Robot BOM Total cost of the prototype robot is estimated at just over$28; and around $55 with accessories (one each per classroom). ### Method of Estimation Some components were drawn from my parts stash. Lacking records of their original price or source, current prices from one of the parts distributors was used. The ATmega328P, 0.1uF capacitors, LED, battery, and brass bracket were estimated in this way. Only part of the brass strip was used so only a partial price of the full strip was used yet. For some components, the origin is known but the original price paid isn't, and so current prices from the known origin are used. This applies to pin headers. The 1/8W resistors came from my parts stash and these were originally obtained in a$10, 500-piece value pack from Radio Shack, so the cost is estimated at $0.02 which is comparable to online prices. Likewise the ceramic resonator came as part of a pack of 5 so the total cost was divided by 5. Several parts were purchased specifically for the project. The actual costs were recorded for the servo, motor, MOSFET motor drivers, blank PCB, the total cost of a toy car and a toy miniature skateboard from which parts were salvaged, and the IR LEDs and phototransistors. Approximately 1/4 (probably less) of the blank PCB was used to fabricate the prototype board, and so the original cost was divided by 4. Several parts in my junk box are salvaged from consumer electronics given to me. I've harvested capacitors and tactile pushbuttons in droves. The 100uF capacitor, reset button, and battery connector/adapter fall into this category. Shipping prices are not included in parts prices unless otherwise indicated. ## Bill of Materials (Mass Produced, Cost Scaling) The mass produced robot kit parts are estimated to cost$12.73 per unit for a 1000 unit run. Parts shipping is not included in the price estimate unless otherwise indicated.

Details can be found on the BOM spreadsheet under the Mass Production tab.

Finding parts in quantities supporting 100 unit builds proved difficult and so cost scaling analysis was performed only for 1000 units.

As mentioned above, batteries are the consumable component for the robot. Low cost (under $3) 3.7V, 1S 500mAH LiPo batteries were selected. The lifetime of these batteries is difficult to determine but most online posts suggest around 150 cycles. If the robot is fully cycled once a day, every day, the battery would need replacement approximately every 22 weeks. The operating cost is approximately$0.02 per cycle or $0.14 per week if cycled once every single day. ### Required Accessories In addition to the parts to build the robot proper, some accessories are required. These can be found on the BOM spreadsheet under the Accessories tab. ## Tools and Equipment The following tools and equipment are required to assemble the robot. Prices based on cursory online searches for these items. The items, prices, and further notes are provided in the BOM spreadsheet under the Tools, Equipment tab. • Hot glue gun,$5.99;
• Hot glue sticks, $2.18; • Soldering iron, Weller SP23L 25 Watt Marksman,$9.97 or
• Soldering iron, FEITA 30-80W, $5.85; • Solder, 60/40 0.032" Solder: 0.6 oz Tube$2.79;
• Aoyue tip cleaner, $7.49; and • Kester no-clean flux pen,$4.75
• Needle nose pliers, Stanley, \$4.37

### Hardware

Sketchup 3D model:

Included below are front, side, and top view images with dimensions.

 Right View, length, rake angle

 Front view, width, height

 Top, board dimensions

 Isometric view, parallel project

## Building Instructions

The following are the instructions for robot assembly. The production version of the instructions would feature full illustration and more detailed text.

### Soldering, Main Board

• Install ATmega328P, align notch
• Install capacitors C4, C6, C8
• Install ceramic resonator
• Install resistors R1 through R8
• Install pin headers for SERVO, MOT, and +V/Gnd
• Install reset switch (if available)
• Install 10uF capacitor C7
• Install motor driver ICs, IC2, IC3, if not pre-populated on your board
• Mount 0.01uF capacitors on motor; one leg on motor lead, one leg on motor body
• Strip one end of motor wires and insert into motor leads along with capacitor leg
• Solder capacitor leg, motor wires onto motor lead
• Strip other end of motor wires
• Install crimp connectors on motor leads, solder
• Install crimp connectors into housing

### Soldering, Sensor Board

• Install LED0 through LED3
• Install Q0 through Q3
• Install resistors R10, R11, R12, R13, R20, R21, R22, R23
• Insert 6-pin header into main board, solder

### Chassis Assembly

• Insert axle into wheels
• Insert axle into motor
• Apply hot glue to top of motor (doesn't matter which is "top"
• Align main board and press down onto motor

### Steering Assembly

• Install bracket at rear left edge of main board with hot glue
• Install servo, aligned horizontally and centered along axis
• Install rear wheel truck onto servo horn

### Testing and Alignment

• Connect battery, should see blinking LED
• Load demo program to center servo and run [software yet to be written]
• Install servo horn onto servo with screw, centered

## Software

Demonstration line following software (Arduino)
motor.pde

Servo centering program (to be written)

Sensor test (to be written)

## Experiments Conducted

Some experiments were deliberate in their execution and purpose. Others, rather accidental. But helpful nonetheless.

### Rear Steer Weight Distribution

Purpose: verify that a single motor will work given the steering design
Description: measure the change in weight on each drive axle when the rear wheels are turned left and right
Expectation: the inboard drive wheel will have less weight than the outer during turns
Equipment: American Weigh Scales 100g hanging scale
Result: weight transfer is inconsistent from left to right, but I did not carefully control the steering angle, nor did I make multiple measurements. The data follows and demonstrates a significant weight difference between the two drive wheels. Testing the robot on a line following course, the inner wheels never failed to slip around turns.

long wheelbase
steer right -- 22g inner, 38g outer (45% / 55%)
steer left -- 28g inner, 34g outer (37% / 63%)

short wheelbase
steer right -- 20g inner, 40g outer (33% / 67%)
steer left -- 26g inner, 38g outer (41% / 59%)

### Low Voltage Operation

Purpose: determine lower bound of voltage required to operate the robot
Description: accidentally over-drained LiPo to 2.0V, observed behavior
Equipment: Voltmeter, programming cable, robot
Result: Servo inoperative at 2V, unresponsive to signals, programming unreliable.

### Operation at 4MHz, Arduino compatibility

Purpose: test functionality at 4MHz operation
Description: use 4MHz crystal, run robot at slower speeds, test IDE configuration
Expectation: proper operation, possibly some issues with interrupt timing
Equipment: 4MHz crystal, programming cable, robot
Result: minor servo glitches, possibly due to Arduino interrupt handlers, IDE successfully reconfigured to program 4MHz board using Optiboot bootloader.

### Motor stall tests, IC temperature tests

Purpose: verify maximum current draw within as-designed limits
Description: remove motor from gearbox, manually force stall, test for heat, watch for magic smoke
Expectation: no undue temperature or malfunction
Equipment: hands, robot
Result: stalling the motor for several seconds caused no excess heat or other issues.

### Line following

Purpose: verify robot operation
Description: write my first line following code, see if robot can follow a line of electrical tape on foam core.
Expectation: more or less capable of following a line
Equipment: programmer, robot, dollar store foam core, electrical tape
Result: Required heat shrink tubing on phototransistors and LEDs. Robot follows line with moderate reliability, sometimes missing turns. This is fixable with a bit more testing and calculation. The prototype design is non-optimal for this particular robot, requiring some redesign. Only two LED/Phototransitor pairs were used. Four might work better. These sensors are not located far enough in front of the robot, only about 60mm in front of the axles, approximately the same distance between rear steer pivot and axles. Some calculations can be done to estimate the optimal location. The design submitted is a guess at an improved distance. Faster servo response can be programmed in, but will result in more instability on straight lines.

### Shoot through Current

Purpose: accidentally test what happens if shoot through current occurs for a few seconds
Description: a mistake on the schematic caused shoot through on all MOSFET pairs in the motor drivers
Equipment: eyes and nose to observe smoke, fingers to detect heat, and dumb brain to goof up the schematic.
Result: A tremendous amount of heat was generated very quickly. It's safe to say that avoiding shoot through is a good idea, and providing a library for motor control that avoids it is the cheapest solution. It's not clear whether the particular motor ICs were destroyed or not; they were rated for more amps than the connected battery could theoretically deliver so it is possible they survived but both were replaced with different ICs.

## Pictures and Videos

### Pictures

 Prototype, posing for the camera

 In the process of following an electrical tape line

## Future Improvements

• Develop an obstacle detection board
• Add low voltage indicator and/or protection for the battery
• A custom charger and/or programming board could reduce cost per classroom
• Improvements to design for home etching
• Research the possibility of using the motor as a manual crank generator for charging
• Add PTC resettable fuses http://www.digikey.com/product-detail/en/0ZCD0200FF2C/507-1371-1-ND/1560238

## Friday, September 7, 2012

### Curve Fitting Sharp IR Rangers

 Sharp GP2Y0A710K0F sensor
Here's an example of curve fitting a function to calibrate a Sharp infrared ranger for distance measurement using OpenOffice Calc.

I tried to do this with Gnuplot but found that using Excel or Calc is infinitely easier.

The voltage measurement versus distance for these sensors is non-linear. Here's a plot of the values I experimentally collected from a GP2Y0A710K0F 100-550cm sensor.

This line can be fit using a power function of the form:

Simply edit the plot, right click on one of the data points and select Insert Trend Line...

Then select Power under the Regression Type section then click the Show Equation checkbox.

You now get a trendline with the equation on your plot.

The equation works out to be:

In c code you'd do the following (this assumes that your MCU or compiler supports floating point, and that using it won't use up all your memory and processing cycles):

To avoid the cpu- and memory-intensive math on an integer-only MCU, a faster option is to use a lookup table and interpolate between adjacent entries. This could be done with floating point or integer math. Store the range values multiplied by 100 for greater precision in the interpolation.

Also of note, the IR rangers have a usable range. If an object is too far away, the range will be unreliable. Modify the adc function so that it returns a large value like 999 if the adc value is below the usable limit (around 300 in this case).

If the object is too close, the ranger reports distance incorrectly. The best solution is to place the ranger so that objects cannot be closer than the minimum distance.

I also like to set a lower range in software.  In our case, an adc value of 500 or higher should report back the minimum distance of 100cm.

One final note, every sensor is a little different, so it might be a good idea to calibrate each one if precision is an issue.

Sources:
http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html
http://www.basicx.com/Products/robotbook/ir%20curve%20fit.pdf