By applying FM and PWM simultaneously, it is possible to transmit two data signals on a single carrier. In this video we will connect two potentiometers on a single wire to a digital microcontroller input and read the position of both.
To read the position of potentiometers or other analog values with a digital device like a microcontroller, you need some kind of analog-to-digital converter or ADC. Even though many microcontrollers have an ADC device built in, they tend to have more digital I/O pins than analog. Therefore, depending on the application, of course, you might want to save the analog inputs for something more important than managing a user interface, and use digital inputs instead.
By applying frequency modulation (FM) and pulse width modulation (PWM) at the same time, it is possible to transmit two data signals on one carrier.
Adjust frequency and pulse width with potentiometers
We will take advantage of the independence between duty cycle and frequency of a PWM signal to transfer the position of two potentiometers with a single rectangular wave. One potentiometer controls the frequency and the other the duty cycle. The microcontroller measures the frequency of the rectangular wave and its duty cycle. It then converts these values back to potentiometer positions in a range of, for example, 0 to 100.
The circuit we use is a classic triangle generator based on an operational amplifier with a comparator. With the given component values, the frequency is adjustable from 250 Hz to 500 Hz. The pulse is adjustable from 10% up to 90%. In fact, you can use any circuit that can modulate frequency and pulse width with potentiometers.
In this video we are going to connect two potentiometers on a single wire to a digital microcontroller input. We can read the position of both through FM and PWM of the input signal.