Example: control a stepper motor. More...
#include "stdio.h"
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include "../c_wrapper/pruio_c_wrapper.h"
#include "../c_wrapper/pruio_pins.h"
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE 1 |
#define | P1 P8_08 |
#define | P2 P8_10 |
#define | P3 P8_12 |
#define | P4 P8_14 |
Functions | |
int | isleep (unsigned int mseconds) |
wait for keystroke or timeout More... | |
void | move (PruIo *Io, char Rot) |
make the motor move the next step. More... | |
int | main (int argc, char **argv) |
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:
gcc -Wall -o stepper stepper.c /usr/local/lib/freebasic/fbrt0.o -lpruio -L"/usr/local/lib/freebasic/" -lfb -lpthread -lprussdrv -ltermcap -lsupc++ -Wno-unused-variable
Definition in file stepper.c.
int isleep | ( | unsigned int | mseconds) |
void move | ( | PruIo * | Io, |
char | Rot | ||
) |
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 82 of file stepper.c.