CIKU + Stepper Motor + 2Amp Motor Driver Shield

DSC_0010

HARDWARE

  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

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

10244

  1. Connect the stepper motor to the motor driver shield. 1 unipolar or bipolar stepper motor need to use both motor 1 and motor 2 connector to drive it in bipolar method (4 connection are needed). You can refer finding the proper wiring sequence for detail explanation at How Does Stepper Motor Works – Part 2
  2. Make sure Motor Driver Shield is using Signed Magnitude  mode.

CIKU 2A MOTOR DRIVER SHIELD LIBRARY FUNCTION

Below is a list for basic 2Amp Motor Driver Shield function that you can used with CIKU. You also can refer to the Shield2AMotor.h that can be download at the bottom of this page.

// Shield2AMotor_begin
// mode: SIGNED_MAGNITUDE/LOCKED_ANTI_PHASE/STEPPER
// sensor: LSS05_ENABLE/LSS05_DISABLE
void Shield2AMotor_begin(BOOL mode, BOOL sensor);
// Shield2AMotor_control
// motor1Speed: 0 - 100
// motor2Speed: 0 - 100
// *minus value will have different direction from positive value
void Shield2AMotor_control(INT16 motor1Speed, INT16 motor2Speed);
// Shield2AMotor_readLSS05
// return status for every IR sensor
// bit 1 represent 'detect line', and vice versa.
// e.g. 0b00100 means middle IR sensor detect black line
// e.g. 0b10000 means most left IR sensor detect black line
// e.g. 0b00001 means most right IR sensor detect black line (next to Cal. push button)
BYTE Shield2AMotor_readLSS05(void);
/*************** STEPPER MOTOR FUNCTION ***************/
// Shield2AMotor_waveDrive
// pulse: 0 - 65535 (unsigned int)
// CW_CCW: CW/CCW
// speed_ms: delay for every pulse (in miliseconds)
void Shield2AMotor_waveDrive(UINT16 pulse, UINT8 CW_CCW, UINT16 speed_ms);
// Shield2AMotor_fullDrive
// pulse: 0 - 65535 (unsigned int)
// CW_CCW: CW/CCW
// speed_ms: delay for every pulse (in miliseconds)
void Shield2AMotor_fullDrive(UINT16 pulse, UINT8 CW_CCW, UINT16 speed_ms);
// Shield2AMotor_halfStepDrive
// pulse: 0 - 65535 (unsigned int)
// CW_CCW: CW/CCW
// speed_ms: delay for every pulse (in miliseconds)
void Shield2AMotor_halfStepDrive(UINT16 pulse, UINT8 CW_CCW, UINT16 speed_ms);

USER CODE

This example code shows related function that you can used in order to drive stepper motor. You also can see this code on User-Stepper.c file that can be download at the bottom of this page.

#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);
}

NOTE

If you want to compile User-Stepper.c, under MPLAB X IDE, first please remove the User-Template.c (CIKU – Source Files – user). Right click on User-Template.c and select Remove From Project. Then, right click on user folder (CIKU – Source Files), choose Add Existing Item…, open User-Stepper.c, and proceed with Build Project.

Buy

,

Related Post

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

Line following robot CT-ARM

Line Following Robot with CT-ARM

Colour Tracking Mobile Robot (PIXY)

Controlling Mobile Robot via Android Bluetooth