Maths help for the terminally dim please


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1

    Default 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.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    multiply your value for 1.333.

    Dammy var word

    YourValue var word

    NewValue var word


    Dammy = yourValue * 1333
    NewValue = DIV32 1000

    NewValue will contain the 4/4 from the 3/4 given in yourValue.

    or another way is

    multiply yourvalue by 4 and divide by 3
    Dummy = YourValue * 4000
    NewValue = DIV32 3000

    Cheers

    Al.
    Last edited by aratti; - 14th December 2010 at 17:08.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks very much. Easy when you know how.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    And for a 16% reduction?

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by retepsnikrep View Post
    And for a 16% reduction?
    Multiply by 1.1905

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Thanks. Sorted now.

  7. #7
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default 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.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: Maths help for the terminally dim please


    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default 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)
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts