Ultrasonic

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello , 

I`m working on an ultrasonic interfaced with AVR , I am connecting the ECHO pin to the INT0 AVR's pin . I am setting the ECHO pin as input and enabling the pullup resistor of INT0 pin.... i have configured The avr to detect any logic change on the INT0 pin MCUCR |= (1 << ISC00) .. and enabled INT0 interrupt ....
my question is if the echo pin went from low to high although the INT0 pin input status is high , will the AVR Sense that logic change from low to high and enters the ISR of INT0???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely the whole thing that makes INTn pins "better" than PCINTn pins is the very fact they don't just trigger on any logic change but you can control this with "rising edge", "falling edge" too? If you only want to see low to high and ignore high to low you set the ISC bits to "rising edge" and if you are only interested in high to low you set it to "falling edge"

 

BTW are you talking about Parallax Ping))) or something else? There is any amount of existing code for those Ping sensors to show you how to operate them. (edge interrupts are not necessarily the best way to do it - in many cases you just poll the IO after triggering the ping)

 

("just one ping please Vasily"!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would look at using T1 input capture to measure the time rather then an interrupt....

As Cliff said, LOTS of examples to look at, google Arduino HC-SR04 to locate example code

 

Jim

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

assuming INT0 is pulled up , how is it possible to trigger a rising edge ?? can you explain it to me in details ^_^

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MuhammedElmaghraby wrote:
assuming INT0 is pulled up , how is it possible to trigger a rising edge ?? can you explain it to me in details ^_^

Simple, the line must be pulled low and then it will trigger on the next rising edge....

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using an HC-SR04 ultrasound module?

 

Have a look at this Thread where I posted a timing diagram for that module.

 

Just because you enabled a pull-up resistor on the pin does not mean that the pin is always high.

 

If another device on the line is actively pulling the line low, (such as the HC-SR04 module's Echo signal), then the pin will be low.

When the device stops driving the line low it will go high from one of two methods:

The driver can actively drive the line high.

or

The driver can go to a high impedance state, and then the pull-up resistor on the AVR's pin will pull the line high.

(This type of driver can only actively pull the line low, it can't force it high.  The pull-up resistor pulls the line high if the driver isn't actively pulling it low.)

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank Thank Thank you mannn <3