I received the PCBs and all other components last week. I also had the campus machine shop make a manifold out of aluminium, which came out perfectly.
After a few hours soldering hunched over a microscope, and some quick programming, I'm happy to say it seems to work so far!
Here is what it looks like: the bare manifold is on the left; valves and fittings are added, then the PCB is stacked on top:
As far as programming goes, this thing is essentially a Sparkfun Pro Micro 3.3V/8MHz. I used a Teensy I had on hand to flash the bootloader via the ICSP header, after which I was able to program my board as an Arduino.
The code is a work in progress; so far, I can read the pressure sensor value, compute a PID output and actuate the valves accordingly, and send & receive sensor values and PID parameters over USB.
The next steps are, roughly:
- Tune the PID controller
- Add support for i2c communication
- Add support for updating the setpoint & current pressure over analog in/out
- Save the PID constants to flash, when modified
Tuning the PID is a bit of a challenge. After a little (manual) tuning, I have gotten it to be stable and keep very close to the setpoint, but the response to a change in setpoint is quite slow (up to 2-3 seconds). Getting a fast response with no oscillating is difficult, I think mostly due to how quickly the pressure changes when the valves are opened even a little bit. My test setup consisted simply of compressed air on the input, and a pressure gauge on the output. There was little dead volume on the output, so opening the vent valve just a little would make the pressure drop very quickly.
This will be a bit different in a real application, with other parts hooked up to the output (and it could even be solved simply by adding a pressure tank on the output), but I still want to improve the performance as much as possible now.
First of all, I have to speed up the ADC.
By default, the sampling frequency is around 500Hz. That's a new reading every 20ms, which is way too slow. Edit : I really can't calculate. It's actually close to 5kHz, which is quite fast enough. Fortunately, it seems pretty easy to increase this. Once that's done, I'll resume messing around with the PID controller.
Ideally, I'd like to model the system and take a smarter approach than just using an autotuner or trying a bunch of different parameters until it works well, but I don't know if I'll have the time to do that. As it is, the regulator is almost good enough to be used in my experiments, so I may have trouble justifying spending lots of time making it perfect.
I will be posting the code on github soon, along with a little demo of the regulator in action.