| ApossC SDK V01.15

Macros | Functions
SDK_Amplifier_MiniMACS6_DS402_Slave.mh File Reference

Declaration of the MiniMACS6 DS402 slave function. More...

Go to the source code of this file.

## Macros
#define | MINIMACS6_RECEIVE_PDO_1_PARAMETER 0x1400
| OBJECT DICTIONARY - MiniMACS6 DS402 Slave. More...
#define | MINIMACS6_RECEIVE_PDO_2_PARAMETER 0x1401
#define | MINIMACS6_RECEIVE_PDO_3_PARAMETER 0x1402
#define | MINIMACS6_RECEIVE_PDO_4_PARAMETER 0x1403
#define | MINIMACS6_RECEIVE_PDO_1_MAPPING 0x1600
#define | MINIMACS6_RECEIVE_PDO_2_MAPPING 0x1601
#define | MINIMACS6_RECEIVE_PDO_3_MAPPING 0x1602
#define | MINIMACS6_RECEIVE_PDO_4_MAPPING 0x1603
#define | MINIMACS6_TRANSMIT_PDO_1_PARAMETER 0x1800
#define | MINIMACS6_TRANSMIT_PDO_2_PARAMETER 0x1801
#define | MINIMACS6_TRANSMIT_PDO_3_PARAMETER 0x1802
#define | MINIMACS6_TRANSMIT_PDO_4_PARAMETER 0x1803
#define | MINIMACS6_TRANSMIT_PDO_1_MAPPING 0x1A00
#define | MINIMACS6_TRANSMIT_PDO_2_MAPPING 0x1A01
#define | MINIMACS6_TRANSMIT_PDO_3_MAPPING 0x1A02
#define | MINIMACS6_TRANSMIT_PDO_4_MAPPING 0x1A03
#define | MINIMACS6_SYNC_MANAGER_2_PDO_ASSIGNMENT 0
#define | MINIMACS6_SYNC_MANAGER_3_PDO_ASSIGNMENT 0
#define | MINIMACS6_CONTROLWORD 0x6040
#define | MINIMACS6_STATUSWORD 0x6041
#define | MINIMACS6_MODES_OF_OPERATION 0x6060
#define | MINIMACS6_OP_PPM 0x01
#define | MINIMACS6_OP_PVM 0x03
#define | MINIMACS6_OP_HMM 0x06
#define | MINIMACS6_OP_CSP 0x08
#define | MINIMACS6_OP_CSV 0x09
#define | MINIMACS6_OP_CST 0x0A
#define | MINIMACS6_MODES_OF_OPERATION_DISPLAY 0x6061

## Functions
long | sdkMiniMACS6_SetupCanBusModule (long axis, long busId, long pdoNumber, long operationMode)
| Setup the Can bus module for an MiniMACS6 DS402 slave. More...
long | sdkMiniMACS6_SetupCanVirtAmp (long axis, long maxRpm, long operationMode)
| Setup the virtual amplifier for an MiniMACS6 DS402 slave with Can bus. More...
long | sdkMiniMACS6_SetupCanVirtCntin (long axis, long operationMode)
| Setup the virtual counter input for an MiniMACS6 DS402 slave with Can bus. More...
long | sdkMiniMACS6_SetupCanSdoParam (long busId, long pdonumber, long slaveAxisNo, long operationMode)
| Setup the Sdo parameter for an MiniMACS6 DS402 slave. More...
long | sdkMiniMACS6_AxisHomingStart (long axis, long busId, long operationMode, long &homingState)
| State machine function for performing a homing on an MiniMACS6 DS402 slave. More...

## Detailed Description

Declaration of the MiniMACS6 DS402 slave function.

Revision
  224

Definition in file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## Macro Definition Documentation

## ◆ MINIMACS6_CONTROLWORD

#define MINIMACS6_CONTROLWORD 0x6040

Definition at line 39 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_MODES_OF_OPERATION

#define MINIMACS6_MODES_OF_OPERATION 0x6060

Definition at line 41 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_MODES_OF_OPERATION_DISPLAY

#define MINIMACS6_MODES_OF_OPERATION_DISPLAY 0x6061

Definition at line 48 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_CSP

#define MINIMACS6_OP_CSP 0x08

Examples
  CAN_4Ax_MiniMACS6_csp.mc.

Definition at line 45 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_CST

#define MINIMACS6_OP_CST 0x0A

Examples
  CAN_4Ax_MiniMACS6_cst.mc.

Definition at line 47 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_CSV

#define MINIMACS6_OP_CSV 0x09

Examples
  CAN_4Ax_MiniMACS6_csv.mc.

Definition at line 46 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_HMM

#define MINIMACS6_OP_HMM 0x06

Definition at line 44 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_PPM

#define MINIMACS6_OP_PPM 0x01

Definition at line 42 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_OP_PVM

#define MINIMACS6_OP_PVM 0x03

Definition at line 43 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_1_MAPPING

#define MINIMACS6_RECEIVE_PDO_1_MAPPING 0x1600

Definition at line 25 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_1_PARAMETER

#define MINIMACS6_RECEIVE_PDO_1_PARAMETER 0x1400

OBJECT DICTIONARY - MiniMACS6 DS402 Slave.

Definition at line 21 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_2_MAPPING

#define MINIMACS6_RECEIVE_PDO_2_MAPPING 0x1601

Definition at line 26 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_2_PARAMETER

#define MINIMACS6_RECEIVE_PDO_2_PARAMETER 0x1401

Definition at line 22 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_3_MAPPING

#define MINIMACS6_RECEIVE_PDO_3_MAPPING 0x1602

Definition at line 27 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_3_PARAMETER

#define MINIMACS6_RECEIVE_PDO_3_PARAMETER 0x1402

Definition at line 23 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_4_MAPPING

#define MINIMACS6_RECEIVE_PDO_4_MAPPING 0x1603

Definition at line 28 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_RECEIVE_PDO_4_PARAMETER

#define MINIMACS6_RECEIVE_PDO_4_PARAMETER 0x1403

Definition at line 24 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_STATUSWORD

#define MINIMACS6_STATUSWORD 0x6041

Definition at line 40 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_SYNC_MANAGER_2_PDO_ASSIGNMENT

#define MINIMACS6_SYNC_MANAGER_2_PDO_ASSIGNMENT 0

Definition at line 37 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_SYNC_MANAGER_3_PDO_ASSIGNMENT

#define MINIMACS6_SYNC_MANAGER_3_PDO_ASSIGNMENT 0

Definition at line 38 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_1_MAPPING

#define MINIMACS6_TRANSMIT_PDO_1_MAPPING 0x1A00

Definition at line 33 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_1_PARAMETER

#define MINIMACS6_TRANSMIT_PDO_1_PARAMETER 0x1800

Definition at line 29 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_2_MAPPING

#define MINIMACS6_TRANSMIT_PDO_2_MAPPING 0x1A01

Definition at line 34 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_2_PARAMETER

#define MINIMACS6_TRANSMIT_PDO_2_PARAMETER 0x1801

Definition at line 30 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_3_MAPPING

#define MINIMACS6_TRANSMIT_PDO_3_MAPPING 0x1A02

Definition at line 35 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_3_PARAMETER

#define MINIMACS6_TRANSMIT_PDO_3_PARAMETER 0x1802

Definition at line 31 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_4_MAPPING

#define MINIMACS6_TRANSMIT_PDO_4_MAPPING 0x1A03

Definition at line 36 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## ◆ MINIMACS6_TRANSMIT_PDO_4_PARAMETER

#define MINIMACS6_TRANSMIT_PDO_4_PARAMETER 0x1803

Definition at line 32 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mh.

## Function Documentation

## ◆ sdkMiniMACS6_AxisHomingStart()

long sdkMiniMACS6_AxisHomingStart | ( | long | axis,
|  | long | busId,
|  | long | operationMode,
|  | long & | homingState
| ) |  |

State machine function for performing a homing on an MiniMACS6 DS402 slave.

This function sets the MiniMACS6 DS402 slave in homing mode and starts the homing defined on the MiniMACS6 DS402 slave. Before calling this function, all homing parameters must be configured on the MiniMACS6 DS402 slave. The function is not blocking. The return parameter must be checked.

Parameters

  axis | Axis module number
  busId | Bus ID of the connected slave
  operationMode | Operation mod which should be set after homing.
  homingState | Call-by-reference variable for the iteration of the different homing states. Must be initialized with 0.

Returns
  value: Process value
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 318 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mc.

320 {
321 long time, displayMode;
322 long axOffset = 0x800;
323 time= Time()%1000;
324
325 switch (homingState) {
326 case 0:
327 print("sdkMiniMACS6_AxisHomingStart: " ,axis);
328 homingState = 1;
329 break;
330 case 1:
331 // x6060 Change operation mode to ”6: Homing mode.”
332 SdoWriten( busId, MINIMACS6_MODES_OF_OPERATION+axOffset*axis, 0, 1, MINIMACS6_OP_HMM);
333 print("...: DS402 Homing AxisNo: ",axis," - Set mode of OP: 0x06");
334
335 Delay(1);
336 print("...: DS402 Homing AxisNo: ",axis," - Enable Drive");
337 AxisControl(axis, ON);
338
339 homingState = 2;
340
341 case 2:
342 displayMode = SdoRead(busId, MINIMACS6_MODES_OF_OPERATION_DISPLAY+axOffset*axis, 0);
343 if(displayMode== MINIMACS6_OP_HMM)
344 {
345 print("...: DS402 Homing AxisNo: ",axis," - Display mode of OP: ",displayMode);
346 homingState = 3;
347 }
348 else if(time==0)
349 {
350 printf("...: DS402 Homing AxisNo: %ld - Waiting for OP mode display: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
351 // This section must be called in a 1 ms loop because of the print function.
352 Delay(1);
353 }
354 break;
355
356 case 3:
357 // Bit 10 Target reached - Homing procedure is interrupted or not started
358 if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[10]==1)
359 {
360 printf("...: DS402 Homing AxisNo: %ld - Homing start signal Status: %lx\n",axis,VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
361 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENP) = 0x1F;
362 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENN) = 0x1F;
363 homingState = 4;
364 }
365 // Bit 13 Homingerror - Homing error occurred
366 else if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[13]==1)
367 {
368 printf("...: DS402 Homing AxisNo: %ld - Homing Error - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
369 return(-1);
370 }
371 else if(time==0)
372 {
373 printf("...: DS402 Homing AxisNo: %ld - Waiting for ready bit: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
374 // This section must be called in a 1 ms loop because of the print function.
375 Delay(1);
376 }
377 break;
378
379 case 4:
380 // Homing procedure is completed successfully
381 if (VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[12]==1)
382 {
383 printf("...: DS402 Homing AxisNo: %ld - Homing done - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
384
385 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENP) = 0x0F;
386 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENN) = 0x0F;
387
388 print("...: DS402 Homing AxisNo: ",axis," - Disable Drive");
389 AxisControl(axis, OFF);
390
391 SdoWriten(busId, MINIMACS6_MODES_OF_OPERATION+axOffset*axis, 0, 1, operationMode ); // 0x6060 Change operation mode to ”8: CSP mode.”
392
393 homingState = 5;
394 break;
395 }
396 // Bit 13 Homingerror - Homing error occurred
397 else if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[13]==1)
398 {
399 printf("...: DS402 Homing AxisNo: %ld - Homing Error - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
400 return(-1);
401 }
402 // Homing procedure is in progress
403 else if(time==0)
404 {
405 printf("...: DS402 Homing AxisNo: %ld - Homing in progress - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
406 // This section must be called in a 1 ms loop because of the print function.
407 Delay(1);
408 }
409 break;
410
411 case 5:
412 displayMode = SdoRead(busId, MINIMACS6_MODES_OF_OPERATION_DISPLAY+axOffset*axis, 0);
413 if(displayMode== operationMode)
414 {
415 print("...: DS402 Homing AxisNo: ",axis," - Display mode of OP: ",displayMode);
416 homingState = 6;
417 }
418 else if(time==0)
419 {
420 printf("...: DS402 Homing AxisNo: %ld - Waiting for OP mode display: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
421 // This section must be called in a 1 ms loop because of the print function.
422 Delay(1);
423 }
424 case 6:
425 print("...: DS402 Homing AxisNo: ",axis," - Finished");
426 homingState = 7;
427 return(1);
428 case 7:
429 return(1);
430 default :
431 print("...: DS402 Homing AxisNo: ",axis," - Incorrect hominState init value: ", homingState);
432 return(-1);
433 }
434
435 return(0);
436 }

## ◆ sdkMiniMACS6_SetupCanBusModule()

long sdkMiniMACS6_SetupCanBusModule | ( | long | axis,
|  | long | busId,
|  | long | pdoNumber,
|  | long | operationMode
| ) |  |

Setup the Can bus module for an MiniMACS6 DS402 slave.

This function sets up the Can bus module for an MiniMACS6 DS402 slave. It can be defined with which operation mode is used. Currently there are no differences in the different operation modes regarding the Bus Module setup.

Parameters

  axis | Axis module number
  busId | Bus ID of the connected slave
  pdoNumber | Used PDO number
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode n 0x0A: Cyclic synchronous torque (cst) mode

Note
  The value passed from "BUSMOD_RXMAP_POVALUE3" is the current torque. The value is given in per thousand of “Motor rated torque”.

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 37 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mc.

38 {
39 long busmod, signedFlag;
40 signedFlag = 0x10000000;
41 busmod = axis;
42
43 print("sdkMiniMACS6_SetupCanBusModule: ", busmod);
44
45 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_DEACTIVATE; // Deactivate (objects will be deleted)
46 BUSMOD_PARAM(busmod, BUSMOD_BUSTYPE) = BUSMOD_BUSTYPE_CAN; // Can bus
47
48
49 BUSMOD_PARAM(busmod, BUSMOD_BUSNO) = busId / 100000; // Bus number (0 = master, 1 = slave CAN bus)
50 BUSMOD_PARAM(busmod, BUSMOD_ID) = busId % 1000; // CAN Id for this bus module
51 BUSMOD_PARAM(busmod, BUSMOD_SYNC) = 1; // Sync active
52 BUSMOD_PARAM(busmod, BUSMOD_GUARDTIME) = 0; // no guarding
53 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_ACTIVATE; // Create bus module
54
55 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT1) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_CMDWORD); // Select the input value sources object (send to bus): CMD Word
56
57 if (operationMode == MINIMACS6_OP_CSP) // cycle synchronous position (csp) mode
58 {
59 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFPOS); // Select the input value sources object (send to bus): position setpoint
60 print("...: cycle synchronous position (csp) mode");
61 }
62 else if (operationMode == MINIMACS6_OP_CSV) // cycle synchronous velocity (csv) mode
63 {
64 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFVEL); // Select the input value sources object (send to bus): velocity setvel
65 print("...: cycle synchronous velocity (csv) mode");
66 }
67 else if (operationMode == MINIMACS6_OP_CST) // cycle synchronous torque (cst) mode
68 {
69 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = AXE_PROCESS_SRCINDEX(axis,REG_USERREFCUR); // Select the input value sources object (send to bus): target torque
70 print("...: cycle synchronous torque (cst) mode");
71 }
72 else// Error
73 {
74 print("...: not supported operation mode");
75 return(-1);
76 }
77
78 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset control word
79
80 if (operationMode != MINIMACS6_OP_CST)
81 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset target position/ velocity
82 else // cycle synchronous torque (cst) mode
83 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT2) = pdoNumber*0x01000000 + 2*0x00010000 + 2; // pdo ; length in bytes; bytes offset target torque
84
85 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset status word
86 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset position actual value
87 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE3) = signedFlag + pdoNumber*0x01000000 + 2*0x00010000 + 6; // pdo ; length in bytes; bytes offset torque actual value
88
89 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_ACTIVATE_NOSTOP; // Start bus module
90
91 return(1);
92 }

## ◆ sdkMiniMACS6_SetupCanSdoParam()

long sdkMiniMACS6_SetupCanSdoParam | ( | long | busId,
|  | long | pdonumber,
|  | long | slaveAxisNo,
|  | long | operationMode
| ) |  |

Setup the Sdo parameter for an MiniMACS6 DS402 slave.

This function sets up the Sdo parameter for an MiniMACS6 DS402 slave. It can be defined with which operation mode is used. Each axis is controlled via its own PDO. A maximum of 4 axes can be controlled.

Parameters

  busId | Bus ID of the connected slave
  pdoNumber | Used PDO number
  slaveAxisNo | Axis module number of the slave (0-5)
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode n 0x0A: Cyclic synchronous torque (cst) mode

Returns
  value: Process value
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 230 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mc.

232 {
233 long nodeid, last_value;
234 long axOffset = 0x8000000;
235 nodeid = busId % 100000;
236
237 print("sdkMiniMACS6_SetupCanSdoParam: " ,nodeid);
238
239 // Set ms loop sync source to CAN PDO, This feature will sync the controllers loop to a bus signal.
240 SdoWrite(busId, 0x2203, 0x13, 1);
241
242 // reset Transmittype
243 SdoWrite(busId, MINIMACS6_TRANSMIT_PDO_1_PARAMETER+ pdonumber-1, 2, 255); // TxPDO1 Transmittype
244
245 // the pdos have to be disabled for configuring
246 last_value = (SdoRead(busId, MINIMACS6_TRANSMIT_PDO_1_PARAMETER+ pdonumber-1, 1));
247 SdoWrite(busId, MINIMACS6_TRANSMIT_PDO_1_PARAMETER+ pdonumber-1, 1, (last_value | 0x80000000)); // disable pdo x
248
249 //the pdos have to be disabled for configuring
250 last_value = (SdoRead(busId, MINIMACS6_RECEIVE_PDO_1_PARAMETER+pdonumber-1, 1));
251 SdoWrite(busId, MINIMACS6_RECEIVE_PDO_1_PARAMETER+ pdonumber-1, 1, (last_value | 0x80000000)); // disable pdo 1
252
253 // Now we setup the correct PDO transmission for Tx and Rx
254 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_PARAMETER + pdonumber-1), 2, 1); // TxPDO Transmittype SYNC
255 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_PARAMETER + pdonumber-1), 2, 1); // RxPDO Transmittype SYNC
256
257 // config RX PDO
258 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber-1), 0x00, 0); // disable
259 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber-1), 0x01, 0x60400010+axOffset*slaveAxisNo); // controlword
260
261 if (operationMode == MINIMACS6_OP_CSP) {
262 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x607A0020+axOffset*slaveAxisNo); // download pdo 0x1600 entry: position set point
263 SdoWrite(busId, MINIMACS6_MODES_OF_OPERATION, 0, MINIMACS6_OP_CSP); // mode of operation CSP
264 print("...: cycle synchronous position (csp) mode");
265 }
266 else if (operationMode == MINIMACS6_OP_CSV ) {
267 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x60FF0020+axOffset*slaveAxisNo); // download pdo 0x1600 entry: target velocity 32bit
268 SdoWrite(busId, MINIMACS6_MODES_OF_OPERATION, 0, MINIMACS6_OP_CSV); // mode of operation CSV
269 print("...: cycle synchronous velocity (csv) mode");
270 }
271 else if (operationMode == MINIMACS6_OP_CST) {
272 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x60710010+axOffset*slaveAxisNo); // download pdo 0x1600 entry: Target torque 16bit
273 SdoWrite(busId, MINIMACS6_MODES_OF_OPERATION, 0, MINIMACS6_OP_CST); // mode of operation CST
274 print("...: cycle synchronous torque (cst) mode");
275 }
276 else { // Error
277 print("...: not supported operation mode");
278 return(-1);
279 }
280
281 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_MAPPING + pdonumber - 1), 0x00, 2); // enable
282
283 // config TX PDO
284 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x00, 0); // disable
285 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x01, 0x60410010+axOffset*slaveAxisNo); // statusword
286 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x02, 0x60640020+axOffset*slaveAxisNo); // actpos
287 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x03, 0x60770010+axOffset*slaveAxisNo); // Torque actual
288 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x00, 3 ); // enable
289
290 // fill in the wanted pdo
291 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_PARAMETER + pdonumber - 1), 1, (0x80000180 + (pdonumber - 1)*0x100 + nodeid) );// fill in pdo
292 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_PARAMETER + pdonumber - 1), 1, (0x80000200 + (pdonumber - 1)*0x100 + nodeid) );// fill in pdo
293
294 // enable
295 SdoWrite(busId, (MINIMACS6_TRANSMIT_PDO_1_PARAMETER + pdonumber - 1), 1, (0x00000180 + (pdonumber - 1)*0x100 + nodeid) );// enable pdo
296 SdoWrite(busId, (MINIMACS6_RECEIVE_PDO_1_PARAMETER + pdonumber - 1), 1, (0x00000200 + (pdonumber - 1)*0x100 + nodeid) );// enable pdo
297
298 return(1);
299 }

## ◆ sdkMiniMACS6_SetupCanVirtAmp()

long sdkMiniMACS6_SetupCanVirtAmp | ( | long | axis,
|  | long | maxRpm,
|  | long | operationMode
| ) |  |

Setup the virtual amplifier for an MiniMACS6 DS402 slave with Can bus.

This function sets up the virtual amplifier with Can bus for an MiniMACS6 DS402 slave. It can be defined with which operation mode is used.

Parameters

  axis | Axis module number
  maxRpm | Definition of the maximum motor speed [rpm]
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode n 0x0A: Cyclic synchronous torque (cst) mode

Note
  The value passed from "PO_BUSMOD_VALUE3" to "VIRTAMP_PISRC_CURRENT" is the current torque. The value is given in per thousand of “Motor rated torque”.

Returns
  value: Always 1 in this function
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 112 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mc.

113 {
114 print("sdkMiniMACS6_SetupCanVirtAmp: ",axis );
115
116 // virtual amplifiers have a fixed connection to axes number, axes 0 uses amplifier 0.
117 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CMDWORD) = AXE_PROCESS_SRCINDEX(axis,REG_CNTRLWORD);
118 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFPOS) = AXE_PROCESS_SRCINDEX(axis,REG_COMPOS);
119 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFVEL) = AXE_PROCESS_SRCINDEX(axis,REG_REFERENCE);
120 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFACC) = AXE_PROCESS_SRCINDEX(axis,PID_FFACCPART);
121 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_STATUS) = BUSMOD_PROCESS_SRCINDEX(axis,PO_BUSMOD_VALUE1); //statusword
122 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CURRENT) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE3); //torque
123
124 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWROFF) = 0x06;
125 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONDIS) = 0x06;
126 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENP) = 0x0F;
127 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENN) = 0x0F;
128 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_QUICKSTOP) = 0x02;
129 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_RESET) = 0x80;
130
131 VIRTAMP_PARAM(axis,VIRTAMP_STOPDELAY) = 0x00;
132 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_BITMASK) = 0x08;
133 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_POLARITY) = 1;
134
135 // Ready bit: Ready to switch on, Switched on, Operation enabled, Voltage enabled
136 VIRTAMP_PARAM(axis,VIRTAMP_READY_BITMASK) = 0x17;
137 VIRTAMP_PARAM(axis,VIRTAMP_READY_POLARITY) = 1;
138
139 if (operationMode == MINIMACS6_OP_CSP) // cycle synchronous position (csp) mode
140 {
141 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in csp
142 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in csp
143 print("...: cycle synchronous position (csp) mode");
144 }
145 else if (operationMode == MINIMACS6_OP_CSV) // cycle synchronous velocity (csv) mode
146 {
147 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = maxRpm;
148 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 2* maxRpm;
149 print("...: cycle synchronous velocity (csv) mode");
150 }
151 else if (operationMode == MINIMACS6_OP_CST) // cycle synchronous torque (cst) mode
152 {
153 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in cst
154 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in cst
155 print("...: cycle synchronous torque (cst) mode");
156 }
157 else // Error
158 {
159 print("...: not supported operation mode");
160 return(-1);
161 }
162
163 VIRTAMP_PARAM(axis,VIRTAMP_MODE) = VIRTAMP_MODE_ENABLE; // has to be the last one because it activates all
164
165 return(1);
166 }

## ◆ sdkMiniMACS6_SetupCanVirtCntin()

long sdkMiniMACS6_SetupCanVirtCntin | ( | long | axis,
|  | long | operationMode
| ) |  |

Setup the virtual counter input for an MiniMACS6 DS402 slave with Can bus.

This function sets up the virtual counter input for an MiniMACS6 DS402 slave. It can be defined with which operation mode is used.

Parameters

  axis | Axis module number
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode n 0x0A: Cyclic synchronous torque (cst) mode

Returns
  value: Process value
  value > 0 Process successful
  value = 0 Process is active
  value < 0 Error

Definition at line 183 of file SDK_Amplifier_MiniMACS6_DS402_Slave.mc.

184 {
185 print("sdkMiniMACS6_SetupCanVirtCntin: ",axis);
186
187 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_PISRC_COUNTER) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE2);
188
189 if (operationMode == MINIMACS6_OP_CSP) // cycle synchronous position (csp) mode
190 {
191 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT; // Source is absolute and is taken as it is
192 print("...: cycle synchronous position (csp) mode");
193 }
194 else if (operationMode == MINIMACS6_OP_CSV) // cycle synchronous velocity (csv) mode
195 {
196 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Source is a position value and difference to last value is added
197 print("...: cycle synchronous velocity (csv) mode");
198 }
199 else if (operationMode == MINIMACS6_OP_CSP) // cycle synchronous torque (cst) mode
200 {
201 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT; // Source is absolute and is taken as it is
202 print("...: cycle synchronous torque (cst) mode");
203 }
204 else // Error
205 {
206 print("...: not supported operation mode");
207 return(-1);
208 }
209
210 return(1);
211 }
VIRTCNTIN_MODE
#define VIRTCNTIN_MODE
Counter mode.
Definition: SdoDictionary.mh:5003
BUSMOD_MODE_ACTIVATE_NOSTOP
#define BUSMOD_MODE_ACTIVATE_NOSTOP
Definition: SdoDictionary.mh:11306
PID_FFACCPART
#define PID_FFACCPART
Definition: SdoDictionary.mh:3454
VIRTCOUNTIN_PARAM
#define VIRTCOUNTIN_PARAM(modno, parno)
Virtual Counter Inputs parameters: Setter.
Definition: SdoDictionary.mh:4985
VIRTAMP_PROCESS_SRCINDEX
#define VIRTAMP_PROCESS_SRCINDEX(modno, parno)
Virtual Amplifier Process Data: Source Index.
Definition: SdoDictionary.mh:6404
VIRTAMP_CNTRLW_QUICKSTOP
#define VIRTAMP_CNTRLW_QUICKSTOP
Controlword to stop drive with internal ramps.
Definition: SdoDictionary.mh:5395
BUSMOD_ID
#define BUSMOD_ID
Slave node id.
Definition: SdoDictionary.mh:11017
MINIMACS6_RECEIVE_PDO_1_PARAMETER
#define MINIMACS6_RECEIVE_PDO_1_PARAMETER
OBJECT DICTIONARY - MiniMACS6 DS402 Slave.
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:21
VIRTAMP_ERROR_POLARITY
#define VIRTAMP_ERROR_POLARITY
Polarity of Error Bit.
Definition: SdoDictionary.mh:5521
VIRTAMP_CNTRLW_RESET
#define VIRTAMP_CNTRLW_RESET
Controlword to reset from error.
Definition: SdoDictionary.mh:5405
MINIMACS6_OP_HMM
#define MINIMACS6_OP_HMM
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:44
MINIMACS6_MODES_OF_OPERATION_DISPLAY
#define MINIMACS6_MODES_OF_OPERATION_DISPLAY
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:48
VIRTAMP_READY_BITMASK
#define VIRTAMP_READY_BITMASK
Bitmask to detect drive ready condition.
Definition: SdoDictionary.mh:5555
VIRTAMP_PISRC_CMDWORD
#define VIRTAMP_PISRC_CMDWORD
Index/subindex of command word.
Definition: SdoDictionary.mh:5300
VIRTAMP_REF100PERC
#define VIRTAMP_REF100PERC
Output reference value to use at 100 percent.
Definition: SdoDictionary.mh:5442
VIRTAMP_READY_POLARITY
#define VIRTAMP_READY_POLARITY
Polarity of Ready Bit.
Definition: SdoDictionary.mh:5565
MINIMACS6_TRANSMIT_PDO_1_MAPPING
#define MINIMACS6_TRANSMIT_PDO_1_MAPPING
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:33
BUSMOD_RXMAP_POVALUE2
#define BUSMOD_RXMAP_POVALUE2
Mapping for RX PDOs (receive from bus)
Definition: SdoDictionary.mh:11216
BUSMOD_BUSTYPE
#define BUSMOD_BUSTYPE
Bus type.
Definition: SdoDictionary.mh:10996
BUSMOD_MODE_ACTIVATE
#define BUSMOD_MODE_ACTIVATE
Definition: SdoDictionary.mh:11305
PO_VIRTAMP_REFVEL
#define PO_VIRTAMP_REFVEL
Output reference velocity.
Definition: SdoDictionary.mh:6438
PO_BUSMOD_VALUE1
#define PO_BUSMOD_VALUE1
Output value of the RX PDOs.
Definition: SdoDictionary.mh:12804
VIRTAMP_PISRC_STATUS
#define VIRTAMP_PISRC_STATUS
Index/subindex of status.
Definition: SdoDictionary.mh:5335
BUSMOD_BUSTYPE_CAN
#define BUSMOD_BUSTYPE_CAN
Definition: SdoDictionary.mh:11309
VIRTCNTIN_MODE_ABSOLUTE
#define VIRTCNTIN_MODE_ABSOLUTE
Definition: SdoDictionary.mh:5080
REG_REFERENCE
#define REG_REFERENCE
Actual reference value generated by position control loop.
Definition: SdoDictionary.mh:3290
BUSMOD_PISRC_INPUT2
#define BUSMOD_PISRC_INPUT2
Index and subindex of Input value.
Definition: SdoDictionary.mh:10872
BUSMOD_TXMAP_INPUT1
#define BUSMOD_TXMAP_INPUT1
Mapping for TX PDOs (send to bus)
Definition: SdoDictionary.mh:11097
MINIMACS6_RECEIVE_PDO_1_MAPPING
#define MINIMACS6_RECEIVE_PDO_1_MAPPING
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:25
VIRTAMP_PARAM
#define VIRTAMP_PARAM(modno, parno)
Virtual Amplifier Parameters: Setter.
Definition: SdoDictionary.mh:5280
BUSMOD_RXMAP_POVALUE1
#define BUSMOD_RXMAP_POVALUE1
Mapping for RX PDOs (receive from bus)
Definition: SdoDictionary.mh:11202
VIRTAMP_ERROR_BITMASK
#define VIRTAMP_ERROR_BITMASK
Bitmask to detect error condition.
Definition: SdoDictionary.mh:5510
REG_USERREFCUR
#define REG_USERREFCUR
Motor current reference value in AxisControl(USERREFCUR) mode.
Definition: SdoDictionary.mh:3414
BUSMOD_BUSNO
#define BUSMOD_BUSNO
Bus number.
Definition: SdoDictionary.mh:11006
VIRTAMP_STOPDELAY
#define VIRTAMP_STOPDELAY
Delay after a STOP command.
Definition: SdoDictionary.mh:5491
BUSMOD_PROCESS_SRCINDEX
#define BUSMOD_PROCESS_SRCINDEX(modno, parno)
Bus Module Process Data: Source Index.
Definition: SdoDictionary.mh:12789
VIRTAMP_PROCESS
#define VIRTAMP_PROCESS(modno, parno)
Virtual Amplifier Process Data: Setter.
Definition: SdoDictionary.mh:6410
VIRTAMP_PISRC_REFACC
#define VIRTAMP_PISRC_REFACC
Index/subindex of acceleration/current reference.
Definition: SdoDictionary.mh:5321
MINIMACS6_MODES_OF_OPERATION
#define MINIMACS6_MODES_OF_OPERATION
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:41
PO_BUSMOD_VALUE3
#define PO_BUSMOD_VALUE3
Output value of the RX PDOs.
Definition: SdoDictionary.mh:12814
PO_VIRTAMP_CMDWORD
#define PO_VIRTAMP_CMDWORD
Output command word.
Definition: SdoDictionary.mh:6426
VIRTAMP_CNTRLW_PWRONENN
#define VIRTAMP_CNTRLW_PWRONENN
Controlword to use in power on enable negative direction state (could be same as above)
Definition: SdoDictionary.mh:5385
VIRTAMP_PISRC_CURRENT
#define VIRTAMP_PISRC_CURRENT
Index/subindex of current.
Definition: SdoDictionary.mh:5328
VIRTAMP_CNTRLW_PWRONENP
#define VIRTAMP_CNTRLW_PWRONENP
Controlword to use in power on enable positive direction state.
Definition: SdoDictionary.mh:5375
BUSMOD_MODE_DEACTIVATE
#define BUSMOD_MODE_DEACTIVATE
Definition: SdoDictionary.mh:11304
VIRTAMP_MODE_ENABLE
#define VIRTAMP_MODE_ENABLE
Definition: SdoDictionary.mh:5581
PO_VIRTAMP_REFPOS
#define PO_VIRTAMP_REFPOS
Output reference position.
Definition: SdoDictionary.mh:6432
REG_COMPOS
#define REG_COMPOS
Set-point position value.
Definition: SdoDictionary.mh:3207
AXE_PROCESS_SRCINDEX
#define AXE_PROCESS_SRCINDEX(modno, parno)
Axis Process Data: Source Index.
Definition: SdoDictionary.mh:3181
MINIMACS6_OP_CSP
#define MINIMACS6_OP_CSP
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:45
BUSMOD_MODE
#define BUSMOD_MODE
Activate / Deactivate.
Definition: SdoDictionary.mh:10839
VIRTAMP_MODE
#define VIRTAMP_MODE
Mode of operation.
Definition: SdoDictionary.mh:5293
BUSMOD_SYNC
#define BUSMOD_SYNC
Sync interval (only for CAN)
Definition: SdoDictionary.mh:11032
MINIMACS6_TRANSMIT_PDO_1_PARAMETER
#define MINIMACS6_TRANSMIT_PDO_1_PARAMETER
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:29
REG_CNTRLWORD
#define REG_CNTRLWORD
Definition: SdoDictionary.mh:3369
VIRTAMP_CNTRLW_PWROFF
#define VIRTAMP_CNTRLW_PWROFF
Controlword to use in power off state.
Definition: SdoDictionary.mh:5355
BUSMOD_RXMAP_POVALUE3
#define BUSMOD_RXMAP_POVALUE3
Mapping for RX PDOs (receive from bus)
Definition: SdoDictionary.mh:11230
VIRTAMP_PISRC_REFPOS
#define VIRTAMP_PISRC_REFPOS
Index/subindex of position reference.
Definition: SdoDictionary.mh:5307
BUSMOD_GUARDTIME
#define BUSMOD_GUARDTIME
Guard interval.
Definition: SdoDictionary.mh:11047
MINIMACS6_OP_CST
#define MINIMACS6_OP_CST
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:47
BUSMOD_PISRC_INPUT1
#define BUSMOD_PISRC_INPUT1
Index and subindex of Input value.
Definition: SdoDictionary.mh:10864
PO_VIRTAMP_STATUS
#define PO_VIRTAMP_STATUS
Status.
Definition: SdoDictionary.mh:6420
VIRTCNTIN_MODE_ABSOLUTE_DIRECT
#define VIRTCNTIN_MODE_ABSOLUTE_DIRECT
Definition: SdoDictionary.mh:5083
VIRTAMP_PISRC_REFVEL
#define VIRTAMP_PISRC_REFVEL
Index/subindex of velocity reference.
Definition: SdoDictionary.mh:5314
VIRTAMP_REFLIMIT
#define VIRTAMP_REFLIMIT
Output reference limit.
Definition: SdoDictionary.mh:5449
MINIMACS6_OP_CSV
#define MINIMACS6_OP_CSV
Definition: SDK_Amplifier_MiniMACS6_DS402_Slave.mh:46
BUSMOD_PARAM
#define BUSMOD_PARAM(modno, parno)
Bus Module Parameters: Setter.
Definition: SdoDictionary.mh:10813
VIRTAMP_CNTRLW_PWRONDIS
#define VIRTAMP_CNTRLW_PWRONDIS
Controlword to use in power on disable state.
Definition: SdoDictionary.mh:5365
BUSMOD_TXMAP_INPUT2
#define BUSMOD_TXMAP_INPUT2
Mapping for TX PDOs (send to bus)
Definition: SdoDictionary.mh:11110
VIRTCNTIN_PISRC_COUNTER
#define VIRTCNTIN_PISRC_COUNTER
Index/subindex of counter source.
Definition: SdoDictionary.mh:5030
PO_BUSMOD_VALUE2
#define PO_BUSMOD_VALUE2
Output value of the RX PDOs.
Definition: SdoDictionary.mh:12809

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

Maxon Support Center