1

So just bought an arduino Uno and I've been playing around with it. I want to connect one of the input pins to one of the PWM outputs and measure the output from there by sending it to my computer through Serial and then plot it in python.

Sorry if this is a basic question. Thanks

asked Oct 11, 2015 at 12:55
3
  • PWM pins don't give an analog value. They are either 0v of 5v. Your idea is possible, but you'll receive almost exclusively 0's and 1023's. Commented Oct 11, 2015 at 13:03
  • ok cool, I'm just worried that I'll burn out the board... Commented Oct 11, 2015 at 13:08
  • That won't happen here. Just be careful to never connect two pins that are both outputs (as setting one to HIGH and the other to LOW would create a short). If you want to be super-save, you could put a resistor between the two pins (e.g. 1kΩ) instead of a wire. Commented Oct 11, 2015 at 16:14

1 Answer 1

2

PWM are digital output pins, and it seems that you wish to measure analog equivalent voltage generated by PWM output. If so, you'd need a filter.

Construct a unity gain op-amp based RC filter with cut-off frequency significantly smaller than PWM clock frequency. This will generate a analog waveform that can drive analog circuits. You could connect this to ADC input pin.

You could Google "Active low pass filter" for a lot of schematics and formula.

BUT

To be able to faithfully reproduce analog signal captured through ADC on a computer screen graph, your ADC sample rate must be more than ~2.5 times analog signal's bandwidth.

If your sample rate is close to Nyquist rates, you'd need to filter (interpolate) your digitized signal in software to generate a smooth graph. This is a bit involved in maths and software. Otherwise you'd only get a "spikey" waveform.

Or preferably have a sample rate> 10 times analog bandwidth. This will give large enough sample counts to reliably show analog data without much processing.

answered Oct 27, 2015 at 12:35
2
  • nope not interested in an "analog equivalent voltage". I just wanted to measure the PWM waveform, and wasn't sure if by using the same board for measuring and generating (of the signal) I could potentially burn it out Commented Oct 30, 2015 at 9:33
  • Usually digital waveforms are better captured by counters + interrupts, because exact voltage level is usually of no concern. i.e. for all transitions (hi->lo, lo->high), trigger interrupt. In ISR record a timer counter value and store. Capture timer clock needs to be (much) faster than PWM clock Commented Oct 30, 2015 at 11:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.