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

rahul
  • 11
  • 1
  • 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 '19 at 06:09
  • Thanks try to search it – rahul May 13 '19 at 13:54

1 Answers1

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.

Sim Son
  • 1,809
  • 9
  • 18