' ' Author: Kevin Cox ' Date: 3/29/2018 ' Description: MAKE SURE RUN %eesav from the console after you run this script dim ppr as integer ppr = 8192 ' Set over voltage conditions. Took this out as the input voltage to ' motors can't get above its max of 24V 'setconfig (_OVL, 300) ' Kolmorgen TBM 6013-B 'setconfig (_OVH, 10) ' Set CAN raw mode setconfig (_CEN, 3) ' Set CAN listening mode 0=receive everything setconfig (_CLSN, 0) ' Set CAN Bus bit rate 0=1Mbps,1=800Kbps,2=500Kbps setconfig (_CBR, 0) ' Put motor controller 1&2 in open loop mode setconfig (_MMOD, 1, 0) setconfig (_MMOD, 2, 0) ' Set brushless feedback sensor to encoder + hall = 2 Pg 331 setconfig (_BFBK, 1, 2) setconfig (_BFBK, 2, 2) ' Set the Home postion counter value setconfig (_BHOME, 1, 0) setconfig (_BHOME, 2, 0) ' Set Brushless operating mode to Sinusoidal = 1 Pg 335 setconfig (_BMOD, 1, 1) setconfig (_BMOD, 2, 1) ' Set the number of brushless motor pole pairs, negative inverts ' counter values. This is driven by mounting of the encoder and the ' alignment waveform. EPPR must match. setconfig (_BPOL, 1, -6) setconfig (_BPOL, 2, 6) ' Set brushless zer seek power (used for BND command) setconfig (_BZPW, 1, 8) setconfig (_BZPW, 2, 8) ' Set the motor amp limit 100 = 10 amps, Pg 306 setconfig (_ALIM, 1, 200) setconfig (_ALIM, 2, 200) setconfig (_ATRIG, 1, 150) setconfig (_ATRIG, 2, 150) setconfig (_ATGD, 1, 100) setconfig (_ATGD, 2, 100) setconfig (_ATGA, 1, 17) ' Safety stop setconfig (_ATGA, 2, 33) ' Safety stop 'Set the feedback sensor for closed loop, 0=encoder/other, 1=hall setconfig (_BLFB, 1, 0) setconfig (_BLFB, 2, 0) ' Set the encoder home count position setconfig (_EHOME, 1, 0) setconfig (_EHOME, 2, 0) ' Set the how encoder is used, Pg. 315 setconfig (_EMOD, 1, 18) ' Channel 1, feedback = 18 setconfig (_EMOD, 2, 34) ' Channel 2, feedback = 34 ' Set the overvoltage condition pin for the regen circuit. pg. 296 setconfig (_DOA, 1, 51) ' Channel 1&2 set DIO 1 high when motor 1/2 overvolt ' Set encoder PPR *4 converts ppr to cpr (each edge of quad A/B is counted) ' /2 because the range is not 0 to ppr*4, rather -ppr/2 to +ppr/2 setconfig (_EPPR, 1, -ppr) ' EPPR polarity should match BPOL setconfig (_ELL, 1, -ppr/2*4) setconfig (_EHL, 1, ppr/2*4) setconfig (_EPPR, 2, ppr) ' EPPR polarity should match BPOL setconfig (_ELL, 2, -ppr/2*4) setconfig (_EHL, 2, ppr/2*4) ' Set the stall condition, Pg. 310 ' Limit the max amps so that won't get in a situation where burn out motor setconfig (_BLSTD, 1, 0) ' Disable stall condition setconfig (_BLSTD, 2, 0) ' Disable stall condition ' Set the close loop error detection, 0=disabled, 2 = 500ms error >250 setconfig (_CLERD, 1, 0) setconfig (_CLERD, 2, 0) ' Set Max RPM value, Pg 324 - THIS IS IMPORTANT ' To see how this relates to the _G command see pg. 220 setconfig (_MXRPM, 1, 10) ' in rpm setconfig (_MXRPM, 2, 10) setconfig (_MAC, 1, 500) ' in tenths of rpms setconfig (_MAC, 2, 500) setconfig (_MDEC, 1, 500) ' in tenths of rpms setconfig (_MDEC, 2, 500) 'Set the default motor speed the controller uses to move to position ' in count position mode setconfig (_MVEL, 1, 10) ' in rpm setconfig (_MVEL, 2, 10) ' Set DIN action value. Took this out as no longer using encoder index pin ' for homing sequence. It was not reliable enough. 'setconfig (_DINA, 1, 24) ' load home value motor 1 'setconfig (_DINA, 2, 40) ' Load home value motor 2 ' Set the motor direction setconfig (_MDIR, 1, 1) ' 0=direct, 1= inverted setconfig (_MDIR, 2, 1) ' Set PID gains for closed loop (except torque mode) setconfig (_KP, 1, 20) ' units = tenths setconfig (_KI, 1, 0) setconfig (_KD, 1, 40) ' units = tenths setconfig (_KP, 2, 40) ' units = tenths setconfig (_KI, 2, 0) setconfig (_KD, 2, 80) ' units = tenths ' Enable script 2 seconds after power up setconfig (_BRUN, 1) ' Save configuration to eeprom setcommand (_EESAV, 1)