EE 552 CAD Tool Documentation
 
Interfacing your FPGA with the Real World

Power Regulation

If you plan to power your project with batteries, regulation of the power is essential.  Unlike DC power supplies, battery power is not constant.  Varying loads or sudden current demands, while difficult to deal with with a battery, can be easily handled by any good power supply.  As well, over time, batteries lose their charge.

Linear Regulators

So, if you choose to use battery power in your project you will need to add a regulator to your battery.  Linear regulators are a good choice if you are looking for a cheap and simple solution.  Typically a three-terminal device (power-in, ground and power-out) linear regulators can be bought for a dollar or two.

For example, an LM7805 is capable of 5.0 volt and 1.0 mA output as long as the input voltage (power-in line) is held between 7.0 and 35.0 volts.

It should be noted that the "power-in" voltage, if using alkaline or NiCad batteries, should be well above 7.5 volts (ie. five alkaline cells, or seven NiCads) as the battery pack will fall below 7.5 volts relatively quickly.  Instead, use seven 1.5 volt alkaline cells (or about nine NiCads).  This will maintain the 5.0 volt output of the regulator up until the time that the alkaline cells are exhausted.

Isolation

Many electrical or electronic devices have variable current demands.  Switching logical states can produce varying demands for current on the power supply.  As well, if you are using your FPGA to drive electrical motors, changes in direction or speed can place huge demands on the power supply.  These changing demands on the power supply can cause noise on the ground and power busses.

During the intial construction of our EE552 FPGA-controlled robot, testing of the table-edge detector resulted in interesting behaviour.  At the time, the sensor was connected to an and-gate, an inverter and a motor-driving chip called an H-bridge.  While the robot was on the table, the table-edge detector sent a high signal into the and-gate and the inverter, telling the H-bridge which way to turn the motors (ie. forward).  As soon as the table edge was reached, the edge-detector sent a low logical signal, causing the H-bridge to reverse the direction of the motors.  As soon as the edge-detector was over the table again, the robot changed directions and moved forward.  Of course, as soon as the table edge was reached, the robot backed up again.

This back and forth motion, about the edge of the table should have continued indefinitely.  Unfortunately, the robot moved less and less each time (much like the dampening sine waves seen in Control Systems classes), until it stopped completely, just over the edge of the table.

The reason for this was that the constant directional switching of the motors was causing noise on the power and ground busses and causing the and -gate and inverter to output conflicting or undefined logical values.

The simple solution was to place a 10uF capacitor between the ground and power (5v) busses.  This is always the first step in implementing noise reduction in your circuit.  Remember!  Tantalum (usually shaped like a skewed bubble) and Electrolytic (usually a black cylinder) capacitors are polarized: the negative lead must be connected to ground and the positive to your 5v (or most positive) bus.  Ceramic (usually flat and round) capacitors can be placed in either direction since they are not polarized.

There are two other methods for ensuring that the power dips, glitches and voltage spikes caused by motors don't affect the logic of your FPGA (or other chips).  These are illustrated below.

In the first case, a capacitor is placed across the ground and power busses.  It is a simple and relatively effective method of removing noise from the power and ground busses.

In the second case, a diode is placed between the power supply and the capacitor.  This helps maintain a constant voltage to the logic during power dips caused by the motor.

The third method is bulkier but is very effective.  It requires two power supplies and the two sections are completely isolated from each other except through the Optocoupler.  The Optocoupler uses a photodiode and phototransistor to pass light signals from one side of the chip to the other.  Since the light cannot travel in the opposite direction, no noise is transferred from the motor to the logic section.

Please note that the "Motor" boxes shown in the first two diagrams have been expanded to include both the motor and the motor controller in the third diagram.
 

Interesting Things to Connect to Your FPGA

Motors and Motor Drivers

Motors can be easily controlled using an H-bridge.  H-bridges allow both speed and directional control of the motor.  For low voltage applications (less than 36 volts) the SGS-Thomson L293D is a good choice.  They are available by special order from Active Electronics (minimum 25 units), but there are currently (Novemeber 1997) 23 in the Electronics Stores room on the 3rd floor of the Civil-Electrical Building.

Each L293D contains two H-bridges and can accept Pulse Width Modulated (PWM) signals from the FPGA.  These PWM (one for each motor) signals can vary the speed of the motors depending on the duty cycle.  If the signal is on (logic high, or 5v) for half its period and off for the other half, the motor will turn at half speed.  If the signal is high longer, the motor will turn faster and vice-versa.

A high or low pulse to the appropriate pins will turn the motor clockwise or counter-clockwise.

The L293D accepts two power supply values and has one ground.  The two power supply lines may be connected together, but the motor-supply voltage must be great-than or equal to the logic supply voltage.  These supply lines have a maximum rating of 36 volts and the higher the motor-supply voltage is made, the faster the motors will spin.

Complete specifications for the L293D can be found in the SGS-Thomson spec books in the Electrical Engineering Stores Room. Please note that the Motorola H-bridge IC referred to in the Mobile Robots book does not seem to exist any longer. If you are looking for an H-bridge IC which can deliver more power, National Semiconductors produces a few good ones.

Please refer to the section on Voltage Regulation before implementing motors, as they can be the cause of many problems with your logic section if they are not properly isolated.
 

Photoreflectors

Photoreflectors are basically switches.  If the light emitted by the photoreflector is not reflected off of an object then the output signal is 0v (logic 0).  If the light is reflected and received by the receiver on the photoreflector, it outputs a 5v signal (logic 1).

During demonstrations, these are more effective than toggle switches if you are trying to demonstrate, for example, an Infra-red security system.

The Hamamatsu P5587 Photoreflectors cost approximately $9 each, including shipping.   (360 Foothill Road, Box 6910, Bridgewater, New Jersey 08807-0910; ph. 800-524-0504, 908-231-0960) www.hamamatsu.com

References

Mobile Robots: Inspiration to Implementation by: Joseph Jones, Anita Flynn
http://www.akpeters.com/robotics.html The publisher of Mobile Robotics