ApossC SDK  V01.15
SDK_Encoder_Setup.mc
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <SysDef.mh>
17 #include "SDK_Encoder_Setup.mh"
18 
43 long sdkSetupIncEncoder(long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
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 }
84 
110 long sdkSetupSinCosEncoder(long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
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 }
151 
152 
153 
179 long sdkSetupAbsSSIEncoder(long axis, long encPort, long encRes, long clockFreq, long fastUpdate, long datlen, long isBinary, long latchBitMask)
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 }
237 long sdkSetupHallEncoderMACS5(long axis, long hallPort,long hallAligment)
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 }
260 
261 
275 long sdkSetupHallEncoder(long axis, long hallAligment, long hallDirection)
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 }
288 
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
SDK_Encoder_Setup.mh
Declaration of the encoder setup function.
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
sdkSetupIncEncoder
long sdkSetupIncEncoder(long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
Settings for an incremental encoder.
Definition: SDK_Encoder_Setup.mc:43
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
sdkSetupHallEncoder
long sdkSetupHallEncoder(long axis, long hallAligment, long hallDirection)
Settings for an hall encoder.
Definition: SDK_Encoder_Setup.mc:275
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
sdkSetupHallEncoderMACS5
long sdkSetupHallEncoderMACS5(long axis, long hallPort, long hallAligment)
Settings for an hall encoder.
Definition: SDK_Encoder_Setup.mc:237
HWAMP_PISRC_ACTPOS
#define HWAMP_PISRC_ACTPOS
Source for actual position.
Definition: SdoDictionary.mh:7680
sdkSetupAbsSSIEncoder
long sdkSetupAbsSSIEncoder(long axis, long encPort, long encRes, long clockFreq, long fastUpdate, long datlen, long isBinary, long latchBitMask)
Settings for a SSI encoder.
Definition: SDK_Encoder_Setup.mc:179
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
sdkSetupSinCosEncoder
long sdkSetupSinCosEncoder(long axis, long encPort, long encRes, long latchType, long latchParam, long latchSlope)
Settings for an SinCos encoder.
Definition: SDK_Encoder_Setup.mc:110
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