Programming (Ping.spin) Trouble w/ PING)))
mophead
Posts: 2
Hello,
Im having trouble with the method (Ticks) in the object (Ping.spin) which is the example program for the Propeller Microcontroller in the ping sensors datasheet. Specifically I cant get the method Ticks to return a correct time interval between the rising edge and the falling edge of the echo pulse, all I get now is some constant value because I tried a smaller resistor (220 Ohm). With the 1k resistor the program could sense the rising edge but not the falling edge, so it would always freeze the program
The following code of concern is below
waitpne(0, |< Pin, 0)
cnt1 := cnt
waitpeq(1, |< Pin, 0)
cnt2 := cnt
Microseconds := (||(cnt2 - cnt1) / (clkfreq / 1_000_000)) >> 1
More info: Gadget Gangster Propeller Platform
5V power supply to board and sensor
220 Ohm
The sensor is functioning properly, because I was able to get it to work with my arduino mega board which correctly calculated the time with the pulseIn() function. Any help or further explanation of whats really going on with this code would be truly appreciated.
Thanks,
mophead
Im having trouble with the method (Ticks) in the object (Ping.spin) which is the example program for the Propeller Microcontroller in the ping sensors datasheet. Specifically I cant get the method Ticks to return a correct time interval between the rising edge and the falling edge of the echo pulse, all I get now is some constant value because I tried a smaller resistor (220 Ohm). With the 1k resistor the program could sense the rising edge but not the falling edge, so it would always freeze the program
The following code of concern is below
waitpne(0, |< Pin, 0)
cnt1 := cnt
waitpeq(1, |< Pin, 0)
cnt2 := cnt
Microseconds := (||(cnt2 - cnt1) / (clkfreq / 1_000_000)) >> 1
More info: Gadget Gangster Propeller Platform
5V power supply to board and sensor
220 Ohm
The sensor is functioning properly, because I was able to get it to work with my arduino mega board which correctly calculated the time with the pulseIn() function. Any help or further explanation of whats really going on with this code would be truly appreciated.
Thanks,
mophead
Comments
The 220 Ohm resistor is way too low. You should actually use something like 2.2K. With a 220 Ohm resistor, the PING can damage the Propeller's I/O pin.
Thanks again for your help,
mophead
Dave
waitpeq( |<Pin, |<Pin, 0) and waitpne( |<Pin, |<Pin, 0)
not waitxx(1,|<Pin,0) (unless your ping is attached to pin 0)
Pin could also be multiple pins ie $0000_0000_0000_00FF for the first 8pins