Posted in IOT (Internet Of Things)

A PLC (Program Logic Controller) that Talks and Sends Email

The following project occupied my time for a couple of weeks.  It required learning how to use a PLC (Program Logic Controller);  do embedded programming on the Arduino platform; send email using IOT (Internet of Things) 8266-12E Wifi Chip.  The project was fun and rewarding. but most of all would enhance the user experience of the CNC Mill.

After working with the CNC mill, you will discover that engraving patterns on wood takes a long time.   One pattern took about 3 hours to complete.  There is no need for me to watch the machine for 3 hours, but I needed to know when the job was done so I can turn off the machine.   Leaving the machine running by itself with a sharp router bit turning is dangerous and asking for disaster to happen.  So I needed a device that would detect when the CNC job was done and would notify me by email.

The project used an “Open Source” PLC to detect when the mill completed a job.   When a job completed, the PLC would play a loud message telling anyone in the vicinity that the job was done.  Next the PLC would tell the 8266 Wifi Internet chip to send an email notification to me.  If I was in the shop, I would know the jobs was done because I can hear the message.  Also, if I was not in the shop, I would know the job was done, by checking my email.

The PLC and 8266 Wifi Chip.

The PLC was purchased from Digital Loggers via Amazon.

https://www.amazon.com/enabled-Powerful-durable-Ardino-compatible/dp/B01BFV7O1U/ref=sr_1_1?ie=UTF8&qid=1491885779&sr=8-1&keywords=plc

The PLC is based on the Arduino Mega2650 which contains the following devices

  • Speakers
  • A touch screen,
  • LCD display.
  • ESP8266 Wifi chip, but we used another 8266 Dev Kit.
  • Digital and Analog Input/Outputs.
  • Relays.
  • Card reader
  • Serial and USB ports.

The NodeMCU LUA WiFi Internet ESP8266 Dev Kit was added to the project.  The ESP8266 on the PLC was not used, because the Dev Kit was more advanced.  The kit was purchased from HiLetGo via Amazon.

https://www.amazon.com/HiLetgo-Version-NodeMCU-Internet-Development/dp/B010O1G1ES/ref=sr_1_1?ie=UTF8&qid=1491886314&sr=8-1&keywords=hiletgo

Setting up the KFLOP to control GPIO.

The CNC machine communicates to the PLC by hooking up an output of the CNC machine to an input of the PLC.  The CNC machine was configured so that the command M30 would set the IO26 state HIGH when executed.  Also the PLC was programmed to detect the state of the input signal.  The KMotionCNC.exe application allows you the configure the IO as shown below;

Also you must also modify the InitKStep3Axis.c program for the KFLOP to configure IO26 bit.  The program is located under C:\KMotion433\C Programs\KStep directory.  If you are using the PWM to control your servos, you will need to change a different program.

You need to add the 2 lines of code.

SetBitDirection(26,1);  // set Enable Signal as Output
SetStateBit(26, 0);        // the Signal is set LOw

Here is the code program that executes the M30 command.  The program was shortened for demonstration purposes.

When command is executed, the KFLOP will set the output state to HIGH.

Setting up the CNC Mill to the PLC and the 8266 NodeMcu Dev Kit

The setup is made up of the

  • PLC
  • 8266 NodeMcu Dev Wifi Internet Kit
  • Phone to detect the email.
  • A 3.3 V volt regulator was used, because the GPIO pins on the PLC and 8266 can only handle 3.3V signal levels.

In other words if you use a higher voltage, you will damage the part.  Do not use 5v on the 3.3v GPIO.

Theory of Operation

Hopefully this is the simplest explanation.  The PLC is connected to the CNC mill via GPIO (General Purpose Input Output).  To send email, the PLC sends a signal to the 8266 Nodemcu Dev Kit.  The implementation incorporates the following steps.

  1. After the CNC mill has finished a job, the G-Code program executes M30 to send a signal to the PLC.
  2. The PLC detects when the signal goes HIGH, then the PLC sends a signal to the 8266.
  3. The 8266 detects when the signal goes HIGH, then the 8266 logins into the Wifi and sends the email notification.

Connecting the KFLOP to PLC

To connect the KFLOP GPIO to the PLC, simply use a 2 conductor wire.  One side goes to ground of the KFLOP and PLC.  The other side goes from JP6 pin 5 (IO26) to IN-31 of the PLC.  When the signal changes the state from LOW to HIGH, the PLC plays a message “Your CNC job is done.  Please check your email for the notification.  Thanks you”.  The message ends with the Ferris Bueller “Oh Yeah”

Connecting the PLC to 8266 NodeMcu Dev Kit

To connect the PLC to the 8266, simply connect Digital Output 38 of the PLC to the Digital Input 16 which is connected to pin D0.

References for the NodeMCU-DEVKIT-V1.0 (8266-ESP12E based).

There are infinite number of the references on the chip but I will show a few.  The dev kit was less than $10 dollars on the Amazon.  I started using the ESPlorer and then moved on the Arduino.  There are many libraries implemented by the Arduino.

  1. NodeMCU-DEVKIT-V1.0 – https://github.com/nodemcu/nodemcu-devkit.
  2. Tutorial for the 8266 – http://www.kloppenborg.net/blog/microcontrollers/2016/08/02/getting-started-with-the-esp8266.
  3. Tutorial to setup the Arduino IDE to develop software on the 8266-http://www.instructables.com/id/Programming-ESP8266-ESP-12E-NodeMCU-Using-Arduino-/

A Video of a PLC (Program Logic Controller) that Talks and Sends Email

Hope you like the video.

Posted in CNC Router

DIY CNC Engraving with the KFLOP and CAMBAM

Hello, I am back again.  I was side-tracked working on an Open Sourced PLC which I will cover in another post.  This post is about engraving patterns using your DIY CNC Mill with the KFLOP and CAMBAM.  CAMBAM has a feature to engrave patterns easy by simply opening a bitmap into CAMBAM.  It is so easy, a Caveman can even do it.  When you open a bitmap in CAMBAM, CAMBAM converts the edges in the image to a polyline.  I have provided the instructions and video to do the engravings.

How to open an Image in CAMBAM.

In this section I used the Boston Marathon logo as an example.  The logo looked like a fun project to do.  Also, I am a runner.  My wife and I ran the marathon in 2013.  Here are the following steps.

Step 1. Open the image from the “HeightMap Generator” under the CAMBAM “Plugins” menu as shown below;

Step 2.   Open the image into CAMBAM

Step 3.  Set your “HeightMap Generator” options.

Be aware that the XStep and YStep size are important.  The smaller size produces a better engraved image, but it takes the machine longer to carve the pattern.  A 4″ x 4″ piece of wood with a 0.04″ step size and feedrate 6″ inch/min will take about 2 hours.  With a 0.02″ step size, the same part will take over 3 hours.  This blog will show the difference between the engravings.

 

Step 4.  Generate the HeightMap

Step 5.  Generate the Tools paths and G-Code.

Video of CAMBAM generating G-Code from a Bitmap.

The video below will show you how to generate G-Code from the “HeightMap Generator” in CAMBAM.

 

 

Video of the CNC Mill engraving the Image on wood.

This video shows how the machine engraves the Boston Marathon Logo on the a CNC machine.  The CNC machine is using the Dynomotion KFLOP to perform the engraving

.  CAMBAM generated the G-Code from a Bitmap.

Final Products.

Before, I engraved the Boston Marathon Logo, I started with a business card to test the first engraving.  I took a photo of the business card and converted it to a black/white bitmap.  The black/white bitmap seemed work better than the color.

The business card is from Run 26 which is a running store in Mill Creek Washington.  If you want to get in shape for long distance running, this is the store.  They can help you select the right gear for you to start running.  They cater to all runners;  fast and slow, old and young.  The owner is a awesome and knowledgeable coach.

Engraving with different Step sizes.

The step size determine the quality of the engraving.  The image on the left was engraved with the steps sizes set to 0.04″ for both X and Y.  The image on the right was used 0.02″ for both X and Y, but took over 3 hours.  The engraving process was stopped after 3 hours.  It would have taken another hour.

If you have any questions or comments please contact us.

Also best of luck to the runners in the Boston Marathon tomorrow April 17, 2017.