LibSpindle-C-Library 1.0
Library Code documentation
Loading...
Searching...
No Matches
FreeRTOS Spindle Library

Introduction

The following code documentation is a set of tipps and diagramms as well as function and structure descriptions which help when using the library. It is used to increase the implementation speed. Some examples are attached in this documentation as well

static compile flags of the library

There are no additional static compile flags or DEFINES which the user can configure

library instantiation

The library is implemented as a singleton pattern. This means that only one instance can be created at runtime. Calling the SPINDLE_CreateInstance multiple times will succeed but always the pointer of the first instance will be returned.

Examples

The following example shows how to create a instance of the spindle controller library.

// set parameters for the physical system
s.maxRPM = 9000.0f;
s.minRPM = -9000.0f;
s.absMinRPM = 1600.0f;
s.setDirection = SPINDLE_SetDirection;
s.setDutyCycle = SPINDLE_SetDutyCycle;
s.enaPWM = SPINDLE_EnaPWM;
s.context = NULL;
SPINDLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 3, c, &s);
...
SpindleHandle_t SPINDLE_CreateInstance(unsigned int uxStackDepth, int xPrio, ConsoleHandle_t cH, SpindlePhysicalParams_t *p)
Definition Spindle.c:357
struct SpindlePhysicalParams SpindlePhysicalParams_t
void * context
Definition Spindle.h:107
void(* enaPWM)(SpindleHandle_t h, void *context, int ena)
Definition Spindle.h:82
void(* setDutyCycle)(SpindleHandle_t h, void *context, int backwards, float dutyCycle)
Definition Spindle.h:51
float absMinRPM
Definition Spindle.h:96
float minRPM
Definition Spindle.h:102
float maxRPM
Definition Spindle.h:88

The following example shows the usage of the spindle library via console. With the spindle command the user can start or stop the spindle and it can also change the spindle speed with the start command The command returns OK or FAIL in the given cases of failure or success. There is also a status command. It returns the state of the spindle (turning) and the RPM which has been set. It also terminates with "OK" or "FAIL"

// starts the spindle
$> spindle start <RPM>
// sets another spped of the spindle
$> spindle start <RPM>
// stops the spindle
$> spindle stop
// get the status the spindle
$> spindle status