Project to control vibe pump power in my Expobar Office Control HX espresso machine
Uses an arduino nano and an optocoupler for zero crossing detection of AC power.
Based on time of zero crossing detect, and value of pin A0 to determine power level, generates timed pulse to a Solid State Relay (SSR) to turn on voltage to pump.
Found this project for pump control. Copied this project a lot for mine, using his ideas as a starting point.
Espresso for Geeks (E4G)
zero cross detect (bottom page)
Other reference links
http://int03.co.uk/blog/2014/12/11/ulka-ep5-pump-pwm-pressure-modulation/
Important notes:
I initially had problems getting it to work, mainly because I didn't fully understand how a triac works. Once the triac is turned on, it stays on until the current or voltage goes to around zero. I thought it would turn off when I turned the arduino output (tied to the triac input) off.
The other problem I had was my choice of a 4n26 optocoupler. It was much slower than I expected, over 2 ms to change. I was ready to change it out, but it still works ok, even with that timing.
If you don't account for the 2 ms delay, the opto tries to turn off too late into the cycle, and then doesn't actually turn off until the zero current time.
I added this statement in the code:
#define OPTO_DELAY 2500
it defines the optocoupler delay as 2500 microseconds = 2.5 milliseconds. I tried 2000, but it wasn't enough, so I just added 500 and then my circuit worked.
If the delay was too short (or not included), it would actually cause a 2nd turn on, and start pumping harder when you were trying to go lower.
I know this sounds like a large delay, but it really had no impact on the pump. It effectively limits power to 69%, I set timing in the program for 5730 usecs instead of 8330 usecs, where 8330 is 1/2 of a 60 Hz cycle. Pump still had power to spare, could have set it lower.
I also changed the minimum time from 0 usecs to 1310 usecs. At 1310, water just barely drips out, and if you go too small, waveform starts acting strangely, not sure why so I don't allow very small times. This could have been higher.
Problem waveform.
In this scope plot, the square wave is the control signal to the SSR. The sine looking waveform is the output to the pump.
Was already on (thought it would be off), then it turned off at the zero current point. Then the square wave turned it on to create a double pulse. Caused pump to speed up instead of slowing down. Pulse should have been just the small one on right
Fixed after I added the 2500 usec optocoupler delay to the code. This is subtracted from the SSR on and off times
Corrected version
This is what the scope looks like after I added the delay to the code.
Now the output goes up properly.
I'm not sure what it appears to be high on the left part of the wave, but it does lower the pump power.
Output at higher power
Schematic
I added the 220 ohm resistor on the SSR ground pin later, to current limit the SSR input.
Optocoupler
Using a 4n26 opto because I had some. Cheap and easy to find
A 4n26 opto has a max forward current of 60ma, but it works best at 10ma
Had a 10k, 7w power resistor, so I used this to limit current to opto
120v/10k = 12ma Close enough to 10ma. Need a power resistor, power is 1.2 watts. 7w is bigger than required, I'd get a 3 watt resistor if I had to buy one.
Diode next to resistor on opto is 1n4007 from my junk drawer
Thought about changing to a HCPL-817 (datasheet) per what E4G used, because the 4n26 was so slow when I tried it with a pump. The response time for the 4n26 was about 2 ms.
But when connected to a vib pump, the 2 ms delay had no impact, pump still had plenty of power.
You must add a factor in the code to account for the delay.
After I did this, code and pump work as expected.
SSR info
AQH2223 SSR is rated at 900mA output, 600V, random (not zero cross).
50 mA max input current, 10 mA typical
Arduino output is 40 mA max, 20 mA recommended max continuous.
Decided to use a 220 ohm resistor for 23 mA current. Worst case is on 75% of the time at full power, so that works out to 17 mA time averaged the arduino needs to supply
Parts list.
A good part of this stuff I had, so didn't order it.
Arduino nano (Used a nano because that's what I had)
4n26 optocoupler
10k power resistor (3w or more)
8.1k resistor for pullup to arduino
Misc connectors /DC jacks to connect
Optional
Pot to set pump power
Pictures of built board.
On the right is a thin insulator that is taped over the bottom of the board. Since the boards has 120V on it, I added this for safety.
Arduino wiring for testing
+5VDC goes to power in, or use USB connector for power in
The Nano supports 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27).
j3 is the connector on my opto/ssr board
Ground to j3-1
+5 to j3-3
ZCD output to j3-5 to D2
SSR output to j3-7 to D12
Pot-2 or analog power setting to A0
Pot-1 to ground
Pot-3 to +5
Initial Test Setup
For initial testing, I connected a scope to make sure the pulse out of D12 was matching the zct output (and 60 hz zero crossing), and that it changed width as I adjusted the pot.
Installation
To install in my Expobar, I cut the AC wires from the control box to the pump. I'm inserting my breadboard into the cut wires.
Refer to my hand drawn schematic and pictures of the board.
The control box side goes to the left connector, and the pump connects to the right connector.
The rest of the installation is to connect the 3 wires from the board (ground, +V and A0)
A0 is input to arduino from ESP32 to set pump power. It connected to the Webserver ESP32 DAC output, GPIO 25.
Installed top view
The blue striped cloth wire is neutral, red striped is pump hot.
Cut them too close to big connector, wanted to mount board further to the right but it fits and works.
Little connector above 10K green resistor is for +5V and ground connections.
The blue screw nuts are to connect the +5 (red) and ground wires (black). They are coming from the LCD case, through the switch in back of the case and D connector.
Connects to ESP32 and Arduino to power them.
There will be a little project box with a display, on/off switch, 4 push button switches for the arduino and a ESP32.
I built this a long time ago, it currently houses a different arduino the reads and displays the group head temp of my HX.
I don't want to bring 120VAC into this box, so I bought a little AC/AC wall transformer so I could bring AC into this box. I need this for the zero cross detect circuit.
I'm going to put the SSR by the pump, so 120VAC will only be in the HX
OLD INFO
Looked at different projects and ways to do this.
Espresso for Geeks (E4G)
Instructables for AC Dimmer 4n25
I also had one of these from a long time ago, but didn't use it.
I had an arduino nano in my junk drawer, and decided to use it dedicated to controlling the power.
I was looking at E4G did, but wanted to use a ESP32 as the main processor and also decided to write my own code (mostly because I don't understand his SW lol).
I'm sure I could have done this project with just a ESP32, but adding the arduino to handle the zero cross detection and control the SSR for the pump simplified things, and I had one available.
It also make it simple to make a "manual" version of this project, with the arduino and a handful of parts, using a pot to tell the arduino what to set pump power to.
5/15 esp32_ota version with web ota and simple file commands
Sketch uses 810026 bytes (41%) of program storage space. Maximum is 1966080 bytes.
Global variables use 41656 bytes (12%) of dynamic memory, leaving 286024 bytes for local variables. Maximum is 327680 bytes.
Deleted wifi and temp stuff
Sketch uses 246402 bytes (12%) of program storage space. Maximum is 1966080 bytes.
Global variables use 13560 bytes (4%) of dynamic memory, leaving 314120 bytes for local variables. Maximum is 327680 bytes.