Weird ADC / Math Results with 9-Bit PWM


Results 1 to 22 of 22

Threaded View

  1. #17


    Did you find this post helpful? Yes | No

    Default Re: Weird ADC / Math Results with 9-Bit PWM

    I expect something to show on the LCD, but it stays blank.

    EDIT: I moved the LCD instructions to the loop to see what I could see and the final PWDuty value is 12291, way more than 512. The LED now ramps up in brightness but then drops down once the duty exceeds 512. I also needed to add a pause after the LCD initialization in order to see anything on the screen).

    Code:
    FadeInPause   CON 5         ; Pause during LED fade in
    
    ' Fade in LED to set brightness
    FOR i = 0 to 100             ; must match ARRAY SIZE of data table above
        ReadCODE  (DataTable + i), DataWord
        PWMDuty = DataWord
    
        GOSUB ChngLEDBrightness 
             
        #IFDEF USE_LCD_FOR_DEBUG
            HSEROUT [LCD_INST, LCD_CLR]
            pause 5
            HSEROUT ["PWMDuty=",DEC PWMDuty,"  "]
        #ENDIF
       
        pause FadeInPause
    NEXT i
    Where the heck is it getting 12291?
    Last edited by RossWaddell; - 23rd February 2016 at 02:06.

Similar Threads

  1. Weird PWM Behaviour on 16F1825
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th October 2012, 21:59
  2. Averaging 16 bit values without using 32 bit math
    By sirvo in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th October 2007, 22:18
  3. Strangw results when using PWM command
    By malc-c in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th July 2006, 12:14
  4. Strange Results in Math
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st August 2005, 07:09
  5. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 14:21

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