ApossC SDK  V01.15
Functions
SDK_Encoder_Setup.mh File Reference

Declaration of the encoder setup function. More...

Go to the source code of this file.

Functions

long sdkSetupIncEncoder (long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
 Settings for an incremental encoder. More...
 
long sdkSetupSinCosEncoder (long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
 Settings for an SinCos encoder. More...
 
long sdkSetupAbsSSIEncoder (long axis, long encPort, long encRes, long clockFreq, long fastUpdate, long datlen, long isBinary, long latchBitMask)
 Settings for a SSI encoder. More...
 
long sdkSetupHallEncoderMACS5 (long axis, long hallPort, long hallAligment)
 Settings for an hall encoder. More...
 
long sdkSetupHallEncoder (long axis, long hallAligment, long hallDirection)
 Settings for an hall encoder. More...
 

Detailed Description

Declaration of the encoder setup function.

Revision
188

Definition in file SDK_Encoder_Setup.mh.

Function Documentation

◆ sdkSetupAbsSSIEncoder()

long sdkSetupAbsSSIEncoder ( long  axis,
long  encPort,
long  encRes,
long  clockFreq,
long  fastUpdate,
long  datlen,
long  isBinary,
long  latchBitMask 
)

Settings for a SSI encoder.

With this function the settings can be made which are required for an SSI encoder. Default is the encoder input 0 of axis 0, the encoder input 1 of axis 1 etc. This function is used to reassign the modules. The encoder assignment can be set up variably.

Example for a latching with a singelturn absSSI encoder:
A latching is performed on an encoder with a resolution of 8192 with the actual value of 2192. At the next overflow (reaching 8192) this value is subtracted by 8192. The last marker value is -6000, after the next turn -14 192 and so on.

Parameters
axisAxis module number
encPortEncoder port number. Usually, module instance 0 is connected to X1 and so on. Please refer to product manual
encResResolution of the encoder for position feed back in increments (quadcounts)
clockFreqClock frequency of the SSI encoder (Hz)
fastUpdateThe fast update is only necessary, when the motor commutation is done with this encoder (PMSM mode)
fastUpdate 0: The encoder is updated with the velocity controller update rate (8 kHz on MiniMACS6)
fastUpdate 1: The encoder is updated with the current controller update rate (24 kHz on MiniMACS6)
datlenDatabit length of endat position
isBinary1 if data coding is binary otherwise it is gray coded.
latchBitMaskThe result from VIRTLATCH_PISRC_LATCHVALID will be ANDed with this bitmask to decide if a latch should be accepted. In this function the virtual input module is set as source. This is linked to the hardware digital inputs by default.
Returns
value: Always 1 in this function
value > 0 Process successful
value = 0 Process is active
value < 0 Error
Note

Definition at line 179 of file SDK_Encoder_Setup.mc.

180 {
181  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT_ENDLESS; // Defines how the source value is handled
182  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_PISRC_COUNTER) = HWCOUNTABS_PROCESS_SRCINDEX(encPort,PO_HWCNTABS_VALUE); // Setup virtual counter module
183  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_OVFL_VALUE) = encRes; // Value where counter should produce an overflow
184 
185  HWENC_PARAM(encPort, HWENCODER_DATLEN) = datlen;
186  HWENC_PARAM(encPort, HWENCODER_CLOCKFREQ) = clockFreq;
187 
188  HWAMP_PARAM(axis, HWAMP_PISRC_ACTPOS) = HWCOUNTABS_PROCESS_SRCINDEX(encPort,PO_HWCNTABS_VALUE); // Source input for actual position
189 
190  HWENC_PARAM(encPort, HWENCODER_MODE) = HWENCODER_MODE_SSI_ACTIVE; // Setup SSI Encoder active clock
191 
192  if(fastUpdate) // Setup fast update for commutation
193  {
194  HWENC_PARAM(encPort, HWENCODER_FAST_UPDATE) = 1;
195  //HWENC_PARAM(encPort, HWENCODER_FAST_UPDATE) = HWENCODER_FAST_UPDATE_ENABLE;
196  }
197  else
198  {
199  HWENC_PARAM(encPort, HWENCODER_FAST_UPDATE) = 0;
200  //HWENC_PARAM(encPort, HWENCODER_FAST_UPDATE) = HWENCODER_FAST_UPDATE_DISABLE;
201  }
202  if(isBinary) // Setup data coding typ
203  {
205  }
206  else
207  {
209  //HWCOUNTABS_PARAM(encPort, HWCNTABS_CODING) = HWCNTABS_CODING_GRAY;
210  }
211 
212  // Virtuallatch module mapping
214  // Set the source for the lathc module
218  // Set the source for input trigger, could be an other source like user param
220  // Bitmask for the latchvalid source
221  VIRTLATCH_PARAM(axis, VIRTLATCH_LATCHVALID_BITMASK) = latchBitMask;
222 
223  return(1);
224 }

◆ sdkSetupHallEncoder()

long sdkSetupHallEncoder ( long  axis,
long  hallAligment,
long  hallDirection 
)

Settings for an hall encoder.

With this function the settings can be made which are required for use hall encoder only.

Parameters
axisAxis module number
hallAligmentHall aligment. See SDO Dictionary Index: 4000, SubIndex: 88
hallDirectionDirection of rotation of the hall signals
hallDirection 1: Normal
hallDirection -1: Inverse (For example Maxon)
Returns
value: Process value
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 275 of file SDK_Encoder_Setup.mc.

276 {
277  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Defines how the source value is handled
279 
280  HWAMP_PARAM(axis, HWAMP_HALL_ALIGNMENT) = hallAligment; // set hall alignment
281  HWHALL_PARAM(axis, HWHALL_MODE) = HWHALL_MODE_ENABLE; // enable hall encoder
282 
283  if(hallDirection==-1)
285 
286  return(1);
287 }

◆ sdkSetupHallEncoderMACS5()

long sdkSetupHallEncoderMACS5 ( long  axis,
long  hallPort,
long  hallAligment 
)

Settings for an hall encoder.

With this function the settings can be made which are required for an hall encoder. This function only valid for a MACS5 controller

Parameters
axisAxis module number
hallPortHall port number
hallAligmentHall aligment. See SDO Dictionary Index: 4000, SubIndex: 88
Returns
value: Process value
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 237 of file SDK_Encoder_Setup.mc.

238 {
239  long hall_ModNo;
240 
241  // Determine Hall Number, note that the Hall-Module number has a fix assignment to the axis number
242  if (axis == 0){ hall_ModNo = 0; }
243  else if (axis == 2){ hall_ModNo = 1; }
244  else if (axis == 3){ hall_ModNo = 2; }
245  else if (axis == 5){ hall_ModNo = 3; }
246  else { // (AxisNo == 1 || AxisNo == 4)
247  print("Axis No ", axis, " cannot be used as BLDC axis");
248  return(-1);
249  }
250 
251  HWAMP_PARAM((axis), HWAMP_HALL_ALIGNMENT) = hallAligment; // set hall alignment
252 
253  // Parameterization Hall Sensors
254  HWENC_PARAM((hallPort), HWENCODER_MODE) = HWENCODER_MODE_HALL; // Set encder mode
255  HWHALL_PARAM((hallPort), HWHALL_MODE) = HWHALL_MODE_ENABLE; // enable hall decoder
256  HWHALL_PARAM((hall_ModNo), HWHALL_PISRC_ENCOUT) = (hallPort); // use input number
257 
258  return(1);
259 }

◆ sdkSetupIncEncoder()

long sdkSetupIncEncoder ( long  axis,
long  encPort,
long  encRes,
long  latchType,
long  latchParam,
long  latchSlope 
)

Settings for an incremental encoder.

With this function the settings can be made which are required for an incremental encoder. Default is the encoder input 0 of axis 0, the encoder input 1 of axis 1 etc. This function is used to reassign the modules. The encoder assignment can be set up variably.

Parameters
axisAxis module number
encPortEncoder port number. Usually, module instance 0 is connected to X1 and so on. Please refer to product manual
encResResolution of the encoder for position feed back in increments (quadcounts)
latchTypeDefines the latch type
0: Default latchTyp Encoder Z signal
1: A digital input is used as latch signal
latchParamParameter depending on the latch type
latchType 0: Parameter can be set to 0
latchType 1: The preferred digital input is set (Digital input 1 - 64)
latchSlopeDefines the slope of the trigger signal (Default 1)
0 HWLATCH_SLOPE_CONTINUOUS: Continuous trigger signal
1 HWLATCH_SLOPE_RISING: Rising trigger signal
2 HWLATCH_SLOPE_FALLING: Falling trigger signal
3 HWLATCH_SLOPE_BOTH: Rising/ Falling trigger signal
Returns
value: Process value
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 43 of file SDK_Encoder_Setup.mc.

44 {
45  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Defines how the source value is handled
46  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_PISRC_COUNTER) = HWCOUNTINC_PROCESS_SRCINDEX(encPort,PO_HWCNTINC_VALUE); // Setup virtual counter module
47 
48  HWENC_PARAM(encPort, HWENCODER_MODE) = HWENCODER_MODE_INCREMENTAL; // Setup encoder type
49  HWAMP_PARAM(encPort, HWAMP_ENCRES) = encRes; // Resolution of the encoder
50  HWAMP_PARAM(axis, HWAMP_PISRC_ACTPOS) = HWCOUNTINC_PROCESS_SRCINDEX(encPort,PO_HWCNTINC_VALUE); // Source input for actual position
51 
52  // Virtuallatch module mapping
67 
68  if (latchType == 0) // Default latchtype, encoder Z signal
69  {
71  }
72  else if (latchType == 1) // Digital input for latch signal
73  {
75  HWLATCH_PARAM(encPort, HWLATCH_SLOPE) = latchSlope;
76  }
77  else // Error
78  {
79  print("Not supported latchType");
80  return(-1);
81  }
82  return(1);
83 }

◆ sdkSetupSinCosEncoder()

long sdkSetupSinCosEncoder ( long  axis,
long  encPort,
long  encRes,
long  latchType,
long  latchParam,
long  latchSlope 
)

Settings for an SinCos encoder.

With this function the settings can be made which are required for an SinCos encoder. Default is the encoder input 0 of axis 0, the encoder input 1 of axis 1 etc. This function is used to reassign the modules. The encoder assignment can be set up variably.

Parameters
axisAxis module number
encPortEncoder port number. Usually, module instance 0 is connected to X1 and so on. Please refer to product manual
encResResolution of the encoder for position feed back in increments (quadcounts)
Input must be multiplied by a factor of 256.
latchTypeDefines the latch type
0: Default latchTyp Encoder Z signal
1: A digital input is used as latch signal
latchParamParameter depending on the latch type
latchType 0: Parameter can be set to 0
latchType 1: The preferred digital input is set (Digital input 1 - 64)
latchSlopeDefines the slope of the trigger signal (Default 1)
0 HWLATCH_SLOPE_CONTINUOUS: Continuous trigger signal
1 HWLATCH_SLOPE_RISING: Rising trigger signal
2 HWLATCH_SLOPE_FALLING: Falling trigger signal
3 HWLATCH_SLOPE_BOTH: Rising/ Falling trigger signal
Returns
value: Process value
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 110 of file SDK_Encoder_Setup.mc.

111 {
112  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Defines how the source value is handled
113  VIRTCOUNTIN_PARAM(axis, VIRTCNTIN_PISRC_COUNTER) = HWCOUNTINC_PROCESS_SRCINDEX(encPort,PO_HWCNTINC_VALUE); // Setup virtual counter module
114 
115  HWENC_PARAM(encPort, HWENCODER_MODE) = HWENCODER_MODE_SINCOS; // Setup encoder type
116  HWAMP_PARAM(encPort, HWAMP_ENCRES) = encRes; // Resolution of the encoder
117  HWAMP_PARAM(axis, HWAMP_PISRC_ACTPOS) = HWCOUNTINC_PROCESS_SRCINDEX(encPort,PO_HWCNTINC_VALUE); // Source input for actual position
118 
119  // Virtuallatch module mapping
134 
135  if (latchType == 0) // Default latchtype, encoder Z signal
136  {
138  }
139  else if (latchType == 1) // Digital input for latch signal
140  {
142  HWLATCH_PARAM(encPort, HWLATCH_SLOPE) = latchSlope;
143  }
144  else // Error
145  {
146  print("Not supported latchType");
147  return(-1);
148  }
149  return(1);
150 }
VIRTCNTIN_MODE
#define VIRTCNTIN_MODE
Counter mode.
Definition: SdoDictionary.mh:5003
HWENCODER_MODE_SINCOS
#define HWENCODER_MODE_SINCOS
Definition: SdoDictionary.mh:8581
HWENCODER_MODE_INCREMENTAL
#define HWENCODER_MODE_INCREMENTAL
Definition: SdoDictionary.mh:8575
VIRTCOUNTIN_PARAM
#define VIRTCOUNTIN_PARAM(modno, parno)
Virtual Counter Inputs parameters: Setter.
Definition: SdoDictionary.mh:4985
VIRTDIGIN_PROCESS_SRCINDEX
#define VIRTDIGIN_PROCESS_SRCINDEX(modno, parno)
Virtual Digital Input Process Data: Source Index.
Definition: SdoDictionary.mh:6519
PO_HWLATCH_FIFOREAD
#define PO_HWLATCH_FIFOREAD
Latch position read from FIFO.
Definition: SdoDictionary.mh:12284
VIRTLATCH_MODE
#define VIRTLATCH_MODE
Latch mode.
Definition: SdoDictionary.mh:5122
VIRTLATCH_PISRC_LATCH
#define VIRTLATCH_PISRC_LATCH
Index/subindex of latch source.
Definition: SdoDictionary.mh:5165
HWLATCH_SLOPE
#define HWLATCH_SLOPE
Slope selector for trigger signal.
Definition: SdoDictionary.mh:9154
PO_HWHALL_POS
#define PO_HWHALL_POS
Position value (incrementing/decrementing)
Definition: SdoDictionary.mh:11982
PO_VIRTCNTIN_VALUE
#define PO_VIRTCNTIN_VALUE
Output of counter module.
Definition: SdoDictionary.mh:6201
HWCOUNTINC_PROCESS_SRCINDEX
#define HWCOUNTINC_PROCESS_SRCINDEX(modno, parno)
HW Counter-inc Process Data: Source Index.
Definition: SdoDictionary.mh:12011
HWENC_PARAM
#define HWENC_PARAM(modno, parno)
HW Encoder Parameters: Setter.
Definition: SdoDictionary.mh:8383
VIRTLATCH_PISRC_LATCHVALID
#define VIRTLATCH_PISRC_LATCHVALID
Index / Subindex of latch valid information.
Definition: SdoDictionary.mh:5183
VIRTLATCH_MODE_SOFTWARE
#define VIRTLATCH_MODE_SOFTWARE
Definition: SdoDictionary.mh:5251
VIRTCNTIN_OVFL_VALUE
#define VIRTCNTIN_OVFL_VALUE
Value (Range) where the input will overflow.
Definition: SdoDictionary.mh:5049
VIRTLATCH_PISRC_LATCHSTAT
#define VIRTLATCH_PISRC_LATCHSTAT
Index/subindex of latch status source.
Definition: SdoDictionary.mh:5175
VIRTCOUNTIN_PROCESS_SRCINDEX
#define VIRTCOUNTIN_PROCESS_SRCINDEX(modno, parno)
Virtual Counter Inputs Process Data: Source Index.
Definition: SdoDictionary.mh:6184
VIRTCNTIN_UUFACT_INCNO
#define VIRTCNTIN_UUFACT_INCNO
Conversion Factor - number of increments.
Definition: SdoDictionary.mh:5074
HWCNTABS_CODING_NONE
#define HWCNTABS_CODING_NONE
Definition: SdoDictionary.mh:8868
HWCOUNTABS_PROCESS_SRCINDEX
#define HWCOUNTABS_PROCESS_SRCINDEX(modno, parno)
HW Counter-abs Process Data: Source Index.
Definition: SdoDictionary.mh:12120
PO_HWLATCH_FLAG
#define PO_HWLATCH_FLAG
Flag signal that a new latch happened.
Definition: SdoDictionary.mh:12265
VIRTCNTIN_MODE_ABSOLUTE
#define VIRTCNTIN_MODE_ABSOLUTE
Definition: SdoDictionary.mh:5080
PO_HWLATCH_AMOUNT_IN_FIFO
#define PO_HWLATCH_AMOUNT_IN_FIFO
Number of latches in FIFO.
Definition: SdoDictionary.mh:12276
HWENCODER_DATLEN
#define HWENCODER_DATLEN
Number of bits for SSI communication.
Definition: SdoDictionary.mh:8473
HWLATCH_PARAM
#define HWLATCH_PARAM(modno, parno)
HW Latch Register Parameters: Setter.
Definition: SdoDictionary.mh:9088
PO_HWCNTABS_VALUE
#define PO_HWCNTABS_VALUE
Position output of absolute encoder Counter.
Definition: SdoDictionary.mh:12139
VIRTLATCH_PISRC_LATCHCNT
#define VIRTLATCH_PISRC_LATCHCNT
Index/subindex of the counter at which the latch module is looking.
Definition: SdoDictionary.mh:5156
HWENCODER_FAST_UPDATE
#define HWENCODER_FAST_UPDATE
Encoder update rate (Not on MACS5)
Definition: SdoDictionary.mh:8542
VIRTLATCH_MODE_HARDWARE
#define VIRTLATCH_MODE_HARDWARE
Definition: SdoDictionary.mh:5250
VIRTLATCH_PISRC_LATCHFIFO_READ
#define VIRTLATCH_PISRC_LATCHFIFO_READ
Index/subindex of Latchfifo informtaion (read register)
Definition: SdoDictionary.mh:5201
VIRTLATCH_PARAM
#define VIRTLATCH_PARAM(modno, parno)
Virtual Latch Inputs Parameters: Setter.
Definition: SdoDictionary.mh:5111
HWCNTABS_CODING_GREY
#define HWCNTABS_CODING_GREY
Definition: SdoDictionary.mh:8866
PO_VIRTDIGIN_VALLONG
#define PO_VIRTDIGIN_VALLONG
Returns the full 32bit output value.
Definition: SdoDictionary.mh:6535
HWAMP_PISRC_ACTPOS
#define HWAMP_PISRC_ACTPOS
Source for actual position.
Definition: SdoDictionary.mh:7680
HWENCODER_MODE_SSI_ACTIVE
#define HWENCODER_MODE_SSI_ACTIVE
Definition: SdoDictionary.mh:8577
HWLATCH_PISRC_TRIGGER
#define HWLATCH_PISRC_TRIGGER
Source for trigger signal.
Definition: SdoDictionary.mh:9134
HWENCODER_MODE_HALL
#define HWENCODER_MODE_HALL
Definition: SdoDictionary.mh:8582
PO_HWCNTINC_VALUE
#define PO_HWCNTINC_VALUE
Output of counter module (position value)
Definition: SdoDictionary.mh:12030
HWHALL_PROCESS_SRCINDEX
#define HWHALL_PROCESS_SRCINDEX(modno, parno)
HW Hall Sensor Process Data: Source Index.
Definition: SdoDictionary.mh:11962
VIRTLATCH_LATCHVALID_BITMASK
#define VIRTLATCH_LATCHVALID_BITMASK
Latchvalid Bitmask.
Definition: SdoDictionary.mh:5138
HWLATCH_PISRC_TRIGGER_ENCZ
#define HWLATCH_PISRC_TRIGGER_ENCZ
Definition: SdoDictionary.mh:9181
VIRTLATCH_PISRC_LATCHFIFO_AMOUNT
#define VIRTLATCH_PISRC_LATCHFIFO_AMOUNT
Index/subindex of LatchFifo information (amount)
Definition: SdoDictionary.mh:5192
HWENCODER_MODE
#define HWENCODER_MODE
Encoder type.
Definition: SdoDictionary.mh:8395
HWHALL_PARAM
#define HWHALL_PARAM(modno, parno)
HW Hall Sensor Parameters: Setter.
Definition: SdoDictionary.mh:8617
HWAMP_PARAM
#define HWAMP_PARAM(modno, parno)
HW Amplifier Parameters: Setter.
Definition: SdoDictionary.mh:7627
HWCOUNTABS_PARAM
#define HWCOUNTABS_PARAM(modno, parno)
HW Counter-abs Parameters: Setter.
Definition: SdoDictionary.mh:8829
HWCNTABS_CODING
#define HWCNTABS_CODING
Data coding.
Definition: SdoDictionary.mh:8853
PO_HWLATCH_VALUE
#define PO_HWLATCH_VALUE
Output of latch module.
Definition: SdoDictionary.mh:12258
HWHALL_MODE_ENABLE
#define HWHALL_MODE_ENABLE
Definition: SdoDictionary.mh:8648
HWHALL_MODE
#define HWHALL_MODE
Enable.
Definition: SdoDictionary.mh:8632
HWAMP_ENCRES
#define HWAMP_ENCRES
Resolution of the encoder for position feed back in increments (quadcounts)
Definition: SdoDictionary.mh:7802
HWLATCH_PROCESS_SRCINDEX
#define HWLATCH_PROCESS_SRCINDEX(modno, parno)
HW Latch Register Process Data: Source Index.
Definition: SdoDictionary.mh:12240
VIRTCNTIN_MODE_ABSOLUTE_DIRECT_ENDLESS
#define VIRTCNTIN_MODE_ABSOLUTE_DIRECT_ENDLESS
Definition: SdoDictionary.mh:5085
HWAMP_HALL_ALIGNMENT
#define HWAMP_HALL_ALIGNMENT
Hall Alignment.
Definition: SdoDictionary.mh:8228
VIRTCNTIN_PISRC_COUNTER
#define VIRTCNTIN_PISRC_COUNTER
Index/subindex of counter source.
Definition: SdoDictionary.mh:5030
VIRTLATCH_PISRC_COUNTER
#define VIRTLATCH_PISRC_COUNTER
Index/subindex of counter source (attached)
Definition: SdoDictionary.mh:5147
HWHALL_PISRC_ENCOUT
#define HWHALL_PISRC_ENCOUT
Source for the HALL Information.
Definition: SdoDictionary.mh:8643
HWENCODER_CLOCKFREQ
#define HWENCODER_CLOCKFREQ
Clock frequency for SSI encoder.
Definition: SdoDictionary.mh:8464
HWLATCH_PISRC_TRIGGER_DINP
#define HWLATCH_PISRC_TRIGGER_DINP
Definition: SdoDictionary.mh:9186

Data Sheets | Released Software | Software Manuals | Hardware Manuals | Maxon Shop

Maxon Support Center