#!/bin/bash # This script uses the ethercat command line to configure the PDOs for a ProNet # based on example downloaded from http://lists.etherlab.org/pipermail/etherlab-users/2012/001684.html # see also end of section 3.4 of ProNet ethercat guide POS=-p0 echo "set MODE. 3=ProfileVelocity 8=CSP" ethercat -p0 -t uint8 download 0x6060 0 8 echo " STATUS word `ethercat -p0 -t uint16 upload 0x6041 0 `" #--------------------------------------------------------- # clear RxPDO ethercat $POS --type uint8 download 0x1C12 0 0 # clear RxPDO counter ethercat $POS --type uint8 download 0x1600 0 0 # clear RxPDO0 nEntries ethercat $POS --type uint8 download 0x1601 0 0 # RxPDO1 ethercat $POS --type uint8 download 0x1602 0 0 # RxPDO2 ethercat $POS --type uint8 download 0x1603 0 0 # RxPDO3 # define RxPdo's ethercat $POS --type uint32 download 0x1602 1 0x60400010 # control word: index=0x6040 subindex=00 bitlen=16 ethercat $POS --type uint32 download 0x1602 2 0x607A0020 # posCommand : index=0x607A subindex=00 bitlen=32 ethercat $POS --type uint8 download 0x1602 0 2 # number of var in this PDO # assign RxPdo's to sync manager ethercat $POS --type uint16 download 0x1C12 1 0x1602 # RxPdo #1 ethercat $POS --type uint8 download 0x1C12 0 1 # nEntries in RxPdo list #-------------------------------------- # clear TxPdo ethercat $POS --type uint8 download 0x1C13 0 0 # clear TxPDO counter ethercat $POS --type uint8 download 0x1A00 0 0 # clear TxPDO0 nEntries ethercat $POS --type uint8 download 0x1A01 0 0 # TxPDO1 ethercat $POS --type uint8 download 0x1A02 0 0 # TxPDO2 ethercat $POS --type uint8 download 0x1A03 0 0 # TxPDO3 # define TxPdo's ethercat $POS --type uint32 download 0x1A02 1 0x60410010 # status word : index=0x6041 subindex=00 bitlen=16 ethercat $POS --type uint32 download 0x1A02 2 0x60640020 # posActual : index=0x6064 subindex=00 bitlen=32 ethercat $POS --type uint8 download 0x1A02 0 2 # number of var in this PDO ethercat $POS --type uint16 download 0x1C13 1 0x1A02 # TxPdo #1 ethercat $POS --type uint8 download 0x1C13 0 1 # nEntries in TxPdo list ethercat rescan sleep 5 ethercat cstruct $POS #dmesg | tail -50 echo "check MODE. should still be as set above" echo "mode = `ethercat -p0 -t uint8 upload 0x6060 0`" echo " STATUS word `ethercat -p0 -t uint16 upload 0x6041 0 `" echo "reset FAULT" ethercat -p0 -t uint16 download 0x6040 0 0x0080 echo " STATUS word `ethercat -p0 -t uint16 upload 0x6041 0 `. bit 3 should be clear" echo "set TargetVelocity to 0" ethercat -p0 -t int32 download 0x60FF 0 0 echo " STATUS word `ethercat -p0 -t uint16 upload 0x6041 0 `" echo "turn on with CONTROL word sequence" ethercat -p0 -t uint16 download 0x6040 0 0x0006 # EnableVoltage+QuickStop ethercat -p0 -t uint16 download 0x6040 0 0x0007 # +SwitchOn ethercat -p0 -t uint16 download 0x6040 0 0x000f # +EnableOperation echo " STATUS word `ethercat -p0 -t uint16 upload 0x6041 0 `"