The tools access control device (which still needs to be named) is designed to allow use of the attached tool to be restricted to inducted members, and to keep track of usage for charging purposes. It's been designed with the aim of being easy to fit to multiple different tools if needed (e.g. lathe and mill), not just the laser cutter - although charging for use is unlikely to be used for other tools.
For the Laser cutter, it keeps track of pledged time, and charges by the second for those that didn't pledge, or have used up their pledged time. Any laser usage which isn't covered by pledged time is charged in the same way as the Vending machine, which results in a monthly email, and can be paid off using either the Snackspace jar, or the NoteAcceptor.
The hardware consists of an Arduino, Ethernet shield, RFID module, (optional) LCD and relay, and it communicates with a server side process on Holly using MQTT, specifically an instance of the Mosquitto MQTT broker.
There is a related tool booking system running on HMS, however the interaction with that is limited; booking a tool in HMS currently has no connection to who can or can't sign on to the laser. HMS can be used by any member to see their use of the laser (and any charges as a result), as well as see if the laser is currently in use or not.
The current device on the Laser cutter is a prototype, built on an Arduino UNO (or clone, I can't remember), wiznet based Ethernet shield and protoshield. The second version (intended for the 3d printer) has been built using a custom PCB, see GitHub for the design, and flickr for photos of the mostly assembled device, minus case.
The attached tool is controlled by using a relay on the protoshield - this is intended more for isolation, and not to switch any great load. In the case of the laser cutter, the relay on the protoshield is wired back to another relay+contactor inside the laser cutter which is wired in series with the incoming mains. There are two push buttons; one to allow authorised members to record other members as having been inducted, and one to sign off. There is also a status LED that lights up when the signed in member is authorized to give inductions, and flashes after the induct button had been pressed and the system is searching for a card to induct (the original idea was that the induct button would be an illuminated push button).
|A4||SDA for LCD|
|A5||SCL for LCD|
|D2||Sign off button|
|D4||(Used by Ethernet shield?)|
|D7||RFID Slave Select (labelled SDA on RFID module)|
|D8||Sign off LED. Currently unconnected - but will be used for tools that don't have an LCD|
|D10||(Used by Ethernet shield?)|
|D11||MISO for RFID & Ethernet|
|D12||MOSI for RFID & Ethernet|
|D13||SCK for RFID and Ethernet|
This is the second version of the enclosure designed for the version 2 PCB. The design files for the laser cut panels and 3D printer parts are available on GitHub at https://github.com/NottingHack/NH-Tool-PCB
- The design is based on using 6mm material for the laser cut panels.
- The LCD is optional, simply omit the hole from the front panel. LCD used: https://www.amazon.co.uk/dp/B019SXNKGU
- The 3D printed card mount should be printed with support material (touching buildplate) and a brim to ensure it does not fall over during printing.
- The hole in the bottom for the IEC C7 socket (figure of 8) is specific to the Embroidery Machine, it can be removed or customized for other tools.
- The micro switch is used for an additional means of card detection but there is currently no support in the firmware.
|8||M3x16mm bolt||front and back panels of the box|
|4||M3x12mm bolt||3D printed card holder|
|2||M3x6mm bolt||(OPTIONAL) to mount LCD module|
|3||M3x30mm bolt||mounting PCBs|
|5 (7 if using LCD)||M3 washers||PCB mounting, microswitch mounting, (OPTIONAL) LCD mounting|
|2||M2.5x12mm bolts||microswitch mounting|
|1||4-way F-F cable||(OPTIONAL) for LCD module|
|1||8-way F-M cable||for RFID reader module|
|1||7-way M-bare end cable||front panel buttons and indicators|
|3||5mm LED||front panel indicators, preferably red, green and yellow|
|2||momentary push switch||typical sub-mini normally-open panel mount push buttons|
|1||WIZnet Ethernet shield|
|1||HSNOTTS nh-tool PCB v0.2||https://github.com/NottingHack/NH-Tool-PCB|
|1||2x16 charter I2C LCD module||(OPTIONAL) https://www.amazon.co.uk/gp/product/B019SXNKGU or similar|
|1||3D Printed card mount||https://github.com/NottingHack/NH-Tool-PCB|
|3||3D Printed M3 spacer||https://github.com/NottingHack/NH-Tool-PCB|
|1||Laser cut 6mm wooden box||(6 panels) https://github.com/NottingHack/NH-Tool-PCB|
The required parts for the construction of the RFID tool control encosure.
Attach the 8-way F-M cable to the RFID-RC522 board, note the colours may be different.
Slot the RFID-RC522 module into the 3D printed plastic card mount.
Due to the thickness of the wooden enclosure (6mm) the panel mounted push button will need to be recessed into the back of the panel. Use a spade bit on the pillar drill to remove about 3mm of the material from the back.
You should now have room to install the push buttons.
Attach the push button and ensure the spring washer is on the back of the panel. Use a pair of pliers to tighten the nuts on the front.
The push buttons should now be securely fastened to the panel.
Lay out the remaining wooden pieces as shown in the photo. The top panel has a cut out for a card on the front edge and the bottom panel has an extended slot for the wires to pass through. The back panel should be orientated so the majority of the holes are near the top. The left and right panels are identical.
Assemble the box and ensure the parts fit together easily with no large gaps.
Use a hot glue gun to glue the side panels of the box together, do not glue the front or back panels in as they are held together with nuts and bolts to allow access to the electronics.
Only a small amount of glue is required in the very corner or the joints.
Allow the glue to cool slightly before continuing.
Pass 3 M3x30mm bolts through the back panel as shown in the photo, note only 3 of the 4 holes are used.
Place the 3D printed M3 spacers over the bolts.
Place the WIZnet Ethernet shield onto the bolts and secure with 3 M3 nuts.
Place 4 M3 nuts into the T-slots towards the back of the enclosure. You may need to use pliers to force the nuts depending on the quality of the wood and laser cutting.
Use 4 M3x16mm bolts to attach the back of the enclosure.
You back panel should look similar to the photo below.
The inside of the enclosure should look similar to the photo below, ensure that the ethernet socket on the WIZnet Ethernet shield is facing the hole in the bottom of the enclosure. If this is not the case you may need to unscrew the back panel and rotate it 180 degrees.
Place the 3 LEDs into holes in the front panel. use red for "STATUS", yellow for "INDUCT" and green for "TOOL". Try and orient the LEDs so that the short legs are all facing the same way to make the wiring easier.
Use some hot glue to secure the LEDs and switches in place.
You should now have a front panel that looks similar to the photo below.
Attach the micro switch with the roller facing towards the bottom using 2 M2.5mm x 12mm bolts, 2x M3 washers and 2x M2.5 nuts
The washer should be near the head of the bolt before it goes through the slots in the 3D printed part as shown in the photo below. You do not need to adjust the position of the switch at this point.
Place 4 M3x12mm bolts through the front panel in the holes.
Attach the 3D printed card mount to the back by securing it with 4 M3 nuts.
Begin wiring the front panel by connecting all of the common/ground connections first, use heat shrink to cover the connections. WARNING: the push buttons and micro switch do not like a lot of heat when soldering as they will very easily melt.
Use the 7-way M to bare ended ribbon cable to make all of the remaining connections including a common/ground. Follow the order based on the board labels to make things easier when connecting the ribbon.
Connect the RFID-RC522 module to the main board, the colours should match up as shown below.
Attach the front panel wiring to the back of the main board.
Connect the main board to the WIZnet Ethernet shield being careful not to bend any pins in the process. Place the front panel onto the enclosure and attach with 4 M3 nuts in the T-slots and 4 M3x16mm bolts in the same way the back panel was attached.
NOTE: the power supply, Ethernet cable and relay connections are not shown but can be attached by removing the main board.
The source code for the Arduino firmware is on GitHub,
The Arduino firmware uses these libraries:
- PubSubClient - https://github.com/knolleary/pubsubclient - for MQTT communications
- HCARDU0023_LiquidCrystal_I2C_V2_1 - http://forum.hobbycomponents.com/viewtopic.php?f=39&t=1125 - for the I2C LCD
- rfid - https://github.com/miguelbalboa/rfid - RFID reader
The firmware includes a serial based setup menu to configure MAC/IP addresses, set the MQTT topic and tool name; these settings are stored in EEPROM. The idea is to be able to set up the device for another tool without having to change any code.
The device can be in one of 6 states (valid transitions shown in the diagram), these are:
|DEV_NO_CON||No network and/or MQTT connection|
|DEV_IDLE||Connected to MQTT broker on Holly, tool not being used, waiting for an RFID card to be scanned.|
|DEV_AUTH_WAIT||An RFID card has been scanned, and a lookup request sent over the network|
|DEV_ACTIVE||Tool access enabled. It is not possible to leave this state with whilst the RFID card is still on the reader (e.g. pressing the sign out button does nothing with the card still present, nor does a loss of network connection); the only exception is if the induct button is pressed and the signed on member is authorised to induct others.|
|DEV_INDUCT||The induct button has been pressed and the currently signed on member is permitted to give inductions. The device starts looking for any RFID card other than the one used to sign on.|
|DEV_INDUCT_WAIT||A second RFID card has been found, and a request to induct the member sent.|
All communications with the server side is done using MQTT; topic names are comprised of "<base topic><tool name>/<command>". Base topic can be the same for all access controlled tools, but obviously the name must be unique. The base topic currently being used is "nh/tools/", and the name set for the laser cutter is "laser".
|Direction (A=Arduino, S=Server)||Command||Payload||Description|
|A > S||AUTH||<RFID Serial>||Sent to the server when a card is first presented|
|S > A||GRANT||<
|| The first character must be either |
Once this command is received, power to the tool is enabled.
|S > A||DENY||<16 character message>||Received in response to an AUTH if the RFID card was rejected - the message in the payload is displayed on the first line of the LCD. Possible reasons at the moment include "Out of credit", "Unknown card"....|
|A > S||COMPLETE||<tool active time>||Sent once either the sign off button is pressed, or the 15s card timeout is reached. The payload is currently always 0, but in the future may be the amount of time the laser tube is active for (there is no hardware or firmware support for this yet).|
|A > S||INDUCT||<induct RFID>
||Sent when the induct button has been pressed, and a second RFID card found.|
|S > A||ISUC||User inducted successfully; device returns to idle state|
|S > A||IFAL||<16 char message>||Induct failed. the payload is the failure reason, and is displayed on the first line of the display. Possible reasons include "Bad card", "Not a member". If received, the device looks for another card to try again.|
|A > S||RESET||
Normal sign on with ~10 hours pledged time remaining, then sign off:
< [nh/tools/laser/AUTH], message= > [nh/tools/laser/GRANT], message=[UFoo Remain 10:02:16] < [nh/tools/laser/COMPLETE], message=
Member "Bar" with RFID "0000000001" signing on, then successfully inducting member with RFID "9999999999":
< [nh/tools/laser/AUTH], message= > [nh/tools/laser/GRANT], message=[IBar Remain 12:07:53] < [nh/tools/laser/COMPLETE], message= < [nh/tools/laser/INDUCT], message=[0000000001:9999999999] > [nh/tools/laser/ISUC], message=
The device has a serial based configuration menu (9600 baud, set local echo on) which can be used to set:
- MAC address
- IP address
- Tool name - e.g. "laser"
- Base topic - e.g. "nh/tools"
The IP address of the server is currently hard-coded to be 192.168.0.1 (Holly), this should probably be added to the configuration menu at some point. Once set, these settings are saved in EEPROM. E.g. showing current settings:
Main menu --------- [ 1 ] Show current settings [ 2 ] Set MAC address [ 3 ] Set IP address [ 4 ] Set name [ 5 ] Set base topic [ 6 ] Reset/reboot Enter selection: 1 Current settings: MAC address: 12:23:34:45:56:67 IP address : 192.0.2.1 Name : test Base topic : nh/tools
Note that the device must be reset after changing any of these settings - option 6 will reset the Arduino by abusing the watchdog timer.
- Allow server IP address to be set using serial config menu
- Tidy up RFID code (remove duplication), and allow the type of RFID reader to be changed relatively easily
The biggest problem at the moment is interference from the TIG welder. This either causes the RFID reader to stop reading cards (causing a time-out and sign-off after 15 seconds), or causes the Arduino to reboot, which one happens seems to vary, but obviously neither is good!
There are also issues with the RFID reader not reading some cards - in particular some newer oyster cards. This is probably down to the choice of RFID reader.
The server side component runs on Holly, is part of the Instrumentation project, and is responsible for authorising members to sign on / induct others, keeping track of pledged time and billing for time used. The source code is on GitHub.
TODO: Add some details.