Maths help for the terminally dim please
I have some OEM hardware and code which produces a word variable containing a current value.
Lets say for this example it's 100 amps.
Now I have modified the hardware so that although 100amps is flowing the hardware only sees
75% of the current so the value in the variable is now 75. A 25% reduction
But what I want is for my gizmo to report the actual current by adding on the 25% to get back to 100amps
How can I do that with the word variable? Multiplication factor?
Adding on 25% to 75 does not give 100 of course so how can I do this?
The variable can be between 0 and 10,000.
Re: Maths help for the terminally dim please
Another maths question.
I have an adc connected to a HV supply via a non linear isolation circuit.
It produces the below 10bit ADC readings at the given input voltage.
That works fine but i want to create a formula from these data points to allow the adc to produce the actual voltage.
I don't want to use a lookup table if possible.
Accuracy to 1V is acceptable. There should be enough adc resolution to do that with the right formula.
225v = 356
200v = 380
175v = 412
150v = 450
125v = 495
100v = 561
75v = 644
50v = 753
25v = 903
10v = 1000
5v = 1020
0v = 1023
How to convert that data into some sort of forumla to produce the voltage from a given adc reading.
It's not linear.
Thanks
Re: Maths help for the terminally dim please
3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3...
Coefficient Data:
a = 7.84284692277E+002
b = -2.42579262304E+000
c = 2.77307340820E-003
d = -1.12332698305E-006
or
Heat Capacity Model: y=a+bx+c/x^2
Coefficient Data:
a = 8.77447057194E+001
b = -1.01937213402E-001
c = 2.18878991436E+007
or use a retrieve table plus 2nd order approx.
Quote:
Accuracy to 1V is acceptable
did you notice 1v is ... 0.5% ???
surely not !!!
Alain
Re: Maths help for the terminally dim please
Alain, hes basically got a circuit for mesuring voltage using a voltage divider so that the voltage going into the ADC is a fraction of what is going into the voltage divider. I have near the same type of setup, I have a circuit measuring my AC wall voltage, I have to rectify it first using a bridge rectifier, and add a capacitor to that and then a load resistor to discharge the cap. that gets me about 170 VCD, I dont want to put that into a ADC channel but I can use a POT or 2 resistors to define the proportion of that voltage that I want to read and then do some math to make the PIC appear to read the higher voltage, the problem you have to watch out for is to set up the voltage divider so that your max reading is still lower than your max input (5 volts) since there could be voltage spikes that are well above what your wanting to read. a possible option is to use a zener diode 5.1v on the actual ADC pin to help voltage spikes, but this doesnt cover 100%. He alread said though that he is on a isolated circuit so that helps. my only question is why is it non linear? Im not sure of his circuit but he should be able to get a 95% or greater linear reading using a voltage divider, he could even use a multiturn pot to tune the voltage to his circuit (code math) if theres a minor discrepency. his accuracy is based on the Mathamatical voltage and his ADC resolution, at 10 bits his 5 Volt ADC is 5v/1024 there are huge amounts of sample code for voltmeters out there, but even if we use his voltage numbers and add a bit for possible voltage spikes, lets use 377Volts as the max (5 volts acutual) then we just do the math 377/1024, this is going to give approx a .3% accuracy, but its still going to be innacurate if his circuit is non linear. i would look at the circuit and try to figure out a way to make it virtually linear. otherwise its going to be very hard to get the math and reality to line up together.
Re: Maths help for the terminally dim please
Quote:
did you notice 1v is ... 0.5% ???
surely not !!!
what I mean is it will be impossible to get 1 v precision over the full measuring range ... due to the very poor resolution @ low and high voltage.
Alain
Re: Maths help for the terminally dim please
yes i see what you mean, sorry i meant that he would have no problem if he was using a voltage divider, and using most or all of the ADC voltage scale for the conversion. not sure what kind of circuit hes using for his input. but anything thats not linear is a pain in the (BEEP)