StepperUNO Library 1.1: Difference between revisions

From lechacal
Jump to navigation Jump to search
 
(14 intermediate revisions by the same user not shown)
Line 3: Line 3:


=Installation=
=Installation=
Download the zip file.<br>
Download the zip file from [[Stepper_UNO_v1.0#Files]].<br>
Copy the StepperUNO folder in the sketchbook/library directory.<br>
Copy the StepperUNO folder in the sketchbook/library directory.<br>


=Configuration=
=Configuration=
Open the config.h file in the library/stepperUNO folder.<br>
Open the config.h file in the library/stepperUNO folder.<br>
Change the KEYPAD_VERSION value as needed. Value should be 1 or 2. If you do not know just try one or the other and see how the button reacts.
Change the KEYPAD_VERSION value as needed. Value should be 0 1 or 2. If you do not know just try one or the other and see how the button reacts.


=Function list=
=Function list=
==Keypad==
==Keypad==
If the keypad does not reply correctly on the left/right/up/down/select button then a calibration should be performed. Values should be changed in the .h file of the library.
===uint8_t ReadKey();===
===uint8_t ReadKey();===
Return which key is currently pressed.
Return which key is currently pressed.
Line 24: Line 24:
  #define BUTTON_LEFT              4  //  
  #define BUTTON_LEFT              4  //  
  #define BUTTON_SELECT            5  //
  #define BUTTON_SELECT            5  //
Note. The RST button uses a different function.


===bool RstReadKey();===
===bool RstReadKey();===
Line 41: Line 43:
//this will be true after a ReadButtons() call if triggered
//this will be true after a ReadButtons() call if triggered
===bool rstbuttonLongPress;===
===bool rstbuttonLongPress;===


==Motor Control==
==Motor Control==
Line 50: Line 51:


===void setDirection(bool dir);===
===void setDirection(bool dir);===
Set the direction.
===void enable();===
===void enable();===
Enable the motor. Holds torque on the motor.
===void disable();===
===void disable();===
Disable the motor. Allows the motor to spin freely.
===void step();===
===void step();===
Perform one single step.
Perform one single step.
Line 59: Line 67:


===uint8_t address;===
===uint8_t address;===
i2c address of the MCU controlling the motor. Usually 0x04 or 0x05.
===void begin(uint8_t _address);===
===void begin(uint8_t _address);===
Initialiser to be used in Setup section of Arduino. address parameter is the i2c address of the motor controller. Usually 0x04 or 0x05.
===bool running;===
===bool running;===
Indicate if the motor is running.
Indicates if the motor is running.


===bool direction;===
===bool direction;===
Indicate the motor direction.
Indicates the motor direction.
 
=State variables=

Latest revision as of 17:13, 3 March 2021

under construction...

Installation

Download the zip file from Stepper_UNO_v1.0#Files.
Copy the StepperUNO folder in the sketchbook/library directory.

Configuration

Open the config.h file in the library/stepperUNO folder.
Change the KEYPAD_VERSION value as needed. Value should be 0 1 or 2. If you do not know just try one or the other and see how the button reacts.

Function list

Keypad

If the keypad does not reply correctly on the left/right/up/down/select button then a calibration should be performed. Values should be changed in the .h file of the library.

uint8_t ReadKey();

Return which key is currently pressed.

Keys are defined as below:

#define BUTTON_NONE               0  // 
#define BUTTON_RIGHT              1  // 
#define BUTTON_UP                 2  // 
#define BUTTON_DOWN               3  // 
#define BUTTON_LEFT               4  // 
#define BUTTON_SELECT             5  //

Note. The RST button uses a different function.

bool RstReadKey();

Return if the RST button is pressed or not.

The RST button is a special case. It has its own pin to the arduino mcu.

bool buttonJustPressed;

//this will be true after a ReadButtons() call if triggered

bool buttonJustReleased;

//this will be true after a ReadButtons() call if triggered

bool rstbuttonJustPressed;

//this will be true after a ReadButtons() call if triggered

bool rstbuttonJustReleased;

//this will be true after a ReadButtons() call if triggered

bool rstbuttonLongPress;

Motor Control

void speed(int speed_m1);

Set the motor speed.

speed_m1 must be the delay between each step in milliseconds.

void setDirection(bool dir);

Set the direction.

void enable();

Enable the motor. Holds torque on the motor.

void disable();

Disable the motor. Allows the motor to spin freely.

void step();

Perform one single step.

void stop();

Stop the motor.

uint8_t address;

i2c address of the MCU controlling the motor. Usually 0x04 or 0x05.

void begin(uint8_t _address);

Initialiser to be used in Setup section of Arduino. address parameter is the i2c address of the motor controller. Usually 0x04 or 0x05.

bool running;

Indicates if the motor is running.

bool direction;

Indicates the motor direction.