Time measurment
RShirley
Posts: 12
Hi Folks,
I am·new to the Javelin, so I hope i don't ask to many stupid questions. How can I get the elasped time between two marks using a Timer or between a mark and a read? Maybe using another object? I need the measure the elasped time between the leading edege of a 1 pps output from a GPS unit on one pin and an input on another pin to the millisecond or better.
Thanks, Russell
I am·new to the Javelin, so I hope i don't ask to many stupid questions. How can I get the elasped time between two marks using a Timer or between a mark and a read? Maybe using another object? I need the measure the elasped time between the leading edege of a 1 pps output from a GPS unit on one pin and an input on another pin to the millisecond or better.
Thanks, Russell
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· /**
·· * Calculate the time passed since the last call to the <code>mark()</code> method.
·· * The returned value is in millisecond units.
·· *
·· * @return Passed time in milliseconds (unsigned)
·· * </code by Peter Verkaik (peterverkaik@boselectro.nl)>
·· */
· public int passedMS() {
··· int l = tickLo(); //current time (unsigned)
··· int h = tickHi();
··· //calculate passed time = current time - mark time = current time + (- mark time)
··· //negate mark time
··· int lo = startLo ^ (short)0xFFFF;
··· int hi = startHi ^ (short)0xFFFF;
··· lo += 1;
··· if (CPU.carry()) hi++;
··· //add current to negated mark time
··· int ah = h;
··· int al = l + lo;
··· if (CPU.carry()) ah++;
··· ah += hi;
··· // now convert ah:al into milliseconds: timeMS = 569*ah + (al/115)
··· // fraction 1/115 = 0x023A
··· return (569*ah)+ UnsignedIntMath.umulf(al,0x023A);
· }
You find my adapted Timer classes here
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/
math support classes here
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/math/
There is also my ScaledTimer16 class that operates with userdefined units.
regards peter
·
When I complie I get this:
[noparse][[/noparse]Java Error] Timer32.javs(105): Error:"UnsignedIntMath" is either a missplaced package name or a non-existent enity.
What am I leaving out?
Now it is.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/math/
Place it in the lib/stamp/math folder
regards peter
·