søndag 19. september 2010

DYP-ME007 with an AtMega8 AVR microcontroller


I wanted to be able to read the distance captured from the ultrasonic range finder device on a microcontroller, to know how to implement this device in a possibly bigger and more complex circuit later on. Starting simple, this code prints out a pattern relative to the distance output of the DYP-ME007. I am using my Atmel STK500 for both programming and operation of the AtMega8, and the pattern will be displayed on the STK500 leds. The comments in the C code will describe what is being done and why. Since C code specific syntax highlighting is not one of blogspots features, I will add a clean syntax highlighted image, and you can always download the code here.

The video quality is no good, but it's easy to see what is going on. Notice the waveform on the scope in the background.







fredag 17. september 2010

Testbench for DYP-ME007 Ultrasonic Range Finder

This is how I set up the test bench for configuring and also just figuring out the DYP-ME007 Ultrasonic Range Finder, bought at GoodLuckBuy.com.
http://www.goodluckbuy.com/ultrasonic-wave-detector-ranging-module-distance-sensor.html

The usage is the same as for the popular SRF0004 equivalent;
The Vcc should be connected to 5v, Gnd is ground. When you pulse the trigger pin at TTL HIGH level (for at least 10uS) the echo pin will go TTL (5v) HIGH for a period proportional to the length between the DYP-ME007 and the nearest object. The period length is actually the time it takes for a ultrasonic sound to travel forth and back to the DYP-ME007 module. Don't mind the other components to the left and right for the module on the picture!
This is how I physically set up the test bench

This is the wiring scheme for the simple test bench

 I suspected there would be some problems with contact bounce at the switch, but fortunately I did not have to deal with that.

These are the readings I got from the oscilloscope. The scope was set up to trigger on a positive edged pulse of amplitude 1v or higher, which is within safe limits for the 5v pulse.
Scope readings on 10cm distance
Scope readings on 20cm distance
 As you can see from the scope screen captures, the pulse width is very much proportional with length it measures. When I double the length, the pulse doubles the width. From the cursor readings you can easily see that the pulse width is approx. 600uS for each 10 centimeters.

First blog entry, lab showoff

As my first entry, I would like to introduce you to my lab, so I can show off some of the instruments I use while trying to be creative. These are all equipment bought on a student budget. Though, while being a student I find all of my semi professional equipment to suit all of my needs.

From the right, there is the MASTECH MS8040 benchtop multimeter.
I love the big back-lit display, the intuitive operation and that it has all functions and need plus many more.
Bought on ebay. This product is no longer produced, so I have no link to the manufacturers specific product site, but you can still find it on ebay, and its cheap.

Next is my main power supply from Maplin store, England. 20 volts, 5 Amps max. Mode for both constant current and constant voltage and a big back-lit display. When testing big application with big motors and such I use separate power supplies salvaged from printers and other hardware.
http://www.maplin.co.uk/Module.aspx?ModuleNo=219129

Besides my main power supply is my smaller "backup" power supply. It has only 6 voltage settings, 3, 4.5, 6, 7.5, 9 and 12 volts. 1.5 amps maximum. I mostly use this to power my RC transmitter while experimenting so I don't have to use up all my batteries on this.
http://www.biltema.no/no/Kontor---Teknikk/Batteri-og-Stromforsyning/Nettaggregat-og-ladere/Nettaggregat-312-V/

Then comes my soldering station. Regulated, 150-450 degrees Celsius. This station is not as temperature stable as I would like it, but is OK for most applications. Also not beeing produced anymore, but has been replaced by a similar one with digital HMI.
http://www.biltema.no/no/Verktoy/Sveising-og-lodding/Loddeverktoy/Loddestasjon/

My newest addition to my lab instrument collection is the 50 MHz Rigol DS1052E oscilloscope. See http://www.eevblog.com/2009/04/05/full-review-of-the-rigol-ds1052e/ for a full review of this. I have to say this is one of the best money I have ever spent! After using the oscilloscopes at school, I quickly found out I wanted one at home. My teacher said I had to spend around $1000 for a decent scope. Needless to say, I was disappointed. Luckily, I found this on one of my favorite webshops, dealextreme.com, read the review and purchased it. DX never sent me the item, so 3-4 months later I ordered it from goodluckbuy.com, which is now my first choice for cheap gadgets and other hardware.
http://www.goodluckbuy.com/rigol-oscilloscope.html

The green PCB with jumper wires is the Atmel STK500 evaluation board for the AVR series microcontrollers. I really could not do anything without this.
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2735