Example: control a stepper motor. More...
#include "BBB/pruio.bi"
#include "BBB/pruio_pins.bi"
Go to the source code of this file.
Macros | |
#define | P1 /* P8_08 */ |
The first pin of the stepper. | |
#define | P2 /* P8_10 */ |
The second pin of the stepper. | |
#define | P3 /* P8_12 */ |
The third pin of the stepper. | |
#define | P4 /* P8_14 */ |
The fourth pin of the stepper. | |
Functions | |
SUB | move (BYVAL_AS_PruIo_PTR Io, BYVAL_AS_BYTE Rot=1) |
make the motor move the next step. More... | |
int | main () |
Variables | |
VAR | io = NEW PruIo |
Create a PruIo structure, wakeup subsystems. | |
VAR | w = 128 |
The wait (delay) value. | |
VAR | d = 0 |
The direction value. | |
VAR | x = 16 |
The cursor column for output. | |
VAR | y = CSRLIN() - 1 |
The cursor line for output. | |
VAR | k = ASC(INKEY()) |
The key code. | |
Example: control a stepper motor.
This file contains an example on how to use libpruio to control a 4-wire stepper motor:
Find a functional description in section stepper.
Licence: GPLv3, Copyright 2014-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net
Compile by: fbc -w all stepper.bas
This file contains an example on how to use libpruio to control a 4-wire stepper motor:
Find a functional description in section stepper. In contrast to example stepper, this code handles the pins simultaneously.
Licence: GPLv3, Copyright 2014-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net
Compile by: fbc -w all stepper2.bas
Definition in file stepper.bas.
int main | ( | ) |
The main function.
Definition at line 151 of file stepper.bas.
SUB move | ( | BYVAL_AS_PruIo_PTR | Io, |
BYVAL_AS_BYTE | Rot = 1 |
||
) |
make the motor move the next step.
Io | pointer to PruIo structure |
Rot | direction of rotation (1 or -1) |
This function sets 4 output pins for a stepper motor driver. It remembers the last step as static variable (starting at 0 = zero) and adds the new position to it. So the Rot parameter should either be 1 or -1 to make the motor move one step in any direction.
Definition at line 50 of file stepper.bas.