Go to content Go to navigation

Bargraph level conversions

5 April 2008, 15:42 by Chad Reynoldson

Here are some notes on converting different ranges of bargraph levels. I know that the new G4 panels support custom min/max ranges, but I still prefer to do it the old way and leave the levels from 0-255 and adjust it from netlinx code.

To convert a range from 0 - 255 to a range of 0 - y:
x = current value
y = high value
(x * y) / 255

To convert a range of 0 - y to a range of 0 - 255 for a bargraph:
x = current value
y = high value
(x * 255) / y

example:  you have a 232 device with discrete levels from 0 - 100.
Use the above equation to convert this number range to a bargraph range.

(0 * 255) / 100    low value of 0
(100 * 255) / 100  high value of 255

Share This Article

Comments

Comments are turned off for this article.