Basic Motion Control Functions

Overview

Basic low level motion control functions for execution of positioning tasks.

The functions in this group allow basic positioning of the pusher using device specific speed and position (increments) values. No syringe configuration is required for these functions because they use the native device units like increments for positions and mrpm for speed. These functions are called from the high level dosing functions (see Dosing and pump control functions).

+ Collaboration diagram for Basic Motion Control Functions:

Functions

long NemV4GetCurrentVelocity (TNemesysV4 *Nemesys, int32_t *Velocity)
 Read the actual velocity from the Nemesys. More...
 
long NemV4GetPosIs (TNemesysV4 *Nemesys, int32_t *PosIs)
 Reads the actual position from the Nemesys. More...
 
long NemV4MoveDistance (TNemesysV4 *Nemesys, int32_t Distance, uint32_t Velocity)
 Moves the pusher a certain distance from the current position. More...
 
long NemV4MoveToPos (TNemesysV4 *Nemesys, int32_t PosAbs, uint32_t Velocity)
 Move pusher to a certain position. More...
 
long NemV4MoveWithVelocity (TNemesysV4 *Nemesys, int32_t Velocity)
 Moves the syringe pusher with the given velocity. More...
 

Function Documentation

long NemV4GetCurrentVelocity ( TNemesysV4 Nemesys,
int32_t *  Velocity 
)

Read the actual velocity from the Nemesys.

Parameters
NemesysNemesys to read from
VelocityStores the velocity in Nemesys units (speed in mrpm - millirevolutions per minute)
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4GetCurrentFlow().

1005 {
1006  int32_t Result;
1007 
1008  *Velocity = 0;
1009  Result = NemV4IsStopped(Nemesys);
1010  if (Result < 0)
1011  {
1012  return Result;
1013  }
1014 
1015  //
1016  // If dosing is finished, then the flow rate is 0
1017  //
1018  if (Result)
1019  {
1020  Nemesys->LastVelocity = 0;
1021  }
1022 
1023  *Velocity = Nemesys->LastVelocity;
1024  return Result;
1025 }
int32_t LastVelocity
last velocity value
Definition: nem4_rs232_api.h:112
long NemV4IsStopped(TNemesysV4 *Nemesys)
Checks if a dosing unit is moving or stopped.
Definition: nem4_rs232_api.c:781

+ Here is the call graph for this function:

long NemV4GetPosIs ( TNemesysV4 Nemesys,
int32_t *  PosIs 
)

Reads the actual position from the Nemesys.

Parameters
NemesysNemesys to read from
PosIsReturns the current position in Nemesys units (increments)
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4GetSyringeLevel(), NemV4MoveDistance(), and NemV4SetSyringeLevel().

695 {
696  long Result;
697 
698  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H6064_ACTUAL_POSITION,
699  0, (uint32_t*)PosIs);
700 
701  return Result;
702 }
struct CsiDev Device
CSI device object.
Definition: nem4_rs232_api.h:107
long CsiDevReadObject(struct CsiDev *pDev, uint16_t ObjDicIdx, uint8_t ObjDicSub, uint32_t *pRxDWord)
This function reads up to 4 bytes of data from device object dictionary.
Definition: csi_dev.c:157

+ Here is the call graph for this function:

long NemV4MoveDistance ( TNemesysV4 Nemesys,
int32_t  Distance,
uint32_t  Velocity 
)

Moves the pusher a certain distance from the current position.

This function executes a relative move from the current position. The sign of the distance parameter configures the direction of the move. A negative value will pull the pusher and a positive value will push the syringe pusher into the syringe

Parameters
NemesysNemesys device to move
DistanceThe distance in increments. The sign configures the direction
VelocityThe device velocity value.
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4DoseVolume().

901 {
902  long Result;
903  int32_t PosIs;
904  int32_t TargetPos;
905 
906  if (Distance < 0)
907  {
908  Nemesys->LastVelocity = 0 - Velocity;
909  }
910  else
911  {
912  Nemesys->LastVelocity = Velocity;
913  }
914 
915  //
916  // First read the actual position - this is our starting point
917  //
918  Result = NemV4GetPosIs(Nemesys, &PosIs);
919  CSI_RETURN_ON_ERROR(Result);
920 
921  TargetPos = PosIs + Distance;
922 
923  //
924  // Finally execute a simple absolute position move
925  //
926  return NemV4MoveToPos(Nemesys, TargetPos, Velocity);
927 }
int32_t LastVelocity
last velocity value
Definition: nem4_rs232_api.h:112
long NemV4MoveToPos(TNemesysV4 *Nemesys, int32_t dwPosAbs, uint32_t dwVelocity)
Move pusher to a certain position.
Definition: nem4_rs232_api.c:806
long NemV4GetPosIs(TNemesysV4 *Nemesys, int32_t *PosIs)
Reads the actual position from the Nemesys.
Definition: nem4_rs232_api.c:694

+ Here is the call graph for this function:

long NemV4MoveToPos ( TNemesysV4 Nemesys,
int32_t  PosAbs,
uint32_t  Velocity 
)

Move pusher to a certain position.

This function executes an move to an absolute position. This is a low level function that is called from other API functions to execute dosing tasks.

Parameters
[in]NemesysThe Nemesys to move
[in]PosAbsThe position value in increments
[in]VelocityThe speed in mrpm (millirevolutions per minute)
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4MoveDistance(), NemV4MoveWithVelocity(), and NemV4SetSyringeLevel().

807 {
808  long Result;
809  uint16_t wControlWord;
810 
811  //
812  // Limit the position move to the maximum possible value and then invert
813  // the position because in real hardware the position value will
814  // decrease if we move away from lower limit but we would like to use
815  // positive values here
816  //
817  if (dwPosAbs > Nemesys->MaxPos)
818  {
819  dwPosAbs = Nemesys->MaxPos;
820  }
821 
822  //
823  // check if operation mode is profile position - if not, then activate
824  // the profile position mode
825  //
826  if (Nemesys->OpMode != NemV4_OP_MODE_PROFILE_POSITION)
827  {
829  if (Result != ERR_NOERR)
830  {
831  return Result;
832  }
833  }
834 
835  //
836  // first we store our target position
837  //
838  Result = CsiDevWriteObject(&Nemesys->Device, NemV4_OD_H607A_TARGET_POSITION,
839  0, dwPosAbs);
840  CSI_RETURN_ON_ERROR(Result);
841 
842  //
843  // now we store our velocity
844  //
845  Result = CsiDevWriteObject(&Nemesys->Device, NemV4_OD_H6081_PROFILE_VELOCITY,
846  0, dwVelocity);
847  CSI_RETURN_ON_ERROR(Result);
848 
849  //
850  // Now start movement
851  //
852  wControlWord = CW_OP_EN;
853  Result = NemV4_SetControlWord(Nemesys, wControlWord);
854  CSI_RETURN_ON_ERROR(Result);
856  return NemV4_SetControlWord(Nemesys, wControlWord);
857 }
struct CsiDev Device
CSI device object.
Definition: nem4_rs232_api.h:107
#define CWBIT_IMMEDIATELY
change set immediately
Definition: nem4_rs232_api.c:38
set device operational
Definition: nem4_rs232_api.c:136
#define CWBIT_NEW_SET_POINT
new set point
Definition: nem4_rs232_api.c:37
long CsiDevWriteObject(struct CsiDev *pDev, uint16_t ObjDicIdx, uint8_t ObjDicSub, uint32_t TxDWord)
This function writes up to 4 bytes of data into device object dictionary.
Definition: csi_dev.c:188
uint8_t OpMode
buffers operation mode
Definition: nem4_rs232_api.h:111
static long NemV4_SetOpMode(TNemesysV4 *Nemesys, TNemOpModes OpMode)
Change operation mode of Nemesys device.
Definition: nem4_rs232_api.c:650
#define ERR_NOERR
No error.
Definition: err_codes.h:102
int32_t MaxPos
maximum position of pusher in increments
Definition: nem4_rs232_api.h:110
profile psoition mode - required for any dosing task
Definition: nem4_rs232_api.c:81
static long NemV4_SetControlWord(TNemesysV4 *Nemesys, uint16_t wControlWord)
Transmits the controlword to the device.
Definition: nem4_rs232_api.c:669

+ Here is the call graph for this function:

long NemV4MoveWithVelocity ( TNemesysV4 Nemesys,
int32_t  Velocity 
)

Moves the syringe pusher with the given velocity.

The sign of the velocity value indicates the direction. A negative value means aspiration and a positive value means dispension. The pusher will move until the minimum or maximum position is reached

Parameters
NemesysThe nemesys device to control
VelocityThe device specific velocity value. The sign indicates the move direction.
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4GenerateFlow().

958 {
959  int32_t TargetPos;
960 
961  Nemesys->LastVelocity = Velocity;
962  //
963  // Now calculate target position - target position depends on the
964  // dwVolume value and on the sign of the dwFlowRate
965  //
966  if (Velocity < 0)
967  {
968  Velocity = 0 - Velocity;
969  TargetPos = Nemesys->MinPos; // move to lower limit
970  }
971  else
972  {
973  TargetPos = Nemesys->MaxPos; // move to upper limit
974  }
975 
976  //
977  // Finally execute a simple absolut position move
978  //
979  return NemV4MoveToPos(Nemesys, TargetPos, Velocity);
980 }
int32_t LastVelocity
last velocity value
Definition: nem4_rs232_api.h:112
int32_t MinPos
minimum position of pusher in increments
Definition: nem4_rs232_api.h:109
long NemV4MoveToPos(TNemesysV4 *Nemesys, int32_t dwPosAbs, uint32_t dwVelocity)
Move pusher to a certain position.
Definition: nem4_rs232_api.c:806
int32_t MaxPos
maximum position of pusher in increments
Definition: nem4_rs232_api.h:110

+ Here is the call graph for this function: