| ApossC SDK V01.15

Functions
SDK_Amplifier_Epos4.mc File Reference

This file provides all the function used to setup a Epos4 drive. More...

`#include <SysDef.mh>`
`#include "SDK_Amplifier_Epos4.mh"`

Go to the source code of this file.

## Functions
long | sdkEpos4_SetupECatBusModule (long axis, long busId, long pdoNumber, long operationMode)
| Setup the ECAT bus module for an Epos4. More...
long | sdkEpos4_SetupECatVirtAmp (long axis, long maxRpm, long operationMode)
| Setup the virtual amplifier for an Epos4 with EtherCat. More...
long | sdkEpos4_SetupECatVirtCntin (long axis, long operationMode)
| Setup the virtual counter input for an Epos4 with EtherCat. More...
long | sdkEpos4_SetupECatSdoParam (long busId, long pdoNumber, long axisPolarity, long operationMode)
| Setup the Sdo parameter for an Epos4 with EtherCat. More...
long | sdkEpos4_SetupCanBusModule (long axis, long busId, long pdoNumber, long operationMode)
| Setup the Can bus module for an Epos4. More...
long | sdkEpos4_SetupCanVirtAmp (long axis, long maxRpm, long operationMode)
| Setup the virtual amplifier for an Epos4 with Can bus. More...
long | sdkEpos4_SetupCanVirtCntin (long axis, long operationMode)
| Setup the virtual counter input for an Epos4 with Can bus. More...
long | sdkEpos4_SetupCanSdoParam (long busId, long pdonumber, long axisPolarity, long operationMode)
| Setup the Sdo parameter for an Epos4. More...
long | sdkEpos4_AxisHomingStart (long axis, long busId, long operationMode, long &homingState)
| State machine function for performing a homing on an EPOS4. More...
void | sdkEpos4_PrintErrorDescription (long errorCode)
| Prints a error description for Epos4 errors. More...

## Detailed Description

This file provides all the function used to setup a Epos4 drive.

The Epos4 can be operated in the different modes csp and csv The amplifiers can be controlled via EtherCAT or CAN bus. The motor, encoder and controller parameters are set directly with "Epos Studio".

Revision
  274

Definition in file SDK_Amplifier_Epos4.mc.

## Function Documentation

## ◆ sdkEpos4_AxisHomingStart()

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

State machine function for performing a homing on an EPOS4.

This function sets the EPOS4 in homing mode and starts the homing defined on the EPOS4. Before calling this function, all homing parameters must be configured on the EPOS4. 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

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, CAN_2Ax_EPOS4-Test_csp.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 607 of file SDK_Amplifier_Epos4.mc.

609 {
610 long time, displayMode;
611 long homingMethode = 0;
612
613 time= Time()%1000;
614
615 switch (homingState) {
616 case 0:
617 print("sdkEpos4_AxisHomingStart: " ,axis);
618 homingMethode = SdoRead(busId, EPOS4_HOMING_METHOD,0);
619 print("...: EPOS4 Homing AxisNo: ",axis," - Homing methode: ",homingMethode);
620 homingState = 1;
621 break;
622 case 1:
623 print("...: EPOS4 Homing AxisNo: ",axis," - Enable drive");
624 // The trajectory generator of the EPOS4 is used for homing. With this command the axis is switched on
625 // and the trajectory generator of the MACS is switched off. Thus REG_COMPOS = REG_ACTPOS is set.
626 AxisControl(axis, USERREFVEL);
627
628 // x6060 Change operation mode to ”6: Homing mode.”
629 SdoWriten( busId, EPOS4_MODES_OF_OPERATION, 0, 1, EPOS4_OP_HMM);
630 print("...: EPOS4 Homing AxisNo: ",axis," - Set mode of OP: 0x06");
631
632 homingState = 2;
633
634 case 2:
635 displayMode = SdoRead(busId, EPOS4_MODES_OF_OPERATION_DISPLAY, 0);
636 if(displayMode== EPOS4_OP_HMM)
637 {
638 print("...: EPOS4 Homing AxisNo: ",axis," - Display mode of OP: ",displayMode);
639 homingState = 3;
640 }
641 else if(time==0)
642 {
643 printf("...: EPOS4 Homing AxisNo: %ld - Waiting for OP mode display: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
644 // This section must be called in a 1 ms loop because of the print function.
645 Delay(1);
646 }
647 break;
648
649 case 3:
650 // Bit 2 Operation enabled - EPOS4 is ready to start
651 // Bit 10 Target reached - Homing procedure is interrupted or not started
652 if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[2]==1 && VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[10]==1)
653 {
654 printf("...: EPOS4 Homing AxisNo: %ld - Homing start signal Status: %lx\n",axis,VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
655 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENP) = 0x1F;
656 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENN) = 0x1F;
657 homingState = 4;
658 }
659 // Bit 13 Homingerror - Homing error occurred
660 else if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[13]==1)
661 {
662 printf("...: EPOS4 Homing AxisNo: %ld - Homing Error - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
663 return(-1);
664 }
665 else if(time==0)
666 {
667 printf("...: EPOS4 Homing AxisNo: %ld - Waiting for ready bit: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
668 // This section must be called in a 1 ms loop because of the print function.
669 Delay(1);
670 }
671 break;
672
673 case 4:
674 // Homing procedure is completed successfully
675 if (VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[12]==1)
676 {
677 printf("...: EPOS4 Homing AxisNo: %ld - Homing done - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
678
679 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENP) = 0x0F;
680 VIRTAMP_PARAM(axis, VIRTAMP_CNTRLW_PWRONENN) = 0x0F;
681
682 SdoWriten(busId, 0x6060, 0, 1, operationMode ); // 0x6060 Change operation mode to ”xxx mode.”
683
684 homingState = 5;
685 break;
686 }
687 // Bit 13 Homingerror - Homing error occurred
688 else if(VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS).i[13]==1)
689 {
690 printf("...: EPOS4 Homing AxisNo: %ld - Homing Error - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
691 return(-1);
692 }
693 // Homing procedure is in progress
694 else if(time==0)
695 {
696 printf("...: EPOS4 Homing AxisNo: %ld - Homing in progress - Status: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
697 // This section must be called in a 1 ms loop because of the print function.
698 Delay(1);
699 }
700 break;
701
702 case 5:
703 displayMode = SdoRead(busId, EPOS4_MODES_OF_OPERATION_DISPLAY, 0);
704 if(displayMode== operationMode)
705 {
706 print("...: EPOS4 Homing AxisNo: ",axis," - Display mode of OP: ",displayMode);
707 homingState = 6;
708 }
709 else if(time==0)
710 {
711 printf("...: EPOS4 Homing AxisNo: %ld - Waiting for OP mode display: %lx\n",axis, VIRTAMP_PROCESS(axis,PO_VIRTAMP_STATUS));
712 // This section must be called in a 1 ms loop because of the print function.
713 Delay(1);
714 }
715 case 6:
716 print("...: EPOS4 Homing AxisNo: ",axis," - Disable Drive");
717 AxisControl(axis, OFF);
718 homingState = 7;
719 case 7:
720 return(1);
721 default :
722 print("...: EPOS4 Homing AxisNo: ",axis," - Incorrect hominState value: ", homingState);
723 return(-1);
724 }
725
726 return(0);
727 }

## ◆ sdkEpos4_PrintErrorDescription()

void sdkEpos4_PrintErrorDescription | ( | long | errorCode | ) |

Prints a error description for Epos4 errors.

This function prints a description for Epos4 error codes

Parameters

  errorCode | Epos4 error code

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, CAN_2Ax_EPOS4-Test_csp.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 735 of file SDK_Amplifier_Epos4.mc.

736 {
737 switch (errorCode) {
738 case EPOS4_F_NO_ERROR:
739 printf("No error.");
740 break;
741 case EPOS4_F_GENERIC:
742 printf("Generic error.");
743 break;
744 case EPOS4_F_GENERIC_INIT1:
745 case EPOS4_F_GENERIC_INIT2:
746 case EPOS4_F_GENERIC_INIT3:
747 case EPOS4_F_GENERIC_INIT4:
748 case EPOS4_F_GENERIC_INIT5:
749 case EPOS4_F_GENERIC_INIT6:
750 case EPOS4_F_GENERIC_INIT7:
751 case EPOS4_F_GENERIC_INIT8:
752 case EPOS4_F_GENERIC_INIT9:
753 printf("Generic initialization error.");
754 break;
755 case EPOS4_F_FIRMWARE_INCOMPATIBILITY:
756 printf("Firmware incompatibility.");
757 break;
758 case EPOS4_F_OVERCURRENT:
759 printf("Overcurrent.");
760 break;
761 case EPOS4_F_POWER_STAGE_PROTECTION:
762 printf("Power stage protection.");
763 break;
764 case EPOS4_F_OVERVOLTAGE:
765 printf("Overvoltage.");
766 break;
767 case EPOS4_F_UNDERVOLTAGE:
768 printf("Undervoltage.");
769 break;
770 case EPOS4_F_THERMAL_OVERLOAD:
771 printf("Thermal overload.");
772 break;
773 case EPOS4_F_THERMAL_MOTOR_OVERLOAD:
774 printf("Thermal motor overload.");
775 break;
776 case EPOS4_F_LOGIC_VOLTAGE_LOW:
777 printf("Logic supply voltage too low.");
778 break;
779 case EPOS4_F_HARDWARE_DEFECT:
780 printf("Hardware defect.");
781 break;
782 case EPOS4_F_HARDWARE_INCOMPATIBILITY:
783 printf("Hardware incompatibility.");
784 break;
785 case EPOS4_F_HARDWARE1:
786 case EPOS4_F_HARDWARE2:
787 case EPOS4_F_HARDWARE3:
788 case EPOS4_F_HARDWARE4:
789 printf("Hardware error.");
790 break;
791 case EPOS4_F_SIGN_OF_LIFE:
792 printf("Sign of life.");
793 break;
794 case EPOS4_F_EXT_1_WATCHDOG:
795 printf("Extension 1 watchdog.");
796 break;
797 case EPOS4_F_INTERNAL_SOFTWARE:
798 printf("Internal software.");
799 break;
800 case EPOS4_F_SOFTWARE_PARAM:
801 printf("Software parameter error.");
802 break;
803 case EPOS4_F_PERSISTENT_PARAM_CORRUPT:
804 printf("Persistent param corrupt.");
805 break;
806 case EPOS4_F_POSITION_SENSOR:
807 printf("Position sensor error.");
808 break;
809 case EPOS4_F_POSITION_BREACH:
810 printf("Position breach.");
811 break;
812 case EPOS4_F_POSITION_RESOLUTION:
813 printf("Position resolution error.");
814 break;
815 case EPOS4_F_POSITION_INDEX:
816 printf("Position index.");
817 break;
818 case EPOS4_F_HALL_SENSOR:
819 printf("Hall sensor error.");
820 break;
821 case EPOS4_F_HALL_NOT_FOUND:
822 printf("Hall not found.");
823 break;
824 case EPOS4_F_HALL_ANGLE:
825 printf("Hall angle detection error.");
826 break;
827 case EPOS4_F_SSI_SENSOR:
828 printf("SSI sensor.");
829 break;
830 case EPOS4_F_SSI_FRAME:
831 printf("SSI frame.");
832 break;
833 case EPOS4_F_MISSING_MAIN_SENSOR:
834 printf("Missing main sensor.");
835 break;
836 case EPOS4_F_MISSING_COMM_SENSOR:
837 printf("Missing comm sensor.");
838 break;
839 case EPOS4_F_MAIN_SENSOR_DIR:
840 printf("Main sensor direction.");
841 break;
842 case EPOS4_F_CAN_OVERRUN_OBJ_LOST:
843 printf("CAN overrun (object lost).");
844 break;
845 case EPOS4_F_CAN_OVERRUN:
846 printf("CAN overrun.");
847 break;
848 case EPOS4_F_CAN_PASSIVE_MODE:
849 printf("CAN passive mode.");
850 break;
851 case EPOS4_F_CAN_HEARTBEAT:
852 printf("CAN heartbeat error.");
853 break;
854 case EPOS4_F_CAN_PDO_COB_ID_COLLISION:
855 printf("CAN PDO COB-ID collision.");
856 break;
857 case EPOS4_F_ETHERCAT_COMM:
858 printf("EtherCAT communication error.");
859 break;
860 case EPOS4_F_ETHERCAT_INIT:
861 printf("EtherCAT initialization error.");
862 break;
863 case EPOS4_F_ETHERCAT_RX_QUEUE:
864 printf("EtherCAT Rx queue overflow error.");
865 break;
866 case EPOS4_F_ETHERCAT_COMM_INTERNAL:
867 printf("EtherCAT communication (internal) error.");
868 break;
869 case EPOS4_F_ETHERCAT_CYCLE_TIME:
870 printf("EtherCAT communication cycle time error.");
871 break;
872 case EPOS4_F_CAN_BUS_OFF:
873 printf("CAN bus turned off.");
874 break;
875 case EPOS4_F_CAN_RX_QUEUE:
876 printf("CAN Rx queue overflow.");
877 break;
878 case EPOS4_F_CAN_TX_QUEUE:
879 printf("CAN Tx queue overflow.");
880 break;
881 case EPOS4_F_CAN_PDO_LENGTH:
882 printf("CAN PDO length error.");
883 break;
884 case EPOS4_F_RPDO_TIMEOUT:
885 printf("RPDO timeout.");
886 break;
887 case EPOS4_F_ETHERCAT_PDO_COMM:
888 printf("EtherCAT PDO communication error.");
889 break;
890 case EPOS4_F_ETHERCAT_SDO_COMM:
891 printf("EtherCAT SDO communication error.");
892 break;
893 case EPOS4_F_FOLLOWING:
894 printf("Following error.");
895 break;
896 case EPOS4_F_NEG_LIMIT_SWITCH:
897 printf("Negative limit switch error.");
898 break;
899 case EPOS4_F_POS_LIMIT_SWITCH:
900 printf("Positive limit switch error.");
901 break;
902 case EPOS4_F_SOFTWARE_POSITION_LIMIT:
903 printf("Software position limit error.");
904 break;
905 case EPOS4_F_STO:
906 printf("STO error.");
907 break;
908 case EPOS4_F_SYSTEM_OVERLOADED:
909 printf("System overloaded.");
910 break;
911 case EPOS4_F_WATCHDOG:
912 printf("Watchdog error.");
913 break;
914 case EPOS4_F_SYSTEM_PEAK_OVERLOADED:
915 printf("System peak overloaded.");
916 break;
917 case EPOS4_F_CONTROLLER_GAIN:
918 printf("Controller gain error.");
919 break;
920 case EPOS4_F_AUTO_TUNING_ID:
921 printf("Auto tuning identification error.");
922 break;
923 case EPOS4_F_AUTO_TUNING_CURRENT_LIMIT:
924 printf("Auto tuning current limit error.");
925 break;
926 case EPOS4_F_AUTO_TUNING_ID_CURRENT:
927 printf("Auto tuning identification current error.");
928 break;
929 case EPOS4_F_AUTO_TUNING_DATA_SAMPLING:
930 printf("Auto tuning data sampling error.");
931 break;
932 case EPOS4_F_AUTO_TUNING_SAMPLE_MISMATCH:
933 printf("Auto tuning sample mismatch error.");
934 break;
935 case EPOS4_F_AUTO_TUNING_PARAM:
936 printf("Auto tuning parameter error.");
937 break;
938 case EPOS4_F_AUTO_TUNING_AMPLITUDE_MISMATCH:
939 printf("Auto tuning amplitude mismatch error.");
940 break;
941 case EPOS4_F_AUTO_TUNING_TIMEOUT:
942 printf("Auto tuning timeout error.");
943 break;
944 case EPOS4_F_AUTO_TUNING_STANDSTILL:
945 printf("Auto tuning standstill error.");
946 break;
947 case EPOS4_F_AUTO_TUNING_TORQUE_INVALID:
948 printf("Auto tuning torque invalid error.");
949 break;
950 case EPOS4_F_AUTO_TUNING_MAX_SPEED:
951 printf("Auto tuning max system speed error.");
952 break;
953 case EPOS4_F_AUTO_TUNING_MOTOR_CONNECTION:
954 printf("Auto tuning motor connection error.");
955 break;
956 case EPOS4_F_AUTO_TUNING_SENSOR_SIGNAL:
957 printf("Auto tuning sensor signal error.");
958 break;
959 default:
960 if(errorCode >= 0x6180 && errorCode <= 0x61F0) //0x6180 through 0x61F0 is internal software error
961 {
962 printf("Internal software error.");
963 }
964 else
965 {
966 printf("Unknown error code: 0x%04X\n", errorCode);
967 }
968 break;
969 }
970 }

## ◆ sdkEpos4_SetupCanBusModule()

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

Setup the Can bus module for an Epos4.

This function sets up the Can bus module for an Epos4. 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 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” and is signed.

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

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, and CAN_2Ax_EPOS4-Test_csp.mc.

Definition at line 313 of file SDK_Amplifier_Epos4.mc.

314 {
315 long busmod, signedFlag;
316 busmod = axis;
317 signedFlag = 0x10000000;
318
319 print("sdkEpos4_SetupCanBusModule: ", busmod);
320
321 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_DEACTIVATE; // Deactivate (objects will be deleted)
322 BUSMOD_PARAM(busmod, BUSMOD_BUSTYPE) = BUSMOD_BUSTYPE_CAN; // Can bus
323 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_ACTIVATE; // Create bus module
324
325 BUSMOD_PARAM(busmod, BUSMOD_BUSNO) = busId / 100000; // Bus number (0 = master, 1 = slave CAN bus)
326 BUSMOD_PARAM(busmod, BUSMOD_ID) = busId % 1000; // CAN Id for this bus module
327 BUSMOD_PARAM(busmod, BUSMOD_SYNC) = 1; // Sync active
328 BUSMOD_PARAM(busmod, BUSMOD_GUARDTIME) = 0; // no guarding
329
330 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT1) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_CMDWORD); // Select the input value sources object (send to bus): CMD Word
331
332 if (operationMode == EPOS4_OP_CSP) // cycle synchronous position (csp) mode
333 {
334 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFPOS); // Select the input value sources object (send to bus): position setpoint
335 print("...: cycle synchronous position (csp) mode");
336 }
337 else if (operationMode == EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
338 {
339 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFVEL); // Select the input value sources object (send to bus): velocity setvel
340 print("...: cycle synchronous velocity (csv) mode");
341 }
342 else if (operationMode == EPOS4_OP_CST) // cycle synchronous torque (cst) mode
343 {
344 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = AXE_PROCESS_SRCINDEX(axis,REG_USERREFCUR); // Select the input value sources object (send to bus): target torque
345 print("...: cycle synchronous torque (cst) mode");
346 }
347 else // Error
348 {
349 print("...: not supported operation mode");
350 return(-1);
351 }
352
353 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset control word
354 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset target position/ velocity
355
356 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset status word
357 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset position actual value
358 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE3) = signedFlag + pdoNumber*0x01000000 + 2*0x00010000 + 6; // pdo ; length in bytes; bytes offset torque actual value
359
360 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_ACTIVATE_NOSTOP; // Start bus module
361
362 return(1);
363 }

## ◆ sdkEpos4_SetupCanSdoParam()

long sdkEpos4_SetupCanSdoParam | ( | long | busId,
|  | long | pdonumber,
|  | long | axisPolarity,
|  | long | operationMode
| ) |  |

Setup the Sdo parameter for an Epos4.

This function sets up the Sdo parameter for an Epos4. It can be defined with which operation mode is used. The CANSYNCTIMER must be set before calling this function.

Parameters

  busId | Bus ID of the connected slave
  pdoNumber | Used PDO number
  axisPolarity | Definition of the polarity, 0: Normal polarity, 1: Inverse polarity
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode 0x0A: Cyclic synchronous torque (cst) mode

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

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, and CAN_2Ax_EPOS4-Test_csp.mc.

Definition at line 497 of file SDK_Amplifier_Epos4.mc.

499 {
500 long nodeid, last_value;
501 nodeid = busId % 100000;
502
503 print("sdkEpos4_SetupCanSdoParam: " ,nodeid);
504
505 if (axisPolarity==1){ // set axis polarity
506 SdoWrite( busId, EPOS4_AXIS_CONFIGURATION, 4, 1);
507 print("...: change axis direction");
508 }
509 else{
510 SdoWrite( busId, EPOS4_AXIS_CONFIGURATION, 4, 0);
511 }
512
513 //interpolation time periode value
514 SdoWrite(busId, EPOS4_INTERPOLATION_TIME_PERIOD, 1, GLB_PARAM(CANSYNCTIMER));
515 print("...: set interpolation time periode: ", GLB_PARAM(CANSYNCTIMER), " ms");
516
517 // reset Transmittype
518 SdoWrite(busId, EPOS4_TRANSMIT_PDO_1_PARAMETER, 2, 255); // TxPDO1 Transmittype
519 SdoWrite(busId, EPOS4_TRANSMIT_PDO_2_PARAMETER, 2, 255); // TxPDO2 Transmittype
520 SdoWrite(busId, EPOS4_TRANSMIT_PDO_3_PARAMETER, 2, 255); // TxPDO3 Transmittype
521 SdoWrite(busId, EPOS4_TRANSMIT_PDO_4_PARAMETER, 2, 255); // TxPDO4 Transmittype
522
523 // the pdos have to be disabled for configuring
524 last_value = (SdoRead(busId, EPOS4_TRANSMIT_PDO_1_PARAMETER, 1));
525 SdoWrite(busId, EPOS4_TRANSMIT_PDO_1_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 1
526 last_value = (SdoRead(busId, EPOS4_TRANSMIT_PDO_2_PARAMETER, 1));
527 SdoWrite(busId, EPOS4_TRANSMIT_PDO_2_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 2
528 last_value = (SdoRead(busId, EPOS4_TRANSMIT_PDO_3_PARAMETER, 1));
529 SdoWrite(busId, EPOS4_TRANSMIT_PDO_3_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 3
530 last_value = (SdoRead(busId, EPOS4_TRANSMIT_PDO_4_PARAMETER, 1));
531 SdoWrite(busId, EPOS4_TRANSMIT_PDO_4_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 4
532
533 //the pdos have to be disabled for configuring
534 last_value = (SdoRead(busId, EPOS4_RECEIVE_PDO_1_PARAMETER, 1));
535 SdoWrite(busId, EPOS4_RECEIVE_PDO_1_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 1
536 last_value = (SdoRead(busId, EPOS4_RECEIVE_PDO_2_PARAMETER, 1));
537 SdoWrite(busId, EPOS4_RECEIVE_PDO_2_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 2
538 last_value = (SdoRead(busId, EPOS4_RECEIVE_PDO_3_PARAMETER, 1));
539 SdoWrite(busId, EPOS4_RECEIVE_PDO_3_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 3
540 last_value = (SdoRead(busId, EPOS4_RECEIVE_PDO_4_PARAMETER, 1));
541 SdoWrite(busId, EPOS4_RECEIVE_PDO_4_PARAMETER, 1, (last_value | 0x80000000)); // disable pdo 4
542
543 // Now we setup the correct PDO transmission for Tx and Rx
544 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_PARAMETER + pdonumber-1), 2, 1); // TxPDO Transmittype SYNC
545 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_PARAMETER + pdonumber-1), 2, 1); // RxPDO Transmittype SYNC
546
547 // config RX PDO
548 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber-1), 0x00, 0); // disable
549 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber-1), 0x01, 0x60400010); // controlword
550
551 if (operationMode == EPOS4_OP_CSP) { // cycle synchronous position (csp) mode
552 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x607A0020); // download pdo 0x1600 entry: position set point
553 SdoWrite(busId, EPOS4_MODES_OF_OPERATION, 0, EPOS4_OP_CSP); // mode of operation CSP
554 print("...: cycle synchronous position (csp) mode");
555 }
556 else if (operationMode == EPOS4_OP_CSV ) {
557 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x60FF0020); // download pdo 0x1600 entry: target velocity 32bit
558 SdoWrite(busId, EPOS4_MODES_OF_OPERATION, 0, EPOS4_OP_CSV); // mode of operation CSV
559 print("...: cycle synchronous velocity (csv) mode");
560 }
561 else if (operationMode == EPOS4_OP_CST) {
562 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber-1), 2, 0x60710010); // download pdo 0x1600 entry: Target torque 32bit
563 SdoWrite(busId, EPOS4_MODES_OF_OPERATION, 0, EPOS4_OP_CST); // mode of operation CST
564 print("...: cycle synchronous torque (cst) mode");
565 }
566 else { // Error
567 print("...: not supported operation mode");
568 return(-1);
569 }
570 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_MAPPING + pdonumber - 1), 0x00, 2); // enable
571
572 // config TX PDO
573 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x00, 0); // disable
574 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x01, 0x60410010); // statusword
575 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x02, 0x60640020); // actpos
576 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x03, 0x30D20110); // Torque actual value averaged
577 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_MAPPING + pdonumber - 1), 0x00, 3 ); // enable
578
579 // fill in the wanted pdo
580 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_PARAMETER + pdonumber - 1), 1, (0x80000180 + (pdonumber - 1)*0x100 + nodeid) );// fill in pdo
581 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_PARAMETER + pdonumber - 1), 1, (0x80000200 + (pdonumber - 1)*0x100 + nodeid) );// fill in pdo
582
583 // enable
584 SdoWrite(busId, (EPOS4_TRANSMIT_PDO_1_PARAMETER + pdonumber - 1), 1, (0x00000180 + (pdonumber - 1)*0x100 + nodeid) );// enable pdo
585 SdoWrite(busId, (EPOS4_RECEIVE_PDO_1_PARAMETER + pdonumber - 1), 1, (0x00000200 + (pdonumber - 1)*0x100 + nodeid) );// enable pdo
586
587 return(1);
588 }

## ◆ sdkEpos4_SetupCanVirtAmp()

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

Setup the virtual amplifier for an Epos4 with Can bus.

This function sets up the virtual amplifier with Can bus for an Epos4. 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 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

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, and CAN_2Ax_EPOS4-Test_csp.mc.

Definition at line 383 of file SDK_Amplifier_Epos4.mc.

384 {
385 print("sdkEpos4_SetupCanVirtAmp: ",axis );
386
387 // virtual amplifiers have a fixed connection to axes number, axes 0 uses amplifier 0.
388 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CMDWORD) = AXE_PROCESS_SRCINDEX(axis,REG_CNTRLWORD);
389 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFPOS) = AXE_PROCESS_SRCINDEX(axis,REG_COMPOS);
390 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFVEL) = AXE_PROCESS_SRCINDEX(axis,REG_REFERENCE);
391 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFACC) = AXE_PROCESS_SRCINDEX(axis,PID_FFACCPART);
392 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_STATUS) = BUSMOD_PROCESS_SRCINDEX(axis,PO_BUSMOD_VALUE1);
393 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CURRENT) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE3);
394
395 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWROFF) = 0x06;
396 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONDIS) = 0x06;
397 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENP) = 0x0F;
398 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENN) = 0x0F;
399 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_QUICKSTOP) = 0x02;
400 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_RESET) = 0x80;
401
402 VIRTAMP_PARAM(axis,VIRTAMP_STOPDELAY) = 0x00;
403 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_BITMASK) = 0x08;
404 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_POLARITY) = 1;
405
406 if (operationMode == EPOS4_OP_CSP) // cycle synchronous position (csp) mode
407 {
408 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in csp
409 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in csp
410 print("...: cycle synchronous position (csp) mode");
411 }
412 else if (operationMode == EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
413 {
414 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = maxRpm;
415 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 2* maxRpm;
416 print("...: cycle synchronous velocity (csv) mode");
417 }
418 else if (operationMode == EPOS4_OP_CST) // cycle synchronous torque (cst) mode
419 {
420 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in cst
421 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in cst
422 print("...: cycle synchronous torque (cst) mode");
423 }
424 else // Error
425 {
426 print("...: not supported operation mode");
427 return(-1);
428 }
429
430 VIRTAMP_PARAM(axis,VIRTAMP_MODE) = VIRTAMP_MODE_ENABLE; // has to be the last one because it activates all
431
432 return(1);
433 }

## ◆ sdkEpos4_SetupCanVirtCntin()

long sdkEpos4_SetupCanVirtCntin | ( | long | axis,
|  | long | operationMode
| ) |  |

Setup the virtual counter input for an Epos4 with Can bus.

This function sets up the virtual counter input for an Epos4. 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 0x0A: Cyclic synchronous torque (cst) mode

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

Examples
  CAN_1Ax_EPOS4-Test_csp.mc, CAN_1Ax_EPOS4-Test_cst.mc, CAN_1Ax_EPOS4-Test_csv.mc, and CAN_2Ax_EPOS4-Test_csp.mc.

Definition at line 450 of file SDK_Amplifier_Epos4.mc.

451 {
452 print("sdkEpos4_SetupCanVirtCntin: ",axis);
453
454 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_PISRC_COUNTER) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE2);
455
456 if (operationMode == EPOS4_OP_CSP) // cycle synchronous position (csp) mode
457 {
458 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT; // Source is absolute and is taken as it is
459 print("...: cycle synchronous position (csp) mode");
460 }
461 else if (operationMode == EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
462 {
463 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Source is a position value and difference to last value is added
464 print("...: cycle synchronous velocity (csv) mode");
465 }
466 else if (operationMode == EPOS4_OP_CST) // cycle synchronous torque (cst) mode
467 {
468 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT; // Source is absolute and is taken as it is
469 print("...: cycle synchronous torque (cst) mode");
470 }
471 else // Error
472 {
473 print("...: not supported operation mode");
474 return(-1);
475 }
476
477 return(1);
478 }

## ◆ sdkEpos4_SetupECatBusModule()

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

Setup the ECAT bus module for an Epos4.

This function sets up the ECAT bus module for an Epos4. 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 1: Cyclic synchronous position (csp) mode 2: Cyclic synchronous velocity (csv) mode

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

Examples
  DeltaRobot_No_SM_EPOS4_ECAT.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 37 of file SDK_Amplifier_Epos4.mc.

38 {
39 long busmod, slaveNo;
40
41 busmod = axis;
42 slaveNo = (busId-1000000);
43
44 print("sdkEpos4_SetupECatBusModule: ",busmod );
45
46 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_DEACTIVATE; // Deactivate (objects will be deleted)
47 BUSMOD_PARAM(busmod, BUSMOD_BUSTYPE) = BUSMOD_BUSTYPE_ECAT_M; // EtherCAT Master
48 BUSMOD_PARAM(busmod, BUSMOD_ID) = slaveNo; // Select the nodeid of the connected slave
49
50 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT1) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_CMDWORD); // Select the input value sources object (send to bus): CMD Word
51
52 if (operationMode==EPOS4_OP_CSP) // cycle synchronous position (csp) mode
53 {
54 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFPOS); // Select the input value sources object (send to bus): position setpoint
55 print("...: cycle synchronous position (csp) mode");
56 }
57 else if (operationMode==EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
58 {
59 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = VIRTAMP_PROCESS_SRCINDEX(axis,PO_VIRTAMP_REFVEL); // Select the input value sources object (send to bus): velocity setvel
60 print("...: cycle synchronous velocity (csv) mode");
61 }
62 else if (operationMode == EPOS4_OP_CST) // cycle synchronous torque (cst) mode
63 {
64 BUSMOD_PARAM(busmod, BUSMOD_PISRC_INPUT2) = AXE_PROCESS_SRCINDEX(axis,REG_USERREFCUR); // Select the input value sources object (send to bus): target torque
65 print("...: cycle synchronous torque (cst) mode");
66 }
67 else // Error
68 {
69 print("...: not supported operation mode");
70 return(-1);
71 }
72
73 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset control word
74 BUSMOD_PARAM(busmod, BUSMOD_TXMAP_INPUT2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset target position/ velocity
75
76 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE1) = pdoNumber*0x01000000 + 2*0x00010000 + 0; // pdo ; length in bytes; bytes offset status word
77 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE2) = pdoNumber*0x01000000 + 4*0x00010000 + 2; // pdo ; length in bytes; bytes offset position actual value
78 BUSMOD_PARAM(busmod, BUSMOD_RXMAP_POVALUE3) = pdoNumber*0x01000000 + 4*0x00010000 + 6; // pdo ; length in bytes; bytes offset current actual value
79
80 BUSMOD_PARAM(busmod, BUSMOD_MODE) = BUSMOD_MODE_ACTIVATE_NOSTOP; // Start bus module
81
82 return(1);
83 }

## ◆ sdkEpos4_SetupECatSdoParam()

long sdkEpos4_SetupECatSdoParam | ( | long | busId,
|  | long | pdoNumber,
|  | long | axisPolarity,
|  | long | operationMode
| ) |  |

Setup the Sdo parameter for an Epos4 with EtherCat.

This function sets up the Sdo parameter with EtherCat for an Epos4. It can be defined with which operation mode is used.

Parameters

  busId | Bus ID of the connected slave
  pdoNumber | Used PDO number
  axisPolarity | Definition of the polarity, 0: Normal polarity, 1: Inverse polarity
  operationMode | Definition of the operation mode 0x08: Cyclic synchronous position (csp) mode 0x09: Cyclic synchronous velocity (csv) mode 0x0A: Cyclic synchronous torque (cst) mode

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

Examples
  DeltaRobot_No_SM_EPOS4_ECAT.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 209 of file SDK_Amplifier_Epos4.mc.

210 {
211 long sm_TX = EPOS4_SYNC_MANAGER_2_PDO_ASSIGNMENT;
212 long sm_RX = EPOS4_SYNC_MANAGER_3_PDO_ASSIGNMENT;
213
214 print("sdkEpos4_SetupECatSdoParam Ax: ",busId," pdoNumber ",pdoNumber);
215
216 SdoWriten( busId, sm_TX, 0x00, 1, 0x00); // disable entry
217 SdoWriten( busId, sm_RX, 0x00, 1, 0x00); // disable entry
218
219 SdoWriten( busId, EPOS4_TRANSMIT_PDO_1_MAPPING, 0, 1, 0); // clear pdo 0x1a00 entries
220 SdoWriten( busId, EPOS4_TRANSMIT_PDO_1_MAPPING, 1, 4, 0x60410010); // download pdo 0x1A00 entry: statusword
221 SdoWriten( busId, EPOS4_TRANSMIT_PDO_1_MAPPING, 2, 4, 0x60640020); // download pdo 0x1A00 entry: actual position
222 SdoWriten( busId, EPOS4_TRANSMIT_PDO_1_MAPPING, 3, 4, 0x30D10120); // download pdo 0x1A00 entry: Current actual value averaged [mA] 0x30D1 / 1 32bit
223 SdoWriten( busId, EPOS4_TRANSMIT_PDO_1_MAPPING, 0, 1, 3); // download pdo 0x1A00 entry: number of entries
224
225 SdoWriten( busId, EPOS4_TRANSMIT_PDO_2_MAPPING, 0, 1, 0); // clear pdo 0x1a01 entries
226 SdoWriten( busId, EPOS4_TRANSMIT_PDO_3_MAPPING, 0, 1, 0); // clear pdo 0x1a02 entries
227 SdoWriten( busId, EPOS4_TRANSMIT_PDO_4_MAPPING, 0, 1, 0); // clear pdo 0x1a03 entries
228
229 SdoWriten( busId, EPOS4_RECEIVE_PDO_1_MAPPING, 0, 1, 0); // clear pdo 0x1600 entries
230 SdoWriten( busId, EPOS4_RECEIVE_PDO_1_MAPPING, 1, 4, 0x60400010); // download pdo 0x1600 entry: controlword
231
232 if (operationMode==EPOS4_OP_CSP) // cycle synchronous position (csp) mode
233 {
234 SdoWriten( busId, EPOS4_RECEIVE_PDO_1_MAPPING, 2, 4, 0x607A0020); // download pdo 0x1600 entry: position set point
235 }
236 else if (operationMode==EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
237 {
238 SdoWriten( busId, EPOS4_RECEIVE_PDO_1_MAPPING, 2, 4, 0x60FF0020); // download pdo 0x1600 entry: target velocity 32bit
239 }
240 else if (operationMode == EPOS4_OP_CST) {
241 SdoWriten(busId, (EPOS4_RECEIVE_PDO_1_MAPPING), 2, 4, 0x60710010); // download pdo 0x1600 entry: Target torque 32bit
242 }
243
244 SdoWriten( busId, EPOS4_RECEIVE_PDO_1_MAPPING, 0, 1, 2); // download pdo 0x1600 entry: number of entries
245
246 SdoWriten( busId, EPOS4_RECEIVE_PDO_2_MAPPING, 0, 1, 0); // clear pdo 0x1601 entries
247 SdoWriten( busId, EPOS4_RECEIVE_PDO_3_MAPPING, 0, 1, 0); // clear pdo 0x1602 entries
248 SdoWriten( busId, EPOS4_RECEIVE_PDO_4_MAPPING, 0, 1, 0); // clear pdo 0x1603 entries
249
250
251 SdoWriten( busId, sm_TX, 1, 2, 0x1600); // download pdo 0x1C1@b 2:01 index
252 SdoWriten( busId, sm_TX, 0, 1, 1); // download pdo 0x1C12 count
253
254 SdoWriten( busId, sm_RX, 1, 2, 0x1A00 ); // download pdo 0x1C13:01 index
255 SdoWriten( busId, sm_RX, 0, 1, 1); // download pdo 0x1C13 count
256
257
258 SdoWriten( busId, EPOS4_INTERPOLATION_TIME_PERIOD, 1, 0, 1); //interpolation time periode value
259
260 if (axisPolarity==1) // set axis polarity
261 {
262 SdoWriten( busId, EPOS4_AXIS_CONFIGURATION, 4, 4, 1);
263 print("...: change axis direction");
264 }
265 else
266 {
267 SdoWriten( busId, EPOS4_AXIS_CONFIGURATION, 4, 4, 0);
268 }
269
270 if (operationMode==EPOS4_OP_CSP)
271 {
272 SdoWriten( busId, EPOS4_MODES_OF_OPERATION, 0, 1, EPOS4_OP_CSP); // cycle synchronous position (csp) mode
273 print("...: cycle synchronous position (csp) mode");
274 }
275 else if (operationMode==EPOS4_OP_CSV)
276 {
277 SdoWriten( busId, EPOS4_MODES_OF_OPERATION, 0, 1, EPOS4_OP_CSV); // cycle synchronous velocity (csv) mode
278 print("...: cycle synchronous velocity (csv) mode");
279 }
280 else if (operationMode == EPOS4_OP_CST) {
281 SdoWriten(busId, EPOS4_MODES_OF_OPERATION, 0, 1, EPOS4_OP_CST); // cycle synchronous torque (cst) mode
282 print("...: cycle synchronous torque (cst) mode");
283 }
284 else // Error
285 {
286 print("...: not supported operation mode");
287 return(-1);
288 }
289
290 return(1);
291 }

## ◆ sdkEpos4_SetupECatVirtAmp()

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

Setup the virtual amplifier for an Epos4 with EtherCat.

This function sets up the virtual amplifier with EtherCat for an Epos4. 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 0x0A: Cyclic synchronous torque (cst) mode

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

Examples
  DeltaRobot_No_SM_EPOS4_ECAT.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 101 of file SDK_Amplifier_Epos4.mc.

102 {
103 print("sdkEpos4_SetupECatVirtAmp: ",axis );
104
105 // virtual amplifiers have a fixed connection to axes number, axes 0 uses amplifier 0.
106 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CMDWORD) = AXE_PROCESS_SRCINDEX(axis,REG_CNTRLWORD);
107 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFPOS) = AXE_PROCESS_SRCINDEX(axis,REG_COMPOS);
108 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFVEL) = AXE_PROCESS_SRCINDEX(axis,REG_REFERENCE);
109 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_REFACC) = AXE_PROCESS_SRCINDEX(axis,PID_FFACCPART);
110 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_STATUS) = BUSMOD_PROCESS_SRCINDEX(axis,PO_BUSMOD_VALUE1);
111 VIRTAMP_PARAM(axis,VIRTAMP_PISRC_CURRENT) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE3);
112
113 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWROFF) = 0x06;
114 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONDIS) = 0x06;
115 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENP) = 0x0F;
116 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_PWRONENN) = 0x0F;
117 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_QUICKSTOP) = 0x02;
118 VIRTAMP_PARAM(axis,VIRTAMP_CNTRLW_RESET) = 0x80;
119
120 VIRTAMP_PARAM(axis,VIRTAMP_STOPDELAY) = 0x0;
121 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_BITMASK) = 0x0008;
122 VIRTAMP_PARAM(axis,VIRTAMP_ERROR_POLARITY) = 1;
123
124 if (operationMode==EPOS4_OP_CSP) // cycle synchronous position (csp) mode
125 {
126 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in csp
127 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in csp
128 print("...: cycle synchronous position (csp) mode");
129 }
130 else if (operationMode==EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
131 {
132 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = maxRpm;
133 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 2* maxRpm;
134 print("...: cycle synchronous velocity (csv) mode");
135 }
136 else if (operationMode == EPOS4_OP_CST) // cycle synchronous torque (cst) mode
137 {
138 VIRTAMP_PARAM(axis,VIRTAMP_REF100PERC) = 0; // not used in cst
139 VIRTAMP_PARAM(axis,VIRTAMP_REFLIMIT) = 0; // not used in cst
140 print("...: cycle synchronous torque (cst) mode");
141 }
142 else // Error
143 {
144 print("...: not supported operation mode");
145 return(-1);
146 }
147
148 VIRTAMP_PARAM(axis,VIRTAMP_MODE) = VIRTAMP_MODE_ENABLE; // has to be the last one because it activates all
149
150 return(1);
151 }

## ◆ sdkEpos4_SetupECatVirtCntin()

long sdkEpos4_SetupECatVirtCntin | ( | long | axis,
|  | long | operationMode
| ) |  |

Setup the virtual counter input for an Epos4 with EtherCat.

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

Parameters

  axis | Axis module number
  operationMode | Definition of the operation mode 1: Cyclic synchronous position (csp) mode 2: Cyclic synchronous velocity (csv) mode

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

Examples
  DeltaRobot_No_SM_EPOS4_ECAT.mc, ECAT_1Ax_EPOS4-Test_cst.mc, and ECAT_3Ax_Epos4-Test_csp.mc.

Definition at line 168 of file SDK_Amplifier_Epos4.mc.

169 {
170 print("sdkEpos4_SetupECatVirtCntin: ",axis);
171
172 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_PISRC_COUNTER) = BUSMOD_PROCESS_SRCINDEX(axis, PO_BUSMOD_VALUE2);
173
174 if (operationMode==EPOS4_OP_CSP) // cycle synchronous position (csp) mode
175 {
176 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE_DIRECT; // Source is absolute and is taken as it is
177 print("...: cycle synchronous position (csp) mode");
178 }
179 else if (operationMode==EPOS4_OP_CSV) // cycle synchronous velocity (csv) mode
180 {
181 VIRTCOUNTIN_PARAM(axis,VIRTCNTIN_MODE) = VIRTCNTIN_MODE_ABSOLUTE; // Source is a position value and difference to last value is added
182 print("...: cycle synchronous velocity (csv) mode");
183 }
184 else // Error
185 {
186 print("...: not supported operation mode");
187 return(-1);
188 }
189
190 return(1);
191 }
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
EPOS4_MODES_OF_OPERATION_DISPLAY
#define EPOS4_MODES_OF_OPERATION_DISPLAY
Definition: SDK_Amplifier_Epos4.mh:133
EPOS4_RECEIVE_PDO_3_PARAMETER
#define EPOS4_RECEIVE_PDO_3_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:45
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
EPOS4_INTERPOLATION_TIME_PERIOD
#define EPOS4_INTERPOLATION_TIME_PERIOD
Definition: SDK_Amplifier_Epos4.mh:181
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
BUSMOD_BUSTYPE_ECAT_M
#define BUSMOD_BUSTYPE_ECAT_M
Definition: SdoDictionary.mh:11311
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
EPOS4_TRANSMIT_PDO_4_MAPPING
#define EPOS4_TRANSMIT_PDO_4_MAPPING
Definition: SDK_Amplifier_Epos4.mh:58
EPOS4_OP_CST
#define EPOS4_OP_CST
Definition: SDK_Amplifier_Epos4.mh:132
EPOS4_SYNC_MANAGER_2_PDO_ASSIGNMENT
#define EPOS4_SYNC_MANAGER_2_PDO_ASSIGNMENT
Definition: SDK_Amplifier_Epos4.mh:60
EPOS4_RECEIVE_PDO_1_PARAMETER
#define EPOS4_RECEIVE_PDO_1_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:43
VIRTAMP_PISRC_CMDWORD
#define VIRTAMP_PISRC_CMDWORD
Index/subindex of command word.
Definition: SdoDictionary.mh:5300
EPOS4_TRANSMIT_PDO_1_PARAMETER
#define EPOS4_TRANSMIT_PDO_1_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:51
VIRTAMP_REF100PERC
#define VIRTAMP_REF100PERC
Output reference value to use at 100 percent.
Definition: SdoDictionary.mh:5442
EPOS4_OP_CSP
#define EPOS4_OP_CSP
Definition: SDK_Amplifier_Epos4.mh:130
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
EPOS4_MODES_OF_OPERATION
#define EPOS4_MODES_OF_OPERATION
Definition: SDK_Amplifier_Epos4.mh:126
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
CANSYNCTIMER
#define CANSYNCTIMER
Cycle time for sending SYNC telegrams on the CAN bus.
Definition: SdoDictionary.mh:132
BUSMOD_TXMAP_INPUT1
#define BUSMOD_TXMAP_INPUT1
Mapping for TX PDOs (send to bus)
Definition: SdoDictionary.mh:11097
EPOS4_TRANSMIT_PDO_3_PARAMETER
#define EPOS4_TRANSMIT_PDO_3_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:53
EPOS4_OP_HMM
#define EPOS4_OP_HMM
Definition: SDK_Amplifier_Epos4.mh:129
VIRTAMP_PARAM
#define VIRTAMP_PARAM(modno, parno)
Virtual Amplifier Parameters: Setter.
Definition: SdoDictionary.mh:5280
EPOS4_TRANSMIT_PDO_4_PARAMETER
#define EPOS4_TRANSMIT_PDO_4_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:54
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
EPOS4_RECEIVE_PDO_3_MAPPING
#define EPOS4_RECEIVE_PDO_3_MAPPING
Definition: SDK_Amplifier_Epos4.mh:49
EPOS4_TRANSMIT_PDO_1_MAPPING
#define EPOS4_TRANSMIT_PDO_1_MAPPING
Definition: SDK_Amplifier_Epos4.mh:55
EPOS4_TRANSMIT_PDO_2_MAPPING
#define EPOS4_TRANSMIT_PDO_2_MAPPING
Definition: SDK_Amplifier_Epos4.mh:56
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
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
EPOS4_RECEIVE_PDO_2_MAPPING
#define EPOS4_RECEIVE_PDO_2_MAPPING
Definition: SDK_Amplifier_Epos4.mh:48
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
EPOS4_RECEIVE_PDO_2_PARAMETER
#define EPOS4_RECEIVE_PDO_2_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:44
EPOS4_TRANSMIT_PDO_2_PARAMETER
#define EPOS4_TRANSMIT_PDO_2_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:52
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
EPOS4_SYNC_MANAGER_3_PDO_ASSIGNMENT
#define EPOS4_SYNC_MANAGER_3_PDO_ASSIGNMENT
Definition: SDK_Amplifier_Epos4.mh:61
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
EPOS4_OP_CSV
#define EPOS4_OP_CSV
Definition: SDK_Amplifier_Epos4.mh:131
EPOS4_RECEIVE_PDO_4_MAPPING
#define EPOS4_RECEIVE_PDO_4_MAPPING
Definition: SDK_Amplifier_Epos4.mh:50
BUSMOD_MODE
#define BUSMOD_MODE
Activate / Deactivate.
Definition: SdoDictionary.mh:10839
EPOS4_TRANSMIT_PDO_3_MAPPING
#define EPOS4_TRANSMIT_PDO_3_MAPPING
Definition: SDK_Amplifier_Epos4.mh:57
EPOS4_HOMING_METHOD
#define EPOS4_HOMING_METHOD
Definition: SDK_Amplifier_Epos4.mh:153
VIRTAMP_MODE
#define VIRTAMP_MODE
Mode of operation.
Definition: SdoDictionary.mh:5293
EPOS4_AXIS_CONFIGURATION
#define EPOS4_AXIS_CONFIGURATION
Definition: SDK_Amplifier_Epos4.mh:79
BUSMOD_SYNC
#define BUSMOD_SYNC
Sync interval (only for CAN)
Definition: SdoDictionary.mh:11032
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
GLB_PARAM
#define GLB_PARAM(parno)
Global Parameters: Setter.
Definition: SdoDictionary.mh:67
BUSMOD_GUARDTIME
#define BUSMOD_GUARDTIME
Guard interval.
Definition: SdoDictionary.mh:11047
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
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
EPOS4_RECEIVE_PDO_4_PARAMETER
#define EPOS4_RECEIVE_PDO_4_PARAMETER
Definition: SDK_Amplifier_Epos4.mh:46
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
EPOS4_RECEIVE_PDO_1_MAPPING
#define EPOS4_RECEIVE_PDO_1_MAPPING
Definition: SDK_Amplifier_Epos4.mh:47

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

Maxon Support Center