StepperUNO Library 1.4
- 1 Installation
- 2 Download
- 3 Configuration
- 4 Function list
- 4.1 Keypad
- 4.2 Motor Control
- 4.2.1 void set_speed(uint16_t step_delay)
- 4.2.2 uint8_t set_speed_rpm(float rpm)
- 4.2.3 void setDirection(bool dir);
- 4.2.4 void enable();
- 4.2.5 void disable();
- 4.2.6 void step();
- 4.2.7 void start();
- 4.2.8 void stop()
- 4.2.9 void brute_stop()
- 4.2.10 void begin(uint8_t _address, uint16_t n_step)
- 4.2.11 void goto_position(int32_t goto_position)
- 4.2.12 void set_position(int32_t new_position)
- 4.2.13 int32_t get_position()
- 4.2.14 void set_acceleration(int16_t Acc)
- 4.2.15 void acceleration_on()
- 4.2.16 void acceleration_off()
- 4.2.17 bool running
- 4.2.18 bool direction
- 4.2.19 float min_rpm
- 4.2.20 float rpm
- 4.2.21 uint16_t step_delay
- 4.2.22 bool acceleration
Download the zip file from Stepper_UNO_v1.0#Files.
Copy the StepperUNO folder in the sketchbook/library directory.
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.
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.
This function should be called as often as possible. Typically inside the main loop. This will update the Keypad.state variable with one of the defined event below.
#define PRESSED_NONE 0 #define PRESSED_RIGHT 1 #define PRESSED_UP 2 #define PRESSED_DOWN 3 #define PRESSED_LEFT 4 #define PRESSED_SELECT 5 #define RELEASED_NONE 6 #define RELEASED_RIGHT 7 #define RELEASED_UP 8 #define RELEASED_DOWN 9 #define RELEASED_LEFT 10 #define RELEASED_SELECT 11
Note this function does not manage the RST button. Use RstReadKey instead.
Same as above but for the RST button only.
The RST button is a special case. It has its own pin to the arduino mcu.
#define PRESSED_RST 12 #define RELEASED_RST 13 #define LONG_PRESSED_RST 14 #define LONG_RELEASED_RST 15
On a conventional Arduino UNO these LCD keypad will connect the RST button directly to the reset of the arduino. This is a waste in our opinion and we have re-routed this button for using it on something more useful.
Event state. Will be equal to one of the define listed above once an event has occurred.
Same as state but for the RST button only.
Must be called once all action have been executed for a given event.
Must be called once all action have been executed for a given event on the RST button.
void set_speed(uint16_t step_delay)
Set the motor speed.
step_delay is the delay between steps in microseconds.
uint8_t set_speed_rpm(float rpm)
Set the motor speed.
rpm is the rotation speed.
This function will check for minimum speed to avoid a step_delay larger than 65535. Returns 0 is successful. 1 otherwise.
void setDirection(bool dir);
Set the direction.
Enable the motor. Holds torque on the motor.
Disable the motor. Allows the motor to spin freely.
Perform one single step.
Stop the motor.
Stop the motor. Will slow down and stop if acceleration is on.
Stop the motor immediately regardless of acceleration.
void begin(uint8_t _address, uint16_t n_step)
Initialiser to be used in Setup section of Arduino. address parameter is the i2c address of the motor controller. Usually 0x04 or 0x05.
n_step is the number of steps per revolution the motor executes. See relevant datasheet. This should be modified accordingly if microstepping.
void goto_position(int32_t goto_position)
Move motor to the given position. 'goto_position' is the position in terms of step number.
void set_position(int32_t new_position)
Modify set position. This is similar as setting the tare.
Returns current motor position.
void set_acceleration(int16_t Acc)
Set the acceleration level. Default is 1000step/s/s.
Set acceleration on.
Set acceleration off.
Indicates if the motor is running.
Indicates the motor direction.
Inform the smallest rpm that can be used. Calculated when begin() is called.
Current speed in rpm. This is only valid if the set_speed_rpm function is used.
Step delay currently used. This is updated when calling set_speed() and set_speed_rpm().
Inform if acceleration is On or off.