Ks0096 keyestudio CNC Kit / CNC Shield V4.0 + Nano 3.0+3pcs a4988 Driver / GRBL Compatible

From Keyestudio Wiki
Jump to navigation Jump to search
KS0096---v4 雕刻机套件(4988 有散热片) (3).jpg

Introduction

keyestudio CNC Shield V4
Keyestudio CNC shield v4.0 needs to work with Keyestudio nano ch340 . It can be used as driver expansion board for engraving machines. It has in total 3 channel slots for A4988 stepper motor driver modules (not included) for driving 3 channel of stepper motors. Each channel of stepper motor only needs 2 IO ports, which means 6 IO ports is sufficient to manage 3 stepper motors. This shield can make quick work for managing stepper motors in your project.

keyestudio nano ch340
keyestudio nano ch340 controller is a small, complete board based on the ATmega328. It’s a open source Simple I/O platform with 12 Digital I/O Pins (of which 6 provide PWM output), 8 Analog Input Pins, pin 0 (RX) and 1 (TX) used to receive (RX) and transmit (TX) TTL serial data, a Mini-B USB connection, an ICSP header and a reset button.


Specification

1.3 axis stepper motor driver
2.Compatible with micro-drive laser engraving machine, three-axis CNC engraving machine.
3.2A can be controlled within the two-phase four-wire stepper motor.
4.Released the digital IO interface, easy to connect to other modules, such as ENDSTOP.
5.Released the I2C interface, you can connect to the LCD I2C or other I2C module.
6.power DC5v interface, 7.5-12V voltage input.
7.GRBL compatible
8.worked with arduino nano.


Kit list

  • 1x CNC Shield V4.0
  • 1x nano board
  • 3x A4988 driver
  • 1x USB cable


Connection Diagram


thumb


Adjusting the drive current

In the kit, we have applied the A4988 drive module to drive stepper motor. When using, you can turn the potentiometer on the drive module to adjust the drive current.
The specific method please refer to the website link below:
https://wiki.keyestudio.com/Ks0281_Keyestudio_Reprap_Stepper_Motor_Driver



Step1| Download the Arduino IDE

When getting this control board, we need to install Arduino IDE.

Enter the website https://www.arduino.cc/,click0173--1.png and 0173--2.png
0173--3.png

Select versions you want to download, the latest version could be downloaded.
0173--4.png

Alternatively, you could select previous release.
In this project, we use 1.8.12 version.
0173--5.png


ClickKS0173----13.png to view the below page
KS0173----14.png


Click 0173--6.pngto download an installer of Arduino 1.8.12 version,which needs to be installed manually. When you tap 0173--7.pnga zip file of Arduino 1.8.12 version will be directly downloaded, and you only need to unzip it to finish installation.
0173--8.png

Click icon0173--9.pngto download Arduino IDE.


Introduction for Arduino IDE Toolbar

Double-click the icon of Arduino software downloaded well, you will get the interface shown below.
989898.png
(Note: if the Arduino software loads in the wrong language, you can change it in the preferences dialog. See the environment page for details.)
KS0173----0.png

The functions of each button on the Toolbar are listed below:
IDE.png

IDE 1.png Verify/Compile Check the code for errors
IDE 2.png Upload Upload the current Sketch to the Arduino
IDE 3.png New Create a new blank Sketch
IDE 4.png Open Show a list of Sketches
IDE 5.png Save Save the current Sketch
IDE 6.png Serial Monitor Display the serial data being sent from the Arduino








(2) Install Driver Software

The driver will be installed after downloading Arduino IDE.

If your system is Windows 10, the computer will automatically install driver. For other systems, like Windows7, we need to install driver manually. The USB to serial chip of control board is CH340G, therefore, we will install the driver(usb_ch341_3.1.2009.06) for it. Connect control board to computer with USB cable. Click Computer----- Properties----- Device Manager, as shown below:


Ks0354 driver 1.png

Then right-click on the USB2.0-Serial and select the top menu option (Update Driver) shown as the figure below.


0096---1.png

Then it will be prompted to either“Search automatically for driver ” or “Browse my computer for drivers”. Shown as below. In this page, select “Browse my computer for drivers”.


Ks0354 driver 3.png

After that, select the option to browse and navigate to the “drivers” folder of usb_ch341_3.1.2009.06 installation.


0096---2.png

Once the software has been installed, you will get a confirmation message. Installation completed, click“Close”.


0096---3.png


Up to now, the driver is installed well. Then you can right click “Computer” —>“Properties”—>“Device manager”, you should see the device as the figure shown below.


KS0173----1.png

Step3| Connect the board

Connect the NANO board to your computer using the USB cable. The power LED should go on.
KS0173-2.png

Step4| Select the Arduino Board

Open the Arduino IDE, you’ll need to click the “Tools”, then select the Board that corresponds to your Arduino.
Ks0313图片1.png

KS0173----2.png


Step5| Setting IDE for new bootloader

Arduino Nano board could burn new and old bootloader. New bootloader is only compatible with 1.8.9 IDE and above. Yet the old one is compatible with all versions.


KS0173----3.png


Step6| Select your serial port

Select the serial device of the Arduino board from the Tools | Serial Port menu. Note: to avoid errors, the COM Port should keep the same as the Ports shown on Device Manager.


KS0173----1.png

KS0173----5.png


Step7| Upload the Code

Below is an example code for displaying the Hello World! Copy and paste the code to the Arduino environment IDE.

///////////////////////////////////////////////////////////////////////////////////////////////
int val; 
int ledpin=13; 
void setup()
{
Serial.begin(9600); 
pinMode(ledpin,OUTPUT);
}
void loop()
{
val=Serial.read();
if(val=='R')
{
digitalWrite(ledpin,HIGH);
delay(500);
digitalWrite(ledpin,LOW);
delay(500);
Serial.println("Hello World!");
}
}
///////////////////////////////////////////////////////////////////////////////////////////////



KS0173----6.png

Then click verify button to check the errors. If compiling successfully, the message "Done compiling." will appear in the status bar.
KS0173----7.png

KS0173----8.png

After that, click the “Upload” button to upload the code. If the upload is successful, the message "Done uploading." will appear in the status bar.
KS0173----9.png

KS0173----10.png



Step8| Open the Serial Monitor

After that, click the button to open the serial monitor.
KS0173----11.png

Then set the baud rate to 9600, enter an “R” and click Send, that is, the computer will send the character R. When NANO board receives it, you should see the RX led on the board flash once, and then D13 led flash once; when keyestudio NANO board sends "Hello World!" to the computer, finally you should see the "Hello World!" is showed on the monitor, and TX led on the board flash once.
KS0173----12.png





Using Method

Test Main Board

First, write below code in IDE to test whether main board, shield and three motors work normally.

Explanation
1. If you properly reduce the value 800 in delayMicroseconds(800) to increase the frequency of input PWM signal, you can increase the rotation speed of stepper motor. The change of value cannot be too much or the motor will stop moving.
2. Rotate the knob on A4988, you can adjust the output current of the motors to change the torque.

Code

#define EN        8       // stepper motor enable, low level effective
#define X_DIR     5       //X axis, stepper motor direction control 
#define Y_DIR     6       //y axis, stepper motor direction control
#define Z_DIR     7       //z axis, stepper motor direction control
#define X_STP     2       //x axis, stepper motor control
#define Y_STP     3       //y axis, stepper motor control
#define Z_STP     4       //z axis, stepper motor control
/*
// Function: step   -control the direction and number of steps of the stepper motor
// Parameter: dir  -direction control, dirPin corresponds to DIR pin, stepperPin correspomds to 


step pin, steps is the number of steps.
// no return value
*/
void step(boolean dir, byte dirPin, byte stepperPin, int steps)
{
  digitalWrite(dirPin, dir);
  delay(50);
  for (int i = 0; i < steps; i++) {
    digitalWrite(stepperPin, HIGH);
    delayMicroseconds(800);  
    digitalWrite(stepperPin, LOW);
    delayMicroseconds(800);  
  }
}
void setup(){// set the IO pins for the stepper motors as output 
  pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
  pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
  pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
  pinMode(EN, OUTPUT);
  digitalWrite(EN, LOW);
}
void loop(){
  step(false, X_DIR, X_STP, 3200); // x axis motor rotates CCW for 1 circle, as in 200 steps
  step(false, Y_DIR, Y_STP, 3200); // y axis motor rotates CCW for 1 circle, as in 200 steps
  step(false, Z_DIR, Z_STP, 3200); // z axis motor rotates CCW for 1 circle, as in 200 steps
  delay(1000);
  step(true, X_DIR, X_STP, 3200); // X axis motor rotates CW for 1 circle, as in 200 steps
  step(true, Y_DIR, Y_STP, 3200); // y axis motor rotates CW for 1 circle, as in 200 steps
  step(true, Z_DIR, Z_STP, 3200); // z axis motor rotates CW for 1 circle, as in 200 steps
  delay(1000);
}


Install Firmware and Grbl Controller


a. Write test program to keyestudio nano ch340 copy the folder GRBL_

Arduino_Library_keyes in the data packet  and paste it into to the folder libraries, in your Arduino IDE document installation.

How to import library:

https://wiki.keyestudio.com/How_to_Install_Arduino_Library

Code:

#include <grblmain.h>
void setup(){
startGrbl();
}
void loop(){}
//Burn the code above to keyestudio nano ch340


b. Install GrblController361 Software
Grbl Controller is a piece of software which is used to send GCode to CNC Machines. Run Grbl Controller361 Setup in your installation packet, the interface below will come out:

Click Next to continue.
thumb

For a license agreement, please check I accept the agreement and click Next.
thumb

When you are ready to continue with Setup, click Next.
thumb

To continue, click Next. If you would like to select a different folder to install, click Browse.
thumb

To continue, click Next. If you would like to select a different folder to place program’s shortcuts, click Browse.
thumb

Select the additional tasks you would like Setup to perform while installing Grbl Controller, then click Next.
thumb

Click Install to continue with the installation.
thumb

Click Next.
thumb

At last, click ”Finish” to finish the installation.
thumb


c. Test G-Code on Grbl Controller
Power the main board using a USB cable and connect correctly all your external devices, then run Grbl Controller.
Choose Port name the same as IDE COM port and click “Open” to open the series port, connecting CNC Machines with computer.

thumb

After opening the series port, the “Open” button change into “Close/Reset” and get red!
At this time you can click the X axis、Y axis、Z axis as shown in below diagram to adjust the motion direction of motors.

thumb

Notes: after adjusting the axies, before beginning G-Code file, you must close and open again .
Now, it is time to have a try! Click ”Choose file” to choose one G-Code file named cn. to test in the data packet for a beginner, and the interface will come out:
GrblController.
thumb

Click “Begin” , and you can see how the motors move on coordinates.



Resources

GRBL_Arduino_Library_keyes (Firmware) Download
https://drive.google.com/open?id=1JzJwVoO0xkxWDXvDlgE8X8atBzl2SJdw
Driver usb_ch341_3.1.2009.06 Download
https://drive.google.com/open?id=1FJ2beDCUNKTNzWsCGDx7JyI_ZDRCl_ry
G-Code for Testing Download
https://drive.google.com/open?id=1BWS4MXaZ-xCg5v_bz4NP3lxg9tbOuZ4r
Grbl Controller361 Setup Download
https://drive.google.com/open?id=1JSCtHr7FLF7UMxXeVGpwMbWn3BVZo7jh

PDF:
https://drive.google.com/open?id=1KBUZFZUAur71cUTBaiqWdkmQPUyjECxK

VIDEO:
http://video.keyestudio.com/KS0096/



Buy from