Close

Testing analog in/out

A project log for Electronic pressure regulator

Closed-loop air pressure control that can talk to a microcontroller

craig-watsonCraig Watson 06/01/2018 at 19:190 Comments

I just added support for analog input & output, i.e. setting the setpoint and reading the current pressure via two pins with voltages between 0 and 3.3V.

To test this, I used a Teensy 3.2 as the "master". A rotary encoder and LCD makes it easy to change the setpoint and view it and the measured pressure. This particular pressure regulator can manage 0-30 psi, so setting a voltage of 1V on the "SP" pin would request a pressure of 10 psi. 

Here's what the test setup looked like:

The power input is 12V, which supplies both the pressure regulator and the pump on the left. The output of the regulator is hooked up to a pressure gauge, for easy validation.

I also monitored the regulator via USB. With only P/I control, the results are already pretty good:

There is some overshoot upon large changes in setpoints, but nothing too dramatic. The pressure doesn't oscillate, and it can easily follow small changes in setpoints. 

I did have to smooth the analog setpoint measurement, as there was some noise in the signal. It would vary by ~ 1% of the ADC range. So to counteract that, I average out several successive readings, and also only consider changes of >10/1023 to be an actual change in setpoint. 

Without this correction, the graph looked like this:

Still pretty good, but this leads to unnecessary adjusting of the output, which wastes quite a bit of air.

Next up: i2c!

Discussions