Close

SW development

A project log for Access system for 3D printers

Custom electronics for access management & communication with remote server.

Miroslav ZuzelkaMiroslav Zuzelka 07/08/2019 at 13:330 Comments

SW side of this project turned out to be the hardest part as we had to make everything from scratch. Development could be divided in two parts. Prusa firmware development and ESP32 firmware development.

1) Prusa firmware development

We started to look at firmware code and we tried to find some similar behavior in the firmware for our use. We did find it in "Farm mode", which is basically separate screen on top of a regular printer menu. This screen is shown when Farm mode is active when printer receives some set of information through UART. When this is done, printer unlocks this screen and let you play with printer as normal. Farm mode is used in Prusa Research factory on their printing line.  

We copied function which is responsible for this behavior and changed it to our needs and here is the result (this time we handle unlock by long press of the knob):

After that we had to find out how to communicate with printer. The easiest way was change the default serial port to number 2, which will disable USB communication, but we do not need this one anyway, as all messages are transfered to serial port num. 2 . USB port still works for uploading firmware to the printer. 

We made Fabman.h file, which contains functions and these are called from ESP32 by custom gcodes. 

For better user experience, and also if there is some problem with the print, we are showing name of the user which is using the printer at top of the printer menu.

We also implemented sending of IP address and ESP32 firmware version to the printer Support menu which looks like this:

There are also some functions which handle responses from the server to inform user that something is not quite right, like "You do not have active package. Please buy one.", "You do not have required training course!!", "You are not allowed to use this printer outside opening hours", "Sorry, I am not online right now. Please try me later." so anyone knows what is wrong. 

You can look at changes to Prusa Firmware at Github.  

2) ESP32 firmware development

On ESP32 first thing what we needed to make work was RFID reader, which communicates through serial line, but just transmit what read from the card. We found out that reader transmits data as plain characters, so we just need to grab part of the data which matches our format and that is all what has to be done. With right ID from the card, we could move forward and combine it with printer firmware. Here is the result:


Printer works this way: 

Power on -> access screen ON -> user swipes is card -> if  user is allowed to use printer -> access screen OFF -> start of the print -> flag that printer is printing -> printing -> end of the print -> take data which updates printer statistics -> push this data to ESP32 -> user is logged off -> access screen ON. 

We are sending data about finished & not-finished prints, so we should cover all prints on printer. With amount of printed filament, we also send file name of the print so users can know how much did each print cost. 

This data is shown in our eshop, where user can with just one click put print/prints in to the shopping basket and pay for them. 

When this is done, print is marked in our database as "Print paid" and by this flag, our eshop will know that it should not be shown to the user again. 

We implemented OTA updates, so device can be anywhere on the Internet. It can be also set up with different Fabman account through build-in captive portal, which is triggered if at startup the log-off button is pressed. In our firmware we also use the Telnet server, so we can see debugging information remotely. We can also implement remote logging to some server, so you could look what is happening afterwards.    

Discussions