16F876A Pulsin issues


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    I have an idiot grin on my face, :-) im making some really good progress, I have the pulse in now displaying on the screen (strange from a JR Rx Im getting a range from 560 - 990 from the pulsin) and have the ability to jump to a servo test (sweep from side to side) at the push of a button, :-)

    My ADC is sort of working, with the voltage divider I'm getting 2.54V on my DMM, however if I display the ADC input Im only seeing 2 and not the .54 (obviously this will be multiplied by 2 once i get the decimals). I have tried:

    Code:
    lcdout $FE, $C0+8, dec volt
    
    and 
    
    lcdout $FE, $C0+8, # volt

    but still only get the first digit. Is this due to the ADC VAR being a "WORD"

    Code:
    Volt    Var     WORD
    .
    .
    .
    ADCIN 4, volt
    .
    .
    .
    My Vref from the regulator is 5.00V on my DMM

    Not sure im getting this whole ADC concept, I;ve read another one of Melanie's posts and from what I can work out, my RAW ADC in variable should be as follows:

    if my Vref = 5.00 then if my ADCIN was exactly 5.00V the ADC result would give me 1024, however I am giving a ADC of 2.54 I should get a value in the variable of 520? however I am displaying a single digit "2" on the LCD with the code above, not sure how to do the math on this.
    Last edited by Bobbo_ZA; - 30th March 2010 at 20:56.

  2. #2
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Ah, ok, finally, im a git, :-)

    Im now reading a 520 adc value with the battery on and the DMM measuring 2.54 (Needs to be multiplied by 2 to reverse the voltage divider effect).

    Err, something not right, im missing something with the math:

    Code:
        ADCIN 4, volt                  ' Read AN4 into temp variable
        Vin = (5*volt/1024)       ' Convert to voltage assuming 5.00 = 1024
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vin,"V"
    pulling out many hairs, :-( my biggest issue is that even in school my maths was not great, spose thats why Excel was invented, for people like me, :-)
    Last edited by Bobbo_ZA; - 30th March 2010 at 21:56.

  3. #3
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    just not getting the decimal places now, :-(

    Latest attempt
    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2
    Vin = (5*volt/1023)
    Vind = (volt // 1000) / 10 'millivolts?
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    Time to pack it in for the night, work tomorrow, fairly good progress, just the decimal points to figure out.

    Kind Regards
    Rob

  4. #4
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Am I on the right track?

    the "//" operator will store the remainder in the chosen Var, thus:

    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2                 'Correct the ADCin for the Voltage divider?
    FVolt = (5*volt/1023)
    MVolt = (5*volt // 1023)  'millivolts?
    
    lcdout $FE, $C0+8, dec FVolt,".",dec4 MVolt,"V"
    Sorry for getting overly complex with this but trying to understand how it works, I have been able to simulate what I need to do in excel, just not sure if the above will work in PBP:

    D1 = Vref @ 5.00
    D5 = Adc Corrected @ 1021
    D6 = 10 bit ADC @ 1024

    D14 = Whole number (Formula =TRUNC(D9,0), result = 4
    D15 = Remainder (Formula =(MOD((D5*D1)/D6,1)*1000)), result = 990

    I could then LCDout D14, ".", D15 in theory if the formula in PBP equaled the excel result.

    not sure though, still a bit confused

    Cheers
    Rob
    Last edited by Bobbo_ZA; - 31st March 2010 at 09:39.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Bobbo_ZA View Post
    just not getting the decimal places now, :-(

    Latest attempt
    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2
    Vin = (5*volt/1023)
    Vind = (volt // 1000) / 10 'millivolts?
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    Time to pack it in for the night, work tomorrow, fairly good progress, just the decimal points to figure out.

    Kind Regards
    Rob
    Ok Rob,

    What about :

    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    
    volt = volt * 2 * 5
    
    Volt = 100*volt               ' See manual for DIV32 !!!
    Vind = DIV32 1024           ' Here we have result in 1/100 Volts ...
    
    Vin = Vind/100                  ' Here we get the integer part ...
    Vind = Vind // 100             ' Here we get the decimal part ...
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    that's all !
    Last edited by Acetronics2; - 31st March 2010 at 09:37.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  6. #6
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Cant believe it can be that simple, i was trying to over complicate things, :-)

    Will try it again tonight, :-)

    Achievements So far:
    1. Hitachi LCD interfaced to 16F876A
    2. Read input from RC Receiver
    3. Drive a Servo from the PIC
    4. Display pulsin values on the LCD
    5. Measure Flight Pack voltage - with load on demand

    Still to do:
    1. Menu system for each function
    2. separate components into sub functions
    3. Move off Breadboard and build into an enclosure of some sort.

    List of proposed features:
    1. Rc Flight pack battery tester
    2. Servo Tester - with Sweep and Centering
    3. Current monitor - planing to add either SI210709-300T (50A) or ACS750
    4. Receiver Pulse monitor for other PIC projects
    5. Thermometer - Although I think I'm all out of AD inputs
    6. Sure Im going to come across some more features to add to it, :-) any ideas?

  7. #7
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Ace, All,

    its working, :-) cant believe it was that simple, :-)

    going to start working on the next phase of the implementation this weekend.

    Hope everyone has a good weekend, :-)

    Cheers
    Rob

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