CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Really Really Need Help on Ping Ultrasonic sensor
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

Re: Hello, I come again
PostPosted: Sat May 16, 2009 3:45 pm     Reply with quote

Lion wrote:


My First code:
For this code, I tried to use 'z' to get in switch loop but it always print out 'default'. Any one can get me some suggetion?
Code:

for(x=0;x<4;x++)
{
z=1;

switch (z)
{

case 1:
   delay_ms(500);
   output_high(PIN_B0);
   delay_us(5);
   output_low(PIN_B0);

   while(!input(PIN_B0))
   set_timer1(0);
   overflow_count=0;

   while(input(PIN_B0))
   disable_interrupts(global);

   z++;
   break;


You Disable interrupt in every iteration of your case statement, but never enable it.... Is that on purpose? What are you trying to achieve with that statement?

Sorry that my solution didn't work for your compiler.
Ttelmah
Guest







PostPosted: Sun May 17, 2009 4:33 am     Reply with quote

It is slightly 'worse' than that. He sits disabling the interrupt continuously (pointless.....), so long as pin B0 is high.
There is a similar behaviour earlier, where he sits resetting timer0, so long as pin B0 is low.
You then have the much more worrying part (depending on the nature of what is attached), that he is using the same pin as both an input, and an output. Unless what is connected to the pin is relatively high impedance, this _will_ lead to the PIC output drawing excessive current at times.
The normal way to handle connections like this, is to have a resistor taking them in one direction (perhaps +ve), and then have the PIC output, and the output of the other chip/circuit, only ever drive low, and when not driving low, switch the pin to being an input (output_float on latter compilers), so there is no clash...

Best Wishes
xjackal



Joined: 29 Oct 2005
Posts: 4

View user's profile Send private message

PostPosted: Mon Oct 19, 2009 4:39 am     Reply with quote

whats the formula of distance?
Panos



Joined: 09 Jun 2010
Posts: 8

View user's profile Send private message MSN Messenger

ask-help
PostPosted: Wed Jul 14, 2010 3:33 pm     Reply with quote

Hello Lion!
I'm having my thesis this period which is a parking sonar using two ultrasonic sensors.

At first I would like to ask you a detail about the ultrasonic sensor in case you use them in real and not in a simulation program (because i' m doing it in Proteus for the present):
Please if you know tell me WHICH IS THE EXACT OUTPUT THAT THE SENSOR GIVES IN ECHO PIN WHEN THE DISTANCE IS LONGER THAN 4m (5,10 OR 1000 meters)???(data sheets don't help)

And secondly in case you haven't solve your problem about the seven sensors I could give you the trick that I'm using to handle two,seven or as many sensors as you want! (of course it might not be the best solution and surely it's not a professional solution).

(Sorry if i' m a little out of the topic's point but for some reason i wasn't able to sent you a pm!).
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 11:33 pm     Reply with quote

Quote:
WHICH IS THE EXACT OUTPUT THAT THE SENSOR GIVES

Funny question. You can determine the exact output by a 3-d simulation of the sound wave, if you know the exact transducer characteristic and target geometry. Seriously, I doubt that you'll ever know. Also, you won't have access to respective finite element tools (e.g. ANSYS) nor be able to operate them.

There's no need to worry about an echo from a distance above 4 m. In practical cases, you'll never see it, because it's much too low.
Panos



Joined: 09 Jun 2010
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Thu Jul 15, 2010 1:56 pm     Reply with quote

FvM wrote:
Quote:
WHICH IS THE EXACT OUTPUT THAT THE SENSOR GIVES

Funny question. You can determine the exact output by a 3-d simulation of the sound wave, if you know the exact transducer characteristic and target geometry. Seriously, I doubt that you'll ever know. Also, you won't have access to respective finite element tools (e.g. ANSYS) nor be able to operate them.

There's no need to worry about an echo from a distance above 4 m. In practical cases, you'll never see it, because it's much too low.


My English are not so good so forgive me if the irony that I detect in your message about me is not true("Seriously, I doubt that you'll ever know..). If you read my message I'm saying that data sheets don't help to much so how could I know "the exact transducer characteristic" to simulate it?

The transducer gives a TTL pulse (5v) output to its echo pin. The duration of this pulse is related to the time that the sound went to the target and came back. IT'S ALWAYS 5v (it can't be lower as you say) AND ONLY THE DURATION CHANGES. So it seems that you don't know to much about these sensors by the time you say "There's no need to worry.....because it's much too low".

In data sheets say that the maximum distance that sensors can measure is 3 or for meters so practically I WOULD LIKE TO KNOW WHAT IS THE SENSORS OUTPUT IF THE DISTANCE OF THE TARGET IS SO LONG THAT THE SOUND WON'T COME BACK.

Please someone who really knows about ultrasonic sensors! I'm talking about Ping))) or HC - SR04 ....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 3:22 pm     Reply with quote

This thread implies that you will get an 18.5 ms pulse if there is no echo:
http://forums.parallax.com/forums/default.aspx?f=36&m=426352

Also, demanding information from us regarding Parallax products would
not be as useful as asking on Parallax's own sensor forum. They have one:
http://forums.parallax.com/forums/default.aspx?f=36
Panos



Joined: 09 Jun 2010
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Thu Jul 15, 2010 3:55 pm     Reply with quote

Thank you very much PCM! I'll see these forums!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group