====== Tool Access Controllers ====== ===== Overview ===== We have access control for some of our power tools, especially where they are dangerous, expensive or easily damaged by untrained users. The access controllers are built on the ESP8266 platform and use PN532 modules to authenticate NFC tokens. Each controller can manage a single tool and enable/disable it's incoming power, or integrate into a more complex control system. The controllers can also perform a basic current usage measurement to determine whether a tool is in active use. ===== Devices ===== Current: * Startrite Bandsaw * Bantam Lathe * EMCO Lathe * Small Laser Cutter * Big Laser Cutter * Mitre Saw * Table Saw * Sander * Welder * CNC Router * Juki Sewing Machine Planned: * Bench grinder(s) * Drill press(es) * Denford CNC Lathe * Denford CNC Mill ===== PCB ===== https://github.com/timhawes/stony_skunk/ Revision 1 had an error in the layout and was not used.\\ Revision 2 uses an ESP-12E module and has been deployed on many of the lab's tools.\\ Revision 3 uses a Wemos D1 Mini module for easier builds and debugging. ^ Ref ^ Item ^ Quantity ^ Selection ^ | U1 | Wemos D1 Mini | 1 | | | U2 | TE OJ/OJE series 5V relay | 1 | Farnell 1891661 | | SP1 | 12.7mm through-hole buzzer | 1 | CPC LS03778 or LS00654 | | D1 | Flyback diode | 1 | Farnell 1625280 (US1D) | | D2 | ESD protection diode | 1 | Farnell 2317508 (ESD5Z3.3T1G) | | Q1, Q2 | N-channel MOSFET SOT-23 | 2 | Farnell 2069541 | | C3 | 10uF 0805 10V+ | 1 | | | R1, R6, R7, R13 | 10K 0603 | 3 | | | R3, R4 | n/a | | burden resistor, easier to fit one externally | | R5 | 1K 0603 | 1 | | | R8, R9 | 2K2 0603 | 2 | | | P1 | 8-way 3.5mm screw terminal | 1 | | | P2 | 4-way 0.1" pin header | 1 | | | P3 | 2-way 5mm pluggable screw terminal | 1 | CPC CN18918 + CPC CN18994 | | P4 | 5-way 0.1" pin header | 1 | | | P7 | 2-way 0.1" pin header | 1 | | ===== Other Components ===== To make a working system, the following components will be required in addition to the PCB: | 20x4 LCD module with I2C backpack | by convention we use black text on a yellow backlight, which is more readable than white on blue | | [[https://www.elechouse.com/elechouse/index.php?main_page=product_info&products_id=2276|PN532 NFC module]] | Buy direct from Elechouse, clones have poor read range and a high failure rate | | Two push buttons | CPC SW03314, but others can be used | | Current transformer | [[https://www.ebay.co.uk/sch/DL-CT08CL5-20A|DL-CT08CL5-20A]] plus 33R burden resistor | Depending on the tool being managed: | 5V 1A power supply | 240V AC-DC, 24V DC-DC from a VFD or 5V from an existing PSU | | AC contactor or no-volt switch | | | Class X2 suppression capacitor | 0.1uF or 0.22uF, if contactor or motors cause interference | ===== Enclosure and Wiring ===== All of our current tool controllers use the same design, an IP65 ABS enclosure from RadioWorld on eBay. This no longer available so new controllers will require a different case and a modified mounting frame. The PCB, LCD and NFC modules are mounted on a laser-cut acrylic frame using nylon screws and spacers. The front frame is cut from 3mm clear acrylic, and the supports from 2mm clear acrylic. Push buttons are panel-mounted to the front of the enclosure. {{ :tool-controller-mount.dxf?linkonly }}\\ {{ :tool-controller-mount.slvs.zip }} [SolveSpace source] **Simple plug-in mains tools:** On a simple tools up to 10A, we use two cable glands for the incoming mains and outgoing switched-mains. The onboard 10A relay is used for switching and the current transformer is fitted inside the enclosure. It is assumed that the relay will not normally switch the full load so we don't de-rate for inductive loads. **More powerful tools:** On more powerful tools we fit a no-volt switch or contactor. Our 10A relay is put in series with the contactor coil supply so that the contactor can be locked-out. The current transformer will be located remotely to measure the full system load or just the motors. **Other:** More complex tools may have their own control systems (remote start/stop, VFD motor controllers, etc). In these cases we may fit our relay to the incoming contactor or to the control signals loop or to the estop/interlock loop. ==== Noise suppression ==== Some motors and contactors will create electrical noise, causing the microcontroller to crash or reset. If this happens the noise should be suppressed at source. A 0.1uF or 0.22uF class X2 capacitor (fitted across live and neutral close to the source) will often resolve the issue. ==== Safety Rules ==== * The tool controller must not be used as an emergency stop (though it may be wired in-series with a real emergency stop). * The tool controller must not cause the device to start any motor or heavy machinery (there must be a separate start button with a no-volt reset). ===== Assembly Process ===== - Assemble the PCB (see earlier section). - Solder wires to two push buttons and twist the wires for tidiness. **WHAT LENGTH?** - Solder five jumper wires to a PN532 module and use hot glue to support the joints. The wires will be connected to VCC, SDA, SCL, GND and the RSTPDN (reset) pin. At the other end the female connectors should be removed from their plastic housing and re-inserted into a 5-way housing. **WHAT LENGTH?** Adjust dip switches to I2C mode. - Laser-cut a front-frame (3mm clear acrylic) and two support pieces (2mm clear acrylic). - Place the frame inside the enclosure. Use it to mark the drill centres for the push buttons. - Double-check that the push buttons are on a straight line between the screw holes of the enclosure and that the holes will be symmetric. - Drill the push button holes and use a hole reamer to get the exact size (the buttons will be inconveniently in-between common drill sizes). - Drill holes for cable glands at the lower edge of the enclosure, or for non-glanded holes in the back of the enclosure (depending on the intended layout). - Fit the acrylic supports in slots 1 (top of the enclosure) and 3. Use a piece of foam adhesive tape at each end to keep the supports in place and to apply upward pressure on the front-frame when it is installed later. - Trim the header pins from an LCD module to provide enough clearance. - Fit the LCD module to the front-frame using nylon screws (4x M3 10mm nylon screw, 8x nylon nut). The LCD should be mounted underneath the frame. The stack should be: screw head, front-frame, nut, LCD module, nut. - Fit the PCB to the front frame with nylon screws and hex spacers. The PCB should be mounted underneath the frame. The stack should be: screw head, front-frame, spacer, PCB, screw head. - Fit the PN532 module to the front-frame. The module should be mounted **above** the frame. The stack should be: screw head, PN532 module, front-frame, nut. - Install the push buttons and place the assembled front-frame into the enclosure lid. - Connect the PN532 and LCD modules. - Install and test the firmware. - Prepare mains wiring. For a plug-in configuration, wire the incoming and outgoing mains cables to a connector block near the bottom of the enclosure. For a hard-wired configuration, mount the enclosure at this point and complete any planned wiring. ===== Software ===== [[https://github.com/timhawes/toolman-firmware|Firmware]] - Arduino C++ built with PlatformIO \\ [[https://github.com/timhawes/toolman-backend|Backend]] - Python 3 asyncio ===== Bugs and Improvements ===== * Delay active->idle transition to avoid triggering on current-measurement glitches. * In //wait// mode, delay idle logout by 1-2 seconds. * Flatten floods of NFC reads. * Measure peak-to-peak current instead of RMS, to reduce time spent on ADC reads. * Drop in free heap space after some network outages (can recreate with iptables -J DROP)