nem_rs232_api.c File Reference

Application programming interface for control of neMESYS via RS232. More...

#include "nem_rs232_api.h"
+ Include dependency graph for nem_rs232_api.c:

Macros

#define CFGBIT_NEW_CONFIG   (1 << 31)
 if bit 31 is set, then this device contains a new configuration
 
#define CFGBIT_VALVE_INSTALLED   0x200
 test bit for valve for old configuration word
 
#define CFGBIT_VALVE_INSTALLED_NEW   0x01
 test bit for valve for new configuration word
 
#define CWBIT_FAULT_RESET   0x0080
 controlword bit fault reset
 
#define CWBIT_HALT   0x0100
 controlword bit halt
 
#define CWBIT_HOMING_START   0x0010
 controlword bit start homing move
 
#define CWBIT_IMMEDIATELY   0x0020
 change set immediately
 
#define CWBIT_NEW_SET_POINT   0x0010
 new set point
 
#define CWBIT_OP_EN   0x0008
 controlword bit operation enabled
 
#define CWBIT_QUICK_STOP   0x0004
 controlword bit quick stop
 
#define CWBIT_RELATIVE   0x0040
 target position is an relative value
 
#define CWBIT_SWON   0x0001
 controlword bit switch on
 
#define CWBIT_VOLT_EN   0x0002
 controlword bit voltage enabled
 
#define DRV_PROC_TIME   10
 processing time
 
#define STATE_IS_FAULT(_wState_)   (((_wState_) & 0x004F) == SW_FAULT)
 Checks if state is fault.
 
#define STATE_IS_FAULT_REAC(_wState_)   (((_wState_) & 0x004F) == SW_FAULT_REAC)
 Checks if state is fault reaction active.
 
#define STATE_IS_OP_EN(_wState_)   (((_wState_) & 0x006F) == SW_OP_EN)
 Checks if state is operation enabled.
 
#define STATE_IS_QUICK_STOP(_wState_)   (((_wState_) & 0x006F) == SW_QUICK_STOP)
 Checks if state is quick stop.
 
#define STATE_IS_SWON(_wState_)   (((_wState_) & 0x006F) == SW_SWON)
 Checks if state is switch on.
 
#define STATE_IS_SWON_DIS(_wState_)   (((_wState_) & 0x004F) == SW_SWON_DIS)
 Checks if state is disabled.
 
#define STATE_IS_SWON_NOT_RDY(_wState_)   (((_wState_) & 0x004F) == SW_SWON_NOT_RDY)
 Checks if state is not ready to witch on.
 
#define STATE_IS_SWON_RDY(_wState_)   (((_wState_) & 0x006F) == SW_SWON_RDY)
 Checks if state is ready to switch on.
 
#define SWBIT_FAULT   0x0008
 fault
 
#define SWBIT_HOMING_ATTAINED   0x1000
 homing position attained
 
#define SWBIT_HOMING_ERROR   0x2000
 homing error occured
 
#define SWBIT_INT_LIM   0x0800
 internal limit active
 
#define SWBIT_OP_EN   0x0004
 operation enabled
 
#define SWBIT_QUICK_STOP   0x0020
 quick stop
 
#define SWBIT_REMOTE   0x0200
 remote
 
#define SWBIT_SWON   0x0002
 switched on
 
#define SWBIT_SWON_DIS   0x0040
 switch on disabled
 
#define SWBIT_SWON_RDY   0x0001
 ready to switch on
 
#define SWBIT_TARG_REACHED   0x0400
 target reached
 
#define SWBIT_VOLT_EN   0x0010
 voltage enabled
 
#define SWBIT_WARNING   0x0080
 warning
 

Typedefs

typedef enum eCtrlWord TCtrlWord
 Control words of object dictionary entry OD_H6040_CTRL_WORD.
 
typedef enum eCustMemId TCustMemId
 Object dictionary sub indexes of OD_H200C_CUST_PERSISTENT_MEM The custom memory in EPOS stores various configuration values.
 
typedef enum eDigOutFunc TDigOutFunc
 Digital out functionalities sub index.
 
typedef enum eDigOutFunction TDigOutFunction
 Function of digital outputs.
 
typedef enum eDigOutPurpose TDigOutPurpose
 

EPOS sepecific purpose of digital outputs

 
typedef enum eErrHistSub TErrHistSub
 Error history sub indexes.
 
typedef enum eHomingModes THomingMode
 Homing methods.
 
typedef enum eNemObjDicEntries TNemObjDicEntries
 Object dictionary entries.
 
typedef enum eNemOpModes TNemOpModes
 Enumeration of nemesys deviceoperation modes.
 
typedef enum eStatusWord TStatusWord
 Status words of object dictionary entry OD_H6041_STATUS_WORD.
 

Enumerations

enum  eCtrlWord {
  CW_SHUTDOWN = 0x06, CW_SWON = 0x07, CW_VOLT_DIS = 0x00, CW_QUICK_STOP = 0x02,
  CW_OP_DIS = 0x07, CW_OP_EN = 0x0F, CW_FAULT_RST = 0x80, CW_UNDEFINED = 0xFF,
  CW_SHUTDOWN = 0x06, CW_SWON = 0x07, CW_VOLT_DIS = 0x00, CW_QUICK_STOP = 0x02,
  CW_OP_DIS = 0x07, CW_OP_EN = 0x0F, CW_FAULT_RST = 0x80, CW_UNDEFINED = 0xFF
}
 Control words of object dictionary entry OD_H6040_CTRL_WORD. More...
 
enum  eCustMemId { CUST_MEM_AXIS_LEN = 2, CUST_MEM_AXIS_CONF = 3 }
 Object dictionary sub indexes of OD_H200C_CUST_PERSISTENT_MEM The custom memory in EPOS stores various configuration values. More...
 
enum  eDigOutFunc { SUB_01_DIG_OUT_STATE = 1, SUB_02_DIG_OUT_MASK, SUB_03_DIG_OUT_POLARITY }
 Digital out functionalities sub index.
 
enum  eDigOutFunction { DIG_OUT_VALVE_SWITCH = DIG_OUT_GENERAL_PURPOSE_C, DIG_OUT_VALVE_8V = DIG_OUT_GENERAL_PURPOSE_D }
 Function of digital outputs. More...
 
enum  eDigOutPurpose {
  DIG_OUT_GENERAL_PURPOSE_A = 0x010000, DIG_OUT_GENERAL_PURPOSE_B = 0x100000, DIG_OUT_GENERAL_PURPOSE_A = 0x8000, DIG_OUT_GENERAL_PURPOSE_B = 0x4000,
  DIG_OUT_GENERAL_PURPOSE_C = 0x2000, DIG_OUT_GENERAL_PURPOSE_D = 0x1000
}
 

EPOS sepecific purpose of digital outputs

 
enum  eErrHistSub { H1003_SUB_01_NUMBER_OF_ERR = 0, H1003_SUB_01_ERR_IDX_1 = 1, H1003_SUB_01_NUMBER_OF_ERR = 0, H1003_SUB_01_ERR_IDX_1 = 1 }
 Error history sub indexes.
 
enum  eHomingModes { HM_POS_LIM = 18, HM_ACTUAL_POSITION = 35 }
 Homing methods. More...
 
enum  eNemObjDicEntries {
  NemV4_OD_H1003_ERROR_HISTORY = 0x1003, NemV4_OD_H210C_CUSTOM_PERSISTENT_MEM = 0x210C, NemV4_OD_H3000_AXIS_CONFIGURATION = 0x3000, NemV4_OD_H3003_GEAR_CONFIGURATION = 0x3003,
  NemV4_OD_H3141_DIG_INPUTS_PROPERTIES = 0x3141, NemV4_OD_H3160_ANALOG_INPUT = 0x3160, NemV4_OD_H3182_ANALOG_OUT = 0x3182, NemV4_OD_H6040_CTRL_WORD = 0x6040,
  NemV4_OD_H6041_STATUS_WORD = 0x6041, NemV4_OD_H6060_OP_MODE = 0x6060, NemV4_OD_H6064_ACTUAL_POSITION = 0x6064, NemV4_OD_H606B_VELOCITY_DEMAND = 0x606B,
  NemV4_OD_H607A_TARGET_POSITION = 0x607A, NemV4_OD_H607D_SW_POS_LIMITS = 0x607D, NemV4_OD_H607F_PROFILE_VELOCITY_MAX = 0x607F, NemV4_OD_H6081_PROFILE_VELOCITY = 0x6081,
  NemV4_OD_H60A9_SI_UNIT_VELOCITY = 0x60A9, NemV4_OD_H60AA_SI_UNIT_ACCELERATION = 0x60AA, NemV4_OD_H60FD_DIGITAL_INPUTS = 0x60FD, NemV4_OD_H60FE_DIG_OUT = 0x60FE,
  NEM_OD_H1003_ERROR_HISTORY = 0x1003, NEM_OD_H200C_CUSTOM_PERSISTENT_MEM = 0x200C, NEM_OD_H2078_DIGITAL_OUT_FUNC = 0x2078, NEM_OD_H2081_HOME_POSITION = 0x2081,
  NEM_OD_H6040_CTRL_WORD = 0x6040, NEM_OD_H6041_STATUS_WORD = 0x6041, NEM_OD_H6060_OP_MODE = 0x6060, NEM_OD_H6064_ACTUAL_POSITION = 0x6064,
  NEM_OD_H606B_VELOCITY_DEMAND = 0x606B, NEM_OD_H607A_TARGET_POSITION = 0x607A, NEM_OD_H607C_HOME_OFFSET = 0x607C, NEM_OD_H6081_PROFILE_VELOCITY = 0x6081,
  NEM_OD_H6098_HOMING_METHOD = 0x6098, NEM_OD_H6099_HOMING_SPEEDS = 0x6099
}
 Object dictionary entries.
 
enum  eNemOpModes { NemV4_OP_MODE_PROFILE_POSITION = 1, NemV4_OP_MODE_HOMING = 6, NEM_OP_MODE_PROFILE_POSITION = 1, NEM_OP_MODE_HOMING = 6 }
 Enumeration of nemesys deviceoperation modes. More...
 
enum  eStatusWord {
  SW_SWON_NOT_RDY = 0x00, SW_SWON_DIS = 0x40, SW_SWON_RDY = 0x21, SW_SWON = 0x23,
  SW_OP_EN = 0x27, SW_QUICK_STOP = 0x07, SW_FAULT_REAC = 0x0F, SW_FAULT = 0x08,
  SW_UNDEFINED = 0xFF, SW_SWON_NOT_RDY = 0x00, SW_SWON_DIS = 0x40, SW_SWON_RDY = 0x21,
  SW_SWON = 0x23, SW_OP_EN = 0x27, SW_QUICK_STOP = 0x07, SW_FAULT_REAC = 0x0F,
  SW_FAULT = 0x08, SW_UNDEFINED = 0xFF
}
 Status words of object dictionary entry OD_H6041_STATUS_WORD. More...
 

Functions

static long Nem_ClearErrHist (TNemesys *Nemesys)
 Clears the device error history and error register. More...
 
static long Nem_ExecDrvStateCmd (TNemesys *Nemesys, uint16_t wCmd, uint16_t *pwState, uint16_t wProcessTime)
 Execute one single drive state command. More...
 
static long Nem_GetAxisLen (TNemesys *Nemesys, uint32_t *pAxisLen)
 Reads the absolut axis length in increments from device. More...
 
static long Nem_GetDevCfg (TNemesys *Nemesys, uint32_t *NemesysCfg)
 Reads device configuration (gear, encoder spindle slope, valve). More...
 
static long Nem_GetHomeOffset (TNemesys *Nemesys, int32_t *pHomeOffset)
 Read the home ofset from the device. More...
 
static long Nem_GetPosIs (TNemesys *Nemesys, int32_t *pdwPosIs)
 Query actual device position value. More...
 
static long Nem_IsState (TNemesys *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
 Test the status word for a certain bit pattern. More...
 
static long Nem_MoveToPos (TNemesys *Nemesys, int32_t dwPosAbs, uint32_t dwVelocity)
 Move pusher to a certain position. More...
 
static long Nem_SetControlWord (TNemesys *Nemesys, uint16_t wControlWord)
 Transmits the controlword to the device. More...
 
static long Nem_SetHomePos (TNemesys *Nemesys, int32_t dwHomePos)
 Set the value of the psotion counter on end of refernce move. More...
 
static long Nem_SetHomingMode (TNemesys *Nemesys, THomingMode Mode)
 Change homing mode for refernce move. More...
 
static long Nem_SetHomingSpeed (TNemesys *Nemesys, uint32_t Velocity)
 Change speed for calibration move. More...
 
static long Nem_SetOpMode (TNemesys *Nemesys, TNemOpModes OpMode)
 Change operation mode of neMESYS device. More...
 
long NemCalibrate (TNemesys *Nemesys, uint32_t Velocity)
 Execute reference move (homing move) for single dosing unit. More...
 
long NemClearFault (TNemesys *Nemesys)
 Clear fault state of device. More...
 
long NemDevInit (struct CsiBus *Bus, uint8_t NodeId, TNemesys *Nemesys)
 Initialize neMESYS device object with all parameters This function reads configuration parameters from device and stores the parameters into the device object. More...
 
long NemDoseVolume (TNemesys *Nemesys, uint32_t dwVolume, int32_t dwFlowRate)
 Dose a certain volume with a certain flowrate. More...
 
long NemGenerateConstantFlow (TNemesys *Nemesys, int32_t FlowRate)
 Generate a constant flow rate. More...
 
long NemGetFlowRate (TNemesys *Nemesys, int32_t *pFlowRate)
 Query actual flow rate of dosing unit. More...
 
long NemGetLastDevErr (TNemesys *Nemesys, int32_t *pLastDevErr)
 Read last device error from error register. More...
 
long NemGetSyringeLevel (TNemesys *Nemesys, int32_t *pSyringeLevel)
 Query actual syringe fill level. More...
 
long NemIsCalibrationFinished (TNemesys *Nemesys)
 Checks if a dosing unit finished the calibration move. More...
 
long NemIsDosingFinished (TNemesys *Nemesys)
 Checks if a dosing unit finished the last dosing task. More...
 
uint32_t NemIsEnabled (TNemesys *Nemesys)
 Check if device is in enabled state. More...
 
uint32_t NemIsInFaultState (TNemesys *Nemesys)
 Query fault state of device Check if device is in fault state. More...
 
uint8_t NemIsValveInstalled (TNemesys *Nemesys)
 Checks the device configuration if a valve is installed. More...
 
uint32_t NemIsValveStateDispense (TNemesys *Nemesys)
 Check if valve is switched to dispense state (output). More...
 
long NemReadStatusWord (TNemesys *Nemesys, uint16_t *pwStatusWord)
 Read status word from device The bits of the statusword indicate the current state of the drive. More...
 
long NemRestorePos (TNemesys *Nemesys, int32_t dwPos)
 Restore position value. More...
 
long NemSetEnabled (TNemesys *Nemesys)
 Set single dosing unit into enable state. More...
 
long NemSetSyringeLevel (TNemesys *Nemesys, uint32_t dwSyringeLevel, uint32_t dwFlowRate)
 Set syringe to a certain fill level. More...
 
long NemStop (TNemesys *Nemesys)
 Stops actual dosing move. More...
 
long NemSwitchValve (TNemesys *Nemesys, uint8_t SwitchToDispense)
 Switch the integrated three way valve (if one is installed). More...
 

Detailed Description

Application programming interface for control of neMESYS via RS232.

Author
Uwe Kindler (UK)
Date
2019/03/12

Enumeration Type Documentation

enum eCtrlWord

Control words of object dictionary entry OD_H6040_CTRL_WORD.

Enumerator
CW_SHUTDOWN 

shutdown drive

CW_SWON 

switch on

CW_VOLT_DIS 

disable voltage

CW_QUICK_STOP 

perform quick stop

CW_OP_DIS 

disable operation

CW_OP_EN 

set device operational

CW_FAULT_RST 

reset device from fault state

CW_SHUTDOWN 

shutdown drive

CW_SWON 

switch on

CW_VOLT_DIS 

disable voltage

CW_QUICK_STOP 

perform quick stop

CW_OP_DIS 

disable operation

CW_OP_EN 

set device operational

CW_FAULT_RST 

reset device from fault state

155 {
156  CW_SHUTDOWN = 0x06, ///< shutdown drive
157  CW_SWON = 0x07, ///< switch on
158  CW_VOLT_DIS = 0x00, ///< disable voltage
159  CW_QUICK_STOP = 0x02, ///< perform quick stop
160  CW_OP_DIS = 0x07, ///< disable operation
161  CW_OP_EN = 0x0F, ///< set device operational
162  CW_FAULT_RST = 0x80, ///< reset device from fault state
163  CW_UNDEFINED = 0xFF
164 } TCtrlWord;
disable operation
Definition: nem_rs232_api.c:160
shutdown drive
Definition: nem_rs232_api.c:156
perform quick stop
Definition: nem_rs232_api.c:159
disable voltage
Definition: nem_rs232_api.c:158
set device operational
Definition: nem_rs232_api.c:161
reset device from fault state
Definition: nem_rs232_api.c:162
enum eCtrlWord TCtrlWord
Control words of object dictionary entry OD_H6040_CTRL_WORD.
switch on
Definition: nem_rs232_api.c:157
enum eCustMemId

Object dictionary sub indexes of OD_H200C_CUST_PERSISTENT_MEM The custom memory in EPOS stores various configuration values.

Enumerator
CUST_MEM_AXIS_LEN 

axis length in encoder increments

CUST_MEM_AXIS_CONF 

axis configuration

145 {
146  CUST_MEM_AXIS_LEN = 2, ///< axis length in encoder increments
147  CUST_MEM_AXIS_CONF = 3, ///< axis configuration
148 } TCustMemId;
axis configuration
Definition: nem_rs232_api.c:147
axis length in encoder increments
Definition: nem_rs232_api.c:146
enum eCustMemId TCustMemId
Object dictionary sub indexes of OD_H200C_CUST_PERSISTENT_MEM The custom memory in EPOS stores variou...

Function of digital outputs.

Enumerator
DIG_OUT_VALVE_SWITCH 

Digital out for switching the valve.

DIG_OUT_VALVE_8V 

Digital out for lowering the valve voltage.

210 {
211  DIG_OUT_VALVE_SWITCH = DIG_OUT_GENERAL_PURPOSE_C,///< Digital out for switching the valve
212  DIG_OUT_VALVE_8V = DIG_OUT_GENERAL_PURPOSE_D, ///< Digital out for lowering the valve voltage
Digital out for lowering the valve voltage.
Definition: nem_rs232_api.c:212
enum eDigOutFunction TDigOutFunction
Function of digital outputs.
Digital out for switching the valve.
Definition: nem_rs232_api.c:211

Homing methods.

Enumerator
HM_POS_LIM 

Move reference to positive limit switch (calibration)

HM_ACTUAL_POSITION 

Take actual position as home position (setting position counter)

188 {
189  HM_POS_LIM = 18, ///< Move reference to positive limit switch (calibration)
190  HM_ACTUAL_POSITION = 35, ///< Take actual position as home position (setting position counter)
191 } THomingMode;
Move reference to positive limit switch (calibration)
Definition: nem_rs232_api.c:189
enum eHomingModes THomingMode
Homing methods.
Take actual position as home position (setting position counter)
Definition: nem_rs232_api.c:190

Enumeration of nemesys deviceoperation modes.

Enumerator
NemV4_OP_MODE_PROFILE_POSITION 

profile psoition mode - required for any dosing task

NemV4_OP_MODE_HOMING 

homing mode - required for calibration and position counter stting

NEM_OP_MODE_PROFILE_POSITION 

profile psoition mode - required for any dosing task

NEM_OP_MODE_HOMING 

homing mode - required for calibration and position counter stting

91 {
92  NEM_OP_MODE_PROFILE_POSITION = 1, ///< profile psoition mode - required for any dosing task
93  NEM_OP_MODE_HOMING = 6, ///< homing mode - required for calibration and position counter stting
94 } TNemOpModes;
homing mode - required for calibration and position counter stting
Definition: nem_rs232_api.c:93
enum eNemOpModes TNemOpModes
Enumeration of nemesys deviceoperation modes.
profile psoition mode - required for any dosing task
Definition: nem_rs232_api.c:92

Status words of object dictionary entry OD_H6041_STATUS_WORD.

Enumerator
SW_SWON_NOT_RDY 

not ready to switch on

SW_SWON_DIS 

switch on disabled

SW_SWON_RDY 

ready to switch on

SW_SWON 

switched on

SW_OP_EN 

operation enabled

SW_QUICK_STOP 

quick stop active

SW_FAULT_REAC 

fault reaction active

SW_FAULT 

fault

SW_UNDEFINED 

undefined state

SW_SWON_NOT_RDY 

not ready to switch on

SW_SWON_DIS 

switch on disabled

SW_SWON_RDY 

ready to switch on

SW_SWON 

switched on

SW_OP_EN 

operation enabled

SW_QUICK_STOP 

quick stop active

SW_FAULT_REAC 

fault reaction active

SW_FAULT 

fault

SW_UNDEFINED 

undefined state

171 {
172  SW_SWON_NOT_RDY = 0x00, ///< not ready to switch on
173  SW_SWON_DIS = 0x40, ///< switch on disabled
174  SW_SWON_RDY = 0x21, ///< ready to switch on
175  SW_SWON = 0x23, ///< switched on
176  SW_OP_EN = 0x27, ///< operation enabled
177  SW_QUICK_STOP = 0x07, ///< quick stop active
178  SW_FAULT_REAC = 0x0F, ///< fault reaction active
179  SW_FAULT = 0x08, ///< fault
180  SW_UNDEFINED = 0xFF ///< undefined state
181 } TStatusWord;
not ready to switch on
Definition: nem_rs232_api.c:172
enum eStatusWord TStatusWord
Status words of object dictionary entry OD_H6041_STATUS_WORD.
switched on
Definition: nem_rs232_api.c:175
operation enabled
Definition: nem_rs232_api.c:176
fault reaction active
Definition: nem_rs232_api.c:178
undefined state
Definition: nem_rs232_api.c:180
quick stop active
Definition: nem_rs232_api.c:177
fault
Definition: nem_rs232_api.c:179
switch on disabled
Definition: nem_rs232_api.c:173
ready to switch on
Definition: nem_rs232_api.c:174

Function Documentation

static long Nem_ClearErrHist ( TNemesys Nemesys)
static

Clears the device error history and error register.

The device keeps track of the errors that occured with an internal error history. The function NemClerFault() calls this function to clear the error history.

Parameters
[in]NemesysThe device to change
Returns
Error code - ERR_NOERR indicates success

Referenced by NemClearFault().

1249 {
1250  return CsiDevWriteObject(&Nemesys->Device, NEM_OD_H1003_ERROR_HISTORY,
1251  H1003_SUB_01_NUMBER_OF_ERR, 0);
1252 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

long Nem_ExecDrvStateCmd ( TNemesys Nemesys,
uint16_t  wCmd,
uint16_t *  pwState,
uint16_t  wProcessTime 
)
static

Execute one single drive state command.

The function excutes one drive state command, waits a certain amount of time for the drive to process the command (wProcessTime) and then reads the statusword of the device and returns it to the application.

Parameters
[in]NemesysThe device to query
[in]wCmdThe command to execute
[out]pwStateState of the devcie after execution of the command in wCmd
[in]wProcessTimeTime between sending the command and reading the status
Returns
Error code - ERR_NOERR indicates success

Referenced by NemSetEnabled().

576 {
577  long Result;
578 
579  Result = Nem_SetControlWord(Nemesys, wCmd);
580  if (Result != ERR_NOERR)
581  {
582  return Result;
583  }
584 
585  if (wProcessTimeMs)
586  {
587  CsiSleep(wProcessTimeMs); // give drive some time to process cmd
588  }
589 
590  return NemReadStatusWord(Nemesys, pwState);
591 }
long NemReadStatusWord(TNemesys *Nemesys, uint16_t *pwStatusWord)
Read status word from device The bits of the statusword indicate the current state of the drive...
Definition: nem_rs232_api.c:721
#define ERR_NOERR
No error.
Definition: err_codes.h:102
static long Nem_SetControlWord(TNemesys *Nemesys, uint16_t wControlWord)
Transmits the controlword to the device.
Definition: nem_rs232_api.c:711
CSI_API void CsiSleep(uint32_t Milliseconds)
Function to sleep for a certain amount of milliseconds.
Definition: csi_common.c:30

+ Here is the call graph for this function:

static long Nem_GetAxisLen ( TNemesys Nemesys,
uint32_t *  pAxisLen 
)
static

Reads the absolut axis length in increments from device.

The axis length is the length in increments between the upper limit sensor and the lower limit sensor. Normally the pusher should never reach the upper or lower limit sensor. If the pusher moves into a limit sensr, the drive is stopped immediatelly and the device goes into fault state. The application then needs to call NemClearFault() and NemSetOperational() to continue dosing. If the device moves into a limit sensor, then a calibration should be excuted.

Parameters
[in]NemesysThe device to query
[out]pAxisLenStores the axis length in increments
Returns
Error code - ERR_NOERR indicates success

Referenced by NemDevInit().

756 {
757  return CsiDevReadObject(&Nemesys->Device, NEM_OD_H200C_CUSTOM_PERSISTENT_MEM,
758  CUST_MEM_AXIS_LEN, pAxisLen);
759 }
axis length in encoder increments
Definition: nem_rs232_api.c:146
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_GetDevCfg ( TNemesys Nemesys,
uint32_t *  NemesysCfg 
)
static

Reads device configuration (gear, encoder spindle slope, valve).

This function is called from NemInitDev() to initialize the nemesys device object.

Parameters
[in]NemesysThe device to query
[out]NemesysCfgStores the device configuration word.
Returns
Error code - ERR_NOERR indicates success

Referenced by NemDevInit().

746 {
747  return CsiDevReadObject(&Nemesys->Device, NEM_OD_H200C_CUSTOM_PERSISTENT_MEM,
748  CUST_MEM_AXIS_CONF, NemesysCfg);
749 }
axis configuration
Definition: nem_rs232_api.c:147
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_GetHomeOffset ( TNemesys Nemesys,
int32_t *  pHomeOffset 
)
static

Read the home ofset from the device.

The pusher of the neMESYS device travels between the upper and lower limit sensors. The home offset defines the range between the zero position and the lower limit sensor and between the maximum position and the upper limit sensor. So the maximum position is the axis length (Nem_GetAxisLen()) minus 2 x the home offset. This ensures that the device never reaches the limit sensors during normal operation. The value of the home offset depends on device configuration (gear, spindle slope, encoder...) and is stored in custom persistent memory.

Parameters
[in]NemesysThe device to query
[out]pHomeOffsetStores the home offset
Returns
Error code - ERR_NOERR indicates success

Referenced by NemDevInit().

737 {
738  return CsiDevReadObject(&Nemesys->Device, NEM_OD_H607C_HOME_OFFSET, 0, (uint32_t*)pHomeOffset);
739 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_GetPosIs ( TNemesys Nemesys,
int32_t *  pdwPosIs 
)
static

Query actual device position value.

Parameters
[in]NemesysThe device to move
[out]pdwPosIsStore position is in increments
Returns
Error code - ERR_NOERR indicates success

Referenced by NemDoseVolume(), NemGetSyringeLevel(), and NemSetSyringeLevel().

766 {
767  long Result;
768 
769  Result = CsiDevReadObject(&Nemesys->Device, NEM_OD_H6064_ACTUAL_POSITION,
770  0, (uint32_t*)pdwPosIs);
771  *pdwPosIs = 0 - *pdwPosIs; // we use invertet postition values
772 
773  return Result;
774 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_IsState ( TNemesys Nemesys,
uint16_t  wMask,
uint16_t  wState,
uint8_t *  pResult 
)
static

Test the status word for a certain bit pattern.

The function applies the mask to the status word and checks if the masked statusword matches the bitpattern in state.

Parameters
[in]NemesysThe device to query
[in]wMaskThe bitmask to apply to device statusword
[in]wStateThe state bitmask to check
[out]pResultResult of the test (0 = false, 1 = true)
Returns
Error code - ERR_NOERR indicates success

Referenced by NemIsCalibrationFinished(), NemIsDosingFinished(), NemIsEnabled(), and NemIsInFaultState().

781 {
782  long Result;
783  uint16_t StatusWord;
784 
785  Result = NemReadStatusWord(Nemesys, &StatusWord);
786 
787  if ((StatusWord & wMask) == wState)
788  {
789  *pResult = 1;
790  }
791  else
792  {
793  *pResult = 0;
794  }
795 
796  return Result;
797 }
long NemReadStatusWord(TNemesys *Nemesys, uint16_t *pwStatusWord)
Read status word from device The bits of the statusword indicate the current state of the drive...
Definition: nem_rs232_api.c:721

+ Here is the call graph for this function:

static long Nem_MoveToPos ( TNemesys Nemesys,
int32_t  dwPosAbs,
uint32_t  dwVelocity 
)
static

Move pusher to a certain position.

This is a private low level function that is called from public API functions to execute dosing tasks. This function performs basic steps like range checking, position value translation and transmission of positon values to device.

Parameters
[in]NemesysThe device to move
[in]dwPosAbsThe position value in increments
[in]dwVelocityThe speed in mrpm (milli revolution per minute)
Returns
Error code - ERR_NOERR indicates success

Referenced by NemDoseVolume(), NemGenerateConstantFlow(), and NemSetSyringeLevel().

903 {
904  long Result;
905  uint16_t wControlWord;
906 
907  //
908  // Limit the position move to the maximum possible value and then invert
909  // the position because in real hardware the position value will
910  // decrease if we move away from lower limit but we would like to use
911  // positive values here
912  //
913  if ((uint32_t)dwPosAbs > Nemesys->MaxPos)
914  {
915  dwPosAbs = Nemesys->MaxPos;
916  }
917  dwPosAbs = 0 - dwPosAbs;
918 
919  //
920  // check if operation mode is profile position - if not, then activate
921  // the profile position mode
922  //
923  if (Nemesys->OpMode != NEM_OP_MODE_PROFILE_POSITION)
924  {
925  Result = Nem_SetOpMode(Nemesys, NEM_OP_MODE_PROFILE_POSITION);
926  if (Result != ERR_NOERR)
927  {
928  return Result;
929  }
930  }
931 
932  //
933  // first we store our target position
934  //
935  Result = CsiDevWriteObject(&Nemesys->Device, NEM_OD_H607A_TARGET_POSITION,
936  0, dwPosAbs);
937  if (Result != ERR_NOERR)
938  {
939  return Result;
940  }
941 
942  //
943  // now we store our velocity
944  //
945  Result = CsiDevWriteObject(&Nemesys->Device, NEM_OD_H6081_PROFILE_VELOCITY,
946  0, dwVelocity);
947  if (Result != ERR_NOERR)
948  {
949  return Result;
950  }
951 
952  //
953  // Now start movement
954  //
956  return Nem_SetControlWord(Nemesys, wControlWord);
957 }
uint32_t MaxPos
maximum position of pusher
Definition: nem_rs232_api.h:42
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
#define CWBIT_IMMEDIATELY
change set immediately
Definition: nem_rs232_api.c:43
static long Nem_SetOpMode(TNemesys *Nemesys, TNemOpModes OpMode)
Change operation mode of neMESYS device.
Definition: nem_rs232_api.c:664
uint8_t OpMode
buffers operation mode
Definition: nem_rs232_api.h:45
set device operational
Definition: nem_rs232_api.c:161
#define ERR_NOERR
No error.
Definition: err_codes.h:102
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41
#define CWBIT_NEW_SET_POINT
new set point
Definition: nem_rs232_api.c:42
static long Nem_SetControlWord(TNemesys *Nemesys, uint16_t wControlWord)
Transmits the controlword to the device.
Definition: nem_rs232_api.c:711
profile psoition mode - required for any dosing task
Definition: nem_rs232_api.c:92

+ Here is the call graph for this function:

static long Nem_SetControlWord ( TNemesys Nemesys,
uint16_t  wControlWord 
)
static

Transmits the controlword to the device.

Call this function to change th controlword.

Parameters
[in]NemesysThe device to change
[in]wControlWordThe new controlword to store into device
Returns
Error code - ERR_NOERR indicates success
See also
NemCalibrate(), Nem_SetHomingSpeed(), Nem_SetHomingMode()

Referenced by Nem_ExecDrvStateCmd(), Nem_MoveToPos(), NemCalibrate(), NemClearFault(), NemRestorePos(), and NemStop().

712 {
713  uint32_t controlword = wControlWord;
714  return CsiDevWriteObject(&Nemesys->Device, NEM_OD_H6040_CTRL_WORD, 0, controlword);
715 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_SetHomePos ( TNemesys Nemesys,
int32_t  dwHomePos 
)
static

Set the value of the psotion counter on end of refernce move.

If device finishes calibration, the home position is loaded into the position counter. Normally if a reference move is executed, the home position should be 0.

Parameters
[in]NemesysThe device to change
[in]dwHomePosHome position to store in position counter after refernece move
Returns
Error code - ERR_NOERR indicates success
See also
NemCalibrate(), Nem_SetHomingSpeed(), Nem_SetHomingMode()

Referenced by NemCalibrate(), and NemRestorePos().

703 {
704  return CsiDevWriteObject(&Nemesys->Device, NEM_OD_H2081_HOME_POSITION, 0, dwHomePos);
705 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_SetHomingMode ( TNemesys Nemesys,
THomingMode  Mode 
)
static

Change homing mode for refernce move.

Call this function the set the homing method for reference move. The following homing methods are supported: If a calibration move is executed the function NemCalibrate() calls this private function to set the speed of the homing move.

Parameters
[in]NemesysThe device to change
[in]ModeHoming mode to set
  • HM_POS_LIM: Homing move to positive limit switch
  • HM_ACTUAL_POSITION: Take actual position as home
Returns
Error code - ERR_NOERR indicates success
See also
NemCalibrate(), Nem_SetHomingSpeed(), Nem_SetHomePos()

Referenced by NemCalibrate(), and NemRestorePos().

693 {
694  uint32_t HomingMode = Mode;
695  return CsiDevWriteObject(&Nemesys->Device, NEM_OD_H6098_HOMING_METHOD, 0, HomingMode);
696 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_SetHomingSpeed ( TNemesys Nemesys,
uint32_t  Velocity 
)
static

Change speed for calibration move.

If a calibration move is executed the function NemCalibrate() calls this private function to set the speed of the homing move.

Parameters
[in]NemesysThe device to change
[in]VelocityThe speed in mrpm (milli revolutions per minute)
Returns
Error code - ERR_NOERR indicates success
See also
NemCalibrate(), Nem_SetHomingMode(), Nem_SetHomePos()

Referenced by NemCalibrate().

684 {
685  return CsiDevWriteObject(&Nemesys->Device, NEM_OD_H6099_HOMING_SPEEDS, 1, Velocity);
686 }
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
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function:

static long Nem_SetOpMode ( TNemesys Nemesys,
TNemOpModes  OpMode 
)
static

Change operation mode of neMESYS device.

A neMESYS device can operate in two different operation modes. During normal dosing the device works in profile position mode (NEM_OP_MODE_PROFILE_POSITION). During calibration the device is in homing mode (NEM_OP_MODE_HOMING).

Parameters
[in]NemesysThe device to change
[in]OpModeThe new operation mode to set
Returns
Error code - ERR_NOERR indicates success

Referenced by Nem_MoveToPos(), NemCalibrate(), NemDevInit(), and NemRestorePos().

665 {
666  long Result;
667  uint32_t dwOpMode = OpMode;
668 
669  Result = CsiDevWriteObject(&Nemesys->Device, NEM_OD_H6060_OP_MODE, 0, dwOpMode);
670  if (Result != ERR_NOERR)
671  {
672  return Result;
673  }
674 
675  Nemesys->OpMode = OpMode; // stroe operation mode in shadow buffer
676  return Result;
677 }
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: nem_rs232_api.h:45
#define ERR_NOERR
No error.
Definition: err_codes.h:102
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41

+ Here is the call graph for this function: