Example: control a stepper motor. More...
Go to the source code of this file.
Macros | |
#define | P1 /* P8_08 */ |
include libpruio More... | |
#define | P2 /* P8_10 */ |
#define | P3 /* P8_12 */ |
#define | P4 /* P8_14 */ |
Functions | |
SUB | move (BYVAL_AS_PruIo_PTR Io, BYVAL_AS_BYTE Rot=1) |
make the motor move the next step. More... | |
Variables | |
VAR | io = NEW PruIo |
create a PruIo structure, wakeup devices More... | |
VAR | w = 128 |
VAR | d = 0 |
VAR | x = 1 |
VAR | y = CSRLIN() - 1 |
VAR | k = ASC(INKEY()) |
Example: control a stepper motor.
This file contains an example on how to use libpruio to control a 4-wire stepper motor:
Licence: GPLv3
Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
Compile by:
fbc -w all stepper.bas
Definition in file stepper.bas.
#define P1 /* P8_08 */ |
include libpruio
include the convenience macros for header pins
Definition at line 33 of file stepper.bas.
#define P2 /* P8_10 */ |
Definition at line 34 of file stepper.bas.
#define P3 /* P8_12 */ |
Definition at line 35 of file stepper.bas.
#define P4 /* P8_14 */ |
Definition at line 36 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 49 of file stepper.bas.
VAR io = NEW PruIo |
create a PruIo structure, wakeup devices
Definition at line 72 of file stepper.bas.
VAR w = 128 |
Definition at line 97 of file stepper.bas.
VAR d = 0 |
Definition at line 97 of file stepper.bas.
VAR x = 1 |
Definition at line 97 of file stepper.bas.
VAR y = CSRLIN() - 1 |
Definition at line 97 of file stepper.bas.
VAR k = ASC(INKEY()) |
Definition at line 100 of file stepper.bas.