BasicMicroUK - Forums
http://forums.basicmicro.co.uk/

A problem with Ultrasonic Sensor HC-SR04
http://forums.basicmicro.co.uk/atompro-f486/a-problem-with-ultrasonic-sensor-hc-sr04-t9858.html
Page 1 of 1

Author:  dendal [ Fri Jun 01, 2012 5:40 pm ]
Post subject:  A problem with Ultrasonic Sensor HC-SR04

Hi everybody,

I'm beginner and i have serious problem :). I connect sensor that P3-VCC, P2-trigger (10us signal), P1-echo(time to signal from trigger back), P0 GND. I know thats maybe funny, but i just start :). Thats my code
Code:
HIGH P3;
HC_trigg CON P2
HC_echo CON P1
range VAR word

Main

low HC_trigg
pulseout HC_trigg,20 ;(for 10 us signal??)

pulsein HC_echo,0,range
range=range/74 ; range in cm?

Serout S_OUT,i9600,["Range: ",DEC range,13]
pause 1000

Goto Main

Author:  BasicMicroUK [ Sun Apr 14, 2013 12:06 pm ]
Post subject:  Re: A problem with Ultrasonic Sensor HC-SR04

HI,

It seems like the problem here is you are trying to use the AtomPro I/O pins as the power supply for your SR04 Ping Sensor and allthough you set P3 high to make it a +5V level the P0 Pin(Gnd) defaults to an input so there would be no power flow unless you set P0 to a 0V with a LOW P0 command,

That may explain why you are getting nothing right now BUT its not advisable to use the Atom Pro I/O Pins as a power supply as they can only provide a limited current and if your SR04 draws more than the pin can provide the Atom Pro could be damaged so the way to do it is to connect the GND and POWER pins of the SR04 to your 0V and +5V supply lines that are running the AtomPro IC and as well as allowing the SR04 to draw more power it frees up 2 of your I/O pins for other tasks,

I hope that helps and I am sure you will soon be up and running :D,

Thanks

Dave
BasicMicroUK

Author:  Acidtech [ Mon Apr 29, 2013 7:18 pm ]
Post subject:  Re: A problem with Ultrasonic Sensor HC-SR04

Good catch Dave. I don't think I would have seen that one. Not something I'm use to seeing. :)

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/