kalle123 wrote:The aim of having those 10 k trim potentiometers in was to be able to try this here out....
- set the values in excel (or on a graphic) and calculate the best values for mVoltPerStep and offset (using a linear regression)
// If this seems to complex, just use 2 voltages as different as possible (but in the range of the normal values you want to measure)
// and apply calculation based on following example: .
// I expect voltage to be normally between 4 volt and 6 volt, so I apply 2 voltages close to those values to End point
// - for first voltage, voltmeter gives 3510 millivolt and telemetry gives 533
// - for secong voltage, voltmeter gives 5900 millivolt and telemetry gives 904
Sorry if the explanation is not clear. It seems that you are not the first one that do not understand this section.
The calibration consists normally of several steps for each voltage.
Note: it is also possible to combine several voltages in one step but it becomes more complex to explain.
Imagine that you want to calibrate Voltage 2 (using the schema you provided but without the 2 pot).
In a first step, you load in OXS a dummy set up just to check the raw data read by the arduino and so calculate the parameter(s) in order to get the expected result.
Therefore, in the config.h file, you first set e.g. :
- the parameter MVOLT_PER_STEP_2 to 1
- the parameter OFFSET_2 to 0
- a line (for the data to transmit) with: T1 , VOLT2 , 1 , 1 ,0 , \
Then OXS will transmit as temperature 1 the value that arduino read on pin A1 without any conversion.
Note: using T1 as telemetry field has the advantage that you can read on the TX the full value (without rounding or decimal)
This value will be between 0 ( when there is 0 volt on arduino pin), and 1023 (when arduino pin get Vcc or higher) because the arduino analog to digital converter has 1023 steps.
While OXS , RX and Tx are running, you have to measure the voltage of your battery with a voltmeter (e.g. imagine you read 7.612 volt between ground and the second cell ; so not between cell1 and cell2).
At the same time you have to read the value you get on your Tx as temperature 1 (e.g. 567 so meaning 567 steps).
Now, you can easily calculate the value for parameter MVOLT_PER_STEP in order to get finally the right value on the Tx. In this example, the right value for MVOLT_PER_STEP_2 has to be 7612/ 567 = 13.425.
If you change your config.h file using "#define MVOLT_PER_STEP 13.425" and if you reload the program into the arduino, making the same test, OXS will read the same number of steps (e.g. 567) but it will multiply it by 13.425 before sending it to the Tx. So Tx will get the expected value 7612.
This 2 step process allows you to get the right result even if the resistors and/or the arduino Vcc does not have exactly the expected values (due to tolerance on the component).
In most of the cases, this will already be quite good but still it could be that it does not give you the most accurate measurements that you could get.
The reason is that arduino is not always 100% linear on the whole range.
It is possible to partly compensate this using the OFFSET_x parameter and changing just a little MVOLT_PER_STEP .
If during the first step (see here above), you apply several voltages (e.g. using once a full loaded and once a nearly empty battery) and for each you measure the exact voltage with a voltmeter and at the same time you read the number of steps reported by the Tx (on the temperature 1 filed e.g.), then you can calculate the best values for OFFSET and MVOLT_PER_STEP (see my explanation in the config.h file).
When this is done for one voltage (e.g. voltage2), you can repeat the process for each of the other process.
When all voltages will be OK, the voltages of each cell will be OK also because they are just calculated by difference.
Please note that with the schema you made, it makes no sense to modify R4 to calibrate voltage 2 because changing R4 does not only change the voltage applied to arduino pin, it also changes the divider factor and so the MVOLT_PER_STEP that you should have to apply.
If order to change the voltage without changing the divider factor, you should have to:
- put R4 directly between V2 and ground.
- connect the upper pin of R1 to the mid pin of R4
- connect the lower pin of R1 (= higher pin of R2) to A1.
Ten, with you voltmeter, you must measure the voltage between mid pin of R4 and ground and adjust the parameter in order to get this back on your Tx.
It is just because this part was quite complex that Davx prefers to present it in a different way in the configurator.
The configurator let you set up a divider factor (based on the resistors) and Vcc and calculates the MVOLT_PER_STEP to be put in the cong.h file.
Working so is normally good but not as optimal as the method I described.
I hope this help you to understand and not make you more confuse.