Bukit Mertajam, Penang

Simple steps to control Stepper Motor using 2Amp Motor Driver Shield and CIKU

INTRODUCTION:

CIKU is born from the experiences of using Arduino and feedback we gathered from SK40C users. Ciku comes with PIC18F4550 pre-programed with Microchip USB HID Bootloader and with this, loading program only requires a USB Mini-B cable, no extra programmer is needed. This will lower the cost needed to get started. In this tutorial, I will show how to integrate CIKU with 2A Motor Driver Shield and a stepper motor.

IMG_20160128_122018

 

 

HARDWARE REQUIRED:

  1. CIKU
  2. USB Mini Cable (2.0)
  3. Adapter 12V 2A
  4. 2 Amp Motor Driver Shield
  5. Bipolar Stepper Motor or Unipolar Stepper Motor

 

SOFTWARE REQUIRED:

Please refer to “Getting Started with CIKU” tutorial.

 

SUGGESTED READING:

  1. How Does Stepper Motor Works – Part 1
  2. How Does Stepper Motor Works – Part 2

 

HARDWARE SETUP:

102441

1. Get a CIKU board, 2Amp Motor Driver Shield, Jumper wires and USB cable

You will need a CIKU board, 2Amp Motor Driver, Jumper wires and USB MiniB Cable (2.0) to start.

2. Download the MPLAB X IDE and XC8 compiler

Download the MPLAB X IDE latest version here and XC8 compiler here. Install the MPLAB X IDE first, followed by XC8 compiler. If you are new to MPLAB, you can refer to Getting Started with MPLAB X IDE tutorial.

3. Download the CIKU library.

CIKU comes with the library that allows you to code it with Arduino’s style. You can get the updated library here, download and extract it to your PC and remember the folder path for later use. You can refer to this link for CIKU library reference.

*Note: You will need to have a Gmail account because you need to add it to your Google Drive first before dowloading.

1                   2

 

4. Power up the CIKU board.

CIKU board will automatically draw power from either the USB connection from the computer OR from an external power supply. To start, just connect your CIKU board to your laptop/computer using a USB cable. The PWR LED (green) will turn ON, to indicate the board is being powered, also the RUN LED (red) will turn ON to indicate the board is in the user mode.

ciku 6

 

ciku 7

5. Connect the CIKU and 2Amp Motor Driver together.

 

IMG_20160128_121940

6.Connect the stepper motor to the CIKU using jumper wires. For wiring details please refer to the datasheet.

IMG_20160128_122018

7. Open CIKU project.

Open MPLAB X IDE. Go to “File – Open Project…”, point to CIKU library that you have downloaded and open CIKU.X. Under Projects tab, you can open User-Template.c (CIKU – Source Files – user – User-Template.c) to see the user code.

cikumplab

 

8. Build CIKU project.

Every time you edit the code and want to upload the program to the CIKU board, you need to build it first. Click on the “Build Project” icon (hammer) to make sure there are no errors. It should display BUILD SUCCESSFUL.

cikubuild

 

9. Enter the bootloader mode.

Before uploading the program to CIKU board, make sure that CIKU is in bootloader mode. To enter the bootloader mode, simply press SW button (and hold), then press the RESET button (and release), then release the SW. The RUN LED (red) will blink to indicate the CIKU board has entered the bootloader mode.
*You can refer to video.
*Please be remind that the bootloader only can be entered when your CIKU board is connected to your PC.

10. Upload the program to CIKU board.

Open HIDBootloader.exe (..\Bootloader Software\win\HIDBootloader.exe). Again, make sure your CIKU board is in bootloader mode: If your CIKU board is in bootloader mode it will display “Device Attached”, but if your CIKU board is in user mode it will display “Device not detected”. Click on the “Import Firmware Image” icon and open your HEX file (..\CIKU.X\dist\default\production\CIKU.X.production.hex).

cikuupload1

11.Then click the “Erase/Program/Verify Device” icon. This state will upload the program to CIKU board.

cikuupload2

12. Once done uploading, click on the “Reset Device” icon to enter the user mode. Now your LED on CIKU board should blink. Done!

cikuupload3

 

Circuit diagram:

Untitled Sketch_bb

CODE OVERVIEW:

#include "Arduino.h"
#include "Shield2AMotor.h"

void setup()
{
pinMode(LED, OUTPUT); //onboard LED as output
pinMode(SW, INPUT); //onboard SW as input

Shield2AMotor_begin(STEPPER, LSS05_DISABLE);
delay(3000);
}

void loop()
{
Shield2AMotor_waveDrive(200, CCW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);
Shield2AMotor_waveDrive(200, CW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);

Shield2AMotor_fullDrive(200, CCW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);
Shield2AMotor_fullDrive(200, CW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);

Shield2AMotor_halfStepDrive(400, CCW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);
Shield2AMotor_halfStepDrive(400, CW, 10); //360 degree rotation using 1.8° stepper motor
delay(1000);
}

 

REFERENCE:

ATTACHMENT:

Buy

Related Posts

Comments (1)

sir
i am searching a single driver which could control 7 stepper motor, 3 solenoid valve and
150 watt heater 2 nos.
if you suggest i am interested to purchase in qty.
pl let me know about this driver

best regards
yatinsane
+91 9867970836

Leave a comment