This is a quick post in regards to how to present and calculate “analog” values or other things you want to express with a decimal point in the Barix Barionet and also on our Audio platforms (when programming in BCL):
Let’s assume you want to use input #1 on the Barionet to measure a current of 0.00-20.00 Amperes, and you have the necessary converter which delivers an analog voltage of 0..5V representing the full scale range of the measured current.
Connecting the converter to the Barionet will allow you to instantly see the corresponding voltage on the UI using a browser.
But .. how do you get the shown values converted to 0-20 Amp ?
The analog resolution of the current Barionet inputs is 10bit, so “full scale” is 1023. You probably want a higher resolution than just the integer part 0..20, so i would suggest to use 2 decimals.
Calculations can easily be done in integer if you just calculate/use the value, converted to 10mA units.
…. this gets the value, multiples by the full scale value (20.00->2000) and divides by the 10 bit fullscale value, resulting in values which are 100 times the current Amp reading.
For example, a voltage value of 2.5V will be digitzed to 512, resulting in a value of 1000 (which is 10.00 Amp).
BCL supports a special format to easily display these values with a decimal point:
will return a string with “Value: 10.00″ content you can use for writing, displaying, storing.
If you just want to display the value on the UI using dynamic HTML tags, things are even easier, no programming in BCL is required ! The following term will emit (for our example) the string “10.00″ on the Barionet if used in a dynamic HTML page:
Note the multiple parameters here. The decimal point is set in the format sting (%0.2F) to be 2 decimals. The first parameter after the format string is the I/O point (501), the second parameter is the multiplicator, the third parameter is an optional offset (if you put -1024000 here, you will have a reading of -10.00 …+10.00 for the example), and the term is divided by the last parameter before being displayed.
So, as with the above example, the value of IO point 501 (let’s assume it is 512) is taken, multiplied with 2000, nothing is subtracted, and the resulting value is divided by 1024. The result (1000) is then formatted as 10.00.
I hope this sparks some ideas how to use the products !