Stepper Pi Lib

This is a Raspian shared library which allows applications to control a stepper motor via a Pi hat (see Stepper Pi and Stepper Pi Hat). Mostly the functions map to commands in the command section on the Stepper Pi page. The idea is that the program on the Stepper Pi page will be running as a process in pipe mode; below I call it 'stepper'.

There is also a Gambas application which uses the library to provide a simple demo of controlling a motor.

Note this will only work with Stepper Pi version 2.03.

Downloads:

Software sources:
https://sourceforge.net/p/gambas/mailman/message/8963849/
http://gambaswiki.org/wiki/howto/extern
https://www.youtube.com/watch?v=L55QYFnnrgo
https://www.youtube.com/watch?v=s1omSb9iwKE#t=120.314828
https://www.youtube.com/watch?v=oeGI5OMAheg
https://www.youtube.com/watch?v=cAymVFeoz3s

Comments

Click to return to index

Functions supplied

int InitStp()
Initialise the module, find stepper process pipes, call before anything else, returns 0 on success

int FinitStp()
Shutdown the module, call when finished with the module.

int RunSpeed(int motor,int speed)
Do stepper rs command - makes the motor run continuously at the given speed.

int SetSpeedMotor(int motor,int speed)
Do stepper sp command - set speed for the motor.

int SetAccelerationMotor(int motor,int acc)
Do stepper ac command - set acceleration for the motor.

int MoveMotor(int motor,int steps)
Do stepper mv command - change the motor position by the given number of steps.

int MoveToMotor(int motor,int steps)
Do stepper mt command - set the motor to an absolute position.

int StopMotor(int motor)
Do stepper xx command - stop the motor i.e. abandon any move operation that is in progress or cancel continuous motion set with the rs command.

int SetCurPos(int motor,int steps)
Do stepper sc command - sets the absolute position without changing the motor position. This is like setting the co-ordinate orgin.

int StepSizeMotor(int motor,int steps)
Do stepper ss command - sets the number of microsteps used for each motor step.

int PowerMotor(int motor,int pw)
Do stepper pw command

int WritePin(int pin,int value)
Do stepper wr command - write value (0 or 1) to a given pin.

int ArmInterrupt(int motor,int interrupt,int mode)
Do stepper ai command

int RemInterrupt(int motor,int interrupt)
Do stepper ri command

int SendCommand(char * string)
Send a command to stepper

int GetResponse(char ** string,int delay)
Get response from stepper. delay is time to wait for a response in ms.

int GetPosition(int motor)
Do stepper ps command

int GetDistanceToGo(int motor)
Do stepper ds command

int ReadPin(int pin)
Do stepper rd command

int TestMoveOver(int motor,int * posn,int delay)
See if a move has completed, returns non-zero on success. Returns position after move. delay is time to wait for a result in ms.

void ResetStepper(unsigned int timeout)

void SetCancelState(int state)
This function lets us tell the DLL that we want to cancel things. Use an argument of 1 to make all operations cancel at once. An argument of 0 to make things behave as normal.

int TestSensor(int pin)
Tests if there is a sensor connected. This works by changing the pull up/down resistors on the given pin. A pin with a sensor attached won't change state. Note the resistors built into the Pi for the Tilt motor input mean results won't be valid for that pin. Stepper ts command.

Page last modified on October 21, 2016, at 12:57 AM
Powered by PmWiki