Stepper DLL

This is a Windows DLL which allows applications to control a stepper motor via an Arduino shield (see Stepper). Mostly the functions map to commands sent to the Arduino and are documented in the command section on the Stepper page.

Downloads:

Functions supplied

int InitStp()

Initialise the module, find Arduino COM port, call before anything else, returns 0 on success

int InitStp2(char * ipaddress,int port) Like int InitStp() but allows an ip address and port. Pass a NULL pointer for COM port.

int RunMotor1(int steps, int interval, int direction, int outputs)

Move steps with interval in ms between them in direction (0 or 1). outputs ignored.

int StopMotor1(int outputs)

Stop motor. outputs ignored

int SetStepMode(int M1Mode, int M2Mode)

Sets power to the motor off

int GetCurrentStatus(int *M1Active, int *M2Active, int *M1Steps, int *M2Steps, int *Inputs)

Fills in M1Active and M1Steps from last number of steps set with RunMotor1()

int RunMotor2(int steps, int interval, int direction, int outputs)

The functions above emulate the Stepper Bee library.

int RunSpeed(int speed)

Do Arduino rs command

int SetSpeedMotor1(int speed)

Do Arduino sp command

int SetAccelerationMotor1(int acc)

Do Arduino ac command

int MoveMotor1(int steps)

Do Arduino mv command

int MoveToMotor1(int steps)

Do Arduino mt command

int SetCurPos(int steps)

Do Arduino sc command

int StepSizeMotor1(int steps)

Do Arduino ss command

int PowerMotor1(int pw)

Do Arduino pw command

int WritePin(int pin,int value)

Do Arduino wr command

int ArmInterrupt(int interrupt,int mode)

Do Arduino ai command

int RemInterrupt(int interrupt)

Do Arduino ri command

int SendCommand(char * string)

Send a command to Arduino.

int GetResponse(char ** string,int delay)

Get response from Arduino. delay is time to wait for a response in ms.

int GetPosition(void)

Do Arduino ps command

int GetDistanceToGo(void)

Do Arduino ds command

int ReadPin(int pin)

Do Arduino rd command

int dbprint(char * string)

Print a string to debug window

int TestMoveOver(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.

int TestSensor(int pin)

void ResetArduino(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 GetProcessor(void)

Visual Basic 2010 definitions

    Declare Function InitStp2 Lib "stpDP.dll" (ByVal ipaddress As String, ByVal port As Integer) As Integer
    Declare Function SetSpeedMotor1 Lib "stpDP.dll" (ByVal speed As Integer) As Boolean
    Declare Function SetAccelerationMotor1 Lib "stpDP.dll" (ByVal acceleration As Integer) As Boolean
    Declare Function MoveMotor1 Lib "stpDP.dll" (ByVal steps As Integer) As Boolean
    Declare Function MoveToMotor1 Lib "stpDP.dll" (ByVal steps As Integer) As Boolean
    Declare Function StepSizeMotor1 Lib "stpDP.dll" (ByVal ms As Integer) As Boolean
    Declare Function PowerMotor1 Lib "stpDP.dll" (ByVal pw As Integer) As Boolean
    Declare Function SendCommand Lib "stpDP.dll" (ByVal command As String) As Boolean
    Declare Function GetResponse Lib "stpDP.dll" (ByRef response As String, ByVal delay As Integer) As Boolean
    Declare Function GetPosition Lib "stpDP.dll" () As Integer
    Declare Function GetDistanceToGo Lib "stpDP.dll" () As Integer
    Declare Function TestMoveOver Lib "stpDP.dll" (ByRef posn As Integer, ByVal delay As Integer) As Boolean
    Declare Function RunSpeed Lib "stpDP.dll" (ByVal speed As Integer) As Boolean
    Declare Function RemInterrupt Lib "stpDP.dll" (ByVal interrupt As Integer) As Boolean
    Declare Function ReadPin Lib "stpDP.dll" (ByVal pin As Integer) As Integer
    Declare Function SetCurPos Lib "stpDP.dll" (ByVal steps As Integer) As Boolean
    Declare Function ArmInterrupt Lib "stpDP.dll" (ByVal interrupt As Integer, ByVal mode As Integer) As Boolean
    Declare Function WritePin Lib "stpDP.dll" (ByVal pin As Integer, ByVal value As Integer) As Boolean
    Declare Function TestSensor Lib "stpDP.dll" (ByVal pin As Integer) As Integer
    Declare Function ResetArduino Lib "stpDP.dll" (ByVal delay As Integer) As Integer
    Declare Function GetProcessor Lib "stpDP.dll" () As Integer
    Declare Function SetCancelState Lib "stpDP.dll" (ByVal state As Integer) As Integer

Page last modified on March 16, 2016, at 03:03 PM
Powered by PmWiki