libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
stepper.bas File Reference

Example: control a stepper motor. More...

#include "BBB/pruio.bi"
#include "BBB/pruio_pins.bi"
Include dependency graph for stepper.bas:

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.
 

Detailed Description

Example: control a stepper motor.

This file contains an example on how to use libpruio to control a 4-wire stepper motor:

  • configure 4 pins as output
  • receive user action in loop
  • inform user about the current state
  • change motor direction
  • change motor speed
  • stop holded or in power off mode
  • move a single step (in holded mode)
  • quit

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

Since
0.0

This file contains an example on how to use libpruio to control a 4-wire stepper motor:

  • configure 4 pins as output
  • receive user action in loop
  • inform user about the current state
  • change motor direction
  • change motor speed
  • stop holded or in power off mode
  • move a single step (in holded mode)
  • quit

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

Since
0.0

Definition in file stepper.bas.

Function Documentation

◆ main()

int main ( )

The main function.

Definition at line 151 of file stepper.bas.

Here is the call graph for this function:

◆ move()

SUB move ( BYVAL_AS_PruIo_PTR  Io,
BYVAL_AS_BYTE  Rot = 1 
)

make the motor move the next step.

Parameters
Iopointer to PruIo structure
Rotdirection 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.