Dosing and pump control functions

Overview

High level functions for pump control and execution of dosing tasks such as volume dosing, flow generation, aspiration and dispension.

These functions work with volumes in microlitres µl and flow rates in microlitres per minute (µl/min). For proper unit conversion a syringe should be properly configured with NemV4SetSyringe().

+ Collaboration diagram for Dosing and pump control functions:

Functions

long NemV4DoseVolume (TNemesysV4 *Nemesys, double Volume_ul, double Flow_ul_min)
 Dose a certain volume with a certain flow rate. More...
 
long NemV4GenerateFlow (TNemesysV4 *Nemesys, double Flow_ul_min)
 Generate a constant flow until syringe is empty or full. More...
 
long NemV4GetCurrentFlow (TNemesysV4 *Nemesys, double *Flow_ul_min)
 Returns the current flow in ul / min. More...
 
long NemV4GetMaxFlow (TNemesysV4 *Nemesys, double *Flow_ul_min)
 Returns the maximum flow in ul / min. More...
 
long NemV4GetMaxSyringeLevel (TNemesysV4 *Nemesys, double *Level_ul)
 Returns the maximum syringe level in µl. More...
 
long NemV4GetSyringeLevel (TNemesysV4 *Nemesys, double *Level_ul)
 Returns the current syringe level in µl. More...
 
long NemV4IsStopped (TNemesysV4 *Nemesys)
 Checks if a dosing unit is moving or stopped. More...
 
long NemV4SetSyringeLevel (TNemesysV4 *Nemesys, double Level_ul, double Flow_ul_min)
 Set syringe to a certain fill level. More...
 
long NemV4Stop (TNemesysV4 *Nemesys)
 Stops the current dosing move. More...
 

Function Documentation

long NemV4DoseVolume ( TNemesysV4 Nemesys,
double  Volume_ul,
double  Flow_ul_min 
)

Dose a certain volume with a certain flow rate.

Depending on the sign of the given volume parameter, this functions will aspirate (negative sign) or dispense (positive sign) a certain amount of fluid with the flow rate given in Flow_ul_min parameter.

Parameters
NemesysThe Nemesys device to control
Volume_ulThe volume in microlitres. A negative volume means aspiration and a positive volume means dispension.
Flow_ul_minThe flow rate for the dosing in microlitres per minute.
Returns
Error code - ERR_NOERR indicates success
See also
NemV4GetSyringeLevel(), NemV4GetCurrentFlow()
934 {
935  int32_t Distance;
936  int32_t Velocity;
937 
938  Distance = NemV4MicrolitresToDevicePos(Nemesys, Volume_ul);
939  Velocity = NemV4MicrolitresPerMinuteToDeviceVel(Nemesys, Flow_ul_min);
940  return NemV4MoveDistance(Nemesys, Distance, Velocity);
941 }
long NemV4MoveDistance(TNemesysV4 *Nemesys, int32_t Distance, uint32_t Velocity)
Moves the pusher a certain distance from the current position.
Definition: nem4_rs232_api.c:900
int32_t NemV4MicrolitresToDevicePos(TNemesysV4 *Nemesys, double ul)
Converts a volume in microliters into a device position in increments using the configred syronge par...
Definition: nem4_rs232_api.c:300
int32_t NemV4MicrolitresPerMinuteToDeviceVel(TNemesysV4 *Nemesys, double ul_min)
Converts a flow rate in ul/min into a device velocity (likely in mrpm).
Definition: nem4_rs232_api.c:321

+ Here is the call graph for this function:

long NemV4GenerateFlow ( TNemesysV4 Nemesys,
double  Flow_ul_min 
)

Generate a constant flow until syringe is empty or full.

The function generates a constant flow. The sign of the given flow value indicates the direction. A positive flow value means aspiration and a negative flow value means aspiration. The pump moves the pusher until it reaches the minimum or maximum position.

Parameters
NemesysThe Nemesys device to control
Flow_ul_minThe flow rate to generate. Negative values mean aspiration.
Returns
Error code - ERR_NOERR indicates success
948 {
949  int32_t Velocity = NemV4MicrolitresPerMinuteToDeviceVel(Nemesys, Flow_ul_min);
950  return NemV4MoveWithVelocity(Nemesys, Velocity);
951 }
long NemV4MoveWithVelocity(TNemesysV4 *Nemesys, int32_t Velocity)
Moves the syringe pusher with the given velocity.
Definition: nem4_rs232_api.c:957
int32_t NemV4MicrolitresPerMinuteToDeviceVel(TNemesysV4 *Nemesys, double ul_min)
Converts a flow rate in ul/min into a device velocity (likely in mrpm).
Definition: nem4_rs232_api.c:321

+ Here is the call graph for this function:

long NemV4GetCurrentFlow ( TNemesysV4 Nemesys,
double *  Flow_ul_min 
)

Returns the current flow in ul / min.

Parameters
NemesysNemesys device to read from
Flow_ul_minReturns the current flow in µl per minute
Returns
Error code - ERR_NOERR indicates success
1055 {
1056  int32_t CurrentVelocity;
1057  long Result = NemV4GetCurrentVelocity(Nemesys, &CurrentVelocity);
1058  CSI_RETURN_ON_ERROR(Result);
1059  *Flow_ul_min = NemV4DeviceVelToMicrolitresPerMinute(Nemesys, CurrentVelocity);
1060  return ERR_NOERR;
1061 }
double NemV4DeviceVelToMicrolitresPerMinute(TNemesysV4 *Nemesys, int32_t Velocity)
Converts a device velocity (likely in mrpm) in a flow rate in ul/min using the configured syringe par...
Definition: nem4_rs232_api.c:312
long NemV4GetCurrentVelocity(TNemesysV4 *Nemesys, int32_t *Velocity)
Read the actual velocity from the Nemesys.
Definition: nem4_rs232_api.c:1004
#define ERR_NOERR
No error.
Definition: err_codes.h:102

+ Here is the call graph for this function:

long NemV4GetMaxFlow ( TNemesysV4 Nemesys,
double *  Flow_ul_min 
)

Returns the maximum flow in ul / min.

Parameters
NemesysNemesys device to read from
Flow_ul_minReturns the maximum flow in µl per minute
Returns
Error code - ERR_NOERR indicates success
1068 {
1069  *Flow_ul_min = NemV4DeviceVelToMicrolitresPerMinute(Nemesys, Nemesys->MaxVelocity);
1070  return ERR_NOERR;
1071 }
double NemV4DeviceVelToMicrolitresPerMinute(TNemesysV4 *Nemesys, int32_t Velocity)
Converts a device velocity (likely in mrpm) in a flow rate in ul/min using the configured syringe par...
Definition: nem4_rs232_api.c:312
#define ERR_NOERR
No error.
Definition: err_codes.h:102
uint32_t MaxVelocity
stores the maximum velocity
Definition: nem4_rs232_api.h:108

+ Here is the call graph for this function:

long NemV4GetMaxSyringeLevel ( TNemesysV4 Nemesys,
double *  Level_ul 
)

Returns the maximum syringe level in µl.

Parameters
NemesysNemesys device to read from
Level_ulReturns the maximum syringe level in µl
Returns
Error code - ERR_NOERR indicates success
1045 {
1046  *Level_ul = NemV4DevicePosToMicrolitres(Nemesys, Nemesys->MinPos);
1047  return ERR_NOERR;
1048 }
int32_t MinPos
minimum position of pusher in increments
Definition: nem4_rs232_api.h:109
#define ERR_NOERR
No error.
Definition: err_codes.h:102
double NemV4DevicePosToMicrolitres(TNemesysV4 *Nemesys, int32_t Pos)
Converts a device position in inc.
Definition: nem4_rs232_api.c:289

+ Here is the call graph for this function:

long NemV4GetSyringeLevel ( TNemesysV4 Nemesys,
double *  Level_ul 
)

Returns the current syringe level in µl.

Parameters
NemesysNemesys device to read from
Level_ulReturns the current syringe level in µl
Returns
Error code - ERR_NOERR indicates success
1032 {
1033  int32_t PosIs;
1034  long Result = NemV4GetPosIs(Nemesys, &PosIs);
1035  CSI_RETURN_ON_ERROR(Result);
1036  *Level_ul = NemV4DevicePosToMicrolitres(Nemesys, PosIs);
1037  return ERR_NOERR;
1038 }
long NemV4GetPosIs(TNemesysV4 *Nemesys, int32_t *PosIs)
Reads the actual position from the Nemesys.
Definition: nem4_rs232_api.c:694
#define ERR_NOERR
No error.
Definition: err_codes.h:102
double NemV4DevicePosToMicrolitres(TNemesysV4 *Nemesys, int32_t Pos)
Converts a device position in inc.
Definition: nem4_rs232_api.c:289

+ Here is the call graph for this function:

long NemV4IsStopped ( TNemesysV4 Nemesys)

Checks if a dosing unit is moving or stopped.

If the pump is stopped, this does not indicate, that dosing was successful (that the requested volume was completely transfered).

Parameters
[in]NemesysNemesys to query
Return values
1stopped - drive stopped because pump reached target or because an error occurred.
0moving - a dosage is active
<0Error code

Referenced by NemV4GetCurrentVelocity().

782 {
783  long Result;
784  uint8_t IsFinished;
785 
786  Result = NemV4_IsState(Nemesys, SWBIT_TARG_REACHED, SWBIT_TARG_REACHED, &IsFinished);
787 
788  //
789  // If function call was successful then return the state of dosing move
790  // if function returns error code then return the error to user
791  //
792  if (Result != ERR_NOERR)
793  {
794  return Result;
795  }
796  else
797  {
798  return IsFinished;
799  }
800 }
static long NemV4_IsState(TNemesysV4 *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
Test the status word for a certain bit pattern.
Definition: nem4_rs232_api.c:708
#define ERR_NOERR
No error.
Definition: err_codes.h:102
#define SWBIT_TARG_REACHED
target reached
Definition: nem4_rs232_api.c:54

+ Here is the call graph for this function:

long NemV4SetSyringeLevel ( TNemesysV4 Nemesys,
double  Level_ul,
double  Flow_ul_min 
)

Set syringe to a certain fill level.

This function moves the pusher to a certain syringe fill level. This means, depending on the current syringe fill level this function will cause a aspiration or a dosing. You can call the function NemV4GetMaxSyringeLevel() to get the maximum syringe fill level for the current syringe configuration. The following example shows how to refill the syringe to its maximum level with the maximum flow rate.

double MaxLevel;
double MaxFlow;
NemV4GetMaxSyringeLevel(Nemesys1, &MaxLevel);
NemV4GetMaxFlow(Nemesys1, &MaxFlow);
NemV4SetSyringeLevel(Nemesys1, MaxLevel, MaxFlow);
Parameters
NemesysThe Nemesys device to control
Level_ulThe target syringe fill level in microlitres
Flow_ul_minThe flow rate in microlitres per minute
Returns
Error code - ERR_NOERR indicates success
See also
NemV4GetSyringeLevel(), NemV4GetMaxSyringeLevel(), NemV4GetMaxFlow()
864 {
865  long Result;
866  int32_t PosIs;
867  int32_t Velocity;
868  int32_t TargetPos;
869 
870  TargetPos = NemV4MicrolitresToDevicePos(Nemesys, Level_ul);
871  Velocity = NemV4MicrolitresPerMinuteToDeviceVel(Nemesys, Flow_ul_min);
872 
873  //
874  // First read the actual position
875  //
876  Result = NemV4GetPosIs(Nemesys, &PosIs);
877  CSI_RETURN_ON_ERROR(Result);
878 
879  //
880  // We save last flow rate now - if the syringe level is > the is position
881  // the we know that we aspirate and flowrate is < 0. If the syringe level is
882  // < then the is position then we know that we dispense and flowrate is > 0
883  //
884  if (TargetPos > PosIs)
885  {
886  Nemesys->LastVelocity = 0 - Velocity;
887  }
888  else
889  {
890  Nemesys->LastVelocity = Velocity;
891  }
892 
893  return NemV4MoveToPos(Nemesys, TargetPos, Velocity);
894 }
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
int32_t NemV4MicrolitresToDevicePos(TNemesysV4 *Nemesys, double ul)
Converts a volume in microliters into a device position in increments using the configred syronge par...
Definition: nem4_rs232_api.c:300
int32_t NemV4MicrolitresPerMinuteToDeviceVel(TNemesysV4 *Nemesys, double ul_min)
Converts a flow rate in ul/min into a device velocity (likely in mrpm).
Definition: nem4_rs232_api.c:321

+ Here is the call graph for this function:

long NemV4Stop ( TNemesysV4 Nemesys)

Stops the current dosing move.

This function immediately stops the actual dosing move.

Parameters
NemesysThe Nemesys device to stop
Returns
Error code - ERR_NOERR indicates success
987 {
988  long Result;
989  uint16_t ControlWord = CW_OP_EN | CWBIT_HALT;
990 
991  Result = NemV4_SetControlWord(Nemesys, ControlWord);
992  if (ERR_NOERR == Result)
993  {
994  Nemesys->LastVelocity = 0;
995  }
996 
997  return Result;
998 }
int32_t LastVelocity
last velocity value
Definition: nem4_rs232_api.h:112
set device operational
Definition: nem4_rs232_api.c:136
#define CWBIT_HALT
controlword bit halt
Definition: nem4_rs232_api.c:34
#define ERR_NOERR
No error.
Definition: err_codes.h:102
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: