;Forum Mikewma 190108
#picaxe 20M
b3 = 2500 'long pause
b4 = 5 'short pause
b5 = 2 'move .002" for surface reading
b6 = 30 'move to minimum spec. .030"
b7 = 33 'move a couple thousanths short of average reading .033"
b8 = 34 'move another thousanth .034"
b9 = 35 'move to average reading .035"
'b10 = 36 'move another thousanth .036"
'b11 = 37 'move another thousanth 037"
b12 = 50 'move to maximum spec. .050"
'This section is used to manually posision the micrometer
main:
If pin1 =1 then 'move in reverse slow
gosub CounterCs
'pause b3
endif
If pin2 =1 then 'move in reverse fast
gosub CounterCf
'pause b4
endif
If pin3 =1 then 'move forward slow
gosub CWises
'pause b3
endif
If pin4 =1 then 'move forward fast
gosub CWisef
'pause b4
endif
'This section runs the sequence for the Micrometer.
'After it moves to one position it waits for a signal
'then moves to the next position etc.
'Using a switch for the signal for right now
If pin5 =1 then goto sequstart
'for b0 = 0 to 5
'lookup b0, (b5, b6, b7, b8, b9, b10, b11, b12),W1
'type in the 6 values you need
'for b1 = 1 to W1
'gosub CWisef
'next
'next 'syntax error
'endif 'syntax error
goto main
CWises:
let pins = %00011000
pause b3
let pins = %00001100
pause b3
let pins = %00000110
pause b3
let pins = %00010010
pause b3
return
CounterCs:
let pins = %00011000
pause b3
let pins = %00010010
pause b3
let pins = %00000110
pause b3
let pins = %00001100
pause b3
return
CWisef:
let pins = %00011000
pause b4
let pins = %00001100
pause b4
let pins = %00000110
pause b4
let pins = %00010010
pause b4
return
CounterCf:
let pins = %00011000
pause b4
let pins = %00010010
pause b4
let pins = %00000110
pause b4
let pins = %00001100
pause b4
return
'problems starting here
sequstart:
for b13=1 to 50
for b2=1 to b5
pulsout 1,1000:pause 100
pulsout 2,1000:pause 100
pulsout 3,1000:pause 100
pulsout 4,1000:pause 100
next b2
next b13
If pin6 =1 then goto Minspec
Minspec:
for b13=1 to 50
for b2=1 to b6
pulsout 1,1000:pause 100
pulsout 2,1000:pause 100
pulsout 3,1000:pause 100
pulsout 4,1000:pause 100
next b2
next b13
If pin6 =1 then goto fstchk
fstchk:
for b13=1 to 50
for b2=1 to b7
pulsout 1,1000:pause 100
next b2
next b13
If pin6 =1 then goto avgchk
avgchk:
for b13=1 to 50
for b2=1 to b8
pulsout 1,1000:pause 100
next b2
next b13
'If pin6 =1 then goto maxspec
'maxspec:
'for b13=1 to 50
'for b2=1 to b8
'pulsout 1,1000:pause 100
'next b2
'next b13
'If pin6 =1 then goto main