Initialisation

Overview

This group defines all required functions to initialize a correct communication to neMESYS Bus and to a certain device.

+ Collaboration diagram for Initialisation:

Functions

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...
 

Function Documentation

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.

After a call to this function all other functions that require a valid device object can be called.

Parameters
[in]BusReference of bus object the device is attached to
[in]NodeIdNodeId of dosing unit to initialize
[in]NemesysReference to device object to initialize
Returns
Error code - ERR_NOERR indicates successfull initialisation
425 {
426  long Result;
427  uint32_t AxisLen;
428 
429  Result = CsiDevInit(Bus, NodeId, &Nemesys->Device, CSI_SERIAL_PROTOCOL_V1);
430  if (ERR_NOERR != Result)
431  {
432  return Result;
433  }
434 
435  Nemesys->LastVelocity = 0;
436  Nemesys->ValveStateDisp = 1;
437 
438  //
439  // Read home offset from device - the home ofset defines the range from
440  // home sensor to 0 position.
441  //
442  Result = Nem_GetHomeOffset(Nemesys, &Nemesys->HomeOffset);
443  if (ERR_NOERR != Result)
444  {
445  return Result;
446  }
447 
448  //
449  // Read device configuration from device
450  //
451  Result = Nem_GetDevCfg(Nemesys, &Nemesys->DevCfg);
452  if (ERR_NOERR != Result)
453  {
454  return Result;
455  }
456 
457  //
458  // Read axis length from device - the axis length is the length from
459  // lower limit sensor to upper limit sensor in encoder increments
460  //
461  Result = Nem_GetAxisLen(Nemesys, &AxisLen);
462  if (ERR_NOERR != Result)
463  {
464  return Result;
465  }
466 
467  //
468  // Set initial operation mode - teh default mode here is
469  // the profile position mode
470  //
471  Result = Nem_SetOpMode(Nemesys, NEM_OP_MODE_PROFILE_POSITION);
472  if (ERR_NOERR != Result)
473  {
474  return Result;
475  }
476 
477  //
478  // Now calculate the maximum position. The maximum position is the length
479  // of the axis minus the offest from lower limit to zero position and
480  // minus offset from upper limit to maximum position. The two offsets
481  // are the same so we can subtract two times the home offset
482  //
483  Nemesys->MaxPos = AxisLen - Nemesys->HomeOffset - Nemesys->HomeOffset;
484 
485  return Result;
486 }
static long Nem_GetAxisLen(TNemesys *Nemesys, uint32_t *pAxisLen)
Reads the absolut axis length in increments from device.
Definition: nem_rs232_api.c:755
int8_t ValveStateDisp
valve state: 1 = dispense, 0 = aspirate
Definition: nem_rs232_api.h:47
static long Nem_GetDevCfg(TNemesys *Nemesys, uint32_t *NemesysCfg)
Reads device configuration (gear, encoder spindle slope, valve).
Definition: nem_rs232_api.c:745
uint32_t MaxPos
maximum position of pusher
Definition: nem_rs232_api.h:42
long CsiDevInit(struct CsiBus *pBus, uint8_t NodeId, struct CsiDev *pDev, enum CsiSerialProtocolVersion SerProtocolVersion)
Initialize CSI device object with all parameters.
Definition: csi_dev.c:127
uint32_t DevCfg
contains configuration for gear, spindle slope, encoder and valve
Definition: nem_rs232_api.h:44
static long Nem_SetOpMode(TNemesys *Nemesys, TNemOpModes OpMode)
Change operation mode of neMESYS device.
Definition: nem_rs232_api.c:664
int32_t LastVelocity
last flowrate value
Definition: nem_rs232_api.h:46
#define ERR_NOERR
No error.
Definition: err_codes.h:102
struct CsiDev Device
CSI device object.
Definition: nem_rs232_api.h:41
static long Nem_GetHomeOffset(TNemesys *Nemesys, int32_t *pHomeOffset)
Read the home ofset from the device.
Definition: nem_rs232_api.c:736
profile psoition mode - required for any dosing task
Definition: nem_rs232_api.c:92
int32_t HomeOffset
offset for homing moves
Definition: nem_rs232_api.h:43
uint8_t NodeId
the node identifier for this device
Definition: csi_types.h:91

+ Here is the call graph for this function: