Hi,
OMG ...
I also think you are exceeding the Pickit sourcing authorized current ...Especially when " pinging " ...
Alain
Hi,
OMG ...
I also think you are exceeding the Pickit sourcing authorized current ...Especially when " pinging " ...
Alain
Last edited by Acetronics2; - 22nd June 2010 at 16:47.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
OK, I tried with this approach and it works, but as you will see in the code, even though the object is under 5 meters away (for eg. 4meters), PORTC.2 goes high & does not toggle. Is there something wrong with my calculation. It is working fine upto 1 meter. LED connected to PortC.2 does alterate it's toggling speed depending upon how far is the object under 1 meter. My latest code goes like this:
Code:; Phase2: RA0=TRIG (OUTPUT) ;;;;RA1- PWM (INPUT) w1 var word pause 500 main1: w1=0 High PortA.0 pause 1 Low PortA.0 pause 1 High PortA.0 main: Pulsin PortA.1,0,w1 if w1>500 or w1=0 then high PortC.2 else toggle PortC.2 pause w1 endif goto main1 end
Hi,
Everything works as written ...
W1 = 500 is a distance of 1 meter ...
...
try 2500 instead ...
and note no measure will send back ... 5000 Pulsin units ( 50 000 µs )
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
500 multiply by 5 meters...
![]()
Dave
Always wear safety glasses while programming.
Being Honest ...
1) read Datasheet Page 3 ...
2) read PbP Manual page 133 ...4: PWM - PWM Output 0-25000US,Every 50US represent 1cm
The resolution of
PULSIN is dependent upon the oscillator frequency. If
a 4MHz oscillator is used, the pulse width is returned in 10us increments.
3) The distance is 5 meters = 500 cm
from 1) and 3) ...
4) Pulse will be 500cm * 50µs/cm = 25 000 µs
from 4) and 2) ...
@4 Mhz Pulsin will return 25 000 / 10 = 2 500 units
This is the mathematical explanation of zeu thing
Alain
PS@ Dave
Don't you think I should add " Need Help " in my signature validity conditions ???
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Yup, need help understanding data sheet.PS@ Dave
Don't you think I should add " Need Help " in my signature validity conditions ???
I think Megahertz is doing fine, sometimes know where to look is a bit different than knowing what to look for.
I just spent parts of two days trouble-shooting a machine. Tried this and that, read the manual, tried other stuff, back to the manual.....
Then the great thought hit me... I wonder if that cable on the floor should be plugged into something![]()
Dave
Always wear safety glasses while programming.
Bookmarks