some changes: bug fixes, working with PMC007

This commit is contained in:
2025-02-18 17:36:25 +03:00
parent 1453398f08
commit f3023b1cc0
20 changed files with 308 additions and 45 deletions

View File

@@ -0,0 +1,32 @@
scripts for two-direction turret
lambda/4
rotates in negative direction
speed=400
full circle = 400 steps (12800 microsteps for 1/32)
35.(5) microsteps per 1 degree
turrret
rotates in positive direction
speed=1000
full circle = 200 steps (6400 mircosteps for 1/32)
six positions, so distance between positions is 1066.(6) microsteps
scripts:
Tinit - init stepper driver (run just after power on)
Tgotopos - move turret to given position (0..5)
Rgotoangle - rotate rotator to given angle (0..359 degrees)
WARNING! If LIM1=1 (i.e. one of limit switches active) but lsw activated by other device than you want move,
you won't be able to move it!
So, if you need to move turret to some position when rotator is at 0 angle, you should first remove rotator from
limit switch (at least to 30 degrees), then rotate turret and after all move rotator to given angle.
The same is for turret position 2: it always on LIM1, so to move rotator when turret is on 2 you should move
turret to any other position first, after that you will be able to rotate rotator
To check just run
steppermove -vvvw -E3 -I11
(twice, if first run won't show you limit switches), and you will see value of LIM1.

View File

@@ -0,0 +1,46 @@
#!/bin/bash
CANID=11
STPPERROT=12800
function onlim(){
eval $(steppermove -I11 -E3 | grep LIM1)
echo $LIM1
}
if [[ $# != 1 ]]; then
echo -e "Usage: $(basename $0) position\n\twhere 'position' is an angle [integer number!!!] from 0 to 360\t0 - limit switch position" >&2
exit 1
fi
if (( $1 > 360 || $1 < 0 )); then
echo "'position' should be from 0 360" >&2
exit 1
fi
steppermove -I${CANID} -m1000
if [[ $(onlim) == "1" ]]; then
echo "Go out from limit switch"
steppermove -I${CANID} -cA
steppermove -I${CANID} -r -$((STPPERROT / 4)) -w
steppermove -I${CANID} -E3 -m1000
if (( $(onlim) == 1 )); then
echo "TURRET is on limit switch, rotate it first!" >&2
exit 1
fi
fi
echo "Go to limit switch"
steppermove -I${CANID} -E3 -r -$STPPERROT -w
steppermove -I${CANID} -cA -w
if (( $1 != 0 )); then
STP=$(printf %.0f $(echo "12800/360*$1 + 31" | bc -l))
STP=$(( STP/32*32 ))
echo "Go to angle $1"
steppermove -I${CANID} -r -$STP -w
fi
echo "OK, at place!"
steppermove -I${CANID} -E3

View File

@@ -0,0 +1,35 @@
# Transmit SDO to driver
# Format: index, subindex, data
# Set heartbeat time to 0
0x1017, 0, 0
# Turn off offline programming
0x6018, 1, 0
0x6018, 2, 0
# Set Node ID to 11
0x2002, 0, 11
# Set speed to 250 (0-20, 1-25, 2-50, 3-100, 4-125, 5-250, 6-500, 7-800, 8-1000)
0x2003, 0, 5
# Set microstepping to 32
0x600A, 0, 32
# Set max phase current to 1.0A
0x600B, 0, 1000
# Set acceleration (0 - no, 1 - highest, 8 - lowest)
0x6008, 0, 2
# Set deceleration
0x6009, 0, 2
# EXT1&EXT2 emergency stop @ rising edge (normal state == 0)
# Rising edge for triggers
0x600F, 2, 3
# Pullup for triggers on rising edge
0x600F, 3, 3
# Enable
0x600F, 1, 3
# Save parameters
0x2007, 0, 2

View File

@@ -0,0 +1,43 @@
#!/bin/bash
CANID=11
STPPERROT=6400
# positions: amount of steps for each turret position
POSITIONS=(4224 5291 6357 7424 8491 9557)
function onlim(){
eval $(steppermove -I11 -E3 | grep LIM1)
echo $LIM1
}
if [[ $# != 1 ]]; then
echo -e "Usage: $(basename $0) position\n\twhere 'position' is a number from 0 to 5\t0 is closed diaphragm" >&2
exit 1
fi
if (( $1 > 5 || $1 < 0 )); then
echo "'position' should be from 0 (closed) to 5" >&2
exit 1
fi
steppermove -I${CANID} -m400
if [[ $(onlim) == 1 ]]; then
echo "Go out from limit switch"
steppermove -I${CANID} -cA
steppermove -I${CANID} -m1000 -r $((STPPERROT / 4)) -w
steppermove -I${CANID} -m400
if (( $(onlim) == 1 )); then
echo "ROTATOR is on limit switch, rotate it first!" >&2
exit 1
fi
fi
echo "Go to limit switch"
steppermove -I${CANID} -E3 -r $STPPERROT -w
steppermove -I${CANID} -cA -w
echo "Go to position $1"
steppermove -I${CANID} -r ${POSITIONS[$1]} -w
echo "OK, at place!"
steppermove -I${CANID} -E3

View File

@@ -0,0 +1,5 @@
#!/bin/sh
CANID=11
steppermove -vvv -I${CANID} -cE3 -s250 -m400 -w

View File

@@ -0,0 +1 @@
scripts for 3-motor local corrector

View File

@@ -0,0 +1,19 @@
#!/bin/sh
# init 3-point local corrector
for I in 2 10 11; do
./steppermove -I$I -m8000 -r-10000
done
for I in 2 10 11; do
./steppermove -I$I -w
done
for I in 2 10 11; do
./steppermove -I$I -0
done
for I in 2 10 11; do
./steppermove -I$I -a 7200
done

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# random move 3-point local corrector around middle point
function rmove(){ # $1 - current motor index, $2 - index of motor to correct into+, $3 - relative steps
arr=(2 10 11) # ID's of motors
ID=${arr[$1]}
#./steppermove -I$ID -w
if [[ $1 -ne $2 ]]; then # move to minus
./steppermove -I$ID -a $(( 7200 - S ))
else # move to plus
./steppermove -I$ID -a $(( 7200 + S ))
fi
}
trap "echo Exited!; exit;" SIGINT SIGTERM
while true; do
I=$(( RANDOM % 3 ))
S=$(( RANDOM % 1280 ))
for i in 0 1 2; do
rmove $i $I $S
done
done

View File

@@ -8,13 +8,19 @@
0x6018, 1, 0
0x6018, 2, 0
# Set Node ID to 10
0x2002, 0, 10
# Set Node ID to 11
0x2002, 0, 11
# Set speed to 250 (0-20, 1-25, 2-50, 3-100, 4-125, 5-250, 6-500, 7-800, 8-1000)
0x2003, 0, 5
# Set microstepping to 32
0x600A, 0, 32
# Set max phase current to 1.5A
0x600B, 0, 1500
# Set acceleration (0 - no, 1 - highest, 8 - lowest)
0x6008, 0, 2
# Set deceleration
0x6009, 0, 2
# EXT1&EXT2 emergency stop: EXT1@falling edge (normal state == 1), EXT2@rising edge (normal state == 0)
# Falling edge for trigger #1

View File

@@ -0,0 +1,20 @@
# Transmit SDO to driver
# Format: index, subindex, data
# Set heartbeat time to 0
0x1017, 0, 0
# Turn off offline programming
0x6018, 1, 0
0x6018, 2, 0
# Set Node ID
0x2002, 0, 11
# Set speed to 250 (0-20, 1-25, 2-50, 3-100, 4-125, 5-250, 6-500, 7-800, 8-1000)
0x2003, 0, 5
# Set max phase current to x mA
0x600B, 0, 1000
# Save parameters
0x2007, 0, 2

View File

@@ -0,0 +1,2 @@
# Disable EXT1, EXT2
0x600F, 1, 0

View File

@@ -0,0 +1,13 @@
# Transmit SDO to driver
# Format: index, subindex, data
# EXT1 emergency stop @ rising edge (normal state == 0)
# Rising edge for trigger #1
0x600F, 2, 3
# Pullup for triggers on rising edge
0x600F, 3, 3
# Enable EXT1
0x600F, 1, 3
# save settings
#0x2007, 0, 2