Shop OBEX P1 Docs P2 Docs Learn Events
PWM, ANALOGIN or ADC - Compare — Parallax Forums

PWM, ANALOGIN or ADC - Compare

VonSzarvasVonSzarvas Posts: 3,527
edited 2007-09-11 12:26 in General Discussion
Hello all,

In the last few days I have tested both PWM & ADC0831 methods to read the output from a 10k pot, and can read fairly smoothly 0 - 255 on my debug screen.


So is there any reason to use an external ADC chip instead of just the SX Comparator (ADC8.SXB in the help file) ?
And what difference (if any) does using an ANALOGIN method bring?

It seems to me that with PWM, to charge the cap and read back the level takes around 200us, so assuming the SX can spare 200us! on each cycle of its Main sub, is there any other reason I might use an ADC ?

Stability? Increased voltage sampling? Habit?


Note:
The ADC 0831 has 8-bit resolution and 1 channel...
I understand that I might switch to another ADC for extra resolution or more channels. But here I just want to compare like-for-like sampling.

Post Edited (Maxwin) : 9/11/2007 12:28:22 PM GMT

Comments

  • BeanBean Posts: 8,129
    edited 2007-09-11 12:06
    SHIFTIN is not used to measure a pot.
    Do you mean PULSIN ? Or ANALOGIN ?

    The ADC will be faster, and is not affected by interrupts.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know what I know, don't confuse me with the facts...
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • VonSzarvasVonSzarvas Posts: 3,527
    edited 2007-09-11 12:26
    Yes, I made an error. PWM (Comparator) method, not SHIFTIN. Mixing my serial comms chaos. Original post edited.

    So if (for my program) the PWM method is fast enough, then no reason to mess with an external ADC.

    I am inexperienced, so this comment may sound silly, but given the memory limitations of the SX, it strikes me that you are more likely to run out of programming space than programming time.

    Mind you I am working with programs that need to drive an output once a second -- guess if you are running micro or milli second critical programs that could be another matter. - Have I hit the nail on the head with that? And whilst I work at >1 second resolution, PWM is just as good as external ADC....?
Sign In or Register to comment.