Hi All,
i am a AS student studying Systems and Control and am making a Speed Trap for a golf club, which displays the speed of the golfers swing to them. having never coded with basic (Only circuit wizard flowcharts) before and struggling to interpret other threads, i am looking for some help with calculating the speed using the PULSIN Command. at the moment my circuit consists of two Laser pointers that will shine directly on 2 LDR's. these allow me to detect when the beams are broken, which turn on and off a flip-flop. Therefore a pulse is received by the chip. if this isn't going to work, feedback is appreciated.
My main concern is the maths to calculate the speed. i looked at other threads with a similar topics but it was all a bit over my head (im a noob). my teacher explained to me the idea that PICAXE uses integer maths, but i still need a bit of help.
i am planning on using a distance of around 2cm between the beams because any wider and the PULSIN command will timeout i think? i will need to be able to record speed from around 10M/s to 80M/s to 1 decimal place at the least.
from other threads i have put together this code but dont know if it will work:
i used 32 to scale the distance (0.02*10^5) as close to 65535 as possible. sorry for the long read. any help appreciated.
i am a AS student studying Systems and Control and am making a Speed Trap for a golf club, which displays the speed of the golfers swing to them. having never coded with basic (Only circuit wizard flowcharts) before and struggling to interpret other threads, i am looking for some help with calculating the speed using the PULSIN Command. at the moment my circuit consists of two Laser pointers that will shine directly on 2 LDR's. these allow me to detect when the beams are broken, which turn on and off a flip-flop. Therefore a pulse is received by the chip. if this isn't going to work, feedback is appreciated.
My main concern is the maths to calculate the speed. i looked at other threads with a similar topics but it was all a bit over my head (im a noob). my teacher explained to me the idea that PICAXE uses integer maths, but i still need a bit of help.
i am planning on using a distance of around 2cm between the beams because any wider and the PULSIN command will timeout i think? i will need to be able to record speed from around 10M/s to 80M/s to 1 decimal place at the least.
from other threads i have put together this code but dont know if it will work:
Code:
main:
symbol PulsePin = C.1
symbol Pulse = w1
Symbol distance = w2
distance = 64000
Speed32 = w3
SpeedQ= w4
SpeedR= w5
pulsin PulsePin,1,Pulse
If Pulse = 0
goto main
End If
Speed32 = Distance/Pulse
SpeedQ = Speed32/32
SpeedR =Speed32//32
serout B.7,N2400,("Your Speed: " SpeedQ"."SpeedR " M/s")