0
\$\begingroup\$

I have some (expensive) weird real time hardware with only two 12-bit ADC inputs vacant, and it needs to read 10-bit samples taken by a MCU with 8-bit PWM output ports. The ADC can take samples at around 100Hz, the PWM operates at 32KHz, and I want samples from my sensor at at least 10Hz (more is better).

I'm planning on encoding 5 bits on each analog channel by hooking the PWM outputs to RC filters, but this seems dangerous in many ways: I can't really guarantee the PWM high/low levels, and when the 5 low bits overflow I'll have a weird discontinuity. Is there a better way?

\$\endgroup\$
2
\$\begingroup\$

Solutions:

  • Use a micro with more PWM bits (many have 16-32 bit PWM)
  • Use a 10 bit separate DAC to generate your 10 bit value.
  • Dither the 8-bit PWM in software (by adjusting the PWM value on each cycle) to increase resolution.
  • Use 4x 8-bit channels in parallel, averaged with resistors.
\$\endgroup\$
  • \$\begingroup\$ The problem is, the MCU is an arduino running some libraries I don't control, so I cannot change the PWM duty cycle at regular intervals or meddle with the interrupts \$\endgroup\$ – FrancoVS Mar 13 '17 at 16:54
  • \$\begingroup\$ Do you have source code for your arduino? \$\endgroup\$ – bobflux Mar 13 '17 at 16:55
  • \$\begingroup\$ I can find it, but I'd rather not meddle with it too much to avoid breaking stuff. If it comes down to this, I'll probably do the 5-bit per channel thing. \$\endgroup\$ – FrancoVS Mar 13 '17 at 17:01
  • \$\begingroup\$ Arduino has 16 bit timer you know? It could output your PWM value directly... \$\endgroup\$ – bobflux Mar 13 '17 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.