The purpose of this project is to provide a 4-20 mA output from a PWM signal generated by a microcontroller. One of the more interesting applications of this circuit would be to replace or to realize a smart sensor with Arduino.
Arduino Uno, or systems based on the ATmega328 chip has no a true analog output. The easiest way is to use one of the PWM outputs and filter the signal with a passive RC filter to obtain an analog signal proportional to the duration of the pulses. This expedient creates a considerable noise due to the frequency of the PWM itself. To eliminate the noise I used a second order active low-pass filter, Sallen-key type. The frequency of the Arduino PWM (with 16 MHz clock) on pin 9 is about 490 Hz, so I used a very low cutoff frequency (11 Hz) but with a bandwidth sufficient for the majority of industrial controls.By connecting the filter directly to the PWM output is obtained a signal which varies from 0 to 5 V which would give an output current of 0 to 20 mA. The pulses duration is programmed with a word of 8 bits, losing 1/5 of the full scale. To improve the current resolution from 20/255 to 16/255, I modified the minimum amplitude of pulses from 0 to 1 volts, giving at the output a 4 to 20mA current.
Elektor Magazine has been one of the leading sources of information on electronics for engineers, designers, start-ups and companies for 65 years. Our magazine is powered by an active community of electronics engineers – from students to professionals – who are passionate about designing and sharing innovative ideas.
For them, we publish hundreds of items a year, in formats such as articles, videos, webinars, and other learning formats. Our mission is to share knowledge in every possible way and inspire readers with the latest developments within the electrical engineering sector.
Thank you for your vote!
Leave further comments in the fields below.
Thank you for your vote!
If you wish to leave a comment with your rating, please first use the login below. If not, just close this window.
Discussion (0 comments)