I have a TMCM 310 with two stepper motors and limit switches. A reference run works out fine and positioning in stand alone mode also.
But in my application I also would like to be able to move the motors with external switches manually. Therefore I wanted to use the digital inputs but this seems to be the first problem. In a simple test application I use a digital output as indicator. In a loop I try to poll an input channel, but the result is only depending on the initial input state at the start of the program and every some starts, one motor begins to move ending up stalling although I did not give any drive command.
What do I do wrong? Here is my code:
- Code: Select all
csub initial // alle parameter setzen
csub referenz // referenzfahrt motoren
csub setpos1 // in SA-Position fahren
csub setnull
csub horizontal
loop:
GIO 1,0
JC ZE, doon
JA donot
ja loop
stop
doon:
SIO 7,2,1
rsub
donot:
SIO 7,2,0
rsub
initial:
sgp 77, 0, 1 //setzt autostart auf "ein"
SIO 0, 0, 1 //pull-up einschalten Input0
SIO 1, 0, 1 //pull-up einschalten Input1
SIO 2, 0, 1 //pull-up einschalten Input2
SIO 3, 0, 1 //pull-up einschalten Input3
SIO 0, 2, 0 //setzt output 0 auf 0
SIO 1, 2, 0 //setzt output 1 auf 0
SIO 2, 2, 0 //setzt output 2 auf 0
SIO 3, 2, 0 //setzt output 3 auf 0
SIO 4, 2, 0 //setzt output 4 auf 0
SIO 5, 2, 0 //setzt output 5 auf 0
SIO 6, 2, 0 //setzt output 6 auf 0
SIO 7, 2, 0 //setzt output 7 auf 0
sgp 80, 0, 0
sgp 80, 0, 1
sgp 80, 0, 2
sgp 80, 0, 3
sap 140, 0, 1 //setzt die Microstepauflösung von Motor 0 auf x Microsteps
sap 140, 1, 1 //setzt die Microstepauflösung von Motor 1 auf x Microsteps
sap 154, 0, 4 //Exponent für die Division des Pulsgenerators für Motor 0
sap 154, 1, 4 //Exponent für die Division des Pulsgenerators für Motor 1
SAP 5, 0, 2047 //setzt die Motorbeschleunigung für Motor 0
sap 5, 1, 2047 //setzt die Motorbeschleunigung für Motor 1
SAP 6, 0, 300 //setzt den Motorarbeitsstrom von Motor 0 auf xxx mA
SAP 7, 0, 10 //setzt den Motorstandbystrom von Motor 0 auf xxx mA
SAP 6, 1, 300 //setzt den Motorarbeitsstrom von Motor 1 auf xxx mA
SAP 7, 1, 10 //setzt den Motorstandbystrom von Motor 1 auf xxx mA
sap 4, 0, 30 //setzt die maximale Positioniergeschwindigkeit für Motor 0
sap 4, 1, 30 //setzt die maximale Positioniergeschwindigkeit für Motor 1
sap 143, 0, 5 //setzt den Motorstopstrom von Motor 0 auf 100% des Motorarbeitsstroms
sap 143, 1, 5 //setzt den Motorstopstrom von Motor 1 auf 100% des Motorarbeitsstroms
SAP 205, 0, -7 //Turn on Stall Detection (use other threshold if needed)
SAP 205, 1, -7 //Turn on Stall Detection (use other threshold if needed)
mst 0 //stoppt Motor 0
mst 1 //stoppt Motor 1
rsub
referenz:
ror 0, 25 //ror bewegung zum endtaster
wait limsw ,0, 0 // stopp bei endtaster
mst 0 // " " "
mvp rel, 0, 100 // etwas weiter fahren
wait pos, 0, 0
wait ticks, 0, 100
rol 1, 25
wait limsw, 1, 0
mst 1
mvp rel, 1, -200
wait ticks, 1, 300
rsub
setpos1:
mvp rel, 0, -4100
wait pos, 0, 0
wait ticks, 0, 100
mvp rel, 1, 9000
wait pos, 1, 0
wait ticks, 0, 100
wait ticks, 1, 100
rsub
setnull:
sap 1, 0, 0
sap 1, 1, 0
rsub
horizontal:
mvp abs, 0, 2050
mvp abs, 1, -4500
wait pos, 0, 0
wait pos, 1, 0
rsub
When I manage that problem the next step would be considering limits in this manual movement also.
Or is the solution much easier because of a special mode I don't know by now. Some other systems have extra inputs for manual positioning, is there a possibility to implement this easily?
Greetings,
Jan Hansen
