Blazemaguire
Senior Member
Hi guys,
I'm starting to get more confident with the BASIC programming (if you've seen any of my previous posts, you'll know i'm a bit of a noob with the code - used to flowcharts) - anyhow, for my latest experiment i'm making a simple 'touch sensor' operated turrent - actuated by a normal micro hobby servo.
The code below works in practice, and it senses my 'touch' sensors fine (I just use a coil of solid core copper glue gunned to the back of a piece of plastic for the touch sensors). - It moves the 'turret' clockwise and anticlockwise as intended and stops when it reaches the programmed limits.
However, my bug bear is it's too slow for my needs - i'd like more rapid traverse. - I've removed all time delays from the coding, even tried running in 16mhz mode. - Basically it takes about 20 seconds of holding the touch pad down to move from one end of rotation to the other, which is too long for what I've got planned.
Am I on a hiding to nothing trying to get this operating faster? - is it a function of the touch sensing command taking up too much time in the program execution? - If it is, does anyone have any suggestions of other avenues I could explore? - I don't want a full answer, just a suggestion of another direction to follow.
thanks in advance
Code below:
'Touch sensing Servo Control MK1'
'connect touch pads to b.0 and b.1 on a PICAXE20M2
'connect servo to pin b.7
init:
symbol moveamount=1'this symbol is the 'amount' of each step back or forth (basically how much it moves per 'touch'
symbol clockwisebuttoncalib = 4700 'callibration value for my touch pads (clockwise button)
symbol anticlockbuttoncalib = 4100 'callibration value for my touch pads (anticlockwise button)
b9=150 'set variable to 150 so servo moves to midpoint
servo b.7,b9 ; initialise servo to midpoint
main:
turnclock: 'routine for rotating clockwise
touch16 b.0,w0 ; read value into w0 from touch sensor UP
if w0 > clockwisebuttoncalib and b9<=225 then 'check value has exceeded 4700 which is threshold for a 'touch', and not exceeded clockwise limits
b9=b9+moveamount 'increase servo variable so it moves clockwise
servopos b.7,b9 ; move servo to one end
else
goto turnanticlock
endif
turnanticlock:
touch16 b.1,w1 ' read value of DOWN sensor into W1
if w1 > anticlockbuttoncalib and b9>=53 then 'check the value is more than 4100 (threshold for a touch) and that it's not exceeded anticlock limits
b9=b9-moveamount 'reduce the variable by the moveamount (moves servo anticlock)
servopos b.7,b9 ; move servo to one end
goto main
else goto turnclock
endif
I'm starting to get more confident with the BASIC programming (if you've seen any of my previous posts, you'll know i'm a bit of a noob with the code - used to flowcharts) - anyhow, for my latest experiment i'm making a simple 'touch sensor' operated turrent - actuated by a normal micro hobby servo.
The code below works in practice, and it senses my 'touch' sensors fine (I just use a coil of solid core copper glue gunned to the back of a piece of plastic for the touch sensors). - It moves the 'turret' clockwise and anticlockwise as intended and stops when it reaches the programmed limits.
However, my bug bear is it's too slow for my needs - i'd like more rapid traverse. - I've removed all time delays from the coding, even tried running in 16mhz mode. - Basically it takes about 20 seconds of holding the touch pad down to move from one end of rotation to the other, which is too long for what I've got planned.
Am I on a hiding to nothing trying to get this operating faster? - is it a function of the touch sensing command taking up too much time in the program execution? - If it is, does anyone have any suggestions of other avenues I could explore? - I don't want a full answer, just a suggestion of another direction to follow.
thanks in advance
Code below:
'Touch sensing Servo Control MK1'
'connect touch pads to b.0 and b.1 on a PICAXE20M2
'connect servo to pin b.7
init:
symbol moveamount=1'this symbol is the 'amount' of each step back or forth (basically how much it moves per 'touch'
symbol clockwisebuttoncalib = 4700 'callibration value for my touch pads (clockwise button)
symbol anticlockbuttoncalib = 4100 'callibration value for my touch pads (anticlockwise button)
b9=150 'set variable to 150 so servo moves to midpoint
servo b.7,b9 ; initialise servo to midpoint
main:
turnclock: 'routine for rotating clockwise
touch16 b.0,w0 ; read value into w0 from touch sensor UP
if w0 > clockwisebuttoncalib and b9<=225 then 'check value has exceeded 4700 which is threshold for a 'touch', and not exceeded clockwise limits
b9=b9+moveamount 'increase servo variable so it moves clockwise
servopos b.7,b9 ; move servo to one end
else
goto turnanticlock
endif
turnanticlock:
touch16 b.1,w1 ' read value of DOWN sensor into W1
if w1 > anticlockbuttoncalib and b9>=53 then 'check the value is more than 4100 (threshold for a touch) and that it's not exceeded anticlock limits
b9=b9-moveamount 'reduce the variable by the moveamount (moves servo anticlock)
servopos b.7,b9 ; move servo to one end
goto main
else goto turnclock
endif