View previous topic :: View next topic |
Author |
Message |
bungee-
Joined: 27 Jun 2007 Posts: 206
|
Re: Hello, I come again |
Posted: Sat May 16, 2009 3:45 pm |
|
|
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
|
|
Posted: Sun May 17, 2009 4:33 am |
|
|
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
|
|
Posted: Mon Oct 19, 2009 4:39 am |
|
|
whats the formula of distance? |
|
|
Panos
Joined: 09 Jun 2010 Posts: 8
|
ask-help |
Posted: Wed Jul 14, 2010 3:33 pm |
|
|
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
|
|
Posted: Wed Jul 14, 2010 11:33 pm |
|
|
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
|
|
Posted: Thu Jul 15, 2010 1:56 pm |
|
|
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
|
|
|
Panos
Joined: 09 Jun 2010 Posts: 8
|
|
Posted: Thu Jul 15, 2010 3:55 pm |
|
|
Thank you very much PCM! I'll see these forums! |
|
|
|