HPWM and A to D interaction question 18F252


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2003
    Location
    San Diego
    Posts
    35

    Question HPWM and A to D interaction question 18F252

    PIC18F252 with HPWM on C2... 20 Mhz osc.
    Using A0 and A1 as analog input with internal 5 volt ref.
    Fixed low Z analog input for testing.
    All power is stable

    HPWM 1,{0 to 255},17000

    As I change the duty cycle of the HPWM my A to D results jump +/- 10 counts or so
    If I delete the HPWM the A to D count is stable +/- 1 count
    This holds true even when there is no load on the C2 PWM output.

    What resources does the PB HPWM statement use that would affect the A to D function?

    My code changes the HPWM duty cycle between each A to D read... If I do not change the HPWM duty cycle and hold it constant, The A to D result is stable.

    Has anyone seen this on the 18F252?

    tcbcats

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i suspect more a hardware problem rather than programming problem. As i understand, when you remove the load on the PWM channel, everything disapear?

    Bad or poor voltage regulation (or regulator), unsufficient PSU filtering is my bet as now.

    I don't hink it will solve somethng but, how about using a higher sampling time in you A/D conversion?

    Can you post your schematic?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    tcbcats,

    as Steve already mentioned, it is most likely something in hardware.

    Could you post a schematic?

    And hey you are not trying this on a breadboard, are you?
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  4. #4
    fanie's Avatar
    fanie Guest


    Did you find this post helpful? Yes | No

    Default

    tcbcats,

    Had the same problem a while back but with a 16f684. I can't remember how I solved it !!!! But it was with the setup of the HPWM I think...

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    ARRRRRRRRRRGHHH invaders from the other camp. Hi Fanie, welcome here!

    HPWM or PWM module can't interfer with a/d. BUT it could have something to do with the CCP2 trigger if there's something bad in the CCP2CON<3:0> register setting. Refer to section 17.5 of datasheet. But if it was the problem... i doubt the PWM will work anyways.

    BUT as we didn't see any code line and schematic, it sounds more like a hardware problem... maybe a overloaded Psu too!
    Last edited by mister_e; - 1st May 2006 at 19:17.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    fanie's Avatar
    fanie Guest


    Did you find this post helpful? Yes | No

    Default

    Eh Steve !

    Thanks for the optimistic welcome, gee whiz... just thought I'd pop in to see if you guys need any help here but everything seems under control... between you and Nav anyways. Well, kind of.

    As far as I remember the PWM (after defined CCP2CON) I had to do after the setup code, ie as part of the program (doesn't sound right). In my case it wouldn't run on it's own as it should and I got funny things happening. No PSU probs...

    tcbcats - upload a bit of code... maybe someone would spot something.

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Have you tried changing the sampling frequency?

    Hi,

    According to you when your CCP pin is floating (there is no load connected) you are experiencing the same problem. This perhaps indicates that your HPWM is not playing anything with the VDD line as this is Vref as well (I assume). A schematic post (with layout if possible) would be appreciated. By that time try playing with the sampling frequency (use the RC clock) and a bit more time for the sampling.
    Regards

    Sougata

  8. #8
    Join Date
    Dec 2003
    Location
    San Diego
    Posts
    35


    Did you find this post helpful? Yes | No

    Smile Got it working.... with ADCIN

    I did not find the problem but did get the code working.
    I was setting up the A to D with the direct registers and had the setup wrong.
    I just changed the code to use the ADCIN command and all is now working.

    Something was messed up where I was reading the A to D justified register into a variable word using. .highbyte and. .Lowbyte

    Yes this is on a breadboard but the results are now very stable as expected.
    Thanks all…
    tcbcats

Members who have read this thread : 1

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