Skip to the content
PCBKitNew board
2 layers93 × 61 mmZero crossing detector, the printed circuit board in 3D

Zero crossing detector

cs2dsb/zcssr10

A PCB and software for a SSR controller that monitors mains AC zero crossings to determine when to turn the SSR on.

Size
93 × 61 mm
Copper layers
2
Thickness
1.6 mm
Parts
98
Nets
91
Pads
313
Tracks, vias
779, 158
Pours
5
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
10 Nov 2019
Updated
8 Nov 2021

Overview

Zero crossing detector is an open-source printed circuit board by cs2dsb, from the cs2dsb/zcssr repository on GitHub, published under the Apache-2.0 licence. It is a 2-layer board of 93 × 61 mm with 98 parts on 91 nets, routed with 779 tracks and 158 vias.

It is built around the HLK-PM01, MAX31855KASA+T and AP2112K-3.3, with the EL357N(C)(TA)-G, USBLC6-2SC6 and B5819W among its other parts. Its parts include 36 resistors, 23 capacitors, 11 diodes, 6 connectors and 5 ICs. It belongs with the STM32 boards of this library.

Main components

6

README

README.md

ZCSSR - Zero crossing solid state relay controller

A PCB and software for a SSR controller that monitors mains AC zero crossings to determine when to turn the SSR on.

Image of v0.1 fully assembled more images

Why

I wanted to build a spot welder from an old MOT (microwave oven transformer) but wasn't satisfied with simply enabling the SSR at random because this makes the pulse +/- 1 half mains cycle (10ms on 50Hz, 8.3ms on 60Hz). It probably doesn't make much difference in the grand scheme of things but I wanted to know exactly how long the pulses were.

This controller solves that issue by monitoring the mains zero crossing and triggering the SSR just before a zero crossing - the SSR has it's own zero crossing circuit to actually turn on it's output so as long as the controller doesn't fire more than 1 cycle early it will work as expected.

I also wanted to completely finish an embedded project written in rust and this project seemed about the right size undertaking.

Uses

  • Spot welder
  • Reflow oven
  • Sous vide
  • Smoker
  • Probably other things that need temp input (K-Type thermocouple) and switched mains ouput

Features

  • Zero crossing detection circuit
    • Pulse at least 0.4ms before the zero crossing
    • Isolated
    • 100-240V, 50/60Hz
    • Details
  • UI
    • Quadrature encoder with push button
    • LED for general status
    • LED for SSR status
    • 4 digit 14-segment LCD display. I2C
    • Trigger input
  • Temperature monitoring
    • NTC thermister for monitoring SSR/Transformer temperature
    • K-Type thermocouple input. MAX31855
  • STM32F1 64-pin LQFP MCU. Specifically STM32F103RCT but any should work
  • SWD (serial wire debug) programming & debugging
  • USB hardware. In theory USB programming will be possible but not yet implemented

Tools used

Not a complete list. Will add to it as features get implemented

Documentation

Getting started

  • Clone the repo
  • Run ./bootstrap script which will:
    • Initialize git submodules
    • Run firmware/bootstrap which will:
      • Checks if OS dependencies are installed
        • Currently gcc, gdb, openocd and libudev-dev
        • sudo firmware/install_apt_deps will install these deps if you are using a distribution that uses apt
      • Install or update rustup
      • Install required rust embedded toolchains
      • Install utils from crates.io
        • cargo-binutils
        • cargo-watch
        • llvm-tools-preview
        • serialitm
      • Run a cargo check, build and doc of the firmware (will take quite a while the first time)
  • Direct flashing the the device
    • firmware/deploy_standalone will start openocd, flash the program and restart the device
  • Debugging with gdb
    • firmware/run_openocd in one terminal
    • firmware/release or firmware/debug to build and launch gdb
    • Take a look at firmware/openocd.gdb and the scripts above to tweak the behaviour
  • Log output
    • Firmware built with --feature itm will log over SWD
    • firmware/monitor_itm will launch serialitm to print this output with the ITM control characters stripped out. You may need to tweak the script if your uart dongle isn't /dev/ttyUSB0
  • Tmux
    • firmware/tmux_workspace is a script that will open a tmux session with firmware/run_openocd, firmware/monitor_itm and firmware/watch in differnt panes to make development easy. Just type ./release in one of the spare panes to deploy the software with gdb

ITM logging

The code uses ITM logging to indicate start up progress and log info like temperatures and user config. If the ITM feature is enabled, the microcontroller won't run without openocd connected because there is some debug config openocd does to the chip that makes ITM work. I've added the obvious checks to the itm_logger crate but there's still something missing that I haven't got to the bottom of yet. There's an issue to track it. The bottom line is if you want to be able to plug the hardware into the mains without OpenOCD connected you need to disable the itm feature (firmware/deploy_standalone already does this.)

More info

Check the docs folder for information on setting up the dev environment and various info on making the hardware.

Mains warning

  • Mains is dangerous, see the disclaimer
  • A specific issue you might hit is powering the device over USB during development then plugging the mains in while the USB dongle is still attached. The mains will power the AC/DC on the board and that will backfeed 5v into the 3.3v/5v provided by the dongle. It's fine to leave the dongle connected if you disconnect it's 3.3v/5v line - only ground, swd, swclk should be connected to the ST-LINK if you want to plug the mains in. The UART connected to ground and swo is also fine. If you do backfeed 5v to the ST-LINK expect the ST-LINK to break as a minimum and the USB port it's connected to as a worst case.

Disclaimer

  • This project uses mains electricity and will kill you if you handle it improperly
  • You are responsible for your own safety
  • Despite best efforts the author makes no guarantees that this design is safe, fit for purpose or meets any quality standards
  • If you decide to build this or a similar device you must understand and take necessary safety precautions before proceeding
  • The author cannot be held responsible for any damages or any form of loss that comes as a result of using any information found in this project

License

This template is licensed under either of

at your option.

Parts

98
QtyValueFootprintReferences
1810kResistor_SMD:R_0402_1005MetricR10, R11, R12, R13, R14, R15, R18, R20, R21, R27, R28, R29, R30, R31, R32, R35 +2
9100nFCapacitor_SMD:C_0402_1005MetricC4, C9, C10, C11, C13, C14, C19, C20, C21
71N4148Diode_SMD:D_SOD-123D1, D2, D3, D4, D5, D9, D12
610nfCapacitor_SMD:C_0402_1005MetricC8, C15, C16, C17, C22, C23
31kResistor_SMD:R_0402_1005MetricR6, R33, R34
32N3904Package_TO_SOT_SMD:SOT-23Q1, Q2, Q3
2100kResistor_SMD:R_0402_1005MetricR25, R26
210uFCapacitor_SMD:C_0402_1005MetricC3, C18
2150Resistor_SMD:R_0402_1005MetricR16, R17
22.2kResistor_SMD:R_0402_1005MetricR19, R40
222Resistor_SMD:R_0402_1005MetricR22, R23
2220kResistor_SMD:R_0805_2012MetricR1, R2
222pFCapacitor_SMD:C_0402_1005MetricC5, C6
2600ohmInductor_SMD:L_0805_2012MetricFB1, FB2
2B5819WDiode_SMD:D_SOD-123D10, D11
2SolderJumper_2_OpenCustom:SolderJumper-2_P1.3mm_Open_TrianglePad1.0x1.5mmJP1, JP2
110uFCapacitor_SMD:C_0805_2012MetricC2
11kResistor_SMD:R_0603_1608MetricR4
11nFCapacitor_SMD:C_0603_1608MetricC1
11ufCapacitor_SMD:C_0402_1005MetricC7
1220Resistor_SMD:R_0402_1005MetricR8
122kResistor_SMD:R_0603_1608MetricR3
12kResistor_SMD:R_0402_1005MetricR24
14.7kResistor_SMD:R_0402_1005MetricR5
14.7ufCapacitor_SMD:C_0402_1005MetricC12
1500mA 250V Slow BlowFuse:Fuseholder_Cylinder-5x20mm_Stelvio-Kontek_PTF78_Horizontal_OpenF1
18MHzCrystal:Crystal_SMD_5032-2Pin_5.0x3.2mmY1
1AP2112K-3.3Package_TO_SOT_SMD:SOT-23-5U3
1BOOT0Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ2
1BOOT1Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ7
1Conn_01x02Custom:Terminal_Block_Dinkle_EK508V_1x02_P5.08mm_VerticalJ1
1Conn_02x15_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x15_P2.54mm_VerticalJ3
1EL357N(C)(TA)-GPackage_SO:SOP-4_3.8x4.1mm_P2.54mmU1
1HLK-PM01Converter_ACDC:Converter_ACDC_HiLink_HLK-PMxxPS1
1K-TypeCustom:PhoenixContact_MKDS_2-3.5J6
1MAX31855KASAPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU4
1PWR_GreenLED_SMD:LED_0603_1608MetricD6
1ResetButton_Switch_SMD:SW_SPST_B3SL-1002PSW1
1STM32F103RCTxPackage_QFP:LQFP-64_10x10mm_P0.5mmU2
1USBLC6-2SC6Package_TO_SOT_SMD:SOT-23-6U5
1USB_B_MicroCustom:ZX62M-B-5P(30)J4
1USR_RedLED_SMD:LED_0603_1608MetricD7
1VaristorVaristor:RV_Disc_D12mm_W3.9mm_P7.5mmRV1

The 93 most common of 98 parts.

Questions

How big is the Zero crossing detector PCB?

It measures 93 × 61 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Zero crossing detector use?

98 parts, built around the HLK-PM01, MAX31855KASA+T, AP2112K-3.3 and EL357N(C)(TA)-G. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Zero crossing detector KiCad files?

From the cs2dsb/zcssr repository on GitHub, at the commit this page was made from: the board is hardware/zero_crossing_detector_surface_mount/zero_crossing_detector.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Zero crossing detector design in my own project?

Its repository publishes it under the Apache-2.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers130 × 110 mm3D Printer Mainboard STM32, the printed circuit board in 3D

    3D Printer Mainboard STM32

    m47812/Custom-3D-Printer-Controller

    A fully custom 3D Printer controller board based on an stm32f7 controller with TMC2209 stepper drivers

    191 parts10GPL-3.0
  • 2 layers31.1 × 34.5 mmOpenThermMonitorTwomes, the printed circuit board in 3D

    OpenThermMonitorTwomes

    energietransitie/twomes-opentherm-monitor-hardware

    Open hardware design files for the Twomes OpenTherm Monitor device

    28 parts3
  • 4 layers80 × 38 mmIntercat, the printed circuit board in 3D

    Intercat

    BarceP/CAT_Interface

    CAT Interface for HAM Radio, USB-C

    99 partsCERN-OHL-S-2.0
  • 2 layers75 × 75 mmHotPlateController, the printed circuit board in 3D

    HotPlateController

    stasiselectronics/HotPlateController

    A simple ESP32 connected controller for a SMD reflow hot plate

    47 parts9
  • 4 layers63.2 × 183.1 mmNeflow, the printed circuit board in 3D

    Neflow

    DrNotThatEvil/neflow

    Not Evils Reflow Oven (neflow

    63 parts
  • 2 layers46.8 × 52 mmUsb dev board, the printed circuit board in 3D

    Usb dev board

    cs2dsb/stm32-usb.rs

    A dev board designed to facilitate the development of USB firmware for STM32

    57 parts30Apache-2.0
  • 4 layers93.2 × 35 mmMk2 routed, the printed circuit board in 3D

    Mk2 routed

    Woz4tetra/auto-battlebot

    This project brings aim-assist and autonomous control to combat robots.

    75 parts3
  • 4 layers64 × 43 mmDalws, the printed circuit board in 3D

    Dalws

    anhldptit2610/dalws

    This project is my attempt to learn about microcontroller and PCB design. Now I realize that making a full, complete electronic project is super hard.

    83 parts2MIT