Initialization and Configuration

Overview

Functions for device initialization and syringe configuration.

+ Collaboration diagram for Initialization and Configuration:

Functions

long NemV4DevInit (struct CsiBus *Bus, uint8_t NodeId, TNemesysV4 *Nemesys)
 Initialize Nemesys device object with all parameters. More...
 
void NemV4SetSyringe (TNemesysV4 *Nemesys, double InnerSyringeDiameter_mm)
 Configure the syringe that is used for flow and volume unit conversion. More...
 

Function Documentation

long NemV4DevInit ( struct CsiBus Bus,
uint8_t  NodeId,
TNemesysV4 Nemesys 
)

Initialize Nemesys device object with all parameters.

This function reads configuration parameters from Nemesys and stores the parameters into the Nemesys object. After a call to this function all other functions that require a valid Nemesys object can be called.

Parameters
BusReference of bus object the Nemesys is attached to
NodeIdNodeId of dosing unit to initialize
NemesysReference to Nemesys object to initialize
Returns
Error code - ERR_NOERR indicates successful initialization
420 {
421  long Result;
422  uint32_t EncoderResolution;
423  uint32_t GearNumerator;
424  uint32_t GearDenominator;
425  uint32_t VelocityUnit;
426  int8_t Prefix;
427  uint16_t RevDivider;
428  double Gear;
429  uint32_t AxisConf;
430 
431  Result = CsiDevInit(Bus, NodeId, &Nemesys->Device, CSI_SERIAL_PROTOCOL_V2);
432  CSI_RETURN_ON_ERROR(Result);
433 
434  Nemesys->LastVelocity = 0;
435  NemV4SetSyringe(Nemesys, 7.28366);
436 
437  //
438  // Read maximum velocity from device
439  //
440  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H607F_PROFILE_VELOCITY_MAX,
441  0, &Nemesys->MaxVelocity);
442  CSI_RETURN_ON_ERROR(Result);
443 
444  //
445  // Now read the minimum and maximum position values.
446  // For the nemesys 4 the position range is from 0 - -xxxxxxxx. So 0 is
447  // 0 is the maximum position
448  // To avoid spurious errors because the pump is too close to the limits
449  // the positions in the pump are a little bit higher than the real
450  // positions - a safety margin has been added to both limits. We remove
451  // this safety margin from both position limits
452  //
453  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H607D_SW_POS_LIMITS,
454  2, (uint32_t*)&Nemesys->MaxPos);
455  CSI_RETURN_ON_ERROR(Result);
456  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H607D_SW_POS_LIMITS,
457  1, (uint32_t*)&Nemesys->MinPos);
458  CSI_RETURN_ON_ERROR(Result);
459  int SafetyMargin = Nemesys->MaxPos;
460  Nemesys->MaxPos -= SafetyMargin;
461  Nemesys->MinPos += SafetyMargin;
462 
463  //
464  // Now read encoder pulse number from device - sub index 5
465  //
466  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H3000_AXIS_CONFIGURATION,
467  5, &EncoderResolution);
468  CSI_RETURN_ON_ERROR(Result);
469 
470  //
471  // Now read gear numerator and gear denominator
472  //
473  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H3003_GEAR_CONFIGURATION,
474  1, &GearNumerator);
475  CSI_RETURN_ON_ERROR(Result);
476 
477  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H3003_GEAR_CONFIGURATION,
478  2, &GearDenominator);
479  CSI_RETURN_ON_ERROR(Result);
480 
481  Gear = (double)GearNumerator / (double)GearDenominator;
482 
483  //
484  // Now we read the velocity and acceleration notation indices because we
485  // need it for proper conversion of speed values into device velocity values
486  //
487  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H60A9_SI_UNIT_VELOCITY,
488  0, &VelocityUnit);
489  CSI_RETURN_ON_ERROR(Result);
490 
491  Prefix = (VelocityUnit >> 24) & 0xFF;
492  RevDivider = (uint16_t) pow((double) 10, abs(Prefix));
493  Nemesys->PosUnitsPerRevolution = (double)EncoderResolution * Gear;
494  Nemesys->VelUnitsPerRPM = (double)RevDivider * Gear;
495 
496  //
497  // Now we read the product type from the device.
498  // The axis configuration is stored in custom persistent memory.
499  // | Bit 31 - 17 | Bit 16 - 10 | Bit 9 - 4 | Bit 3 - 0 |
500  // |--------------------------+--------------+------------+----------------+
501  // | reserved | Product Type | reserved | Spindle Slope |
502  //
503  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H210C_CUSTOM_PERSISTENT_MEM,
504  3, &AxisConf);
505  CSI_RETURN_ON_ERROR(Result);
506  Nemesys->ProductType = (AxisConf >> 10) & 0x7F;
507 
508  //
509  // Initialize the scaling parameters for the different analog sensors and
510  // signals
511  //
512  Result = NemV4_InitForceScalingParam(Nemesys);
513  CSI_RETURN_ON_ERROR(Result);
514 
515  Result = NemV4_InitDigOutShadowRegister(Nemesys);
516  CSI_RETURN_ON_ERROR(Result);
517 
518  //
519  // Set initial operation mode - the default mode here is
520  // the profile position mode
521  //
523  CSI_RETURN_ON_ERROR(Result);
524 
525 
526  return ERR_NOERR;
527 }
struct CsiDev Device
CSI device object.
Definition: nem4_rs232_api.h:107
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
void NemV4SetSyringe(TNemesysV4 *Nemesys, double InnerSyringeDiameter_mm)
Configure the syringe that is used for flow and volume unit conversion.
Definition: nem4_rs232_api.c:533
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
double PosUnitsPerRevolution
conversion factor between Nemesys position units and revolutions
Definition: nem4_rs232_api.h:113
int ProductType
Nemesys product type -.
Definition: nem4_rs232_api.h:120
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
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
uint32_t MaxVelocity
stores the maximum velocity
Definition: nem4_rs232_api.h:108
double VelUnitsPerRPM
conversion factor between Nemesys velocity units and RPM
Definition: nem4_rs232_api.h:114
uint8_t NodeId
the node identifier for this device
Definition: csi_types.h:91

+ Here is the call graph for this function:

void NemV4SetSyringe ( TNemesysV4 Nemesys,
double  InnerSyringeDiameter_mm 
)

Configure the syringe that is used for flow and volume unit conversion.

Parameters
NemesysNemesys device to configure
[in]InnerSyringeDiameter_mmThe inner syringe diameter in mm

Referenced by NemV4DevInit().

534 {
535  Nemesys->InnerSyringeDiameter_mm = InnerSyringeDiameter_mm;
536  Nemesys->InnerSyringeArea_mm2 = M_PI * pow(Nemesys->InnerSyringeDiameter_mm, 2) / 4;
537 }
double InnerSyringeDiameter_mm
conversion factor speed/position into velocity/volume
Definition: nem4_rs232_api.h:115
double InnerSyringeArea_mm2
stores the calculated inner syringe area
Definition: nem4_rs232_api.h:116