Built by Wolves for Wolves


EE362


EE362 Final Project:

Ultrasonic range finder based on the Scenix SX28AC Microcontroler.

Actual Report, which explains the construction and theory:

In the beginning there were two objects.  Wolf and SgtYork decided that the distance between these objects should be measured electronically and thus was born the rangefinder project.  Since we weren’t sure what we could achieve due to the physics of our problem we laid out the project into three phases.  Phase 1: Build a motion detector.  Phase 2: Build a ranger finder.  Phase 3: Build a radar system.  Our project only got to phase because of two factors.  First, we scheduled more time than was available in our project statement and second, the rangefinder doesn’t return well off of surfaces at more than about 20° to the range-finding module.

For our development system we chose a Scenix microcontroller over the Cubit system.  The main reason for this is we wanted the rangefinder to be a mobile device and we also are working on a boat project on which we may want to include a range-finding system.  

Our basic design consisted of ultrasonic modules to send and receive the sound signal, the microcontroller to measure the time between pings and display the results on a 16 by 2 LCD display.  The software consists of an interrupt running every 125 cycles.  Since the processor runs at 50MHz and the interrupt runs every 125 cycles, the frequency at which the interrupt is called is 400kHz.  This interrupt takes care of timers, and creating the 25kHz pulses for the ultrasonic transducer.  The program first sets up the ports, memory, LCD display, and sets variables to their initial values.  The program then goes into the main loop.  The main loop toggles the 2nd line advertisement for our domain names, then it has two sub loops once a ping has been sent out.  First it goes into a loop to wait for the actual pinging to stop.  Then it goes into a loop to wait for the ping to return.  From this juncture one of two things will happen.  The ping could time-out in which case we just jump to the top and send out another ping.  Or the ping could return with a value on the timer.  In this event we divide the count by 32 to get the range sound has traveled in inches.  Then we divide by two again to get the range to the object, which is half the distance to the object and back.  As for some of the functions used in the program… to display the range on the LCD display, the range is converted to ASCII by the function DistToAscii, then displayed by calling DisplayRange.  We also wrote some functions such as MoveStepper to control a stepper motor for phase three of the project, but as mentioned above, we never got that far.  The SendPing function sets all the flags and resets all the counters necessary to send out a ping.  Last but not least there are the LCD functions.  At first we wrote our own set of LCD functions but couldn’t get the LCD to work so we downloaded a 4-bit driver from Ubicom (Scenix) that they had available in the library of device modules, they call them Virtual Peripherals.  To this code we did some modifications, however the LCD still didn’t work.  At this time we re-examined our hardware and discovered an error in the wiring.  After correcting this error, the LCD worked just fine and we never went back to using and perhaps debugging our old LCD source.  So that is the story behind the functions lcd_init, lcd_write_command, and lcd_write_data.  So that’s pretty much the story of the software.  Most everything went smoothly.  The only annoying thing that we had to deal with was the conversion from the count to distance in inches.  But fortunately it ended up being a divide by 32.4 or something like that, so dividing by 32, a left bit shift of 5 gave only little error which was kind of nominal considering we approximated the speed of sound to be 700 miles an hour anyway.

The circuit was first designed by using the spec sheets of each component, we knew what kind of signal needed to be input to the transmitting transducer and what kind of signal was expected from the receiving transducer.  For the initial stages of the project, the transmitting ultrasonic transducer was connected to a TIP-120 switching transistor, and was run at 5-volts.  This produced a decent output that could be detected using the scope, connected to the receiving transducer, with its volt/div scale set real low.  Next a 741 operational amplifier was connected to amplify the receiving transducer’s signal.  The amplifier’s gain was set at 10,000 and this brought the signal up to a manageable voltage levels, but also it amplified a lot of the noise.  But during this time we were able to move the receiver around and watch the waveform on the scope move back and forth, showing the displacement of the receiver.  This proved the feasibility of the project.  Next a comparator was connected to the output from the amplifier, and its other input connected to the output from the receiving transducer.  This allowed for a differential compare to the noise and resulted in only the pings being output from the comparator.  Next we looked into getting a charge pump, or building a voltage quadrupler, in order to get the necessary 20 volts to drive the transmitter.  By looking at the schematics from other sonar range finders, we found one in which a simple step-up transformer was used.  The transformer worked so well that we actually had to connect a pot as a voltage divider to limit the voltage to the transducer to only 20 volts.  Everything was built on breadboards, with the CPU in its development board.  Once the entire project was built and working that way we wanted it, it was then laid out and transferred to perfboard, and soldered point to point.  This took about four hours to build the final hardware version, that was demonstrated, plus an additional 30 min to track down a microscopic solder bridge that was shorting the output of the transformer, thus causing the transmitter not to transmit.  Figure 1. shows the schematic of the final version of the circuit built.  The LCD module was wired according to the spec sheet and was then tested by connecting it up to a computer’s parallel port, using a program called Test_LCD.  The microprocessor was also wired according to its spec sheet and all its support components like the resonator, reset switch and 5-volt regulator were also added to keep everything working. 

Figure 1. Transmit and Receive Circuit

 

In conclusion this turned out to be a good project, we learned much, and best of all it really works.  The realization that this project was conceivable was when, we had it pinging and we were looking at the scope and seeing the wave form move, in time with the movements of the receiver, something like “why’s it doing that?” was spoken, then after a few seconds of thought, we were after all quiet tired, “Holy crap!!! We are measuring time!!!” high fives all around.  A couple weeks of smooth sailing with just a few problems here and there, but nothing we could not over come, we had a working project, and it was good.

Pics of the finished Range Finder:

    

Front and Top views, the red LED indicates a "lock" on a target.  The first pic is actually measuring the distance from the top of my desk to the ceiling (62 inches).

        

Close up pics of the rangefinder

The Range Finder in action, click on the animated "gif" for a larger image so you can see the range on the display change.

While looking for the project report, I stumbled across a price sheet/parts list for this project, I think originally it was supposed to go in the final report but never made it, so here it is:

EE362 Final Project parts list
Rangefinder
Part Quantity Price
Ultrasonic transducer (transmit) 1 $1.25
Ultrasonic transducer (receive) 1 $1.25
Scenix (Ubicom) SX28AC/DP microcontroller 1 $4.33
50 MHz resonator 1 $1.66
LM741 op amp 1 $0.25
LM393 Dual comparator 1 $0.29
TIP120 Darlington transistor 1 $0.58
7805 Voltage regulator 1 $0.29
Reset button 1 $0.25
Red LED 1 $0.12
DC transformer jack 1 $0.25
1/4 watt 330 ohm resistor 2 $0.02
1/4 watt 10k ohm resistor 2 $0.02
1/4 watt 22M ohm resistor 1 $0.01
1/4 watt 2.2k ohm resistor 1 $0.01
1/2 watt 11 ohms resistor 1 $0.05
.1uF cap 1 $0.22
1k pot 1 $0.45
180uF 10V electrolytic capacitor 1 $0.15
47uF 10V electrolytic capacitor 2 $0.03
25pin male connector 1 $0.49
25pin female connector 1 $0.55
7 pin sipp 1 $0.12
7 pin sipp socket & 3 sipp socket 1 $0.45
LCD display 1 $7.50
1:10k transformer 1 $2.00
4.7k pot 1 $0.45
PCB board 1 $3.00
4 standoffs 4 $0.40
9V battery connector 1 $0.25
Misc. hardware (screws, wood, mounting) $1.00
Sub Total $27.69
Tax 5% $1.38
Total $29.07