servo control help

jshenfield

New Member
I am currently having a go at making a remote controlled mount for an SA80. I have sorted the remote aspects of the program but need to have the servos communicate with it.

My intention is to have the remote move the servos in one direction by a certain amount when a button is pressed and the the other direction when another button is pressed. I think I have to use the registry to have the position of the servo in it, then have a sum to add 5 (or something) so the servo will look to that all the time then move accordingly. This is where I am a little lost. This is what I have so far but the servo just pulses when I press the button.

symbol try = w1
w2 = 75
main:

servo 4,75
irin [1000,main],C.0,b0 ;
if b0 = 1 then moveup

goto main

moveup:
let w1 = w2 + 5
write w1,w3
servopos 4,w3
pause 100

goto main


Thanks in advance
 

Buzby

Senior Member
HI,

Welcome to the forum !.

If an SA80 is what I think it is, and DSFC is where I think it is, then quite a lot of the forum elders will be asking you a lot of questions !.

I'm not a servo expert, so let's see if anyone is up to it.

Cheers,

Buzby
 

hippy

Ex-Staff (retired)
If an SA80 is what I think it is, and DSFC is where I think it is, then quite a lot of the forum elders will be asking you a lot of questions !
I think you're right on all counts !

Fears of helping someone build something that appears it could be pretty dangerous, lethal in fact, may have people steering clear, reluctant to help, and asking more questions about what you are doing than actually providing help.

For controlling a servo to move under IR remote control, what you have is heading in the right direction ( bad pun ) but overly complicated; no need for any WRITE for example.
 

jshenfield

New Member
Haha, yea I could see how that would look. However we will not be fitting an SA80 to the system, it will house a dummy rifle to demonstrate the principles of the design.

You mention that I have over complicated it with the write, what would you recommend?
 

hippy

Ex-Staff (retired)
You could trim it down to something like ...

Code:
b1 = 75
servo 4, b1

main:
  irin [1000,main], C.0, b0
  if b0 = 1 then moveup
  goto main

moveup:
  let b1 = b1 + 5
  servopos 4, b1
  pause 100
  goto main
What I think may have been the main problems in the first code was always resetting back to 75 when you go back to main, and when set to 'w3', the 'w3' hadn't been calculated, was zero.

were you perhaps using "write w1,w3" to move 'w1' into 'w3' ? That would have been 'Let w3 = w1".
 
Top