Archive 2022

Design and fast prototyping of a milk curd stirrer and heater using Arduino.

Foreword.

This project adhere to the DIY/maker ethos and use a fast prototyping, modular electronics approach.
It also demonstrates that a project can be done even without all the ‘proper’ tools, situations that are encountered
every day in workshops of less developed and fortunate countries, or simply in bad luck situations or when working in a secondary workshop that is not well furnished.
Some tools are non negotiable, but at other times, all it requires is a little inventivity, a bit more skill, patience and the zen spirit.

This is my first true project involving mechanics and electronics. I consider myself with a bit of experience under the belt in electronics, more experience in MCU coding, although
my code is crap before I decide to clean it up and properly factorize (which takes a long time to be put in motion) specially when i code in a rush (that was the case in that project).
I’m sorry for that.
As for mechanical engineering, I am an absolute beginner.
For the thermodynamics aspect, a little research online helped quite a lot.

There are overall a lot of lessons learned and practices confirmed to be important in completing a somewhat complex DIY project.
The more important are, in my case were :

For the idea to proof of concept part, check for state of the art using online resources, specifically video advertisements of similar devices, and see what features you can keep
from them. also check other makers work, and apply the Japanese philosophy of making an already existing product better if you dare.
careful beforehand planning of operation steps. write things.
Ordering of the operations so they don’t conflict each other and make another step impossible because of oversights is the most difficult part, at least for me.
CAD is advised to have a virtual look at the project and is good for post project documentation, although it takes time, and won’t be of real help
if you don’t use machining shops in your project.
May be useful in the future though if you decide to produce more, and also as an advertising and proof of seriousness in your endeavor.
Document your project during execution of the machining, packaging, and all the ‘practical’ work. it will serve you later by giving you a precise
view of the challenges you encountered, so that you can refine the production cycle through continuous improvement. sometimes a picture may be enough.
Video is paramount if you want to make your project public for other DIYers, and advertise it. It is hard to find the time to take pictures or videos when you’re in
the flow doing shop work, because it may break that flow. take it as a break time. making the video useful by being always centered on the work area is the big time cruncher.
In these cases, pictures are a perfect compromise.
Take inspiration of the hackaday like sites to see how experienced makers and hackers document their project.

analyze f***-ups in detail when they happen (root cause analysis, including psychological factors that lead to the mishap) so they don’t happen again
assumptions are the mother of a lot of them.

a great part of the skill required comes from an intuitive feel of Newtonian physics in the conception phase, and dexterity in the shop phase.
Look at a lot of DIY and shop videos to learn skills you don’t have beforehand.

compile the CAD files for parts and from the electronics EDA tool so that your BOM is comprehensive, and order more than required for cheap parts, especially if sourced
from China. sourcing skills are also something you’ll need to work on, and also it is quite fun to browse marketplaces when it is not for mindless consumerism.

Good luck to you !

1) Presentation.

milk curd stirrers are one of the critical devices used in the dairy and cheese industry.
A professional device usually performs these operations :

  • Precise control of heating (heating slope and temperature hold control, multi-step heating)
  • Stirring
  • Curd cutting using a cutting grate.

Some devices implement passive or active cooling using a refrigerant coil.

Professional devices are usually large, several hundred litres devices in the entry level market.
This scale is not suitable for small family farm operations.

This device performs heating control using the PID method (proportional / integral / derivative) and control stirring (on/off).
Curd cutting has to be performed by hand but there are several methods envisioned to expand the prototype into making this process automated.

Vessel used is a 15L Gredil brand stainless steel pan.

1.1 Heating control.

Using a standard 1200W kitchen hotplate that has been wired to be controlled by an SSR relay (fotek brand) and a PWM signal, heating duty cycle can be defined by the
PID algorithm.

  • Heating phase uses open loop control with inputted estimations of thermodynamic parameters (vessel geometry, external temperature, quantity of milk, heat capacity & transfer terms)
  • Heat transfer terms take into account conductive and convective effects.

Due to the large mass of the heating plate, thermal inertia is quite high and has to be compensated with a large derivative parameter in the PID controller loop.
Ceramic is a good choice, induction plates even better, although there are few single plate portable models for these technologies. Price tag is higher.

Closed loop control kicks-in at a defined set point before reaching temperature hold plateau to minimize temperature overshoot.

A thermoter probe well is present and secured to the base plate to perform temperature measurement as close as possible to the project center of mass of the liquid to be heated.

1.2 Stirring.

A 28W low rpm single phase AC motor, geared for 15 rpm, provides enough torque to enable consistent stirring. The motor is coupled to a 8mm shaft, ending with two perforated 12*15 cm , 2mm wide 308 stainless steel plates, with each having 5 33mm diameter holes. the shaft is terminated on its contact point on the steel pan with a conical taper to reduce friction between the two. The shaft is secured by a standard 8mm flanged bearing to the base plate crossbar.

Not included in this prototype, but highly recommended is to provide a rotor lock detection mechanism by monitoring the current drawn by the motor, and disabling it in case of overcurrent. Monitoring the motor temperature is also recommended based on the provided datasheet parameters.

1.3 Protection and conformity devices.

The devices uses two DIN circuit breaker inside a 2 breaker box. one 10A for the hot plate power, one 2A for motor and Arduino power. the circuit breaker box is secured by screws to mounting struts across the two slotted aluminum profiles, earthing of the whole metallic chassis of the device is provided at this point.
Note that fast period PWM induces switching noise on the mains AC. An adequate line filter for a 1200W hot plate is recommended.

1.4 The controller.

An Arduino Mega 2560 with an LCD 1602 keypad shield is used to perform the following operations :

-Motor on-off control for stirring and hot plate PWM control
-Temperature measurement
-Liquid quantity measurement using a laser distance measurement module.
-User interface (LCD 1602 keypad shield) to input program parameters and program selection

Liquid quantity measurement is tricky and one need to carefully plan the placement of the module based on the datasheet recommendations.
Specifically, the hole through through the baseplate and electronics enclosure has to be wide enough not to disturb the laser cone, and it is also very important that the PMMA protection window is mounted as close as possible to the module, ideally in contact with it. A distance larger than a couple of mm is sufficient to induce large crosstalk, making the measurements lose precision. at 10mm distance, measure is no more effective. The placement of the module on the horizontal plane also has to be made distant enough to the vessel walls for the same reasons. Two more constraints : the protection window has to be thin and provide adequate IR transmittance. PMMA is a good choice. Also, water vapor condensation is a problem for hot running measurements. A hydrophobic treatment of the PMMA window is therefore required.
On the other hand, milk is quite reflective and allows rather precise measurement to a 5% to 10% error margin.
This module requires quite a lengthy process of calibration : distance offset, measurement of materials with different reflectance, and crosstalk calibration.

A simpler approach would simply to ask the user to input the quantity of milk present inside the vessel.

2. Bill of Materials.

  • Aluminum strip 30mm x 2mm (for struts between the aluminum profiles, and to secure the breaker box) 50 cm
  • slotted 20×20 aluminum profile, length depending on the vessel depth, and adaptability for varying depth vessels qty 1
  • 68KTYZ motor, 10 rpm qty 1
  • 68KTYZ right angle mounting bracket qty 1
  • 8mm 303 stainless steel shaft, length depending on the vessel depth, and possibility of using vessels of varying depths qty 1
  • 8mm ball bearing with mounting holes, model KFL08 qty 1
  • aluminum shaft D19L25 coupling nut 7mm to 8mm qty 1
  • stainless steel 309 plate, 12x30cm 2mm width. This depends on the vessel geometry. used for both paddle wings qty 1
  • slotted profile 20×20 nuts, to secure struts, motor bracket, and plate to profile mounting brackets qty 12
  • aluminum profile 20×20 90° corner brackets, to secure aluminum profile to baseplate qty 4
  • ABS electronics enclosure 140x110x35mm Gainta Brand G738 qty 1
  • thermometer probe on cable DS18B20 qty 1
  • thermometer well, 20 cm length, 11mm width qty 1 2 DIN breaker wall mounting box (PawBol C.2030) qty 1 Arduino mega 2560 qty 1
  • perfboard (at least 140×110 mm) qty 1
  • LCD 1602 Arduino keypad shield qty 1
  • laser time of flight (distance measurement) module TOF050C (VL6180X based) qty 1
  • standard 5V relay module qty 1
  • Fotek SSR40DA solid state relay (5V DC control) qty 1
  • Hi-Link 5V power supply module, 3W qty 1
  • 275V varistor qty 1
  • 4.7K resistor (for temperature probe) qty 1
  • Silicon wire hookup cable, 22AWG qty 1
  • M2,M4 and M5 screws qty 1
  • IEC C14 male cable connectors qty 2
  • IEC C14 female connector qty 1
  • schuko cable C14 female terminated qty 1
  • 1.5mm2 conductors, blue, brown and green/yellow, 1m
  • cable relief and clamp nuts (for cables entering the electronics enclosure) qty 3
  • 1200W hotplate qty 1
  • 15L stainless steel vat, Gredil brand qty 1
  • U bolts. geometry will depend on the stainless steel vat handles position qty 2
  • butterfly bolts to secure U bolts to the baseplate qty 4

3. Tools needed

  • bench drill and HSS metal drills up to 12mm diameter
  • angle grinder with cutting disk and grinding disks
  • drilling and cutting oil
  • threading taps
  • 33mm hole saw for metal
  • stainless steel 2mm stick welding electrodes
  • stick welding inverter
  • perforated welding table or at least two vices, with one vice with XY axis regulation
  • spacers of varying widths to assist in vertical position of the paddle during welding
  • piece of copper to use as heat sink for stainless steel welding (to prevent warping)
  • a dremel with 28mm cutting disks and small abrasive (diamond) milling bits with various forms
  • soldering iron
  • multimeter
  • power screwdriver and angle grinder (to make the conical taper at the end of the shaft) or better, a lathe.
  • caliper and measuring tools
  • sharpie pen

4 Making the prototype

4.1 preparation of the baseplate

clean it and remove any protective film. mark the center with a sharpie. this will be the hole for the shaft.
drill the shaft hole some 20% larger so that there is leeway in final positioning of the shaft and bearing assembly

4.2 mounting the aluminum 20×20 profile

cut your aluminum profile in two parts (if applicable). the original extremities will be positioned over the baseplate,
since it is not certain that your cut angle is perfectly perpendicular if done with an angle grinder or a hand saw.

4.3 mounting the motor 90° bracket

place all T slot nuts inside the profile and position them for screwing the bracket. ensure that the base of the motor bracket is
parallel to the baseplate during test positioning. Screw the 68KTYZ motor to the bracket, install the shaft coupler, pass the shaft through
the bearing, position once again the assembly to the baseplate passing the shaft through the baseplate hole. test for shaft perpendicularity
using a protractor and you eyeballing abilities, using a protractor oriented in X then Y axis. beware of parallax. Note that this is not critical
since shaft coupling nuts have a helical groove to allow precession of the shaft, but it’s better to have the habit to do the right thing.

mark with a sharpie the outline of the corner brackets of the profile/motor assembly and the center of the holes of the brackets and shaft.
Check that the shaft does not contact the baseplate hole.
drill the holes for the baseplate to profile L brackets, again a bit larger so there is leeway for final positioning and screwing. once drilled secure the baseplate to the profile/motor assembly while checking that the assembly sits so that the shaft is perpendicular to the baseplate, again use protractor or a fancy laser. also at this point position the baseplate so the
shaft comes into contact at the center of the vessel bottom.

4.4 U-bolt baseplate to vessel fasteners

At this point it’s time to prepare the u-bolt holes that will be used to secure the whole device to the vessel using its handles.
this part is critical.

mark the contact point of the vessel lid to the baseplates, 4 points in total. will be useful if it moves inadvertently.

Since there is no contact except at the lid of the vessel, you’ll need to use a square ruler with a large contact area to project the handle of the vessel to the baseplate, offset to the centerline (axial) of the handle cylinder, and add offset of half the distance center to center of the u-bolt, mark the holes and drill. better drill to exact u-bolt bolt body dimensions, so there is no room for it wiggle if the butterfly bolts come loose during operation.

once again unscrew the motor/profile assembly and remove the shaft, and drill the u-bolt holes.
after that repeat the positioning steps above with the motor/profile assembly on the baseplate secured, and the baseplate secured to the vessel using u-bolts and check that
the shaft once again contacts the center of the vessel.

4.5 layout of thermometer well and electronics enclosure

test layout of the remaining components all at the same time :
the thermometer well, the bearing orientation, and the electronics enclosure.

there is a constraint on the VL6180X laser distance sensor (the laser cone of avoidance). some trigonometry will be helpful to define the minimum diameter of the electronics
enclosure window and the baseplate window. verify that the cone divergence does not intersect the wall of the vessel.
you can also skip this part because it is quite tricky and go for static liquid quantity input by the user.

4.6 securing the ball bearing to the baseplate

mark the holes for the ball bearing while the motor/profile assembly is correctly positioned.
remove the assembly again
secure the ball bearing. position and secure the motor profile assembly again, check that the shaft does not contact the baseplate.

4.7 thermometer well installation.


you can either place the thermometer well in the hole, it will rest on its flange, (quick and dirty) or glue a NFT threaded adapter to the baseplate so you can screw in the well and it does not move. you’ll have to carve out a slot in the paddles so that the well does not collide with the rotating paddles

4.8 define the layout for the components inside the electronics enclosure

at this point you should have the positioning constraint for the distance laser module on the XY axis.
non soldered components are the SSR and motor relay : they will be freestanding inside the enclosure and secured by the perfboard on their sides
the Arduino and LCD shield assembly will be secured to the top part of the enclosure.

Drill two holes in the perfboard at least, diagonally, you’ll use the same screws to secure the perfboard to the enclosure and to the baseplate.

position and mark baseplate with a sharpie through the bottom cover holes.
Drill the baseplate holes. baseplate holes maybe threaded or not and you’ll use bolts. it’s up to you. I tapped threads and was lucky. beware that threads in aluminum are soft compared to steel. threading is less robust but a little more elegant than bolting.
test mount bottom cover and perfboard to the baseplate.

Carve out the perfboard for SSR, relay and Arduino footprints. This step is required if you use the enclosure specified (Gainta) since there is not enough space on the Z axis for these components. if you find a better enclosure on the market, lucky you ! or just 3D print one.

The good side of the tightness of placing was that the perfboard maintained the two relays in place. better carve out less so that you finish with a
mill bit on the dremel and obtain a tight grip of the perfboard to the components.

also note that I had to chop parts of the fotek SSR plastic near the connecting terminals to connect the washer type electrical connectors.

of course, before carving out, you have to make sure that the remaining components fit on the little perfboard you have left : that is, the varistor on the AC side, power module, and the thermometer module resistors, maybe an electrolytic capacitor on the PSU output.

4.9 remaining holes on the bottom part of the enclosure

the bottom part of the enclosure will have three additional holes for the wire ports, two at the side closer to the center of the device :
one for the hot plate electrical wiring input to the enclosure (phase, neutral, and ground) the other port for the stirring motor power output (AC), and the MCU + motor power input (AC)
the distal hole from the center is for power output going to the plate.

If you have a precision bench drill use it for the holes in the enclosure, and finish with a dremel when required. the port holes are better milled with the dremel, since there is usually no
clearance to drill them with a precision bench drill, unless your setup allow to do so.

so, to sum up, the enclosure bottom part has these holes :
2 mounting holes to secure to baseplate and perfboard
3 holes for cable routing

finally, one of the enclosure plastic insert sides should have a hole for the arduino USB connector.

4.10 Soldering the components to the perfboard

First, A note about the VL6180X module

if you decide to implement it, remember that the PMMA window has to :

  • make the enclosure airtight and watertight
  • be in contact with the module itself to lower crosstalk to a minimum
  • be fog treated
  • be heat resistant. better measure the temperature at that point at the maximum operating temperature and liquid quantity of the device. 92°C liquid temperature is used for milk sterilization

that means that the Z axis section for the laser module has to be layered as this (going downwards) :

  • perfboard
  • laser module (using 90° header pins)
  • pmma window
  • enclosure bottom cover
  • baseplate

the PMMA window should be way larger than the hole so that the epoxy gluing step does not smear glue down the hole. use the least amount of glue over a rectangular path,
so the enclosure stays airtight.

Remember step 5 and check underside that the VL6180X chip is well inside its positioning margin so that the laser cone does not interfere with any part. re-mill if needed.
better perform calibration before gluing the window. the process is outside of the scope but there are well documented in the datasheet. You’ll have to write into quite a lot of registers.
on the VL6180X, check my code (will comment it better soon)

Also the module will be soldered on the perfboard bottom layer. a dual layer perfboard is thus required.
Finally, the perfboard may not be in contact with the bottom of the enclosure because of the module, in the case you do not use the provided mounting holes on the enclosure, as they provide some clearance from the bottom cover. if I remember well, I could not use them because of the crowded layout. This may lead to the bending of the perfboard, and axial force on the perfboard/cover/baseplate screws. if you manage to add plastic standoffs washers over the screws between the perfboard and the bottom cover, it will give a better result.

4.11 wire soldering to the perfboard (perfboard to perfboard and perfboard to freestanding)

pass the DS18B20 wires inside the wire restrain port and solder them to the perfboard.
solder the AC carrying wires leads (low amperage, these will connect to the 2A breaker and supply power to the module and motor) to the varistor and pass them through the port, later they will be bundled with the hotplate carrying wires. this could lead however to stronger switching noise coupling from the PWM operation to the AC power lines to the controller and motor.
In my case I did not use any line filter in the enclosure since there was no room left, but the hi-link module probably handled this well as controller operation is stable.

solder the hi-link power supply, and all interconnect wires.

this project feeds 5V to the Arduino through the 5V pin, so it bypasses the regulator, thus an electrolytic capacitor is advised to smooth DC when the motor relays kick in.
hi-link power supplies are good if you get the real thing, mine had to be opened, and a soldered wire was loose so it didn ot supply 5V. either i did not have luck or it was
counterfeit crap. lucky that it was just a wire issue. Always test ‘complex’ modules and components on breadboard first ! and if you can, order more than required since they’re cheap
and take time to get to you. Always think about logistics in any project !

One more advice :
I made the rookie mistake to use single stranded breadboard wires. don’t do that, they are fragile as f*** and break on torsion. used proper multistranded hookup wire.

label all the hookup wires on the perfboard side with a Dymo.
secure for the final time (hopefully) the perfboard, bottom cover, and baseplate together.
put the Fotek SSR and the relay in their designated perfboard placeholders
additional internal wiring using DuPont connectors are 5V,GND,relay logic for the motor relay, SSR relay logic and SSR DC ground.
the Chinese 5V relay modules provide male header pins. I advise not to directly solder hookup wires since that will make any servicing difficult.
Fotek SSR use large screw terminals the like used on overcurrent protection breakers, you’ll have to use washer type electrical connectors.

4.12 hot plate power power wiring

Pull neutral and ground 1.5mm2 wire through the enclosure through one of the ports on one side, across the enclosure, to the exit port.
split the same length of brown phase wire in two and solder a washer type electrical connector on one end of each wire, connect them to the AC part of the Fotek SSR.
the connectors will connect one one side to the dual pole 10A breaker on one side, and to the female (important that you use Schuko IEC C14 female connector here to prevent electrocution from the potentially energized prongs when it is disconnected from the plate) Schuko connector that will connect to the male ended Schuko connector cable going to the hot plate.

4.13 prepare the Arduino and the LCD 1602 shield

unfortunately the LCD 1602 shield pin headers come into contact with the top cover in my configuration. the easiest way for me was to saw them off with the dremel.
take care to not let drop the shavings mindlessly.

next solder hookup wires to the LCD shield for :

  • DS18B20 data
  • SSR relay logic
  • motor relay logic
  • 5V
  • GND

And if you use the I2C VL6180X laser distance module, add these cable leads (that’s because the LCD1602 keypad does not route the SDA/SCL through its pins, what a shame) :

  • SDA
  • SCL

4.14 prepare the top part of the enclosure

The fact that the LCD keypad shield plus Arduino have to be secured to the top part of the cover introduces a severe constraint for wiring the whole project.
That’s all Aliexpress had to offer in 2022.
This whole part will have to be rethought in any next iteration, with ideally an LCD keypad solution with ribbon cables and board to board JST connectors, and a PCB plus embedded Arduino on the bottom part, and a larger enclosure on the Z axis.

The top part will have a carved out rectangle for the LCD display, 4 holes to secure the Arduino/LCD and 5 holes for the keypad buttons,
Mill an opening on the enclosure top cover for the LCD1602 display and the five buttons keypad, with the dremel using cutting disks for the opening and milling bits for the keypad. you’ll also need mounting holes, beware when milling there is very little clearance between the holes and the display opening. go slow.

finally connect the shield to the Arduino and mount the Arduino with the shield to the top cover. screws and nuts required.

4.15 connecting the hookup wires leads from the Arduino to the wire leads going to the perfboard, the SSR, and the relay.

put a heat shrink tubing section on the cable solder all hookup wires from the perfboard / relays to the corresponding hookup wires of the Arduino/LCD, place the heat shrink tube over the solder and apply heat.
Of course, for this part you can go for ease of maintenance and just use DuPont male to female connectors cables to connect the bottom cover components to the Arduino, I just trust them less in the long term.
This part is a bit cumbersome since it has to be done with the enclosure partially closed, just to expose the wires.

4.16 closing the enclosure

once everything is in place close the enclosure slowly, checking not to pinch any cable, and screw and tighten the top cover.

4.17 circuit breaker box installation.

While one side of the parallel two 20×20 profiles is used for the motor and its bracket,
the other side will be populated by the electrical breaker box. I used a model for two DIN breakers, since I’m in Europe.
the box will be mounted on the two aluminum strips that serve also as struts. I made two diagonal holes to secure the box, one of these holes will also be used to ground
the device chassis, by the means of a washer electrical connector. grounding for the hot plate has to be provided, so you will need a 3P Wago to extend the earth or use two washer
connectors on the grounding point.

functional tests of the completed device will be covered in another post.

4.18 shaft conical taper

use a lathe or if you haven’t any, make the shaft spin on a power screwdriver, with support along the axis with a ball bearing secured on a vice.
have someone assist you or clamp the power driver trigger so it spins without assistance. once the shaft spins, make the conical taper using the angle grinder.

4.19 paddle cutting and perforation

using a metal hole saw, drill the holes on each paddle, using the same layout for both paddles. check the CAD model.
use plenty of drilling oil and stop drilling and let the saw cool down if smoke appears.

4.20 paddle welding

This part is tricky, because the fixture is a bit complicated to make when you don’t have the proper tools. Best is to have a true welding table with different types of clamps. If you have no welding experience, better give the work to a welding shop.

Without adequate tools you can make a somewhat ok-ish fixture using one vice to secure the shaft, and another 2 axis vice. you will need some spacers placed under the vice to adjust the them on the vertical axis relative to one another, so that the paddle width centerline is aligned diametrically to the shaft.
Then adjust XY axis on the vice that hold the paddle, just above the conical taper. better to have some margin if the paddle ends misplaced so that it does not contact
the vessel when you’ll test it, it will spare you some grinding. in my case, i ended with a max. 5mm margin between the paddles and the vessel, on the base and on the side.

If you’re a beginner like me, it should work (not ruining the parts) but aesthetically it could be crap.
I made a 45° bevel on both sides of the edge to be welded to create a groove to improve the weld robustness.
not sure if it really helped though, better ask a professional.
I used 2.8mm 308 stainless steel rods at 80A, I think it is a bit too hot, but I don’t know if my crap welder is calibrated for amp measurement.
The most important thing is a precise alignment of the paddle to the shaft and to use one or two copper heat sinks contacting both the paddle and the shaft close to the
weld area, underside of course. even like that, the shaft may warp. do not be too alarmed if it does though, because when welding the reverse side, the warping will revert, but because of this you could have trouble to make precise contact to the copper heat sink though.
repeat for the other paddle.

I learned that stainless steel welds may need passivation or electropolishing after welding to be fully corrosion resistant. there are DIY electropolishing methods involving strong acids like phosphoric acid and current, passed through some mineral fiber soaked in acid, and connected to an electrode. check Youtube.

4.21 final paddle assembly rotation tests

make free wheel shaft/paddles spinning tests with the motor coupling Allen nuts loose. it should not contact the vessel sides or bottom. A final test will be required with the motor on.

upload a test firmware to the Arduino and test the relays. at this point the motor relay is the focus of our attention, make the paddle spin, and if it contacts the vessel, grind the paddles at the point of contact until they no longer do.

4.22 breaker box to enclosure wiring connection, enclosure to motor wiring connection, enclosure to hotplate wiring connection, breaker box to main AC input connection

To sum up, there are three bundle of cables : phase, neutral, protective earth for the hot plate, passing through the enclosure and going to the 10A breaker, plus phase and neutral going to the 2A breaker. (since there is no line filter the protective earth does not need to be routed to the controller enclosure) these will provide power to the controller and to the motor through the relay.

and finally a bundle of cables exiting the other side is going from the enclosure to the hotplate.

the lone remaining cable is for the DS18B20 probe and will be shoved down the thermometer well.

use shrink tubing over each bundle and hot air gun blast it. then pass the leads down the breaker box hole on the top and connect them to the respective breakers.
do the same for the enclosure to hotplate, with a Schuko IEC C14 female termination. since the hotplate has to be easily disconnect from the rest, that’s why we terminate we a Schuko. keep this cable and Schuko connector length short.
Screw Schuko connectors are a bit tricky to fasten properly, in my opinion. If I had to do it again I would sacrifice a power cable to use the molded connectors.
repeat the process for the main power AC input, use a male IEC C14 Schuko this time. this cable enters the breaker box through the bottom. keep this cable and Schuko connector length short.

5. Additional resources.

5.1 Firmware

Firmware is available at https://www.github.com/rodv92/milk_heater2

Alpha Version.

5.2 CAD model

Take the model with a grain of salt. it’s mainly for illustration purposes and I used available GrabCAD and Mc Master Carr parts models, some of them do not match the components I’ll used.
the model, as for the date of this post, lacks drilling information, the breaker box is also not modelled.
If one day we have an AI managed database of all market available solid parts, using 3D reconstruction, that will make modelling easier, but human modelers will be rendered obsolete.
AI will drive one of the largest work shifts in human history, that’s for sure.

CAD model uses FreeCAD v 0.2 the model is available in :

https://github.com/rodv92/MILK_HEATER2/tree/main/hw

5.3 Schematics

Also available at (authoritative resources are uploaded on GitHub) :

https://github.com/rodv92/MILK_HEATER2/tree/main/hw/

5.4 Pictures

I hope to keep this project alive so It may serve the makers community well.

3 Phase Modbus Smart Power meter with relay actions and power line communication telemetry

# PMTR_001_SRV_001 V0.22

Disclaimer

PMTR_001_SRV IS NOT INTENDED FOR DISTRIBUTION / POWER UTILITY NETWORKS !

It should be installed on the customer side of the power utility meter. This project is open source and implementation should be done according to local electrical code.

It is designed to operate on high voltages up to 400V AC. These voltage levels may cause serious bodily harm or death. You should have the necessary qualifications to operate and design at these voltages.

There is no guarantee or responsibility whatsoever with this project from our part. If you wish to design and implement your own devices based on the information presented thereof, You do this at your own risk.

Description

PMTR (Power Meter, Telemetry & Relay) is an open source project that allows precise monitoring of mains parameters (voltage, current, active power, energy, power factor and frequency) and allows to act on external relays based on formula triggers (ex: overcurrent or overvoltage). It is a client/server project with a Web interface for data display, logging and device configuration.It uses power line communication and the industrial proved Modbus protocol to transfer data between the client and servers; no need to have ethernet or wifi at your main power panel, although LoRa telemetry is envisioned in future iterations.
It is modular and robust in approach, using off the shelf components available on local or Chinese or vendor sites to ease replacement of parts if need arise, and thus lower TCO for many years.
The server(s), (PMTR_001_SRV) is an Arduino based device that performs the power measurements and relay operations. Its configuration is pushed by a client.
The client(s) (PMTR_001_CLI) is a Raspberry Pi device that grabs power telemetry and pushes configuration and time synchronisation to the server(s) device. As stated above, it does not rely on an Ethernet connection, just a Power line communication based on the ES-1642 NC module from EastSoft.
Relay actions are used mainly to protect your equipment (for industrial settings) and control energy costs (ex: hotel industry, power charging for EV), It will also allow to cut/enable power at specific time of the day.
This project uses the Modbus RTU protocol, and allow several servers, as Modbus RTU is a shared bus protocol. Thus, you can monitor individual circuit legs or even devices on power subpanels.
Two flavour of servers are being developped : A single phase/device meter, and a 3 phase meter. They are rugged devices and implement ceramic fuses for ovecurrent protection and varistors for overvoltage protection. Metering is based on a modified PZEM-004t v3.0 modules that can measure line to line voltages up to 437V AC.


For more information on the client, check: https://www.github.com/rodv92/PMTR_001_CLI

For more code information on the modbus server, check: https://github.com/rodv92/PMTR_001_SRV


Current State of the project.


A single phase proof of concept with a Raspberry pi client and a single phase power meter was done and shows good results. The server code integrate formula based actions, and time synchronization. A basic web chart of power parameters and logging into a MariaDB database is part of this POC.

What has been done :

  • Prototype server for 3 phase line/line measurement and line/neutral measurement (with 400V support, still needs thorough testing)
  • ADG333 serial line switching support added to query sequentially all three PZEM-004t V3 modules
  • DS3231 RTC time-keeping support added.
  • USB Serial shell added to print current time, set time, get PZEM-004t metrics (instantaneous and moving average), dump circular buffer, dump EEPROM event log.
  • EEPROM logging of important events, for further inquiry by Modbus client or through serial shell
  • Modbus RTU device address DIP switch selector added plus code support.


Priority tasks as of August 2024:

  • Add supercapacitor bank to provide limited time power to the 12V bus and 3.3/5V buses in case of power outage. This will allow communication to the Modbus client of black-out or brown-out events, or AC/DC converter failure. Note that the PZEM-004t v3.0 metering unit is powered through L/N lines, not through the UART connector. The 5V/GND lines on the UART connector only provide power to the optocouplers. Low scale voltage before the library returns NaN is around 60V AC, While the AC/DC converters YHT4S operation low voltage threshold is 85V AC. This feature would thus improve metering range in case of brown-outs.
  • Test relay actions (using SSR / TRIACS) first, such as Fotek units)
  • Harden and test formula actions where conflicting pins are used with different actions.
  • Test communication over long runs of power line wire and over electrically noisy environments.
  • Make the raspberry pi (wifi, serial) configuration seamless.
  • Expand the raspberry pi client to query several servers with auto-detection of servers residing on the Power Line Communication bus.
  • Add LoRa support for failsafe communication in case of power line communication failure.
  • Add a MQTT layer on the raspberry pi for upstream telemetry reporting.
  • keep in touch with PeaceFair, the maker of the PZEM-004t V3.0 to make a hardened 400V module (there are still some issues regarding with high voltage tolerance).
  • Enclosure design for prototype, ideally DIN Rail compatible.
  • Add LCD Display and keys.

INSTALLATION and SETUP



typical use case for 3 phase delta-wired measurement:

This use case shows the installation of the PMTR_001_SRV for monitoring voltage and current drawn by a 3 phase induction motor, and all remaining power parameters.


Note that in that example, since the motor is a 3 phase delta wired device, and in the absence of a neutral return path, PMTR_001_SRV measurement mode rocker switches should be set for line-line measurement.


The setup contains a single digital pin operating a 5V relay (NO) that provides in turn power to a contactor (NO) that power ups (or down) the induction motor.
It is then trivial to use logic to specify a relay action that evaluates and power ups or down the motor upon specific power conditions. More on relay actions below.
Also note that the PMTR_001_SRV and PMTR_001_CLI are connected on the same line (L1) for PLC communication to occur.

Other installation best practices & Miscellanous

  • PMTR_001_SRV Contains a ES-1642 NC PLC modem (Power Line Communication). No Line filter should be present between the server and the client, the client would be unable to communicate with the server.
  • PMTR_001_SRV can operate over IT, TT, TN-C TN-CS earthing schemes.
  • As fort the prototype, it will be designed aroud a non metallic chassis, unless EMI hardening mandates to do so. so, PMTR_001_SRV does not require connection to the PEN.
  • PMTR_001_SRV implements ceramic fuse protection for overcurrent and varistors for overvoltage protection.
  • PMTR_001_SRV will be packaged inside a standard DIN Rail plastic enclosure for ease of installation inside a power distribution main panel.
  • Check the HW folder of this project for the terminal pin references.

Installation Steps

  • Disconnect power to the L1 L2 L3 lines powering the meter or to the VFD for safe installation of the current coils and metering unit
  • Make sure the low voltage board / Arduino is not connected to the 5V and GND lines (and JH 4pin cables linking the low voltage mezzanine board to the high voltage board are NOT installed)
  • Setup Modbus Address using the 8 position DIP switch to any value between 1 and 254. 0 is a broadcast address. 255 is a bridge address. Do not use these on the PMTR_001_SRV2) Set the 3 jumpers to LN metering – default – (line to neutral) or LL metering (line to line) Usually LN is preferred if the metering is on a standard european consumer network. LL metering is usually reserved for Variable Frequency Drive metering, or for star/delta starters, or on the secondary of a transformer with delta outputs. In that case, skip step 4.
  • After each phase is disconnected from the terminals, insert the current coil over the wire and reattach to the input and output terminals. repeat for each phase.
  • Connect CT- and CT+ wires to the appropriate PMTR-001-SRV terminals. Repeat for each phase
  • Connect neutral wire to the PMTR_001_SRV neutral terminal
  • Connect L1 L2 L3. It is advisable to install L1 L2 L3 while the upstream circuit breaker is off, screw terminals are high voltage, always use an electrician screwdriver or HV gloves. When connecting L1, the unit should power up, unless on a VFD where you need at least two phases. You can test that all DC power supplies are providing backup power by connecting them individually. PMTR_001_SRV should work with either L1, L2 or L3 connected in LN metering.
  • If a backup / battery supply is available you can connect it to AUX12VDC to the positive terminal and GND to the negative terminal
  • Set the DC step down module potentiometer to output 5V DC !
  • Screw the arduino mezzanine to the low voltage mezzanine, screw the serial lines, DIP switch lines, 5V and GND lines going from the Arduino to the low voltage mezzanine.
  • Screw the low voltage mezzanine board with the Arduino mezzanine already attached to it to the high voltage board and connect the 5V and GND lines to the arduino mezzanine board.
  • Tie the SEND terminal to any L1 L2 or L3 phase, now the Rasperry Pi (PMTR_001_CLI) can be connected to the same phase and neutral as the PMTR_001_SRV and it should set the time up.
  • Note: as of today, the PLC modem use line to neutral signalling. line to line signalling still needs testing.
  • Repeat the same actions above on any other PMTR_001_SRV to install on the network. use the same phase line for all the PMTR_001_SRV that you install
  • Relay connection : PMTR_001_SRV can supply up to 0.8A at 12V over the 12VDC_OUT terminal, Electromechanical relays can be powered by 12V IF the 5V relay action pin voltage is sufficient to be recognized as logical HIGH by the relay. Remember that The relay action pins on Arduino cannot supply more than 20mA continuous current. Always use relay modules with a separate power pin. Modules also take care of the inductive kickback. On the other hand, Digital pin action pin sourcing current is sufficient for SSR (TRIAC modules such as Fotek), and thus does not require external power.
  • Note : PMTR_001_SRV can supply up to 1.7A at 5V over the 5VDC_OUT terminal.
  • Proceed to PMTR_001_CLI Readme to finish setup.

Modified PZEM-004t v3.0 information and general PZEM-004t v3.0 limitations


The original PZEM-004t v3.0 can measure up to 267V RMS.
Here, The metering is done through a modified PZEM-004t v3 for up to European phase to phase voltage tolerance :up to 427V RMS with 0.2V resolution. Compared to the non-modified version, This ALSO allows phase to phase metering, and phase to neutral in case of neutral fault.Power, Energy, power factor resolution are doubled due to the fact that their computing involve instantaneous voltage measurement which is affected by the PZEM modification.
Otherwise, the floors, ceilings of the remaining parameters conforms to the PZEM-004T v3.0 datasheet of this day.It is expected that frequency measurement is not affected by the PZEM-004t v3.0 HV modification.

As for power factor, leading or lagging info is not provided, and neither power flow direction.

As of August 2024, no new version of PZEM-004t with 400V support seems to have hit the market.

PMTR_001_SRV does not measure the phase shift between phases.

PMTR_001_SRV performs instantaneous measurement as fast as the 9600 bps serial interface allows, which is a little less than 100 bytes per second (all parameters read). When performing 3 phase metering the PMTR_001_SRV performs serial port switching (using an ADG333A Quad SPDT switch) So it shares a single serial port on the Arduino for 3 PZEM-004T modules. This lowers the read rate to less than 33 bytes per second on average, which is still sufficient to get all line parameters with a polling of the 3 phases each second.
Sampling is thus done each second, and these samples are the basis for moving average computations.
The device has 5 memory slots for Moving Average information of all parameters (except energy)For instance, We could store the Moving Average over 5, 10, 20, 30, or 60 seconds.
The incentive behind moving average calculation is to apply low pass filtering and filter any spurious spike that would command an inappropriate relay action.

Relay Actions


A ‘relay action’ is a set of the following parameters :

  • An expression : using tokens representing PMTR_001_SRV parameters, and a set of inequalities and logic.- A moving average to use for expression evaluation (except energy which is never averaged)
  • A dry run bit (Yes/No), which tells whether to perform or not the relay action, while still logging all action behaviour
  • A recovery period during which the expression must keep evaluating to false before reverting relay action. This hysteresis is implemented for protecting devices which should not be turned on/off too frequently.
  • A HIGH or LOW state to command the relay when expression evaluates to true. (on false evaluation the state commanded will the be opposite ) nb : This evaluation from memory is the first action to be executed at boot up.
  • A list of pins on which DIGITALWRITE Will be performed.It is recommended that each action activates a separate set of pins, otherwise the last evaluated actions will have precedence and overwrite the status of pins.


There are 5 actions slots.

Examples of valid expressions :

  • (L1U > 253) || (L2U > 253)) || (L3U > 253)
  • LII > 16
  • LIp > 1200
  • L2e > 10
  • (L1f < 49.1) && (L2f < 49.1) && (L3f < 49.1)

Ex : L1U is phase to neutral L1 RMS voltage, L1I is phase to neutral RMS current, L2f is L2 frequency, L2e is energy counter for L2. Units use are SI, excepts for energy which is in kWh.

Let’s parse these formulas further.
First case formula would be the detection of a voltage swell over 253V over L1, L2 and L3 at the same time. The second formula equates to a current of more than 16A on L1. Next formula is an active power of more than 1200VA on L1. Next, A total energy consumed of more than 10kW over L2. Finally a frequency sag of 49.1 Hz over any of the phases.

Neutral fault detection

This feature is experimental and has not been yet implemented.

Broken neutral (floating) fault in three phase systems can have disastrous consequences by essentially rewiring the loads in a delta fashion.

Depending on the location of the fault and earthing arrangements, voltage imbalances arise, and the neutral point is shifted and may be subjected to voltages relative to earth that may be unsafe.

A sucessful neutral fault detection without false positives is not trivial based on a limited number of voltage readings (three power meters only), absence of phase angle information, and absence of a neutral to separate ground electrode voltage measurement

However, using magnitudes of voltages only and their variation in the time domain according to load variation, we could tentatively propose an lightweight algorithm suitable for MCUs to detect such occurrences.

Keeping in mind that if the load are reasonably balanced the fault will be harder to detect, until a disturbance in the balance of loads will unbalance voltages.

Generally speaking, a broken neutral condition will translate in an increase of one phase voltage, while the other two will decrease with reference to the nominal value, or one will decrease while the other two will increase.

A lightweight pre-check for discriminating between single phase power disturbances and neutral fault would be to check for any voltage exceeding a 10% nominal value deviation, and then proceed to check remaining voltages for disturbances.

A valuable tool for analysis of neutral fault conditions is the three phase voltage triangle. By using basic trigonometric identities of the equilateral triangle, we can characterize the least possible deviation in absolute values of the other two voltages assuming epsilon is the deviation factor from nominal value for the upmost voltage.

$$ \epsilon = 1.1 $$

$$ V_{p} = 230V $$ is the nominal phase RMS voltage

$${V_p}^{‘} = \frac{V_p \sqrt{4+12\epsilon^2}}{4\epsilon} $$ is the least possible deviation from nominal values for the two remaining voltages.

Thus we can write : $$ V_pdev >= |V_p – {V_p}^{‘}| $$

So, in terms of ratio we have $$ \frac{V_p^{‘}}{V_p} $$

The algorithm has to check that the remaining two voltages is higher or equal to that ratio for the first voltage and lower or equal to that ratio for the second voltage. Once this pre-characterization is done, a second part, more computationally intensive part of the algorithm can kick-in, to check that the sum angle derived from magnitude of the phase voltages is still close to 360° degrees, while analyzing voltages changes in the time domain.

Phase angles can be derived from magnitudes using sine and cosine trigonometric identities of the triangle. voltages fluctuations on the three phases with time that keep their sum angle close to 360° can be assigned a score for each angle sum characterization. With a value close to 360° giving a positive score, and a value diverging from 360° giving a negative score.

A sum of absolute values differences between discrete time samples of the three voltages can assign a weight to the characterization. This characterization puts into evidence the variation of load impedance in a broken neutral condition, and gives more credence to the computation if the angle sum keeps getting close to 360°

Once a positive score compounded by the previous weight reach a threshold, a broken neutral condition can be raised.

There are caveats however. a robust algorithm must assess the stability of the line voltages over time, preferably over a long term period. Using only three power line meters, a common occurence of unstable line voltages will degrade significantly the predictive abilities of the algorithm.

Hardware in-depth information

AC protection features

  • 20mm x 5mm 0.1 A ceramic fuses, fast blow 250V, this for each phase L1 L2 L3 and neutral N.
  • 14D481K varistors between each phase and neutral, and for protection of the PLC module.

AC/DC conversion

Power is provided by YHT4S12V/10W modules AC 400V tolerant.the three modules are connnected line to neutral and should be tolerant to neutral fault and up to 2 phase faults.


DC Bus

Matched Schottky diodes are used to improve power sharing betweeen the modules at 11.5V after the diode drop. a single LM2596 dc step down module provides 5V to the DC bus for the Arduino, PZEMs and ES-1642NC 5V line. ES-1642NC also needs 12V power.

PLC

ES-1642NC uses a separate hardware serial port for modbus communication over one phase and neutral, or a separate communication bus. line to line signalling is not yet tested. The serial line speed is 9600 bps. the PLC speed is between 2.5 to 4.5 kbps. Check Taidacent/Eastsoft product page for more information.

MCU


The main controller is an Arduino mega 2560 it is on a separate mezzanine board than the HV parts / PZEM Modules.
The ADG333 IC allows routing a single hardware serial port to the three PZEM modules. Querying is continuous and sequential, With a polling interval of 333ms between each module, giving a net polling interval of 1 second.
It could be technically feasible to have all PZEM modules on the same RX/TX serial TTL pair, but that would need to ensure that the optocouplers do not overload the RX/TX current sourcing capabilities, and also would need a factory preset of the PZEM-004t V3.0 addresses. Note that PZEM-004t V3.0 itself is a Modbus device.
The server itself encapsulate telemetry queries and present the 3 PZEM-004t V3.0 as a single Modbus server device to the Raspberry Pi client, although with Modbus register addresses remapped.
Thus, it seems more adequate to use the same Modbus address on each module, and switch them using an IC switch like the ADG333.

Time keeping & Synchronisation

A real time clock (RTC) 3231 mini module is used to keep track of time and the synchronization is done over PLC / Modbus.
Modbus address encoding of the server is done through a 8 bit DIP switch encoder.

Software (Github repositories)

Most of the single phase functionality is POC tested.three phase hardware testing and hardening is still in progress.Software is still in POC phase. Consider the code to be in alpha stage.

https://github.com/rodv92/PMTR_001_SRV

https://github.com/rodv92/PMTR_001_CLI

Hardware Schematics

Logic Board – Low Voltage
This is the logic mezzanine board.

Power board – High Voltage
HV PCB Layout


Software library includes & Credits

Thanks to the Electrolab hacker space for providing me working room and resources to complete the prototype of this project.

https://www.electrolab.fr

Modbus library used for PLC client/servers communication

ArduinoModbus depends on the ArduinoRS485 library :

https://github.com/arduino-libraries/ArduinoRS485https://github.com/arduino-libraries/ArduinoModbusby sandeepmistry

Specific modbus conditioning and parsing library for the power monitoring modules :

https://github.com/mandulaj/PZEM-004T-v30 by mandulaj


library for timekeeping :

https://github.com/PaulStoffregen/Time/blob/master/TimeLib.h by PaulStroffregen

library for scheduling task by timer ISRs :

https://github.com/khoih-prog/TimerInterruptby khoih-prog


library for parsing math and logical expressions (for relay logic) :

https://github.com/zserge/expr/blob/master/expr.h by zserge