libpruio  0.0
AM33xx-PRU driver for digital input / output and analog input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stepper.bas File Reference

Example: control a stepper motor. More...

Include dependency graph for stepper.bas:

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())
 

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

Licence: GPLv3

Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net

Compile by:

fbc -w all stepper.bas

Definition in file stepper.bas.

Macro Definition Documentation

#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.

Function Documentation

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 49 of file stepper.bas.

Here is the call graph for this function:

Variable Documentation

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.