Author Topic: no floating point challenge  (Read 13206 times)

Ken Talley

  • Newbie
  • Posts: 12
    • View Profile
no floating point challenge
« on: April 29, 2002, 08:22:20 PM »
Hello everyone,

I have a requirement where I must look at a ring gear in a drive axle.  The axle has 33 teeth on it and the tire size is such that each tooth equals roughly 0.32' or 3306 pulses per 1000'.  I am trying to use pulsewidth to figure my speed in feet per minute.  What I came up with was this....   Feet per minute = ((((6000000))/(((Pulsewidth)X(3306))/(10000))))   Again where 3306 is pulses per thousand feet.  My first question is whether or not the TM100MD can process such large numbers, I think it can.  Secondly, is there a simpler/cleaner code for such a task.  The situation requires resolution to 1 gallon per minute.

Thanks,
Ken ::)
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Ken

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: no floating point challenge
« Reply #1 on: April 30, 2002, 07:53:52 AM »
PULSEWIDTH measure the time in microseconds it takes the sensor to sense from the start of the gear tooth's edge to the end. Speed = distance / time. So mathematically:

  Speed (fpm) = 60 x 0.3306 / (0.000001 x pulsewidth)
                      = 19836000 / pulsewidth


The number is well within the 32-bit integer range. The trick is to work out the constant using the calcuator first and then check if it is within the range of 32-bit integer math. If you need greater precision in the feet per minute, e.g. down to 0.01 ft per minute, then just increase the constant x 100 and each unit represent 0.01 ft per minute.  That's still within the 2e+31 limit of the 32-bit math.  :)
                    
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ken

  • Newbie
  • Posts: 16
    • View Profile
Re: no floating point challenge
« Reply #2 on: April 30, 2002, 12:45:49 PM »
I understand the math to convert but am a little confused on what you said about the way pulsewidth works.  In order to clarify it a little I have some questions.  Pulsewidth is based soley upon ON time with no regard for off time?  Secondly, does it matter if the gap between the teeth is greater than the tooth width?

Thanks,
Ken
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: no floating point challenge
« Reply #3 on: April 30, 2002, 01:13:31 PM »
Yes, pulsewidth only measure the amount of ON time.  It does not matter if the OFF time is longer than the ON time. However, the maximum length of time that the function can measure is about 3 seconds.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Ken Talley

  • Newbie
  • Posts: 12
    • View Profile
Re: no floating point challenge
« Reply #4 on: April 30, 2002, 07:13:24 PM »
I've got two more questions.  Your formula shows decimal values.  Is that strictly for informational purposes or will Trilogi convert the values to none decimal values in compilation?  In other words can I use decimal values when programming?  Next question, does PULSEPERIOD count from leading edge to leading edge, ie the instant the sensor turns on to the instant the sensor turns on?

Thanks,
Ken
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Ken

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: no floating point challenge
« Reply #5 on: April 30, 2002, 07:30:21 PM »
1) The decimal value is only shown for informational purpose as you rightly put it. Since the PLC only support Integer math for now floating point is not recognized.

2) Yes, Pulseperiod measures lead edge to leading edge and it counts from the moment the input turns from OFF to ON and to the next moment when the input goes from OFF to ON again.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS