e-techgarage.com — Larry's Workbench
Archive for the "Hardware" Category

Creating a Small Single Board Computer (SBC) – Part 1

One weekend afternoon I was wondering how much real estate a small SBC compatible with an RCM4xxx would take.  Since my main hobby is designing and building electronic circuits I sat down with my favorite schematic capture program (DipTrace) and proceeded to draw a minimal function SBC.  Now, I suppose the design I developed is not a “true” SBC since it uses a Rabbit Core Module but Rabbit has been doing the same thing for years.
The process of designing an SBC has to start with asking the questions “What should it do?” and “What are the constraints and/or design criteria?”  I wanted the board to be as small as the RCM41xx but still have a useful complement of I/O.  My initial decision has eight current sinking outputs and eight digital inputs.  The results are shown in schematic 1.  The picture below is very close to full size.  Notice that it is slightly larger than the RCM4100.  I was not able to quite make things fit the way I wanted and still keep it the same size as the RCM41xx.  The pull-down resistors on the input circuit caused me to exceed the size of the RCM by aboutOne weekend afternoon I was wondering how much real estate a small SBC compatible with an RCM4xxx would take.  Since my main hobby is designing and building electronic circuits I sat down with my favorite schematic capture program (DipTrace) and proceeded to draw a minimal function SBC.  Now, I suppose the design I developed is not a “true” SBC since it uses a Rabbit Core Module but Rabbit has been doing the same thing for years.
That is a pretty tiny computer!

That is a pretty tiny computer!

The process of designing an SBC has to start with asking the questions “What should it do?” and “What are the constraints and/or design criteria?”  I wanted the board to be as small as the RCM41xx but still have a useful complement of I/O.  My initial design has eight current sinking outputs and eight digital inputs.  The results are shown in schematic 1.  The picture below (the photograph is of my second version which allows the use of the A/D converter on the RCM4100) is very close to full size.  Notice that it is slightly larger than the RCM4100.  I was not able to quite make things fit the way I wanted and still keep it the same size as the RCM41xx.  The pull-down resistors on the input circuit caused me to exceed the size of the RCM by about 0.1”.

I elected to use FDV303 FETs for the open drain outputs.  These devices can sink up to 200ma, have a breakdown of 25V and an on resistance of 0.6 ohms at VGS=2.7V.  They provide adequate features for many real world applications.  Another possible FET is the 2N7002.  It has a higher breakdown voltage at 60V but has a higher “ON” resistance.  Both devices can be obtained for the same cost and in the same package.  If you do decide to use the 2N7002 because you need a higher voltage you will also have to change the clamp diodes since the BAT54 is rated at 30V.  Each FET has a pull down resistor (100K) on its gate to insure that it is never floating.  One of the features of the Rabbit processor is that when it comes out of reset any I/O bit which can be an input will be set as an input.  Without the presence of the resistor this condition would leave the gates floating.

Digital Output Circuit

One of the Digital Outputs

“Back EMF” is generated when an inductive load (such as a relay coil) is turned off.  This voltage will appear at the device doing the switching (the junction of Q1, D1 and K1 above) and can easily be double the voltage supplied to the inductor.  A diode on the output clamps the voltage to that of the power supply.  You can see in the schematics that the cathodes of all the clamp diodes are tied together.  This point should be connected to the highest voltage power supply that is used for the loads.
0.1”.
A small board layout for the Rabbit 4000 family

The Board Layout

The digital input circuits simply provide current limiting via the series resistors and the clamp diodes.  The diodes are needed because the Rabbit 4000 does not have internal clamps.  These two diodes prevent the voltage applied to the Rabbit from exceeding the maximum allowed input voltage and from going below ground.  I chose high speed diodes in order to prevent high frequency spikes from reaching the processor’s inputs.  The series resistor will limit the current to about 10ma with 50V applied.  The trip point of the circuit will still be close to VDD/2.  The resistors from each input to ground keep the inputs from floating when no signal is applied.

The layout of the board is fairly simple and can be done with two layers – see Fig. 1.  The circuit uses single row, right angle headers for all I/O connections.  I chose these for two reasons:

  1. Cost – they are quite inexpensive
  2. Low profile – required since the Core Module sits on top

I decided to use a linear regulator to minimize cost and board space.  A switching regulator would certainly be more efficient but would cost more and take up more room.  The power input connector is a three pin header of the same type as the I/O headers.  I added a series diode to protect against reverse voltage.  This adds a small cost but I feel is well worth it.  The same is true for the power indicating LED – not necessary but probably a good idea.

Ready to go in the palm of my hand.

Ready to go in the palm of my hand.

The total Bill of Materials cost, in high volume, I estimate to be about $5 – excluding the RCM4xxx.

Schematic 1

Schematic_1

Full Schematic

Battery Charger

Just a short article about the battery charger I just assembled.

Charging Ni-Cad Batteries

Ni-Cad batteries can be fairly easily charged using a constant current source.  For best results with this type of charger you should set the current no higher than C/10, where C is the Amp-Hour rating of the battery.  Here is a link to a site which discusses several methods of charging Ni-Cads.

This simple charger can be built with very few parts.

  • One 3-pin header (H1)
  • Voltage Regulator (U1)
  • Four 82 ohm resistors
  • One 2-pin cable connector (H2)

Here is the schematic:

BatteryCharger

I used four 82 ohm resistors simply because that is what I had on-hand.  The required resistor value can easily be calculated using Ohms Law:  R = E/I.  Our battery packs are either 1600 maH or 2200 maH so I chose to use 160 ma for the charger.  Therefore, the resistance needs to be 3.3 V/160 ma = 20.6 ohms.  Four 82 ohm resistors in parallel yield 20.5 ohms – close enough for government work!  There will also be the current required by the regulator (about 5 ma) but that is relatively insignificant relative to the total current.

Pictures of the unit

The first is a close-up  and you can see that it is built on a piece of breadboard material I cut  from a larger piece.  The second shows the connector assembly that mates to the connectors of the batteries we purchased.

battery_charger_close

The second shows the connector assembly that mates to the connectors of the batteries we purchased.

battery_charger_wide

Rover’s Eyes are now on a rotating neck!

Puck and I have always known we would have to allow Rovers “eyes” to, well, rove. We have now mounted his eyes on a small turret that can be rotated using a Futaba S3004 RC servo.

Rover with Servo-Driven SONAR Turret

Rover with Servo-Driven SONAR Turret

This is a relatively small servo which mounts nicely in an existing cutout of Rover’s top plate. The servo specifies that it requires 4.8V to 6V in order to operate but we are supplying it with 3.3V and it seems to be quite happy about it. The control signal is PWM which is typical of RC servos. The PWM signal does not actually drive the motor within the servo but is simply used as a comparison value.

I wrote a simple test program to see what pulse width is required for the various rotation positions. With a 0.5msec pulse width the servo rotates pretty close to its full CW (Clock-Wise) position. It takes about 1.38msec to be centered. The function I wrote uses this formula to calculate the required pulse in milliseconds to achieve the requested angle:

Pulse Width Formula: msec = 0.5 + 0.88*((float)Angle + 90.0)/90.0;

The reason for the “+90″ factor is because I want the caller to use a range of -90 degrees to +90 degrees. Here is a picture of what I am talking about:

Specific Pulse widths = Specific Servo Positions

Specific Pulse widths = Specific Servo Positions

Most RC systems are set up to control up to 8 servos. The systems operate such that each servo is basically “assigned” a 2.5msec time slot within a 20msec interval. The pulse width required for each servo is between 0.5msec and 2.5msec with 1.5msec being relatively close to centered. In order for the Rabbit processor’s PWM system to achieve a low pulse rate with high resolution it is necessary to utilize the feature which removes, or swallows, X pulses out of every Y pulses. To get the 50Hz (20msec period) signal I wanted I calculated the base PWM frequency to be 200Hz. I then programmed the PWM system to swallow 3 of every 4 pulses. This creates a PWM signal with a 50Hz rate but still leaves me with the full 10 bit resolution capability of the PWM system. The following diagram may help:

Shows Pulse Swallowing

Shows Pulse Swallowing

The PWM setup calculations also derive a value which is the number of input clock pulses required to generate a 1msec pulse width (pulses per millisecond). Using the Pulse Width Formula to calculate the required number of milliseconds and then multiplying that result by the pulses per millisecond I get the number of clock pulses to generate the requested angle.

Rover Additions

Puck and I have added a few features to Rover:SMODE Switch

  • SMODE Switch – The Rabbit processors have four bootstrap modes.  Usually, when you connect a programming cable, the SMODE pins are pulled high and the Rabbit wants to communicate with its development environment.  Resetting the Rabbit with the cable off causes the Rabbit to start executing its program.  In the case of the RCM5600W, there is a manual jumper that needs to be removed when you want the Rabbit to boot into its Run mode.  The jumper needs to be inserted when you want to program it.  In our case, we got tired of inserting and removing that jumper so I installed a toggle switch on the back of Rover and wire-wrapped the connections to the jumper posts.

Power Switch

  • Power Switch – We added a switch so we can connect and disconnect the battery.  We still need to work with the screw terminals to switch between an external pow er supply and the battery.  Eventually, I hope to insert some kind of connector.

The latest software now supports the SRF05 Ultra-Sonic Ranger.  This will be used to tell Rover some information about his surroundings – at least what is in front of him.  The software enables the SRF05 to continuously inform Rover of the distance to the nearest object within the beam pattern.  As we said in an earlier post, we will be mounting the SRF05 on a mast that turns ±90° so we can also look side-to-side.  We did some initial testing this morning and, so far, it is looking pretty good.

Here is a picture of the unit just sitting on my bench connected to an RCM4100 and prototype board.  The same code works in both the Rabbit 4000 and Rabbit 5000 processors.

SRF05 bench

And here is a movie of Puck and me testing the unit showing the SRF05 Trigger pulse and Echo pulse.

Motor Controller Circuit

H-Bridge Schematic

H-Bridge Schematic

As indicated on Puck’s blog we have been talking about a controller board to drive the four motors on the Rover.  The original circuit used an op-amp to convert the 3.3V signal from the Rabbit processor to the 5V signal required by the H-Bridges.  The main reason for using the op-amp was quite pragmatic – I had them on hand.  The new circuit uses a bus driver, 74HCT541, instead.  The inputs on the 74HCT541 are TTL  compatible, that is the meaning  of the “T” in the device name, so they will easily handle the 3.3V signals from the Rabbit.  You can download all the DipTrace design files from here (about 300kB).

As can be seen from the schematic, it has the following features:

  1. Two 50-pin headers which allow the board to be inserted anywhere in the “stack” of Rabbit MiniCore boards.
  2. A socket for an XBee module if/when we want to try using one in place of the RCM5600W (WiFi).
  3. A power supply which has both +5V and +3.3V.  The +5 is for the ‘541 as well as the MiniCore.  The +3.3 is for the XBee (if used)
  4. A 74HCT541 to translate the +3.3V logic levels of the Rabbit to the +5V required by the H-Bridges
  5. Four H-Bridges, one for each motor.  See my earlier post and this post on Puck’s blog.
  6. A 12 terminal block with screw terminals for all the connections – power input, +5V for the RCM5600W and the drive signals for the H-Bridges

Here are some photos of the circuit boards.  The hand-wired board was used to test the initial library and to determine some of the motor characteristics.  The printed circuit board will be used in the final product.  I used DipTrace to do the schematic and board layout.  DipTrace generated the Gerber files which are needed to make the PCBs.  The PCBs were etched by Alberta Printed Circuits.  The cost for the two boards, including the silk screen, was $94. and about $15 for shipping via FedEx.  I have used APC a number of times in the past and they have always provided excellent service.

Handwired board

Hand-wired board

Printed Circuit Boards

Printed Circuit Boards