You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While attempting to use these function blocks for an experiment setup in RIX I found that these function blocks don't appear to work properly for negative values. I had to make some quick hacks (as these needed to be functional in ~30 minutes at the time), resulting in pcdshub/lcls-plc-crixs-motion#7. For example, the analog output terminal I was using needed to operate from -10 to 10 Volts. The analog output conversion does the following:
However, if fReal is negative, and fTermMin is negative (as it would be for a bipolar output card) then a requested value of e.g. -9.0 V would result in:
(-9.0V - (-10 V)) * (2^16 - 1) / (10 V - (-10 V)) = 3277 (a 1 V positive output)
For the analog input, setting the iTermBits to 16, fTermMax to 10 and fTermMin to -10, an input value of e.g. -30000 ADC, or about -9V, would result in the following:
fReal = (-30000) / [(2^16 - 1)/(10 V - (-10 V))] + (-10 V) = -19.1 V
The text was updated successfully, but these errors were encountered:
While attempting to use these function blocks for an experiment setup in RIX I found that these function blocks don't appear to work properly for negative values. I had to make some quick hacks (as these needed to be functional in ~30 minutes at the time), resulting in pcdshub/lcls-plc-crixs-motion#7. For example, the analog output terminal I was using needed to operate from -10 to 10 Volts. The analog output conversion does the following:
However, if fReal is negative, and fTermMin is negative (as it would be for a bipolar output card) then a requested value of e.g. -9.0 V would result in:
(-9.0V - (-10 V)) * (2^16 - 1) / (10 V - (-10 V)) = 3277 (a 1 V positive output)
For the analog input, setting the iTermBits to 16, fTermMax to 10 and fTermMin to -10, an input value of e.g. -30000 ADC, or about -9V, would result in the following:
fReal = (-30000) / [(2^16 - 1)/(10 V - (-10 V))] + (-10 V) = -19.1 V
The text was updated successfully, but these errors were encountered: