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 gather from SK40C users. Ciku comes with PIC18F4550 pre-programed with Microchip USB HID Bootloader and with this, loading program will only require a USB Mini-B cable, no extra programmer is needed. This will lower the cost needed to get the start. In this tutorial, I will show how to integrate CIKU with Shield 2A motor and 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. After downloaded finish, please proceed with the installation. Install the MPLAB X IDE first followed by XC8 compiler. If you are new to this software, you can refer to Getting Started with MPLAB X IDE tutorial.

3. Download the CIKU library.

CIKU comes with the library where you can easily write a coding like Arduino style. You can get the updated library here. After downloaded finish, extract to your PC and please remember the folder path. You can refer to this link for CIKU library reference.

*Note: You will need to have a Gmail account. To download it you need to add to your Google Drive first, then you can proceed with the download.

1                   2

 

4. Power up the CIKU board.

CIKU board will automatically draw power from either USB connection to the computer OR external power supply. To start, just connect your CIKU board to your laptop/computer using 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 CIKU board, you need to build it first. Click on the “Build Project” icon (hammer) and make sure there have no errors. It will display BUILD SUCCESSFUL.

cikubuild

 

9. Enter the bootloader mode.

Before uploading the program to CIKU board, we need to make sure that the CIKU is in the 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 is already entered the bootloader mode.
*You can refer to video.
*Please be remind that the bootloader only can be entered when there has a USB connection between your CIKU board and your PC.

10. Upload the program to CIKU board.

Open HIDBootloader.exe (..\Bootloader Software\win\HIDBootloader.exe). 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”. So make sure your CIKU board is in bootloader mode. 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.After 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:

[code]#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);
}[/code]

 

REFERENCE:

ATTACHMENT:

Buy

, , , , , , , , ,

Related Post

Control and Monitor via SMS Part 2

How to Make your Line Following Robot Faster?

DC Motor

How to choose a suitable DC motor?

PIC16F VS PIC18F:Analysis of PIC Mid-Range 8 bit family and Advanced 8-bits Family

Leave a Reply

Your email address will not be published. Required fields are marked *