Shop OBEX P1 Docs P2 Docs Learn Events
LED dimmer — Parallax Forums

LED dimmer

Macgman2000Macgman2000 Posts: 59
edited 2008-10-13 03:24 in General Discussion
OK this is very weird, I am hoping a fresh pair of eyes can see what I am not seeing. I borrowed this code from jonnymac used in thread for motor control animatronic head. I modified it with a potentiometer routine in main. When I turn the pot about half way I see about 3.1v if I keep turning it all the way to 10K it drops back down to 1.8v. Turning the pot all the way the other direction is as expected 0v. I am using a 0.1uf and 10K pot. I am unsure of why it is not going to 5v output at max pot setting. Why isn't it behaving as I expect it to?

Comments

  • CapdiamontCapdiamont Posts: 218
    edited 2008-10-11 05:59
    Are these multimeter voltages? How is the pot wired?
  • BeanBean Posts: 8,129
    edited 2008-10-11 12:29
    How do you have the POT and cap connected ?
    Also don't enable the pull-up on RB.0 (the pot pin).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter

    www.iElectronicDesigns.com

    ·
  • Macgman2000Macgman2000 Posts: 59
    edited 2008-10-11 15:17
    I am using the SX Tech board with 5v regulator. The cap and pot are as described in the practical sx/b paper. I have tripple checked the function of the pot and cap. Do you think it is related to the interrupt frequency limiting the longer discharge time?

    Nick
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-11 15:55
    Probably; you could either use an ISR-based A2D function (see G. Daubach's book) or use an ADC083x which is not affected by interrupts.
  • pjvpjv Posts: 1,903
    edited 2008-10-11 18:46
    Hi Macgman;

    Not knowing how things are wired makes things a bit difficult to analyze, but looking at your code, how do you ever get out of the loop in the following snippet copied from your DELAY routine?

    ·DO
    ··· \ CLRB isrFlag
    ··· \ JNB isrFlag, $
    ··· DEC msTix
    ·LOOP

    Cheers,

    Peter (pjv)

    Post Edited (pjv) : 10/11/2008 6:51:21 PM GMT
  • Macgman2000Macgman2000 Posts: 59
    edited 2008-10-12 02:10
    Like I said previously I borrowed the code from another post. I set up the output pin to drive an LED, LED to the port other side of LED grounded through 300 ohm resistor. The pot is a textbook setup, series resistor with shunt cap and shunt pot. That's it nothing else. It may be overkill since all I need is to detect pot position and put out a corresponding pwm in interrupt at 1kHz

    I think I have to start from scratch since I always seem to spend more time figuring out code I didn't write.

    Nick
  • Macgman2000Macgman2000 Posts: 59
    edited 2008-10-13 00:59
    I stripped out everything down to the minimum. I am still seeing weird things. When the pot is turned to one extreme is outputs 99% duty cycle not 100%. When I turn it to the other direction it outputs 60% duty cycle. I am at a loss for what the problem could be.

    Still textbook setup for the pot/cap. 0.1uf with 10K pot

    code enclosed.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-13 02:37
    I still think the ISR is causing the result of RCTIME to be off.
  • Macgman2000Macgman2000 Posts: 59
    edited 2008-10-13 02:52
    is there a way to disable the interrupt and re-enable it later in main? maybe I can keep the interrupt from distorting the RC routine. Although I will be bound at no faster than main.....not an easy fix.

    Nick
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-13 03:24
    That would be a mess. You should just do the A2D in the interrupt (NOT RCTIME, use an appropriate assembly segment) -- problem solved.
Sign In or Register to comment.