Search This Blog

Tuesday, May 28, 2013

HC-SR04 ultrasonic range finder (max 4000mm)

I built some time ago a "range finder" based on the cheap ultrasonic module HC-SR04 (max 4000mm). I wrote a small program in Mikrobasic and have the result displayed on a 8x2 LCD. All needed is here:
HEX, source, sch, brd (EAGLE), datasheet, pictures

A video to show how it works:
Youtube video

Note theconnections to 16F630 PIC:
LCD_RS as sbit at RC5_bit
LCD_EN as sbit at RC4_bit
LCD_D4 as sbit at RC3_bit
LCD_D5 as sbit at RC2_bit
LCD_D6 as sbit at RC1_bit
LCD_D7 as sbit at RC0_bit
RA.5 is output for trigger input of the HC-SR04, RA.4 is input from the echo output of the HC-SR04. The LED on RA.0 is for testing only.

The push-button triggers (by powering the assembly), so the distance is displayed. No consumption unless push-button is pressed.

More explanations, see these links:
http://www.mikroe.com/forum/viewtopic.php?f=97&t=53891
http://www.mikroe.com/forum/viewtopic.php?f=97&t=54466

Some pictures
Overview:
 LCD display:
Inside the box (note the 12V battery wrapped in 3M band - I could not fit a 9V battery, and a 6V would not work as I have a regular 78L05):

UPDATE 2013/11/16: cod for 16F877a also available Source+HEX .
Connections:
    LCD_RS as sbit at RB7_bit
    LCD_EN as sbit at RB6_bit
    LCD_D4 as sbit at RB5_bit
    LCD_D5 as sbit at RB4_bit
    LCD_D6 as sbit at RB3_bit
    LCD_D7 as sbit at RB2_bit
    RB1=trigge
    RB0=echo received
    RC7 is output (LED) continuously ON.

Saturday, February 16, 2013

4CH R/C system (encoder - decoder) - Home made style



Finally, I got to get all together and test my system. It works, as expected!

DIY 4ch PPM encoder-decoder system. Encoder system displays on LCD the position (in percentage) of the lever and change symbol based on position (1ms to 1.4ms - DOWNWARDS or LEFT ARROW, 1.4ms to 1.6ms - "-", 1.6ms to 2ms - UPWARDS or RIGHT ARROW - for channels 1 to 3), shows position ("L", "C" or "H") for a 3 position switch (type (ON)-OFF-(ON)), and monitored value of the Tx battery (displays "!" under the battery recharge level).

I used a 16F677 (690) to create the PPM sequence based on the 4 measured voltages. The PPM signal is to be Tx via radio link to the decoder (12F635). The Red LED on the decoder is flashing when correct signal is decoded. It is mainly useless for the Rx system, but it is a visual indication for correct communication.

I intend to use it for a R/C boat for pleasure, and yes it cost more than a ready-to-buy system.

NB: I agree the PICs are highly underused, but I had them getting dusty for about 3 years and had to give them a life too :).

PS: for curious guys, the noisy background is Helloween's "Straight Out Of Hell", a simple coincidence, no setup.