Make a new control board #2
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Given than fixing the original board is going to be too painful (#1), I will design a new board that I can easily debug and fix myself. The good thing is that I don't need to use a non-isolated power supply, so I don't need to risk shoking myself.
For now, I have more or less an idea of how it would fit together, but I need to find a way to test it before I make the final design.
There are too many digital inputs to use a ESP8266 which I have at hand, so I will try hooking directly an ATmega328p. This makes it cheap but also small with the drawback that it won't have WiFi.
Roughtly this is the plan:
Prototype 1: Dummy
Make a dummy circuit so that I can program the ATmega and debug that the firmware does what I want.
This is mostly done, I wrote a simple C firmware program that mimics a basic coffee machine. I would need to adjust it later to add more features, but for now it seems to work.
I'm running the ATmega with no external clock, which seems to be one of the hardest things of this project so far. I had to patch the Arduino bootloader so it works reliably at 8MHz with the internal clock and hook an external clock to program the fuses to switch to the internal clock (eww).
Prototype 2: Hook control signals, no power
For this version I want to hook all control cables to the coffee machine so that the ATmega reads the input from the real buttons and sensors of the machine. I will leave the 220 V port disconnected until I can check that it works fine.
I managed to use a floppy cable to extend the stupid JST connectors which don't fit in standard 2.54mm pitch pins. I guess you never have enough jumper cables. This is how it looks so far:
I still need to check continuity of all connections and make some room in the receiving end. I would also need to think how I hook the pull up resistors, as it seems they were in the control board instead of in the button board.
The idea is to be able to drive the machine with the MCU outside, so it is easy to debug. The water deposit will cover most of the space needed for debugging, but the long floppy cable seems to work fine.
Prototype 3: Hook relays to pump and heater
We need to be sure that we have galvanic isolation from the main AC, so we don't accidentally fry the controller (or me). I would need to solder some cables to some spare clips I have and find a way to
This prototype should be able to allow the water deposit to be installed, so we can begin to do some test runs. I need to calibrate the water sensor and the temperature thermistor. Is probably a good moment to also take measurements of the temperature on top of the heater, where the control board would be placed.
Prototype 4: Design PCB and place everything inside
Once I can get it to work reliably, I think we can place everything in a nice PCB. I have some stripboards but that would probably end up being messy.
Another approach is to let the control board be outside, which would be easy for debugging access, but would be more bulky. We can only expose the low power control signals as well as the galvanic insulated relay lines.
Another topic that I would need to consider is what we do with the 12V coil that controls the return of the lever that closes the water circuit. A potential path is to ignore it and let the user stop the lever when the time is up. This makes the power distribution much simpler as we only need a single 5V power supply, which is easy to get. We would we a boost converter to bump it, but I need to first measure how much power it draws. Another option migh be to replace it with a lower voltage coil (more turns?) or change the turns myself.
I'll decide this later.
Managed to get the power button, the red LED and the NTC connected to the control board. It seems to be working fine.
I manually connected the heater to the power line by directly connecting the AC line end to the heater. Then, I connected the plug briefly to the power line. It uses around 1.4 kW of power and it heats very fast.
I left it cool for some minutes and tried again with the control board reporting the temperature. Below 40 C I plugged it again and stopped as soon as the relay opened again at around 50 C. However, the temperature keeps rising for a long time, as it can be seen in this plot:
Hopefully it was under the fuse limits so I didn't burn anything, but I would need to change the temperature controller to handle the big swing. I would assume they could do PID with variable PWM so they can control better the temperature.
The test is also running without any water, so that might be better when I fill the deposit. In any case, we should be able to measure how fast the temperature is rising and stop before it is too late.
The relays should be able to handle the load, as they are designed to control up to 10 A at 250 VAC. The heater will use around 6 A so it should be fine. However, the PCB tracks underneath the relay pins are probably too thin. We may want to add some extra wires to help reduce the heat.
I would need to repeat the experiment after connecting the relay so I can dump the data with the state of the relay, the temperature and the current time.
I would consider the prototype 2 mostly done, so I can move on to the next one.
Hooked the relay common pin to the AC neutral line and the normally open (NO) pin to the heater. I repeated the same experiment but this time recording the time and state of the relay. When the temperature reaches 50 °C the relay opens again disconnecting the heater.
The temperature again rises too quickly and reaches 80 °C. I would need to add a check that detects this sudden rise in temperature because in the event that the heater runs dry, nothing will be able to detect that is dry until the pump is active and the flow meter sees that there is no water flowing.
We can simply keep a ring buffer with the last N temperature samples. If the difference is bigger than a threshold we abort and complain because it is likely running dry. We can only do this while below 50-60°C otherwise it would be too late and the overshoot will burn the thermal fuses.
Same experiment but with overheat protection enabled. At 34°C it already triggers the overheat protection and shuts down the heater. The temperature only rises up to 55 °C.
I would need to adjust the threshold to avoid triggering it with water. So far the heat relay seems to be able to handle the load just fine.
I think I can now move to the pump and hook it to the other relay. Then I can do a test run with water and see how that changes the heating curve.
Connected the pump to the relay and filled the water deposit. I primed the circuit by turning on the pump until water came on the other side. Then I turn on the heater, but the overheat protection kicked in and disconnected the heater:
I don't think we will be able to use the slope only to prevent overheating. We will need to slowly turn on and off the relay until we approach the brewing temperature. We can also charaterize the heating curve so we can do a controlled burn of a given time, knowing the overshoot will approach us to the target temperature. Then simply correct by small increments.
In any case, both the heater and pump relays are working as expected and I can place the water deposit with the cover open.
Added a PID controller with very slow relay PWM cycle (integral component is disabled for now). The PID controller outputs a value from 0 to 1, which in turn determines the time the relay will be kept on in the next cycle. Current cycles are 5 seconds long. It managed to keep temperature more or less stable at 78 °C (target 80 °C). The small difference is expected because we don't have the integral component.
While hot, I also tested the pump while hot and it quickly drops the temperature, despite the heater turning on again.
We will need to have two PID controllers for still and flowing water. We can ensure there is flow of water passing through the heater by reading the flowmeter which is located at the start of the water intake.
I have increased the setpoint to 85°C and configured the heater relay to always stay on if the pump is enabled. It has caused the temperature probe to reach almost 100°C with the following trace:
Interestingly, it slows down when is reaching 100 °C. I would expect this outcome if we are starting to boil the water, so it transfers heat into the state change. That would tell me that my guessed thermocouple constants are right, which seems too suspicious. If that were the case, I would expect flow changes due to the expansion of water into gas, but I haven't observed any. I may be just luck as we start to steal heat from the thermoblock.
In any case, the output temperature comes at around 60 °C, measured directly at the output flow. This is not enough to make proper coffee which should be around 90-95°C (pre-loses), so I made myself some tea instead:
I'm starting to suspect that even if we drive the heater at full power we are unable to transfer enough heat. I doubt that they do any PWM in the pump as that would have varied the sound pitch and it didn't originally.
I guess we can try to increase the stored heat in the thermoblock to around 100°C and then keep it powered during the whole brew time. The output temperature will be decreasing all the time, so we won't be able to have a good control.
I can also get the theoretical maximum heat exchanged as I know the water flow, input and output temperature and the power of the heater. Using the sensible heat equation for the about 160g of water that I heated from about 15°C to 60°C:
Q = mc\Delta T = 160g · 4.184 J⋅g−1⋅K−1 · (60 - 15)K = 30124.8 JFrom the CSV I can see how much time the pump was on:
It was on for 29983 ms or about 30 seconds (the maximum limit allowed). So, we can compute the estimated power that we would need to transfer:
P = Q/t = 30124.8 J / 29.983 s = 1004.7 WWhich seems reasonable given that the heater is rated at 1400 W. However, if we were trying to make the water boil at 100°C, we would need:
Q = mc\Delta T = 160g · 4.184 J⋅g−1⋅K−1 · (100 - 15)K = 56902.4 JP = Q/t = 56902.4 J / 29.983 s = 1897.8 WSo, clearly it is unable to sustain enough heat transfer, we would need to accumulate an excess of heat before the shot. We may be able to safely exceed 100°C as water requires a lot of energy to perform the phase change. In any case, we are bounded by the thermal fuses which are rated for 133 °C.
Given that I have not blown the fuses yet, we can assume that the thermocouple probe can safely reach what is currently measured as 95°C, so maybe we can repeat the test from a higher setpoint and see what temperature we reach in the output. Before increasing it above 100°C I would need to have a better calibration of the thermocouple, or I'll risk blowing the fuses.
A possible way to self-calibrate it is to increase the input temperature so that we can boil it just from the input power of the heater, which we could do at around 35 °C. This is coincidentally the limit of the pump water temperature, I assume before it overheats. If the heat transfer were perfect, we should see steam forming in the output and 100°C in the probe.
Another aspect to consider is that we are driving the circuit without any load in the output, which allows free flow. As soon as we place a coffee cup, we will need to raise quite a lot the pressure to make it pass through the coffee grains, and that would reduce the flow making the exchange time larger and increasing the water temperature.