1

I have spwm output from arduino, and when i read on analogread it shows only 1023 and 0, because it is digital signal. Is there any way to convert these spwm value into analog value reading

2
  • arduino had 10 bit ADC that means maximum value that you can read is 0-1023. It is an analog signal. or if you want to convert digital value into analog value use can DAC IC easily available in the market.
    – Vaibhav
    May 13, 2019 at 6:09
  • Thanks try to search it
    – rahul
    May 13, 2019 at 13:54

1 Answer 1

4

The problem seems to be clear to you: for slow systems a pwm signal can be considered analog, but measuring at higher rates and without a filter reveales the digital nature behind pwm and all you see is either logic high (1023) or low (0). Possible solutions are:

  1. apply a filter in hardware (LC low-pass)
  2. apply a filter in software (e.g. by calculating a running mean)
  3. attach interrupts to the rising/falling edge of your signal and measure the high/low time to calculate the duty cycle

Which of those options to choose will mainly depend on the PWM frequency you want to measure. For low frequency I recommend option 3 (special cases are duty cycles around 0% and 100% as there are no edges), for higher frequencies I would use option 1/2.

1
  • Thanks very much helping
    – rahul
    May 13, 2019 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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