TConnolly

MrPLC Member
  • Content count

    934
  • Joined

  • Last visited

Files posted by TConnolly

  1. TRUNCATE IEEE754 FLOAT

    Sometimes is necessary to truncate (remove the fraction) or round a floating point number that is outside the range of -32678 to +32767 - making it impossible to use a MOV to an integer to make the conversion.
    This is a program I worte that shows how to perform a truncation directly on the floating point number by copyng the 32 bit pattern of the float and then determining which bits of the mantissa to keep and clearing all the rest. It includes three subroutines two of which show two different methods of truncating the float and a third which rounds the float to the nearest whole float.
    An understanding of the IEEE-754 float format is helpful in understanding how this program works but its not necessary to use it.

    1673 downloads

    Updated

  2. LONG DURATION PRECISION TIMER.pdf

    From time to time a long time base precision timer may be required. The SLC .01 second timebase timer is good for only 327 seconds. Cascading a timer and a counter together is undesirable as it will introduce a cumulative error into the time because of differences between when the time period
    actually expires and when the timer is next scanned.
    By running two timers in parallel we can maintain an accurate time reference from which to compute a floating point time with .01 second precision up to 32767 seconds. The first timer has a one second time base and it is the primary timer. The second timer has a .01 second time base and it is
    used solely to compute the fractional seconds. By using a comparison to subtract one second from the .01 second time base ACC when ever it exceeds a full second we can maintain an accurate time independent of the processor scan time so long as the rung is evaluated more than once a
    second.

    2426 downloads

    Updated