|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
||||
|
||||
|
Re: Best way to measure period between pulses? Counters and FPGA
Quote:
So we probably need to decide some happy medium rotational velocity that we want to control and set the period accordingly. -al g |
|
#47
|
||||
|
||||
|
Re: Best way to measure period between pulses? Counters and FPGA
Quote:
Agree that the stall feature is solving the zero divide problem but probably more importantly its dealing with the issue of period growing dramatically as rotational velocity approaches zero. Take the following scenario: you decelerate very rapidly and your last transition happens at a time that is equivalent to 200 RPM. The wheel is stopped but the code continues to report 200 RPM. If the timeout (max period/min rate) is set for 10 RPM this will continue for 6 seconds. Another interesting C++ fact that I never realized before (or once I knew but forgot): For IEEE floats, division of a finite nonzero float by 0 is well-defined and results in +infinity (if the value was >zero) or -infinity (if the value was less than zero). The result of 0/0 is NaN. If you use integers, the behaviour is undefined. |
|
#48
|
|||
|
|||
|
Re: Best way to measure period between pulses? Counters and FPGA
The IEEE defined behavior is the same for LV, and I presume Java.
Greg McKaskle |
|
#49
|
|||
|
|||
|
Re: Best way to measure period between pulses? Counters and FPGA
It is pretty certain that is is going to be the same for C++/Java/LV as this behavior is typically determined by the FPU in the processor. I know that PPC conforms to the IEEE spec, and it properly handles x/0 for the three cases above.
|
|
#50
|
|||
|
|||
|
Re: Best way to measure period between pulses? Counters and FPGA
I agree that PPC is IEEE 754 compliant, but some languages will have their own conventions, and since Java in interpreted, it would be pretty easy and efficient for them to have thrown an exception or taken some other action.
Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|