Wireless adaptation for a standalone CNC controller
Abstract
Grado en Ingeniería de Tecnologías Específicas de Telecomunicación
Full text
Universidad de Valladolid E.T.S.I. Telecomunicaci´ on Trabajo Fin de Grado Grado en Ingenier´ ıas Espec´ ıficas de Telecomunicaci´ on, Menci´ on en telem´ atica Wireless adaptation for a standalone CNC controller Draadloos uitbreiden van een stand-alone CNC-besturingseenheid Autor: Daan Ver Eecke Tutor de UVa: Dr. Jes´us Arias ´ Alvarez Tutor de Vives (Brugas, B´elgica): Mr. Tom Cordemans Valladolid, Junio 2019
Title: Wireless adaptation for a standalone CNC controller Author: Daan Ver Eecke Tutor: Dr. Jes´us Arias ´ Alvarez Department: Department of Electronics Court Chairman: Dr. Mart´ın Jara´ız Maldonado Member Dr. Jes´us Arias ´ Alvarez Secretary: Dr. Jes´us M. Hern´andez Mangas Substitute: Dr. Ruth Pinacho Substitute: Dr. Pedro L´opez Date: 21 of June 2019 Qualification: 1
Preface With this bachelor’s thesis I finish my three years as an electronics student at the university of applied sciences Vives in Bruges, Belgium. A thesis is the perfect way to prove that I can apply the knowledge I have gained over the past three years in a large project. I would like to thank a number of people who helped me to complete this thesis as well as the people who have supported me in the past years. First of all I want to thank my two mentors from the University of Valladolid, Dr. Jes´us Arias ´ Alvarez and Dr. Jes´us M. Hern´andez Mangas. If I encountered a problem during my thesis, I could always count on you and your experience. I would also like to thank my internship promoter, Mr. Tom Cordemans. Thank you for the support during my Erasmus. If I had a problem with administration during my Erasmus, I could always count on you. Without you it would not have been possible to go on Erasmus to Valladolid. In addition, I would like to thank all my teachers who have taught me a lot in the past three years. The tips and tricks were very useful during the development of this thesis. I also want to thank my classmates and friends for all the wonderful memories of the past three years. You provided the necessary relaxation during this period. A special thanks to Elias Verstappe for sharing with me the Erasmus experience. Ultimately, I want to thank my parents who support me in everything I do. Since high school you encourage me to do my best for school and I want to thank you for that. I also want to thank you for supporting me in my Erasmus experience, this was a very educational experience.
Abstract English Togheter with Elias Verstappe I worked on this thesis. We are two students at the university of applied sciences Vives in Bruges, Belgium. This thesis has been worked out at the University of Valladolid in Spain where we are both on Erasmus. A Bachelor’s thesis aims to solve a specific problem. In our case this is a problem which is related to electronics because we are both students electronics. The aim of this thesis is to control an old CNC machine with an electronic system designed by Elias and I. As technological developments follow each other in rapid succession in recent years, some outdated devices are no longer supported by the latest control systems. Dr. Jes´us Arias ´ Alvarez and Dr. Jes´us M. Hern´andez Mangas, both professors at the University of Valladolid, suggested the following problem: They currently have an old CNC machine that is controlled by an old MS-DOS computer. Our assignment is to control the CNC machine on the basis of a selfdesigned control unit. The CNC machine must also be capable of being controlled via a website. To replace the functionality of the old MS-DOS computer, we designed a printed circuit board ourselves. You can control the machine in two different ways: on one hand everything can be operated by means of a touchscreen, on the other hand the CNC machine can be fully controlled on the basis of a website. Now that the project is finished, I can conclude that the functionality of a program on an old computer can be applied fairly easily in a website. The only additional costs that the website entails are the working hours of the person who develops the website. Once the WiFi module has been purchased and the website has been developed, the website does not incur any additional costs. This thesis shows that many old machines can be controlled via a printed circuit board and can also be controlled by a website. This method could be applied to other machines where newer technology is desired. 2
6
Abbreviations Abbreviation explanation WiFi Wireless Fidelity MS-DOS MicroSoft Disk Operating System CNC Computer Numerical Control USB Universal Serial Bus PCB Printed Circuit Board IC Integrated Circuit SPI Serial Peripheral Interface UART Universal Asynchronous Receiver Transmitter IO Input/Output bps Bits Per Second TxD Transmit Data RxD receive data HTTP Hypertext Transfer Protocol HTTPS Hypertext Transfer Protocol Secure URL Uniform Resource Locator WAN Wide Area Network LAN Local Area Network IP Internet Protocol DDNS Dynamic Domain Name Server MAC Media Access Control TCP Transmission Control Protocol UDP User Datagram Protocol NAT Network Address Translation HTML HyperText Markup Language CSS Cascading Style Sheets JS JavaScript SGML Standard Generalized Markup Language CRC Cyclic Redundancy Check 3D three-dimensional STL stereolithography PLA polylactide 7
Chapter 1 Introduction 1.1 Definition of terms This final settlement was an exam. The comments made during the defence were not included. This bachelor’s thesis was in colaboration with Elias Verstappe .We are two Belgian students from university of applied sciences Vives, campus Bruges Station. We study electronics, which is part of the applied sciences and technology field of study. Mr. Tom Cordemans is our mentor at the university of Bruges, Belgium . Our two mentors from the University of Valladolid are Dr. Jes´us M. Hern´andez Mangas and Dr. Jes´us Arias ´ Alvarez. 1.2 Old situation vs new situation 1.2.1 Old situation Figure 1.1: Old situation The old situation is fairly simple, an old computer that communicates with the CNC machine via a parallel connection. This computer has two programs, ‘drillpro’ and ‘routepro’. The ‘drillpro’ program is only able to drill holes in the PCB. The ‘routepro’ program can only mill traces. This old MS-DOS computer works quite slowly and needs to be replaced. That’s why Elias Verstappe and I have worked out a new situation. 8
1.2.2 New situation Figure 1.2: New situation In the new situation, the old MS-DOS computer has been replaced by a printed circuit board with a microcontroller on it. This microcontroller replaces all the functionality of the MS-DOS computer and adds a number of extra features. Just as in the old situation, the communication between the CNC controller and the CNC machine happens via parallel communication. With the new situation, there are two possible ways to interact with the CNC machine. The first way is via a touch screen, this touch screen ends up on top of the circuit board. the touch screen also has an SD card slot, through this slot we can upload a file to the microcontroller, which will then control the CNC machine. The communication between the touch screen, SD card slot and the microcontroller is both serial and parallel. The second way to communicate with the CNC machine is via a WiFi module. This WiFi module will host a website, which has the same functionality as both programs on the old MS-DOS computer. In this study I will explain the WiFi module / website part of our thesis. A general explanation of the hardware follows in the next chapter. If you want a more detailed explanation about the printed circuit board or touch screen, I am happy to refer you to Elias his study on the hardware of our thesis. 1.3 Description of the chapters •chapter 1 : general description of the project •chapter 2 : description of the hardware •chapter 3 : description of the website •chapter 4 : description of the case •chapter 5 : cost calculation •chapter 6 : conclusion 9
Chapter 2 Hardware 2.1 General 2 1 9 4 7 6 8 10 3 5 11 Figure 2.1: Picture PCB This chapter briefly explains the hardware of this project and which components are used. This is explained on the next page using numbering on the photo above. The schematics of the PCB can be found in Appendix A at the back of this study. This appendix also contains the power dissipation analysis and heat dissipation analysis, if you want more information about this I am happy to refer you to Elias his study. 10
1: These are two USB connectors, on the right a mini-USB connector and on the left a micro-USB connector. The PCB is powered on the basis of these connectors. The LPC and the ESP8266[1][2] can be programmed through these connectors. As you can see the micro USB is not mounted, this is not necessary since the PCB can work without the micro USB 2: There are three different voltage levels on the PCB. The PCB is powered via USB, the voltage with which the PCB is powered is five volts. To achieve the other two voltage levels, there are two voltage regulators on the PCB. These two voltage regulators can be seen in circle number two on the photo above. The first converter converts 5 volts to 3.3 volts and the second converter converts 3.3 volts to 1.8 volts. These two components convert voltages and therefore these components can get quite hot, therefore these components are connected to a copper surface to better transfer the heat. 3: This is the 40 pin header. On this connector the touch screen is mounted. The touch screen is the interface with the user, on the touch screen the user can set a number of settings and upload a file via an SD card. 4: This component is the WiFi module, the ESP8266. This component is explained a little further below as this thesis is mainly about this ESP8266. 5: This is a 25 pin SUB-D connector, this connector is the interface between the microcontroller and the CNC machine. 6: This push button serves as an emergency stop. This is very important because if a dangerous situation should arise, it must be possible to stop the machine safely. This ensures that the machine cannot be damaged and people cannot be hurt. 7: The IC U5 is a 16 bit IO expander, this IC is controlled by the LPC2106 via SPI. Since all IO pins of the microcontroller were busy and a number of things still needed to be controlled, we needed an IC to make this possible. The 16 bit IO expander makes it possible to control an additional 16 IO pins via SPI. 8: There was a problem with SPI communication, the microcontroller operates on a voltage of 3V3 and the IO expander operates on a voltage of 5V, so we need a level shifter to make the SPI communication possible. This application uses an IC 74HCT04D as a level shifter, this is a NOT gate. By passing a SPI signal through two NOT gates, the signal is inverted twice and therefore no longer inverted, this IC converts the signal from 3V3 to 5 volts which makes it possible for the microcontroller to communicate with the IO expander via SPI. 9: The microcontroller is located halfway down the printed circuit board, this component will control all other components and is therefore one of the more important components. On the left above the microcontroller is the crystal (14.7456 MHz), this determines the clock frequency for the microcontroller, in our application the internal clock frequency is 58.9824 MHz. 10: At the top left of the PCB you will see a slide switch, through this switch the user can choose whether the LPC or the ESP8266 will be programmed. If the switch is to the left, the ESP8266 will be programmed, if the switch is to the right, the LPC will be programmed. The switch also serves to activate the communication between the LPC and the ESP8266. when the slide switch is slided to the left, the ESP8266 can communicate with the ESP8266. The LPC has two serial interfaces, ‘Serial0’ interface is used to program the LPC, the ‘Serial1’ interface is used to communicate with the ESP8266. The ESP8266 has only one serial interface so programming and communicating happens with the same serial interface. 11: This is a USB to UART converter. This component makes it possible to program the two microcontrollers via a computer. 11
2.2 ESP8266 2.2.1 ESP 8266 specifications Figure 2.2: Foto ESP8266[3] The figure above shows the ESP8266[2], which has the following specifications. On the figure above you can also see that the ESP8266[1][4] works within the 2,4 GHz band and uses the protocol 802.11 b/g/n. Description Parameters Protocols 802.11 b/g/n (HT20) Frequency range 2,4G - 2,5G CPU Tensilica L106 32-bit processor Peripheral interface UART/SDIO/SPI/I2C/... Operating voltage 2,5V - 3,6V WiFi mode Station/SoftAP/SoftAP+Station Security WPA/WPA2 Encryption WEP/TKIP/AES Netwerk Protocols IPv4, TCP/UDP/HTTP 12
2.2.2 Schematic Figure 2.3: Pinout ESP8266 This section explains how the ESP8266 is connected and how the communication between the ESP8266 and the microcontroller works. The figure above shows how the ESP8266 is connected. The ESP8266 is supplied with a voltage of 3.3 volts. The reset pin of the ESP8266 is connected to the reset pin of the USB to UART converter. All components can be reset using this reset signal. The enable pin is connected to the 3V3 via his own 10 kilo ohm resistor. The enable pin must of course be connected to the 3V3 otherwise the esp8266 would not work. Pins 22 and 21 are responsible for communication with the microcontroller, pin 22 is the TxD and pin 21 is the RxD. Pins 18, 17 and 16 are explained a bit further in this section since these 3 pins are more important. To prevent us from getting floating voltages, the microcontroller’s ground must of course be connected to the ground. All the pins that are not described here are not used. All these pins could not be connected without consequences. GPIO15 GPIO0 GPIO2 mode explanation L H H flash boot from SPI flash L L H UART program via UART H x x SDIO boot from SD-card The table above shows three different modes[5] for the ESP8266. In our application pin 16 is connected to the ground via a pulldown resistor, which means that the third mode in the table can never occur in our application. Pin 17 is connected via a pull up resistor to the VCC, this means that the signal ‘ESP BTL’ determines in which mode the ESP8266 will be. If the signal ‘ESP BTL’ is high, the ESP8266 will load the program that is in the SPI flash. To load a program via serial communication, the ‘ESP BTL’ signal must be low. 13
2.2.3 Arduino Arduino[6][7] is an open source computer platform intended to make microcontrollers simple. With Arduino it is possible to create devices and objects that respond to their environment through digital and analogue input signals. The Arduino can be programmed with the Arduino IDE. This software makes it easy to write your own code and upload it to an Arduino. Libraries are available for well-known tasks, such as connecting to Wi-Fi. It is also possible to download libraries, or write your own library to reduce repetitive code. All the Arduino source code can be found in Appendix D at the back of this study. This appendix is divided into different parts to keep it organized. Below you will see a screenshot of the arduino IDE. Figure 2.4: Screenshot of the arduino IDE As you can see on the photo on the previous page, an empty arduino project contains two functions. An arduino project always contains these two functions. These two functions are explained in the following subsections 2.2.4 Void setup The ‘setup()’ functions will only run once, after each powerup or reset of the Arduino board. This function is used to initialize variables, pin modes and to include libraries. Below you can see the setup function of this project. 1void setup (void ) { 2Serial.begin ( 115200 ); 3WiFi.mode (WIFI_STA ); 4WiFi.begin (ssid ,password ); 5 6server.on ("/ Login ",handleLogin); 7server.on ("/",changeWebPage ); 8server.on ("/changeWebPage",changeWebPage); 9server.on ("/handleData",handleData); 10 server.on ("/handleToolsData",handleToolsData); 11 server.on ("/handleButtonsPressed",handleButtonsPressed); 12 13 server.onNotFound (handleNotFound ); 14 server.begin(); 15 Serial.println (" HTTP server started " ); 16 } In computer programming, when void is used as a function return type, it indicates that the function does not return a value. The setup function only initializes things so it makes sense that this function 14
Offset page Figure 3.7: Offset web page The CNC machine has a horizontal working plane that is determined by X and Y coordinates. The home position of the horizontal work plane is X = 0 and Y = 0. If a PCB is placed on the horizontal work surface, it may be that the home position of the work surface does not match the home position of the PCB. This problem can be solved with the offset page. The user can give an X and Y offset to the CNC machine so that these home positions nevertheless match. If the PCB is placed on a raised base, then the Z offset will not be correct either. The user can solve this by setting the correct Z offset in the offset page. If the user wishes to consult the offset page, a warning screen will first be displayed, because the CNC machine will move to its home position if the machine is not there. This is a safety procedure so that the user sees that the machine will move, to prevent accidents from happening. For each axis there are two buttons, for the Z-axis an ‘up’ and ‘down’ button, for the X-axis a ‘forward’ and a ‘backward’ button and for the Y-axis a ‘left’ and ‘right’ button. These buttons allow the user to set the offset for each axis, the machine will also move so that the user can check whether the entered offset is correct. The user can set the size of the desired step on the basis of a selection box. There are three possible steps: 1, 10 and 100. If the user wants to leave the offset page, a warning box will be displayed again, because the machine will move to its home position again, so this is the same safety procedure as before. 21
Tools page Figure 3.8: tools web page The tools page has a table showing all the tools that the machine has. A number of parameters are displayed per tool. The page has 15 different tools and each tool has its own name. The depth, iteration, X feed, Z feed, spindle, start, used and tabulation are all shown in the table. ‘Depth’ determines how deep the routing of the traces will be. When a hard material needs to be processed, iterationis is to be used. Based on this setting, a certain operation is repeated a number of times, but each time the tool will mill a little deeper. ‘X-feed’ describes how fast the jobs are milled in mm / min, ‘Z-feed’ describes how fast the tool will move vertically. By changing the ‘Spindle’ value, the user can determine at what speed the tool will rotate. 22
3.3 Responsive web pages 3.3.1 Explanation responsive website Responsive[9][10] web design is an approach to web design where the web developer strives for an optimal web experience for a wide range of devices (from desktop computer screens to mobile phones). The design of a responsive website scales with the dimensions of a screen, without compromising on readability of text or usability of the user interface. The viewport is the user’s visible area of a web page. The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen. With the code below we set the viewport for a webpage. 1<meta name="viewport" content =" width = device - width , initial - scale =1.0 " > Many web pages are based on a grid-view, which means that the page is divided into columns. A responsive grid-view often has 12 columns, and has a total width of 100%, and will shrink and expand as you resize the browser window. First we must calculate the percentage for one column: 100% / 12 columns = 8.33% Then we make one class in CSS for each of the 12 columns. On the picture you see the 12 classes. 1.col-1 { width : 8.33%;} 2.col-2 { width : 16.66%;} 3.col-3 { width : 25%;} 4.col-4 { width : 33.33%;} 5.col-5 { width : 41.66%;} 6.col-6 { width : 50%;} 7.col-7 { width : 58.33%;} 8.col-8 { width : 66.66%;} 9.col-9 { width : 75%;} 10 .col -10 { width : 83.33%;} 11 .col -11 { width : 91.66%;} 12 .col -12 { width : 100%;} Now we can make a row in the HTML code. In each row the numbers of columns should be equal to 12, as shown in the example below. 1<div class =" row " > 2<div class ="col -3" >... </ div> <!-- 25% --> 3<div class ="col -9" >... </ div> <!-- 75% --> 4</div> 23
The previous steps only makes the website responsive for a computer screen, if we want to make the website responsive for smaller devices we have to add other classes to specify the screen layout. Below these classes are showcased. 1/* For mobile phones : */ 2[class *="col -"] { 3width: 100%; 4} 5 6@media only screen and (min-width: 600 px) { 7/* For tablets : */ 8.col-s-1 { width : 8.33%;} 9.col-s-2 { width : 16.66%;} 10 .col-s-3 { width : 25%;} 11 .col-s-4 { width : 33.33%;} 12 .col-s-5 { width : 41.66%;} 13 .col-s-6 { width : 50%;} 14 .col-s-7 { width : 58.33%;} 15 .col-s-8 { width : 66.66%;} 16 .col-s-9 { width : 75%;} 17 .col-s-10 { width : 83.33%;} 18 .col-s-11 { width : 91.66%;} 19 .col-s-12 { width : 100%;} 20 } Now we also have to make a small adjustment to the HTML so that the site is also displayed correctly on a smaller screen. As you can see below, there are three columns within one row. When we visit this page from a computer, the three divs will be the same width since they are all three equally wide, namely four columns. However, when we visit this page via a mobile phone, the three divs are 12 columns wide, so the divs will be displayed below each other. 1<div class =" row " > 2<div class ="col -4 col -s -12 "> 3... 4</div> 5<div class ="col -4 col -s -12 "> 6... 7</div> 8<div class ="col -4 col -s -12 "> 9... 10 </div> 11 </div> 24
3.3.2 Example responive routepro/drillpro page In this subsection we will see the routepro/drillpro page three times but each time with a different screen ratio. The first part will display the route pro / drillpro page on a computer, the second part via a tablet and the third part via a mobile phone. Routepro/drillpro page on computer screen Figure 3.9: Routepro/drillpro page seen from computer This is how the routepro/drillpro page will be displayed when a user surfs to this page on a computer. As you can see, the middle row is split into 12 columns. The buttons are two columns wide, the first table is 8 columns wide and the last table is 4 columns wide, so there are twelve columns in total. 25
Routepro/drillpro page on tablet screen Figure 3.10: Routepro/drillpro page seen from a tablet If a user surfs to this webpage from a tablet, the screen depends on how the user is holding his tablet. If the user holds his tablet horizontally, the layout of the web page will be almost the same as the layout seen from a computer. However, if the user holds his tablet vertically, the layout will be a bit different. As you can see, everything is still in the same place, but everything is somewhat narrower. We also see that there is much more free space at the bottom. 26
Routepro/drillpro page on phone a tablet Figure 3.11: Routepro/drillpro page seen from a phone As you can see, the layout seen from a mobile phone is completely different from previous layouts. For clarity this image is a ‘scrolling screenshot’, this to show the entire web page. If a user surfs to this page via his mobile phone, everything will be displayed up to and including the first table, by scrolling the user can view the rest of the web page. In this layout the three different columns of the previous layouts are displayed below each other. You will also see that every ‘column’ will now take up the entire width of the screen. 27
3.4 Word wide web 3.4.1 General cnccontroller.ddns.net 192.168.1.1 MAC adress: 60:01:94:03:00:A5 Laptop Device 192.168.1.101 157.80.110.205 ESP8266 Internet Figure 3.12: Network diagram Above you see the network diagram. The WiFi module located on the PCB will connect to the router in the classroom. This router is connected to the internet. If a computer on an external network surfs to the URL ‘cnccontroller.ddns.net’, then using a DDNS[11] service this URL will be converted to the WAN IP address of the router in the classroom. The following subsections explain which settings must be made to make the website available on the internet. 28
3.4.2 Router Figure 3.13: Linksys WRT54G/GL/GS[12] The photo above shows the router that is located in the classroom, namely the Linksys WRT54G/GL/GS. To make the website available on the internet, three settings must be set in the router. The first thing to do is to set a fixed IP address for the ESP8266, this is done using the MAC address of the ESP8266. Then port forwarding is switched on and then DDNS is set. The following three sections explain these settings step by step. 3.4.3 Fixed IP address The first step to get the website on the internet is to assign a fixed IP address to the ESP8266. To assign a fixed IP address to the ESP8266, we need the MAC address of the ESP8266. In the Arduino we need the WiFi library to connect the ESP8266 to a router, this library also has a function that returns the mac address of the ESP8266. The mac address of the ESP8266 on our printed circuit board is equal to 60:01:94:03:00:A5. Below is the arduino code that returns the mac address of the ESP8266 1Serial.print(" MAC: "); 2Serial.println (WiFi.macAddress()); After we get the mac address we can set a fixed IP address for the ESP8266 in the router. Now the router will ensure that the ESP8266 will always get the same IP address within the network. Below you see how the setting of a fixed IP address is done on the router Figure 3.14: Fixed IP address 29
3.4.4 Port forwarding After setting the fixed IP address, the port forwarding is set. Port forwarding or port mapping is the forwarding of a TCP or UDP package in a NAT gateway to connect an internal network to an external network (for example the internet) by means of port numbers. This technique is used to enable communication between external hosts and other services within a LAN. Port forwarding makes it possible to make a connection to a specific computer within a private network (LAN) via an external computer. A router is the connection between a local network and the worldwide web. That is why a router has two network interfaces, an internal interface and an external interface. The external IP address of the router is in the classroom 157.88.110.205. A HTTP request is typical on port 80, so if we enable port forwarding for the router, we will enable it for port 80. On the photo below you can also see that we enable it for both TCP and UDP, this is to be sure that there will be no problems. To be specific, if an external HTTP request arrives at port 80 of the router, the router will forward this package to the ESP8266 at port 80. The photo below shows how the port forwarding is set up on the router. Figure 3.15: Port forwarding 3.4.5 DDNS DDNS stands for dynamic DNS or dynamic domain name system. A DDNS is a service that converts internet domain names to IP addresses. A DDNS service makes it possible to control your home computer from anywhere in the world via a domain name and not having to type in an IP address. Two things must happen to get a DDNS working, log in to a DDNS service and choose a domain name, set the router up for DDNS. I have chosen ‘no-IP.com ’as the DDNS service. Below you can see how I have configured the DDNS service on the no-IP website. Figure 3.16: No-IP.com 30
If data updates occur on the website, the data must also be updated in the ESP8266 as well as in the microcontroller. Saving data in the ESP8266 is done on the basis of HTTP request, as already explained. Once the values are updated in the ESP8266, the values are sent to the microcontroller based on serial communication. The flowchart diagram above shows the method used for sending data via serial communication. This method is used for every website except for sending the file and some other exceptions. First a payload will be created that will contain all data from a certain web page, then the length of this payload will be calculated. Then the frame is set up that will be sent to the ESP8266. Once the frame is set up, a CRC is calculated on this frame. The CRC is added to the frame and sent to the microcontroller. The microcontroller will process the data and in some cases the microcontroller will control the CNC machine. 37
3.6.5 Frame structure 1 byte 256 byte1 byte 1 byte Start of frame Payload length Payload CRC8 Figure 3.22: UART frame structure The figure above shows the structure of a UART frame. The first byte is a start character, in this case the start character is a ‘$’. On the basis of a start character the receiver can know when a frame starts, everything that the receiver receives that does not start with the start character is ignored. The second byte indicates the length of the payload, since this is indicated by a byte the maximum length of the frame can be 256, this because 28= 256. This is followed by the payload, which is a maximum of 256 bytes. The structure of the payload is explained in the following subsection. The last byte of a frame is a CRC. A CRC can be used to calculate whether the frame has been received correctly. CRC8 is used here, the ‘8’ points to the fact that a CRC8 is 8 bits long, which is equal to 1 byte. ‘CRC-8-CCITT’ is used in this application, this CRC8 has a polynomial x8+x2+x+ 1, which corresponds to ‘0x07’ hexadecimal. 3.6.6 Payload structure Figure 3.23: UART payload structure The figure above shows the structure of the payload of a UART frame. The first byte indicates what the data is about, if this byte is equal to ‘0xC3’ then the data contains information about a screen, if the first byte is equal to ‘0xC5’ then the data contains information about a file. Since it was not possible to process a file via the website, this option is not further explained here. In case the data contains information about a screen, the second byte will indicate which screen the data is about. The table below shows which value corresponds to which screen. screen value configuration screen 1 routepro/drillpro screen 2 tools screen 3 load screen 4 offset screen 5 The effective payload, namely the data, starts from the third byte. This data can be up to 254 bytes in length. 38
Chapter 4 Case 4.1 Process 3D printing Designing and creating a 3D housing consists of various steps that must be completed. In this section these steps are explained one by one. Photos of the case can be found in Appendix B at the back of this study. 4.1.1 Tinkercad Figure 4.1: Screenshot tinkercad The first step is to design a 3D case. The figure above shows a screenshot of the tinkercad[16] program. Tinkercad is a free and user friendly web application made by Autodesk[17]. On the basis of a number of 3D objects that are freely adaptable, it is fairly easy to make a simple housing. Our housing consists of a number of different parts, the screenshot above shows the design of the top of the housing. After the design is ready we can download the design as an ‘STL’ file. stereolithography[18] (abbreviated ‘STL’) is a file format native to the stereolithography CAD software created by 3D Systems. STL describes the geometric surface of a 3D object. 39
4.1.2 Ultimaker cura Figure 4.2: Screenshot Ultimaker cura After receiving the ‘STL’ file from tinkercad, the cura program is used to process this file, this program is made by ultimaker[19]. Via this program, a number of important settings can be adjusted, such as the material used, printing speed, ... . The figure above is a screenshot of the cura program. Via this program we can also determine the cost price per part, this is important in the next chapter where the total price of the entire project is calculated. When the ‘slice’ button is pressed, the G code[20] is generated. This code contains all the commands that the 3D printer must execute. At the bottom right of the screenshot you can see the time it takes the 3D printer to print the 3D object. The table below shows the time that the 3D printer needs per object. It also displays the weight of the object and length of the material used. 3D object weight length time grams meters hours case top 25 8,47 3h15 case bottom 98 32,81 10h22 case slide switch 1 0,23 0h05 case emergency stop 5 1,60 0h22 total weight total length total time 129 43,11 14h04 40
4.1.3 Anycubic I3 Mega Figure 4.3: Photo anycubic I3 mega The photo above shows the 3D printer used for printing for the case, this is the anycubic I3 mega[3D˙printer]. This 3D printer has a working surface of 210 x 210 x 205 mm. This 3D printer has a layer resolution of 0.05 - 0.3 mm. The recommended print speed is 60mm/s. Various parameters can be set via a touchscreen such as print bed temperature, extruder temperature, ... . For our case all parameters were set to the standard values. the G code can be loaded via a sd card and the 3D printer is be started via the touchscreen screen. Progress is displayed on the touch screen during printing 41
4.2 Top Figure 4.4: Case top This is the top of the case that will ensure that the case is completely sealed. The large hole is provided for the screen. This hole is slightly smaller than the screen of the TFT, because this way there is certainly no gap along the edge the screen, so the chance of dust in the case is smaller. The hole below the big hole is provided for the emergency stop. The four holes on the corners of the top are provided for mounting the top to the bottom of the case. These four holes are also conical so that the screw is completely recessed in the top, this makes the surface nicer and even. 42
4.3 Bottom Figure 4.5: Case bottom This is the second big part of the case, in this part the PCB will be mounted. As you can see on the photos above, 4 pins are provided in the bottom, these are perfectly positioned so that the PCB fits nicely in the housing and everything is nicely aligned. These 4 pins ensure that the PCB cannot move, once the top is mounted on the bottom, then the TFT screen is just against the bottom of the top, so the PCB can not move. The housing also has two higher tubular pillars, which serve to mount the TFT shield. On one side the shield is attached to the PCB with a 40 pins header and on the other side it is mounted on these pillars. The bottom also has a number of holes in the bottom, this is to let the heat out of the case. The holes in the sides each have a specific task. The largest hole is located at the front of the case and is provided for the 25 SUB-D connector. The other three holes are on the other side of the case. The long narrow hole that is located the highest is used to place the SD card in the TFT shield. The left hole on the left photo is provided to be able to access the switch which determines which component can be programmed. The right hole on the left photo serves to pass the USB cable that will serve as power supply. 43
4.4 Emergency button Figure 4.6: Emergency stop On the figure above you can see the emergency stop. The emergency stop is fairly long, this because the emergency stop has to fit through the whole case and must fit on the push button. On the photo the emergency button is showed upside down, this is because the 3D printer can not print it otherwise. On the top you see a small cubic hole, this whole just fits the push button, this ensures that the button stays in place. 44
4.5 Slide switch Figure 4.7: Slide switch On the figure above you can see the slide switch. If the PCB is mounted in the case, it is difficult to change the position of the slide switch as this is a small button. One part of this piece passes over the sliding part of the slide switch. The other side comes through the hole and makes it easier to use the slide switch. 45
Bibliography [1] Wikipedia. ESP8266 wikipedia. May 6, 2019. url:https://en.wikipedia.org/wiki/ESP8266. [2] ESP8266 arduino core. ESP8266 arduino core. May 6, 2019. url:https://arduinoesp8266 . readthedocs.io/en/latest/index.html. [3] www.kiwi-electronics.nl. ESP8266. May 28, 2019. url:https://www.kiwi-electronics.nl/image/ cache/data/products/netwerk/wireless/KW-1847-02-1000x667.jpg. [4] Espressif Systems. ESP8266 datasheet. June 8, 2019. url:https://www.espressif.com/sites/ default/files/documentation/0a-esp8266ex datasheet en.pdf. [5] Forward Computing and Control Pty. ESP8266. June 11, 2019. url:https://www.forward.com. au/pfod/ESP8266/GPIOpins/index.html. [6] arduino. arduino. June 8, 2019. url:https://www.arduino.cc/. [7] wikipedia. arduino wikipedia. June 8, 2019. url:https : / / nl . wikipedia . org / wiki / Arduino (computerplatform). [8] wikipedia. HTTPS. June 6, 2019. url:https://nl.wikipedia.org/wiki/HyperText Transfer Protocol Secure. [9] w3schools.com. responsive webpages.url:https://www.w3schools.com/css/css rwd intro.asp. [10] Wikipedia. responsive webpages. Jan. 30, 2018. url:https://nl.wikipedia.org/wiki/Responsive webdesign. [11] Wikipedia. DynamisDNS. Apr. 24, 2019. url:https://en.wikipedia.org/wiki/Dynamic DNS. [12] ugc.kn3.net. linksys router. May 27, 2019. url:https:// ugc.kn3.net/i /760x /http ://www. appinformatica.com/imf/routers-router-linksys-ap-54mbpswrt54gl-(-linux)-1g.jpg. [13] Wikipedia. HyperText Markup Language. Apr. 17, 2019. url:https://nl.wikipedia.org/wiki/ HyperText Markup Language. [14] Wikipedia. Cascading Style Sheets. June 17, 2018. url:https : / / nl . wikipedia . org / wiki / Cascading Style Sheets. [15] Wikipedia. JavaScript. May 6, 2019. url:https://nl.wikipedia.org/wiki/JavaScript. [16] Autodesk. tinkercad. June 6, 2019. url:https://www.tinkercad.com/. [17] Autodesk. Autodesk. June 6, 2019. url:https://www.autodesk.com/. [18] wikipedia. STL explanation. June 6, 2019. url:https://en.wikipedia. org/wiki /STL (file format). [19] ultimake. curaultimaker. June 6, 2019. url:https://ultimaker.com/. [20] wikipedia. Gcode. June 6, 2019. url:https://nl.wikipedia.org/wiki/G-code. [21] www.vacature.com. cost hours of work. June 4, 2019. url:https : / / www . vacature . com / nl - be/carriere/salaris/hoeveel-verdien- je-in-de-sector-elektronica- en-technologische- industrie. [22] anycubic. anycubic I3 mega. June 6, 2019. url:http://www.anycubic3d.com/products/show/ 1048.html. 50
Appendix A Schematics PCB This appendix contains the schematics for the PCB. •page 1 : microcontroller •page 2 : UART converter, USB connections and voltage regulators •page 3 : 40 pin TFT header, 25 pin SUB-D connector, the 16 bit IO expander and the NOT port •page 4 : WiFi module, emergency stop and slide switch •page 5 : power dissipation analysis •page 6 : heat dissipation analysis 51
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 1 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project P0.16-TFT_DB0 P0.17-TFT_DB1 P0.18-TFT_DB2 P0.19-TFT_DB3 P0.20-TFT_DB4 P0.21-TFT_DB5 P0.22-TFT_DB6 P0.23-TFT_DB7 P0.24-TFT_DB8 P0.25-TFT_DB9 P0.26-TFT_DB10 P0.27-TFT_DB11 P0.28-TFT_DB12 P0.29-TFT_DB13 P0.30-TFT_DB14 P0.31-TFT_DB15 SPI SCK SPI MISO SPI MOSI SPI /GPIO_CS TXD1 RXD1 TXD0 RXD0 /RESET BTL/EMERGENCY SPI /TP_CS TFT /WR TFT /CS TFT RS TFT /RD STROBE SPI /SD_CS XTAL1 11 XTAL2 12 DBGSEL 27 RTCK 26 P0.0/TxD0/PWM1 13 P0.1/RxD0/PWM3 14 P0.2/SCL/CAP0.0 18 P0.3/SDA/MAT0.0 21 P0.4/SCK/CAP0.1 22 P0.5/MISO/MAT0.1 23 P0.6/MOSI/CAP0.2 24 P0.7/SSEL/PWM2 28 P0.8/TxD1/PWM4 29 P0.9/RxD1/PWM6 30 P0.10/RTS1/CAP1.0 35 P0.11/CTS1/CAP1.1 36 P0.12/DSR1/MAT1.0 37 P0.13/DTR1/MAT1.1 41 P0.14/DCD1/EINT1 44 P0.15/RI1/EINT2 45 P0.16/EINT0/MAT0.2 46 P0.17/CAP1.2/TRST 47 P0.18/CAP1.3/TMS 48 P0.19/MAT1.2/TCK 1 P0.20/MAT1.3/TDI 2 P0.21/PWM5/TDO 3 P0.22/TRACECLK 32 P0.23/PIPESTAT0 33 P0.24/PIPESTAT1 34 P0.25/PIPESTAT2 38 P0.26/TRACESYNC 39 P0.27/TRACEPKT0/TRST 8 P0.28/TRACEPKT0/TMS 9 P0.29/TRACEPKT2/TCK 10 P0.30/TRACEPKT3/TDI 15 P0.31/EXTIN0/TDO 16 V18 5 RST 6 VSS 7VSS 19 VSS 31 VSS 43 V3 17 V3 40 U1 LPC2106FBD48/01,15 QFP50P900X900X160-48 12 X1 LFXTAL030358 XTAL C7 33pF 0805_CAP C8 33pF 0805_CAP 3V3 C9 100nF 0805_CAP C10 100nF 0805_CAP C11 100nF 0805_CAP 1V8 Microcontroller Clock crystal R5 3k3 0805_RES 3V3 GND PIN TFT /WR PIN TFT /CS PIN TFT RS PIN TFT /RD PIN R8 3k3 0805_RES 3V3 Remark: P0.2 & P0.3 are open-drain, this is why pull-up resistors are essential 52
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 2 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project USB_TXD USB_RXD /RESET BOOTLOADER L1 2508051217Y0 0805 TXD 1 RXD 5 RTS 3 CTS 11 DTR 2 DSR 9 DCD 10 RI 6 CBUS0 23 CBUS1 22 CBUS2 13 CBUS3 14 CBUS4 12 3V3OUT 17 USBDM 16 USBDP 15 RESET 19 OSCI 27 OSCO 28 VCCIO 4 TEST 26 U3 FT232RL-REEL SOP65P780X200-28 VCC=5V VDD 1 D- 2 D+ 3 NC 4 GND 5 GND 6 J1 67503-1020 USB MINI-8 SMT C1 100nF 0805_CAP C2 100nF 0805_CAP C4 100nF 0805_CAP IN 3OUT 2/4 GND 1 U2 TC2117-3.3VDBTR SOT223-4 IN 3OUT 2/4 GND 1 U4 MC33375ST-1.8T3G SOT223-4 C3 22uF/6.3V 0805_CAP C5 22uF/6.3V 0805_CAP C6 22uF/6.3V 0805_CAP 3V3 1V8 5V 3V3 Power supply Mini USB Tybe B USB to UART converter this package should really be SOT223-3 and not -4 but it is not a problem in our case VDD 1 D- 2 D+ 3 NC 4 GND 5 GND 6 J5 10118194-0001LF MICRO-USB-TYPE-B 3V3 PIN 5V PIN 1V8 PIN USB-TXD PIN USB-RXD PIN /RESET PIN BOOTLOADER PIN Micro USB Type B 53
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 3 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project SEL PE BUSY ACK DATA_OUT_7 DATA_OUT_6 DATA_OUT_5 DATA_OUT_4 DATA_OUT_3 SELIN DATA_OUT_2 INIT DATA_OUT_1 ERROR DATA_OUT_0 AUTOF DATA_OUT_0 DATA_OUT_1 DATA_OUT_2 DATA_OUT_3 DATA_OUT_4 DATA_OUT_5 DATA_OUT_6 DATA_OUT_7 SEL PE BUSY ACK SELIN INIT ERROR /RESET TFT RS TFT /WR TFT /RD P0.24-TFT_DB8 P0.25-TFT_DB9 P0.26-TFT_DB10 /RESET P0.31-TFT_DB15 P0.30-TFT_DB14 P0.29-TFT_DB13 P0.28-TFT_DB12 P0.27-TFT_DB11 SPI /SD_CS SPI MOSI SPI SCK SPI MISO SPI MISO SPI MOSI SPI /TP_CS SPI SCK P0.23-TFT_DB7 P0.22-TFT_DB6 P0.21-TFT_DB5 P0.20-TFT_DB4 P0.19-TFT_DB3 P0.18-TFT_DB2 P0.16-TFT_DB0 P0.17-TFT_DB1 TFT /CS SPI SCK SPI MOSI SPI /GPIO_CS AUTOF SPI MISO STROBE 1 14 2 15 3 16 4 17 5 18 6 19 7 20 8 21 9 22 10 23 11 24 12 25 13 J3 5504F1-25S-02-03-F1 25 PIN SUBD CONNECTOR GPA0 21 GPA1 22 GPA2 23 GPA3 24 GPA4 25 GPA5 26 GPA6 27 GPA7 28 GPB0 1 GPB1 2 GPB2 3 GPB3 4 GPB4 5 GPB5 6 GPB6 7 GPB7 8 SI 13 CS 11 SO 14 INTA 20 INTB 19 A0 15 A1 16 A2 17 RESET 18 SCK 12 U5 MCP23S17-E/SO SOIC127P1030X265-28 VDD=5V VSS=GND TFT 40 pin header Parallel port 16 bit IO expander R6 560 0805_RES R7 1k 0805_RES 1 2 U8:A 74HCT04D SOIC127P600X180-14 VCC=5V 3 4 U8:B 74HCT04D SOIC127P600X180-14 VCC=5V 5 6 U8:C 74HCT04D SOIC127P600X180-14 VCC=5V 13 12 U8:D 74HCT04D SOIC127P600X180-14 VCC=5V 11 10 U8:E 74HCT04D SOIC127P600X180-14 VCC=5V 98 U8:F 74HCT04D SOIC127P600X180-14 VCC=5V GND 1 3V3 2 NC0 3 RS 4 WR 5 RD 6 DB8 7 DB9 8 DB10 9 DB11 10 DB12 11 DB13 12 DB14 13 DB15 14 CS 15 F_CS 16 RESET 17 NC5 18 LED_A 19 NC1 20 DB0 21 DB1 22 DB2 23 DB3 24 DB4 25 DB5 26 DB6 27 DB7 28 T_CLK 29 T_CS 30 T_DIN 31 NC4 32 T_DO 33 T_IRQ 34 SD_DO 35 SD_CLK 36 SD_DIN 37 SD_CS 38 NC3 39 NC2 40 M1 TFT_43 TFT_43_ONLY_HEADER 3V3 3V3 LEVEL CONVERTER 5V C14 100nF 0805_CAP C15 100nF 0805_CAP 5V Decoupling for IO expander Decoupling for U8 SPI-MISO PIN SPI-MOSI PIN SPI-SCK PIN /SPI-GPIO_CS PIN Remark: ESP (Wifi) - module is not 5V tolerant. These resistors convert a high signal from 5V to 3V3 54
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 4 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project USB_TXD ESP_RXD TXD1 RXD0 USB_RXD TXD0 ESP_TXD RXD1 BOOTLOADER BTL/EMERGENCY ESP_BTL ESP_TXD ESP_RXD ESP_BTL R9 10k 0805_RES Wifi interface 1 2 3 6 5 4 S1 JS202011AQN PACKAGE=JS202011AQN R1 10k 0805_RES R4 10k 0805_RES 3V3 C12 10uF 0805_CAP 3V3 R11 10k 0805_RES R2 1k 0805_RES R3 10k 0805_RES 3V3 R12 1k 0805_RES UART SWITCH BOOTLOADER RST 1 ADC 2 EN 3 GPIO14 5GPIO16 4 GPIO12 6 GPIO13 7 VCC 8 TXD 22 RXD 21 GPIO5 20 GPIO4 19 GPIO0 18 GPIO2 17 GPIO15 16 GND 15 CSO 9 MISO 10 GPIO9 11 MOSI 13 GPIO10 12 SCLK 14 M2 WIFI_MODULE_ESP12F ESP-12F ESP-TXD PIN ESP-RXD PIN ESP-BTL PIN 1 2 3 4 S2 BUTTON B3F-1050 55
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 5 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project ~~~~~~~~~~~~~~~~~ POWER DISSIPATION ~~~~~~~~~~~~~~~~~ +---------------------------------+--------------------------------+-------------------------+ |5V |3V3 |1V8 | +---------------------------------+--------------------------------+-------------------------+ |40uA (level-converter) |15mA (USB to UART controller) |35mA (microcontroller) | |2mA (I/O expander) |200mA (TFT) | | |420.2mA (3V3) |170mA (WIFI module) | | |130uA (3V3 regulater internal) |35mA (1V8) | | | |200uA (1V8 regulator internal) | | +---------------------------------+--------------------------------+-------------------------+ |TOTAL @ 5V = 422.3mA |TOTAL @ 3V3 = 420.2mA |TOTAL @ 1V8 = 35mA | +---------------------------------+--------------------------------+-------------------------+ |POWER @ 5V = 2.12W |POWER @ 3V3 = 1.39W |POWER @ 1V8 = 0.063W | +---------------------------------+--------------------------------+-------------------------+ 56
FILE NAME: BY: DATE: PAGE: CNC CONTROLLER 26/02/2019 Elias Verstappe/ Daan Ver Eecke AB C D E F G H J K A B C D E F G H J K 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 6 of 6 REV: 0.1 TIME: 9:17:14 DESIGN TITLE: CNC CONTROLLER VIVES & UVa Final Project ~~~~~~~~~~~~~~~~ HEAT DISSIPATION ~~~~~~~~~~~~~~~~ +------------------------------+------------------------+-----------------------+----------------------------+ |component |IC code |max temperatur (°C) |conditions | +------------------------------+------------------------+-----------------------+----------------------------+ |microcontroller |LPC2016 |85 |IDD(45mA)@60MHz | |USB to UART |FT232RL |85 |/ | |16 bit I/O expander |MCP23S17 |125 |/ | |level converter (NOT port) |74HCT04D |70 |above 70°C Ptot drops 8mW/K | |wifi interface |ESP-12F |125 |operating temperature | |3V3 voltage regulator |MC33375ST-1.8T3G |245°C/W |/ | |1V8 voltage regulator |TC2117-3.3VDBTR |59°C/W |/ | +------------------------------+------------------------+-----------------------+----------------------------+ ~~~~~~~~~~~~~~~~~~~~~ 1V8 voltage regulator ~~~~~~~~~~~~~~~~~~~~~ P = U * I = 35mA * (3V3-1V8) = 0.0525W => T = 245°C/W * 0.0525W + Ta = 12.86°C + 25°C = 37.86°C ~~~~~~~~~~~~~~~~~~~~~ 3V3 voltage regulator ~~~~~~~~~~~~~~~~~~~~~ P = U * I = 420.2mA * (5V-3V3) = 0.72W => T = 59°C/W * 0.72W + Ta = 42.15°C + 25°C = 67.15°C 57
40 } 41 } 42 . header { 43 background - color : #4 CAF50 ; 44 color : # ffffff ; 45 padding : 15 px; 46 } 47 . footer { 48 background - color : #4 CAF50 ; 49 color : # ffffff ; 50 padding : 15 px; 51 text - align : center ; 52 } 53 body{ 54 background - color : # c5cedd ; 55 } 56 button { 57 dispay : inline - block ; 58 width : 60%; 59 background - color : #4 CAF50 ; 60 border : none ; 61 color : white ; 62 padding : 15 px 32 px; 63 text - align : center ; 64 text - decoration : none ; 65 } 66 button : hover { 67 background - color :#00802 b; 68 color : # c5cedd ; 69 } 70 . form { 71 text - align : center ; 72 border :2 px solid #4 CAF50; 73 border - radius :4 px ; 74 } 75 input [ type = text ] { 76 width : 60%; 77 border :2 px solid # aaa ; 78 border - radius :4 px ; 79 height :30 px; 80 display : inline - block ; 81 text - align : center ; 82 background -color: white; 83 color : #4 CAF50 ; 84 transistion :.3s 85 } 86 input [ type = text ]: focus { 87 border - color : #4 CAF50 ; 88 border - shadow : 0 0 8px 0 #4 CAF50 ; 89 } 90 input [ type = password ] { 91 width : 60%; 92 border :2 px solid # aaa ; 93 border - radius :4 px ; 94 height :30 px; 95 display : inline - block ; 96 text - align : center ; 62
97 background -color: white; 98 color : #4 CAF50 ; 99 } 100 input [ type = password ]: focus { 101 border - color : #4 CAF50 ; 102 border - shadow : 0 0 8px 0 #4 CAF50 ; 103 } 104 #infoText { 105 display : inline - block ; 106 } 107 p { 108 text - align : center ; 109 } 110 . photo { 111 display : block ; 112 margin - left : auto ; 113 margin - right : auto ; 114 } 115 </style > 116 </head > 117 <body > 118 <div class =" header" > 119 <h1 > Welcome </h1 > 120 </div > 121 <div class =" row"> 122 <div class ="col -12" > 123 <p> This thesis project is created by Verstappe Elias and Ver Eecke Daan . </p> 124 <p> This is a wireless adaptation for a standalone CNC controller .</p> 125 </div > 126 </div > 127 <div class =" row"> 128 <div class ="col-2"> 129 </div > 130 <div class ="col-8 form" > 131 <p> To proceed , please enter username and password .</p> 132 < input type =" text" id =" username" placeholder =" Username" ><br /> 133 < input type =" password" id =" password" placeholder =" Password" >< br /> 134 <p id=" infoText" ></p>< br /> 135 < button onClick =" login()">Log in </ button > 136 </div > 137 <div class ="col-2"> 138 </div > 139 </div > 140 <div class =" row"> 141 <div class ="col -12"> 142 <p id=" colaboration" >A colaboration between :</p> 143 </div > 144 </div > 145 <div class =" row"> 146 <div class ="col-6"> 147 <img src =" https:// www . vives .be / sites / default / files / thumbnails / image /Logo - VIVES . png " alt =" VIVES " height ="120" class =" photo "> 148 </div> 149 <div class ="col -6 "> 63
150 <img src=" https :// upload . wikimedia . org / wikipedia / en / thumb /7/75/ University_of_Valladolid_Crest.svg/220px-University_of_Valladolid_Crest. svg . png " alt=" UVa " height ="120" class=" photo " > 151 </div> 152 </div> 153 <div class =" footer " > 154 <h1 >CNC-controller </h1 > 155 </div> 156 <script> 157 function login () { 158 var user =document.getElementById("username"). value; 159 var pass =document.getElementById("password"). value; 160 var answer =""; 161 var xhttp =new XMLHttpRequest (); 162 var url =" Login ? credentials " +"=" +user +"!" +pass; 163 xhttp.onreadystatechange =function() { 164 if (this.readyState == 4 && this.status == 200) { 165 var answer =this.responseText; 166 handleResponse(answer); 167 } 168 } 169 xhttp.open("GET ",url ,true); 170 xhttp.send(); 171 } 172 173 function handleResponse (answer) { 174 if(answer == " correct "){ 175 document.getElementById("infoText"). innerHTML ="Username and password correct !"; 176 document.getElementById("infoText"). style.color =" green "; 177 document.location.href ="/ changeWebPage ? webpage = Routepro / Drillpro"; 178 }else{ 179 document.getElementById("infoText"). innerHTML ="Username or password wrong !"; 180 document.getElementById("infoText"). style.color =" red "; 181 } 182 } 183 184 document.onkeypress =function(event) { 185 var x =event .charCode; 186 switch(x){ 187 case 13: 188 login() ; 189 break; 190 } 191 }; 192 </ script > 193 </body > 194 </html > 195 ) ===== "; 64
C.0.2 Routepro/Drillpro web page 1const char ROUTEPRO_page[] PROGMEM =R" =====( 2<html > 3<head > 4<meta name="author" content =" Daan Ver Eecke "> 5<meta name="viewport" content =" width=device -width ,initial - scale=1.0"> 6<title > routepro </ title > 7<style > 8* { 9box - sizing : border - box ; 10 } 11 .row :: after { 12 content : ""; 13 clear : both ; 14 display : table ; 15 } 16 [ class *= "col-"] { 17 float : left ; 18 padding : 15 px; 19 } 20 html { 21 font - family : " Lucida Sans " , sans - serif ; 22 } 23 [ class *= "col-"] { 24 width: 100%; 25 } 26 @media only screen and (min -width : 600 px ) { 27 .col -s -1 { width : 8.33%;} 28 .col -s -2 { width : 16.66%;} 29 .col -s -3 { width : 25%;} 30 .col -s -4 { width : 33.33%;} 31 .col -s -5 { width : 41.66%;} 32 .col -s -6 { width : 50%;} 33 .col -s -7 { width : 58.33%;} 34 .col -s -8 { width : 66.66%;} 35 .col -s -9 { width : 75%;} 36 .col -s -10 { width : 83.33%;} 37 .col -s -11 { width : 91.66%;} 38 .col -s -12 { width : 100%;} 39 } 40 @media only screen and (min -width : 768 px ) { 41 .col -1 { width : 8.33%;} 42 .col -2 { width : 16.66%;} 43 .col -3 { width : 25%;} 44 .col -4 { width : 33.33%;} 45 .col -5 { width : 41.66%;} 46 .col -6 { width : 50%;} 47 .col -7 { width : 58.33%;} 48 .col -8 { width : 66.66%;} 49 .col -9 { width : 75%;} 50 .col -10 { width : 83.33%;} 51 .col -11 { width : 91.66%;} 52 .col -12 { width : 100%;} 53 } 54 body { 65
55 background - color : # c5cedd ; 56 } 57 button { 58 background - color : #4 CAF50 ; 59 border : 1 px solid green ; 60 color : # c5cedd ; 61 text - align : center ; 62 text - decoration : none ; 63 display : inline - block ; 64 display : block ; 65 width: 100%; 66 height : 5%; 67 } 68 button : hover { 69 background - color :# c5cedd ; /* Green */ 70 color : #4 CAF50 ; 71 } 72 b { 73 color : yellow ; 74 } 75 . table1 { 76 border : 1 px solid black ; 77 border - collapse : collapse ; 78 text - align : center ; 79 height : 50 px ; 80 width: 100%; 81 } 82 . table1 th { 83 border : 1 px solid black ; 84 height : 75 px ; 85 width : 20%; 86 } 87 . table1 td { 88 border : 1 px solid black ; 89 height : 50 px ; 90 } 91 # tableheader { 92 width : 20%; 93 } 94 # small { 95 width : 10%; 96 } 97 . table2 { 98 border : 1 px solid black ; 99 border - collapse : collapse ; 100 text - align : center ; 101 height : 50 px ; 102 width: 100%; 103 } 104 . table2 th { 105 border : 1 px solid black ; 106 height : 75 px ; 107 width : 50%; 108 } 109 . table2 td { 110 border : 1 px solid black ; 111 height : 50 px ; 66
112 } 113 input { 114 align - self : center ; 115 text - align : center ; 116 width : 75 px ; 117 } 118 . header { 119 background - color : #4 CAF50 ; 120 color : # ffffff ; 121 padding : 15 px; 122 } 123 . footer { 124 background - color : #4 CAF50 ; 125 color : # ffffff ; 126 text - align : center ; 127 font - size : 12 px ; 128 padding : 15 px; 129 } 130 </style > 131 </head > 132 <body > 133 <div class =" header"> 134 <h1 > Routepro / drillpro </h1 > 135 </div > 136 <div class =" row"> 137 <div class ="col-2 col-s-12"> 138 <button id =" config_button" onclick =" saveOrIgnoreChanges ('Configuration')" ><b >C </ b> onfig . </ button > 139 <button id =" tools_button" onclick =" saveOrIgnoreChanges( 'Tools')" ><b>T </b >ools </ button > 140 <button id =" offest_button" onclick =" saveOrIgnoreChanges ('Offset')" ><b >O </b > ffset </ button > 141 <button id =" load_button" onclick =" saveOrIgnoreChanges(' Load')" ><b>L </ b>oad </ button > 142 <button id =" save_button" onclick =" receivingRouteproData ()" >S <b >a </b>ve </ button > 143 </div > 144 <div class ="col-7 col-s-12"> 145 < table class =" table1"> 146 <tr > 147 <th > </th > 148 <th >O<b>f </b> fset :</th > 149 <th >Cl <b>i </b>p:</th > 150 <th > </th > 151 <th id=" small" ><b>V </ b> ectors : </ th > 152 <th id=" tableheader"> </th > 153 </tr > 154 <tr > 155 <td >X: </td > 156 <td >< input type =" number" id =" X_offset" value =" 0" ></td > 157 <td >< input type =" number" id =" X_clip" value =" 325" ></td > 158 <td id=" small">from </ td > 159 <td >< input type = " number" id=" X_vectors" value =" 0" ></td > 160 <td > </td > 67
161 </tr > 162 <tr > 163 <td >Y: </td > 164 <td >< input type =" number" id =" Y_offset" value =" 0" ></td > 165 <td >< input type =" number" id =" Y_clip" value =" 278" ></td > 166 <td id=" small">to </td > 167 <td >< input type =" number" id =" Y_vectors" value = "0" ></td > 168 <td > </td > 169 </tr > 170 <tr > 171 <th > </th > 172 <th > Boar <b >d </b >: </ th > 173 <th ><b>B </b>ase :</th > 174 <td >< span id =" X_min_value" >0 </td > 175 <td id=" small" >& lt ; X <</td > 176 <td >< span id =" X_max_value" >0 </td > 177 </tr > 178 <tr > 179 <td >Z: </td > 180 <td >< input type =" number" id =" Z_board " value =" 1.5" ></td > 181 <td >< input type =" number" id =" Z_base" value =" 2.0" ></td > 182 <td >< span id =" Y_min_value" >0 </td > 183 <td id=" small" >& lt ; Y <</td > 184 <td >< span id =" Y_max_value" >0 </td > 185 </tr > 186 </table > 187 </div > 188 <div class ="col-3 col-s-12"> 189 < table class =" table2"> 190 <tr > 191 <th > Count : </th > 192 <th > </th > 193 </tr > 194 <tr > 195 <td > Total </ td > 196 <td >< span id =" Total" >0</td > 197 </tr > 198 <tr > 199 <td >Done </td > 200 <td >< span id =" Done" >0</td > 201 </tr > 202 </table > 203 </div > 204 </div > 205 <div class =" footer"> 206 <p>CNC - controller for Bungard CNC - machine </p> 207 </div > 208 < script src =" https:// ajax . googleapis . com / ajax / libs / jquery /3.3.1/ jquery . min . js " ></ script > 209 <script> 210 var saved =false ; 211 68
212 function saveOrIgnoreChanges(webpage ){ 213 if (saved == false){ 214 var r =confirm (" Save changes ? "); 215 if (r== true){ 216 receivingRouteproData(); 217 } 218 } 219 document.location.href ="/ changeWebPage ? webpage =" + webpage ; 220 } 221 222 function receivingRouteproData (){ 223 saved =true; 224 var index = [$("#X_offset"). val() ,$("# X_clip "). val() ,$( "#X_vectors"). val() , 225 $("#Y_offset"). val() ,$("# Y_clip ").val() ,$("#Y_vectors") .val() ,$("# Z_board ").val() , 226 $("# Z_base "). val() ,$("# X_min_value "). text() ,$("# X_max_value"). text() ,$("# Y_min_value ") . text() ,$("# Y_max_value ") . text() , 227 $("# Total "). text() ,$("# Done ") . text() ,$("#File_Name"). text() ]; 228 var url =" handleData ? RouteproData ="; 229 for (let i =0;i<index.length;i++){ 230 if(i== 0){ 231 var temp =index [i]; 232 }else{ 233 var temp ="!" +index [i]; 234 } 235 url += temp; 236 } 237 var xhttp =new XMLHttpRequest (); 238 xhttp.open("GET ",url); 239 xhttp.onload =function() { 240 var data =JSON.parse (xhttp .responseText); 241 console .log(data); 242 } 243 xhttp.send(); 244 } 245 246 document.onkeypress =function(event) { 247 var x =event .charCode; 248 switch(x){ 249 case 99: 250 document.location.href ="/changeWebPage? webpage = Configuration "; 251 break; 252 case 116: 253 document.location.href ="/changeWebPage? webpage = Tools "; 254 break; 255 case 111: 256 document.location.href ="/changeWebPage? webpage = Offset "; 257 break; 258 case 108: 259 document.location.href ="/changeWebPage? webpage = Load "; 69
260 break; 261 case 97: 262 receivingRouteproData(); 263 break; 264 case 102: 265 document.getElementById("X_offset"). focus(); 266 break; 267 case 105: 268 document.getElementById(" X_clip "). focus(); 269 break; 270 case 118: 271 document.getElementById("X_vectors"). focus(); 272 break; 273 case 100: 274 document.getElementById(" Z_board "). focus(); 275 break; 276 case 98: 277 document.getElementById(" Z_base "). focus(); 278 break; 279 } 280 }; 281 </ script > 282 </body > 283 </html > 284 ) ===== "; 70
C.0.3 Configuration web page 1const char CONFIG_page[] PROGMEM =R" =====( 2<html > 3<head > 4<meta name="author" content =" Daan Ver Eecke "> 5<meta name="viewport" content =" width=device -width ,initial -scale =1.0" > 6<title > config . </ title > 7<style > 8* { 9box - sizing : border - box ; 10 } 11 .row :: after { 12 content : ""; 13 clear : both ; 14 display : table ; 15 } 16 [ class *= "col-"] { 17 float : left ; 18 padding : 15 px; 19 } 20 html { 21 font - family : " Lucida Sans " , sans - serif ; 22 } 23 [ class *= "col-"] { 24 width: 100%; 25 } 26 @media only screen and (min -width : 600 px ) { 27 .col -s -1 { width : 8.33%;} 28 .col -s -2 { width : 16.66%;} 29 .col -s -3 { width : 25%;} 30 .col -s -4 { width : 33.33%;} 31 .col -s -5 { width : 41.66%;} 32 .col -s -6 { width : 50%;} 33 .col -s -7 { width : 58.33%;} 34 .col -s -8 { width : 66.66%;} 35 .col -s -9 { width : 75%;} 36 .col -s -10 { width : 83.33%;} 37 .col -s -11 { width : 91.66%;} 38 .col -s -12 { width : 100%;} 39 } 40 @media only screen and (min -width : 768 px ) { 41 .col -1 { width : 8.33%;} 42 .col -2 { width : 16.66%;} 43 .col -3 { width : 25%;} 44 .col -4 { width : 33.33%;} 45 .col -5 { width : 41.66%;} 46 .col -6 { width : 50%;} 47 .col -7 { width : 58.33%;} 48 .col -8 { width : 66.66%;} 49 .col -9 { width : 75%;} 50 .col -10 { width : 83.33%;} 51 .col -11 { width : 91.66%;} 52 .col -12 { width : 100%;} 53 } 54 body{ 71
113 } 114 input [ type = number ]: focus { 115 border - color : #4 CAF50 ; 116 border - shadow : 0 0 8px 0 #4 CAF50 ; 117 } 118 </style > 119 </head > 120 <body > 121 <div class =" header"> 122 <h1 > Tool Data </ h1 > 123 </div > 124 <div class =" row button-group" > 125 <div class ="col -12 col-s-12"> 126 <button id =" load_button" onclick =" window.location.href='/ changeWebPage ? webpage = Load '" ><b >L </b >oad </ button > 127 <button id =" save_button" onclick =" receivingToolsData()" ><b >S </b > ave </ button > 128 <button id =" back_button" onclick =" saveOrIgnoreChanges() " ><b >B </ b> ack </ button > 129 </div > 130 </div > 131 <div class =" row"> 132 <div class ="col -12 col-s-12" overflow="auto"> 133 <table id=" tableData"> 134 <tr > 135 <th >Pl .</th > 136 <th ><b>D </b>epth </ th > 137 <th ><b >I </b > ter . </ th > 138 <th ><b>X </b> Feed </th > 139 <th ><b>Z </b> Feed </th > 140 <th >S<b>p </b> indle </ th > 141 <th > Start </ th > 142 <th >Used </th > 143 <th > Tab .</th > 144 </tr > 145 <tr > 146 <td > </td > 147 <td >mm </td > 148 <td >/n </ td > 149 <td >mm/min </ td > 150 <td >mm/min </ td > 151 <td >1/ min </td > 152 <td > Vect .</td > 153 <td >mm </td > 154 <td > </td > 155 </tr > 156 <tr > 157 <td >01 </ td > 158 <td >< input type = " number" id=" depth_1 " value =" 00.00" ></td > 159 <td >< input type = " number" id=" itr_1" value =" 01" ></td > 160 <td >< input type = " number" id=" X_feed_1" value =" 0050" ></td > 161 <td >< input type = " number" id=" Z_feed_1" value =" 0050" ></td > 162 <td >< input type = " number" id=" spindle_1" value =" 30000" ></td > 163 <td id=" start_1 " >... </ td > 164 <td id=" used_1" >... </ td > 165 <td id=" tab_1" >... </ td > 166 </tr > 78
167 <tr > 168 <td >02 </ td > 169 <td >< input type = " number" id=" depth_2 " value =" 00.00" ></td > 170 <td >< input type = " number" id=" itr_2" value =" 01" ></td > 171 <td >< input type = " number" id=" X_feed_2" value =" 0050" ></td > 172 <td >< input type = " number" id=" Z_feed_2" value =" 0050" ></td > 173 <td >< input type = " number" id=" spindle_2" value =" 30000" ></td > 174 <td id=" start_2 " >... </ td > 175 <td id=" used_2" >... </ td > 176 <td id=" tab_2" >... </ td > 177 </tr > 178 <tr > 179 <td >03 </ td > 180 <td >< input type = " number" id=" depth_3 " value =" 00.00" ></td > 181 <td >< input type = " number" id=" itr_3" value =" 01" ></td > 182 <td >< input type = " number" id=" X_feed_3" value =" 0050" ></td > 183 <td >< input type = " number" id=" Z_feed_3" value =" 0050" ></td > 184 <td >< input type = " number" id=" spindle_3" value =" 30000" ></td > 185 <td id=" start_3 " >... </ td > 186 <td id=" used_3" >... </ td > 187 <td id=" tab_3" >... </ td > 188 </tr > 189 <tr > 190 <td >04 </ td > 191 <td >< input type = " number" id=" depth_4 " value =" 00.00" ></td > 192 <td >< input type = " number" id=" itr_4" value =" 01" ></td > 193 <td >< input type = " number" id=" X_feed_4" value =" 0050" ></td > 194 <td >< input type = " number" id=" Z_feed_4" value =" 0050" ></td > 195 <td >< input type = " number" id=" spindle_4" value =" 30000" ></td > 196 <td id=" start_4 " >... </ td > 197 <td id=" used_4" >... </ td > 198 <td id=" tab_4" >... </ td > 199 </tr > 200 <tr > 201 <td >05 </ td > 202 <td >< input type = " number" id=" depth_5 " value =" 00.00" ></td > 203 <td >< input type = " number" id=" itr_5" value =" 01" ></td > 204 <td >< input type = " number" id=" X_feed_5" value =" 0050" ></td > 205 <td >< input type = " number" id=" Z_feed_5" value =" 0050" ></td > 206 <td >< input type = " number" id=" spindle_5" value =" 30000" ></td > 207 <td id=" start_5 " >... </ td > 208 <td id=" used_5" >... </ td > 209 <td id=" tab_5" >... </ td > 210 </tr > 211 <tr > 212 <td >06 </ td > 213 <td >< input type = " number" id=" depth_6 " value =" 00.00" ></td > 214 <td >< input type = " number" id=" itr_6" value =" 01" ></td > 215 <td >< input type = " number" id=" X_feed_6" value =" 0050" ></td > 216 <td >< input type = " number" id=" Z_feed_6" value =" 0050" ></td > 217 <td >< input type = " number" id=" spindle_6" value =" 30000" ></td > 218 <td id=" start_6 " >... </ td > 219 <td id=" used_6" >... </ td > 220 <td id=" tab_6" >... </ td > 221 </tr > 222 <tr > 223 <td >07 </ td > 79
224 <td >< input type = " number" id=" depth_7 " value =" 00.00" ></td > 225 <td >< input type = " number" id=" itr_7" value =" 01" ></td > 226 <td >< input type = " number" id=" X_feed_7" value =" 0050" ></td > 227 <td >< input type = " number" id=" Z_feed_7" value =" 0050" ></td > 228 <td >< input type = " number" id=" spindle_7" value =" 30000" ></td > 229 <td id=" start_7 " >... </ td > 230 <td id=" used_7" >... </ td > 231 <td id=" tab_7" >... </ td > 232 </tr > 233 <tr > 234 <td >08 </ td > 235 <td >< input type = " number" id=" depth_8 " value =" 00.00" ></td > 236 <td >< input type = " number" id=" itr_8" value =" 01" ></td > 237 <td >< input type = " number" id=" X_feed_8" value =" 0050" ></td > 238 <td >< input type = " number" id=" Z_feed_8" value =" 0050" ></td > 239 <td >< input type = " number" id=" spindle_8" value =" 30000" ></td > 240 <td id=" start_8 " >... </ td > 241 <td id=" used_8" >... </ td > 242 <td id=" tab_8" >... </ td > 243 </tr > 244 <td >09 </ td > 245 <td >< input type = " number" id=" depth_9 " value =" 00.00" ></td > 246 <td >< input type = " number" id=" itr_9" value =" 01" ></td > 247 <td >< input type = " number" id=" X_feed_9" value =" 0050" ></td > 248 <td >< input type = " number" id=" Z_feed_9" value =" 0050" ></td > 249 <td >< input type = " number" id=" spindle_9" value =" 30000" ></td > 250 <td id=" start_9 " >... </ td > 251 <td id=" used_9" >... </ td > 252 <td id=" tab_9" >... </ td > 253 </tr > 254 <tr > 255 <td >10 </ td > 256 <td >< input type = " number" id=" depth_10" value =" 00.00" ></td > 257 <td >< input type = " number" id=" itr_10" value =" 01" ></td > 258 <td >< input type = " number" id=" X_feed_10" value =" 0050" ></td > 259 <td >< input type = " number" id=" Z_feed_10" value =" 0050" ></td > 260 <td >< input type = " number" id=" spindle_10" value =" 30000" ></td > 261 <td id=" start_10" >... </ td > 262 <td id=" used_10 " >... </ td > 263 <td id=" tab_10" >... </ td > 264 </tr > 265 <tr > 266 <td >11 </ td > 267 <td >< input type = " number" id=" depth_11" value =" 00.00" ></td > 268 <td >< input type = " number" id=" itr_11" value =" 01" ></td > 269 <td >< input type = " number" id=" X_feed_11" value =" 0050" ></td > 270 <td >< input type = " number" id=" Z_feed_11" value =" 0050" ></td > 271 <td >< input type = " number" id=" spindle_11" value =" 30000" ></td > 272 <td id=" start_11" >... </ td > 273 <td id=" used_11 " >... </ td > 274 <td id=" tab_11" >... </ td > 275 </tr > 276 <tr > 277 <td >12 </ td > 278 <td >< input type = " number" id=" depth_12" value =" 00.00" ></td > 279 <td >< input type = " number" id=" itr_12" value =" 01" ></td > 280 <td >< input type = " number" id=" X_feed_12" value =" 0050" ></td > 80
281 <td >< input type = " number" id=" Z_feed_12" value =" 0050" ></td > 282 <td >< input type = " number" id=" spindle_12" value =" 30000" ></td > 283 <td id=" start_12" >... </ td > 284 <td id=" used_12 " >... </ td > 285 <td id=" tab_12" >... </ td > 286 </tr > 287 <tr > 288 <td >13 </ td > 289 <td >< input type = " number" id=" depth_13" value =" 00.00" ></td > 290 <td >< input type = " number" id=" itr_13" value =" 01" ></td > 291 <td >< input type = " number" id=" X_feed_13" value =" 0050" ></td > 292 <td >< input type = " number" id=" Z_feed_13" value =" 0050" ></td > 293 <td >< input type = " number" id=" spindle_13" value =" 30000" ></td > 294 <td id=" start_13" >... </ td > 295 <td id=" used_13 " >... </ td > 296 <td id=" tab_13" >... </ td > 297 </tr > 298 <tr > 299 <td >14 </ td > 300 <td >< input type = " number" id=" depth_14" value =" 00.00" ></td > 301 <td >< input type = " number" id=" itr_14" value =" 01" ></td > 302 <td >< input type = " number" id=" X_feed_14" value =" 0050" ></td > 303 <td >< input type = " number" id=" Z_feed_14" value =" 0050" ></td > 304 <td >< input type = " number" id=" spindle_14" value =" 30000" ></td > 305 <td id=" start_14" >... </ td > 306 <td id=" used_14 " >... </ td > 307 <td id=" tab_14" >... </ td > 308 </tr > 309 <tr > 310 <td >15 </ td > 311 <td >< input type = " number" id=" depth_15" value =" 00.00" ></td > 312 <td >< input type = " number" id=" itr_15" value =" 01" ></td > 313 <td >< input type = " number" id=" X_feed_15" value =" 0050" ></td > 314 <td >< input type = " number" id=" Z_feed_15" value =" 0050" ></td > 315 <td >< input type = " number" id=" spindle_15" value =" 30000" ></td > 316 <td id=" start_15" >... </ td > 317 <td id=" used_15 " >... </ td > 318 <td id=" tab_15" >... </ td > 319 </tr > 320 </table > 321 </div > 322 </div > 323 <div class =" footer"> 324 <p>CNC - controller for Bungard CNC - machine </p> 325 </div > 326 < script src =" https:// ajax . googleapis . com / ajax / libs / jquery /3.3.1/ jquery . min . js "></ script > 327 <script> 328 var saved =false ; 329 330 function saveOrIgnoreChanges(){ 331 if (saved == false){ 332 var r =confirm (" Save changes ? "); 333 if (r== true){ 334 receivingToolsData(); 335 } 336 } 81
337 document.location.href ="/ changeWebPage ? webpage = Back "; 338 } 339 340 function receivingToolsData (){ 341 saved =true; 342 var index = [$("# depth_1 ").val() ,$("# depth_2 ").val() , 343 $("# depth_3 "). val() ,$("# depth_4 ").val() , 344 $("# depth_5 "). val() ,$("# depth_6 ").val() , 345 $("# depth_7 "). val() ,$("# depth_8 ").val() , 346 $("# depth_9 "). val() ,$("#depth_10"). val() , 347 $("#depth_11"). val() ,$("#depth_12").val() , 348 $("#depth_13"). val() ,$("#depth_14").val() , 349 $("#depth_15"). val() , 350 $("# itr_1 ").val() ,$("# itr_2 ").val() , 351 $("# itr_3 ").val() ,$("# itr_4 ").val() , 352 $("# itr_5 ").val() ,$("# itr_6 ").val() , 353 $("# itr_7 ").val() ,$("# itr_8 ").val() , 354 $("# itr_9 ").val() ,$("# itr_10 "). val() , 355 $("# itr_11 "). val() ,$("# itr_12 "). val() , 356 $("# itr_13 "). val() ,$("# itr_14 "). val() , 357 $("# itr_15 "). val() , 358 $("#X_feed_1"). val() ,$("#X_feed_2").val() , 359 $("#X_feed_3"). val() ,$("#X_feed_4").val() , 360 $("#X_feed_5"). val() ,$("#X_feed_6").val() , 361 $("#X_feed_7"). val() ,$("#X_feed_8").val() , 362 $("#X_feed_9"). val() ,$("#X_feed_10").val() , 363 $("#X_feed_11"). val() ,$("#X_feed_12").val() , 364 $("#X_feed_13"). val() ,$("#X_feed_14").val() , 365 $("#X_feed_15"). val() , 366 $("#Z_feed_1"). val() ,$("#Z_feed_2").val() , 367 $("#Z_feed_3"). val() ,$("#Z_feed_4").val() , 368 $("#Z_feed_5"). val() ,$("#Z_feed_6").val() , 369 $("#Z_feed_7"). val() ,$("#Z_feed_8").val() , 370 $("#Z_feed_9"). val() ,$("#Z_feed_10").val() , 371 $("#Z_feed_11"). val() ,$("#Z_feed_12").val() , 372 $("#Z_feed_13"). val() ,$("#Z_feed_14").val() , 373 $("#Z_feed_15"). val() , 374 $("#spindle_1"). val() ,$("#spindle_2").val() , 375 $("#spindle_3"). val() ,$("#spindle_4").val() , 376 $("#spindle_5"). val() ,$("#spindle_6").val() , 377 $("#spindle_7"). val() ,$("#spindle_8").val() , 378 $("#spindle_9"). val() ,$("#spindle_10").val() , 379 $("#spindle_11"). val() ,$("#spindle_12"). val() , 380 $("#spindle_13"). val() ,$("#spindle_14"). val() , 381 $("#spindle_15"). val() , 382 $("# start_1 "). text() ,$("# start_2 "). text() , 383 $("# start_3 "). text() ,$("# start_4 "). text() , 384 $("# start_5 "). text() ,$("# start_6 "). text() , 385 $("# start_7 "). text() ,$("# start_8 "). text() , 386 $("# start_9 "). text() ,$("#start_10") . text() , 387 $("#start_11"). text() ,$("#start_12"). text() , 388 $("#start_13"). text() ,$("#start_14"). text() , 389 $("#start_15"). text() , 390 $("# used_1 "). text() ,$("# used_2 "). text() , 391 $("# used_3 "). text() ,$("# used_4 "). text() , 392 $("# used_5 "). text() ,$("# used_6 "). text() , 393 $("# used_7 "). text() ,$("# used_8 "). text() , 82
394 $("# used_9 "). text() ,$("# used_10 ") . text() , 395 $("# used_11 "). text() ,$("# used_12 "). text() , 396 $("# used_13 "). text() ,$("# used_14 "). text() , 397 $("# used_15 "). text() , 398 $("# tab_1 "). text() ,$("# tab_2 "). text() , 399 $("# tab_3 "). text() ,$("# tab_4 "). text() , 400 $("# tab_5 "). text() ,$("# tab_6 "). text() , 401 $("# tab_7 "). text() ,$("# tab_8 "). text() , 402 $("# tab_9 "). text() ,$("# tab_10 ") . text() , 403 $("# tab_11 "). text() ,$("# tab_12 "). text() , 404 $("# tab_13 "). text() ,$("# tab_14 "). text() , 405 $("# tab_15 "). text() 406 ]; 407 var url =" handleToolsData ? ToolsData ="; 408 for (let i =0;i<index .length ;i++){ 409 if(i== 0){ 410 var temp =index [i] 411 }else{ 412 var temp ="!" +index [i]; 413 } 414 url += temp; 415 } 416 var xhttp =new XMLHttpRequest (); 417 xhttp.open("GET ",url); 418 xhttp.onload =function() { 419 var data =JSON.parse (xhttp .responseText); 420 console .log(data); 421 } 422 xhttp.send(); 423 } 424 425 document.onkeypress =function(event) { 426 var x =event .charCode; 427 switch(x){ 428 case 108: 429 document.location.href ="/ changeWebPage ? webpage = Load " ; 430 break; 431 case 98: 432 document.location.href ="/ changeWebPage ? webpage = Back " ; 433 break; 434 case 115: 435 receivingToolsData(); 436 break; 437 case 100: 438 document.getElementById(" depth_1 "). focus(); 439 break; 440 case 105: 441 document.getElementById(" itr_1 "). focus(); 442 break; 443 case 120: 444 document.getElementById("X_feed_1"). focus(); 445 break; 446 case 122: 447 document.getElementById("Z_feed_1"). focus(); 448 break; 449 case 112: 450 document.getElementById("spindle_1"). focus(); 83
451 break; 452 } 453 }; 454 </ script > 455 </body > 456 </html > 457 ) ===== "; 84
C.0.5 Offset web page 1const char OFFSET_page[] PROGMEM =R" =====( 2<html > 3<head > 4<meta name="author" content =" Daan Ver Eecke "> 5<meta name="viewport" content =" width=device -width ,initial -scale =1.0" > 6<title > offset </ title > 7<style > 8* { 9box - sizing : border - box ; 10 } 11 .row :: after { 12 content : ""; 13 clear : both ; 14 display : table ; 15 } 16 [ class *= "col-"] { 17 float : left ; 18 padding : 15 px; 19 } 20 html { 21 font - family : " Lucida Sans " , sans - serif ; 22 } 23 [ class *= "col-"] { 24 width: 100%; 25 } 26 @media only screen and (min -width : 600 px ) { 27 .col -s -1 { width : 8.33%;} 28 .col -s -2 { width : 16.66%;} 29 .col -s -3 { width : 25%;} 30 .col -s -4 { width : 33.33%;} 31 .col -s -5 { width : 41.66%;} 32 .col -s -6 { width : 50%;} 33 .col -s -7 { width : 58.33%;} 34 .col -s -8 { width : 66.66%;} 35 .col -s -9 { width : 75%;} 36 .col -s -10 { width : 83.33%;} 37 .col -s -11 { width : 91.66%;} 38 .col -s -12 { width : 100%;} 39 } 40 @media only screen and (min -width : 768 px ) { 41 .col -1 { width : 8.33%;} 42 .col -2 { width : 16.66%;} 43 .col -3 { width : 25%;} 44 .col -4 { width : 33.33%;} 45 .col -5 { width : 41.66%;} 46 .col -6 { width : 50%;} 47 .col -7 { width : 58.33%;} 48 .col -8 { width : 66.66%;} 49 .col -9 { width : 75%;} 50 .col -10 { width : 83.33%;} 51 .col -11 { width : 91.66%;} 52 .col -12 { width : 100%;} 53 } 54 body { 85
55 background - color : # c5cedd ; 56 } 57 button { 58 width: 100%; 59 background - color : #4 CAF50 ; 60 color : # c5cedd ; 61 font - size : 16 px ; 62 padding : 10 px 24 px; 63 -webkit - transition - duration : 0.4 s; /* Safari */ 64 transition - duration : 0.4 s; 65 } 66 button : hover { 67 background - color :# c5cedd ; /* Green */ 68 color : #4 CAF50 ; 69 } 70 . header { 71 background - color : #4 CAF50 ; 72 color : # ffffff ; 73 padding : 15 px; 74 } 75 . footer { 76 background - color : #4 CAF50 ; 77 color : # ffffff ; 78 text - align : center ; 79 font - size : 12 px ; 80 padding : 15 px; 81 } 82 .container { 83 display : block ; 84 position: relative; 85 padding - left : 35 px; 86 margin - bottom : 12 px; 87 cursor : pointer ; 88 font - size : 22 px ; 89 -webkit - user - select : none ; 90 -moz - user - select : none ; 91 -ms - user - select : none ; 92 user - select : none ; 93 } 94 . container input { 95 position: absolute; 96 opacity : 0; 97 cursor : pointer ; 98 height : 0; 99 width : 0; 100 } 101 .checkmark { 102 position: absolute; 103 top : 0; 104 left : 0; 105 height : 25 px ; 106 width : 25 px ; 107 background - color : # eee ; 108 } 109 . container : hover input ˜ . checkmark { 110 background - color : # ccc ; 111 } 86
112 . container input : checked ˜ . checkmark { 113 background - color : #4 CAF50 ; 114 } 115 . checkmark : after { 116 content : ""; 117 position: absolute; 118 display : none ; 119 } 120 . container input : checked ˜ . checkmark : after { 121 display : block ; 122 } 123 .container .checkmark:after { 124 left : 9 px ; 125 top : 5px; 126 width : 5 px ; 127 height : 10 px ; 128 border : solid white ; 129 border - width : 0 3 px 3 px 0; 130 -webkit - transform : rotate (45 deg ); 131 -ms - transform : rotate (45 deg); 132 transform : rotate (45 deg ); 133 } 134 b { 135 color : yellow ! important ; 136 } 137 # button_table { 138 width: 100%; 139 height : 30%; 140 } 141 #button_td { 142 width : 33%; 143 } 144 #up_down_table { 145 vertical - align : center ; 146 width: 100%; 147 height : 30%; 148 } 149 #up_down_td { 150 width: 100%; 151 } 152 #movement_button { 153 height : 100%; 154 } 155 </style > 156 </head > 157 <body > 158 <div class =" header"> 159 <h1 > Offset </ h1 > 160 </div > 161 <div class =" row"> 162 <div class ="col -12 col-s-12"> 163 <button id =" back_button" onclick =" window.location.href='/ changeWebPage ? webpage = Back '" ><b >B </b >ack </ button > 164 </div > 165 <div > 166 <div class =" row"> 167 <div class ="col-6 col-s-12"> 87
166 167 function file_selected (){ 168 var name_path = document . getElementById ('file'). files [0]. name . split ("."); 169 document . getElementById (" start_button"). disabled = false ; 170 document . getElementById (" emergency_stop"). disabled = false ; 171 document . getElementById (" file_name").innerHTML = name_path[0]; 172 document . getElementById (" file_extension").innerHTML = name_path [1]; 173 document . getElementById (" file_size"). innerHTML = document . getElementById('file') . files [0]. size ; 174 } 175 176 var numberOfHTTPRequestsDone = 0; 177 178 function send_file (){ 179 var file_size = file . length ; 180 var f_size = file_size 181 var numberOfHTTPRequest = 1; 182 for ( let i = 0; 1000 < file_size ;i ++) { 183 numberOfHTTPRequest ++; 184 file_size -= 1000; 185 } 186 console . log ( file_size ); 187 console.log(numberOfHTTPRequest); 188 189 requests = new Array ( numberOfHTTPRequest ); 190 for ( let i = 0; i < numberOfHTTPRequest ; i++){ 191 for ( let i = 0; i < 3; i++) { 192 } 193 numberOfHTTPRequestsDone++; 194 var sub_string = file . slice (i *1000 ,(( i +1) *1000) -1); 195 var sub_string = sub_string . replace (/;/g ,"!"); 196 if (i == 0){ 197 var url = " handleFileUpload?file"+i+"=" + f_size + "!" + sub_string; 198 } else { 199 var url = " handleFileUpload?file"+i+"=" + sub_string; 200 } 201 requests [i] = new XMLHttpRequest (); 202 } 203 } 204 205 document . onkeypress = function ( event ) { 206 var x = event . charCode ; 207 switch (x){ 208 case 98: 209 document . location . href = "/changeWebPage?webpage =Back"; 210 break ; 211 case 115: 212 document . location . href = "/changeWebPage?webpage =Start"; 213 break ; 214 case 101: 215 alert (" EMERGENCY STOP!"); 216 break ; 217 } 218 }; 94
219 </script > 220 </body > 221 </html > 222 ) ===== "; 95
Appendix D Arduino source code D.0.1 Libraries and variables 1# include < ESP8266WiFi .h> 2# include <WiFiClient.h> 3# include <ESP8266WebServer.h> 4# include < ESP8266mDNS .h> 5# include <ESP8266WiFiMulti.h> 6# include <FS.h> 7# include < SoftwareSerial .h> 8 9//webpages 10 # include "z_routepro_drillpro.h" 11 # include " z_config .h" 12 # include " z_load .h" 13 # include " z_tools .h" 14 # include " z_offset .h" 15 # include "z_welcome.h" 16 17 ESP8266WiFiMulti wifiMulti; 18 ESP8266WebServer server (80); 19 20 # define INTEG (N) ( payload [N]|( payload [N +1] < <8) |( payload [N +2] < <16) |( payload [N+3] < <24) ) 21 # define I2B (i , N) send_payload [N ]=i & 0xFF ; send_payload [N +1]=(i > >8) & 0 xFF ; send_payload [N +2]=(i > >16) & 0 xFF ; send_payload [N +3]=(i > >24) & 0 xFF ; 22 char send_payload[253]; 23 char payload [253]; 24 25 # define STASSID "Wifi_Lab_Proyectos" 26 # define STAPSK " R3B00TY0URM1ND " 27 //# define STASSID " MIWIFI_2G_Y3mu " 28 // #define STAPSK " tUPMfUKv " 29 const char *ssid =STASSID ; 30 const char *password =STAPSK ; 31 32 String username =" root "; 33 String pass =" admin "; 34 bool login =false ; 35 36 char web_page; 37 38 char requested_web_page ='\0 '; 96
39 40 bool RDdataReady =false ; 41 bool CdataReady =false ; 42 bool TdataReady =false ; 43 44 String routepro_drillpro_variables [] = {"0"," 325","0","0"," 278","0","15","2 ","0","0","","0","0","0"," No file selected "}; 45 int routepro_drillpro_arrayLength = 15; 46 47 String configuration_variables[] = {" ... " ,"05","32 ,78 "," 03 ,00 "}; 48 int configuration_arrayLength = 4; 49 50 String offset_variables[] = {"000 ,00 "," 000 ,00"," 32 ,78 "}; 51 String movement_distance =""; 52 String movement_direction =""; 53 int offset_arrayLength = 3; 54 55 int tool_arrayLengths = 15; 56 String tool_depths [] = {"00 ,00" ,"00 ,00 ","00 ,00" ,"00 ,00 ","00 ,00 ","00 ,00"," 00 ,00 ","00 ,00" ,"00 ,00 "," 00 ,00 ","00 ,00 ","00 ,00" ,"00 ,00 ","00 ,00 ","00 ,00"}; 57 String tool_iterations[] = {"01"," 01 "," 01 "," 01 "," 01 "," 01 "," 01","01","01"," 01" ,"01","01","01","01","01"}; 58 String tool_X_feeds [] = {" 0050 "," 0050 "," 0050 "," 0050 " ," 0050 " ," 0050 " ," 0050 " ," 0050"," 0050 " ," 0050 " ," 0050 "," 0050 "," 0050 " ," 0050 "," 0050 "}; 59 String tool_Z_feeds [] = {" 0050 "," 0050 "," 0050 "," 0050 " ," 0050 " ," 0050 " ," 0050 " ," 0050"," 0050 " ," 0050 " ," 0050 "," 0050 "," 0050 " ," 0050 "," 0050 "}; 60 String tool_spindles[] = {" 30000 "," 30000 " ," 30000 " ," 30000 "," 30000 " ," 30000 " ," 30000 "," 30000 " ," 30000 " ," 30000 "," 30000 " ," 30000 "," 30000 " ," 30000 " ," 30000 "}; 61 String tool_starts [] = {"..." ," ... ","... ","... "," ..."," ... " ," ... " ,"... "," ... ","... "," ..."," ... " ," ... " ," ... " ," ... " }; 62 String tool_useds[] = {" ... ","... ","... ","... "," ..." ," ... " ," ... ","... ","... ","... ","... "," ..."," ... " ," ... " ," ... " }; 63 String tool_tabs[] = {" ..." ," ... " ," ... " ," ... ","... ","... "," ..." ," ... " ," ... " ,"... ","... "," ..."," ... " ," ... " ," ... "}; 97
D.0.2 Void setup 1void setup (void ) { 2Serial.begin ( 115200 ); 3WiFi.mode (WIFI_STA ); 4WiFi.begin (ssid ,password ); 5 6server.on ("/ Login ",handleLogin); 7server.on ("/",changeWebPage ); 8server.on ("/changeWebPage",changeWebPage); 9server.on ("/handleData",handleData); 10 server.on ("/handleToolsData",handleToolsData); 11 server.on ("/handleButtonsPressed",handleButtonsPressed); 12 13 server.onNotFound (handleNotFound ); 14 server.begin(); 15 Serial.println (" HTTP server started " ); 16 } D.0.3 Void loop 1void loop (void ) { 2server.handleClient(); 3checkSerialDataAvaibleToSend(); 4} 98
D.0.4 Handle web pages 1void handleLogin(){ 2String arguments =server.arg("credentials"); 3String receivedUser =getValueFromString(arguments ,'!',0); 4String receivedPass =getValueFromString(arguments ,'!',1); 5String payload =""; 6if(receivedUser == username && receivedPass == pass){ 7payload =" correct "; 8login =true; 9}else{ 10 payload =" wrong "; 11 login =false; 12 } 13 server.send(200 , " text / plain " ,payload ); 14 } 15 16 void changeWebPage() { 17 String s =""; 18 if (login == true ){ 19 String command =server.arg(" webpage "); 20 char selector =command .charAt (0); 21 switch(selector){ 22 case 'R': 23 web_page ='R'; 24 s=ROUTEPRO_page; 25 break; 26 case 'C': 27 web_page ='C'; 28 s=CONFIG_page; 29 break; 30 case 'T': 31 web_page ='T'; 32 s=TOOLS_page; 33 break; 34 case 'L': 35 web_page ='L'; 36 s=LOAD_page; 37 break; 38 case 'B': 39 web_page ='R'; 40 s=ROUTEPRO_page; 41 break; 42 case 'O': 43 web_page ='O'; 44 s=OFFSET_page; 45 break; 46 } 47 }else{ 48 web_page ='W'; 49 s=WELCOME_page; 50 } 51 server.send(200 , " text / html " ,s); 52 } 53 54 void handleNotFound() { 55 String message =" File Not Found \n\n"; 99
56 message += " URI : "; 57 message += server.uri(); 58 message += "\ nMethod : "; 59 message += ( server.method() == HTTP_GET )?" GET " :" POST "; 60 message += "\nArguments: "; 61 message += server.args(); 62 message += "\n"; 63 for (uint8_t i =0;i<server .args() ; i++ ) { 64 message += ""+server.argName (i)+":"+server .arg (i)+"\n"; 65 } 66 server.send ( 404 , " text / plain " ,message ); 67 } 100
D.0.5 Read data 1void handleData() { 2switch(web_page){ 3case 'R': 4readData(routepro_drillpro_variables ,routepro_drillpro_arrayLength , " RouteproData "); 5RDdataReady =true; 6break; 7case 'C': 8readData(configuration_variables ,configuration_arrayLength ," ConfigurationData "); 9CdataReady =true; 10 break; 11 } 12 } 13 14 void readData (String dataArray[] , int arrayLength ,String webpage ){ 15 String webPageData =server.arg(webpage ); 16 for(int i=0;i<arrayLength;i++) { 17 dataArray[i] = getValueFromString(webPageData ,'!',i); 18 } 19 } 20 21 void handleToolsData(){ 22 String Toolsdata =server.arg("ToolsData"); 23 for(int i=0;i<tool_arrayLengths;i++){ 24 tool_depths[i] = getValueFromString(Toolsdata ,'!',i); 25 tool_iterations[i] = getValueFromString(Toolsdata ,'!',i+15); 26 tool_X_feeds[i] = getValueFromString(Toolsdata ,'!',i+30); 27 tool_Z_feeds[i] = getValueFromString(Toolsdata ,'!',i+45); 28 tool_spindles[i] = getValueFromString(Toolsdata ,'!',i+60); 29 tool_starts[i] = getValueFromString(Toolsdata ,'!',i+75); 30 tool_useds[i] = getValueFromString(Toolsdata ,'!',i+90); 31 tool_tabs[i] = getValueFromString(Toolsdata ,'!',i+105) ; 32 } 33 TdataReady =true; 34 } 35 36 void handleButtonsPressed(){ 37 String movement =server.arg("MovementAxes"); 38 movement_distance =getValueFromString(movement ,'!', 0); 39 movement_direction=getValueFromString(movement ,'!', 1) ; 40 serialSendButtons(); 41 } 101
D.0.6 Serial communication 1void checkSerialDataAvaibleToSend(){ 2if (RDdataReady == true){ 3makeRouteproDrillproPayload(); 4RDdataReady =false; 5}else if (CdataReady == true){ 6makeConfigurationPayload() ; 7CdataReady =false; 8}else if (TdataReady == true){ 9makeToolPayload(); 10 TdataReady =false; 11 } 12 } 13 14 void makeRouteproDrillproPayload(){ 15 int arrayLength =routepro_drillpro_arrayLength; 16 int values [arrayLength -1]; 17 for(int i=0;i<arrayLength -1; i++){ 18 if(i== 6 || i== 7){ 19 values[i] = routepro_drillpro_variables[i]. toFloat () *10; 20 }else{ 21 values[i] = routepro_drillpro_variables[i]. toInt(); 22 } 23 } 24 int numberOfInts =sizeof (values )/ sizeof(values[0]); 25 send_payload[0] = 0 xC3; 26 send_payload[1] = 2; 27 for(int i=0;i<numberOfInts;i++) { 28 I2B(values [i] ,2+ i*4); 29 } 30 constructFrame(send_payload ,58); 31 } 32 33 void makeConfigurationPayload() { 34 int arrayLength =configuration_arrayLength; 35 int values [arrayLength]; 36 for(int i=0;i<arrayLength;i++) { 37 values[i] = configuration_variables[i+1].toInt(); 38 } 39 int numberOfInts =sizeof (values )/ sizeof(values[0]); 40 send_payload[0] = 0 xC3; 41 send_payload[1] = 1; 42 for(int i=0;i<numberOfInts;i++) { 43 I2B(values [i] ,2+ i*4); 44 } 45 constructFrame(send_payload ,14); 46 } 47 48 void makeToolPayload(){ 49 send_payload[0] = 0 xC3; 50 send_payload[1] = 3; 51 for(int i=0;i< 5; i++) { 52 send_payload[2+i*24] = i+1; 53 I2B(tool_depths[i]. toInt () ,6+i*24); 54 I2B(tool_iterations[i]. toInt() ,10+i*24); 55 I2B(tool_X_feeds[i]. toInt () ,14+ i*24); 102