PDA

View Full Version : More Servo Woes



chrisshortys
- 27th February 2009, 17:31
Hi guys, I am currently building a projct which uses the analoge input from a 3 axis accelerometer and turns this into a proportional servo output.

I have now managed to get y chip to read ADC input from one input and to put out a servo ouput using a FOR loop.

Now the problem I am having is the FOR loop doesnt seem to be interuptable. So the servo will only respond to a new input once it has reached its current destination. I want to find a way to have the servo change direction before it reaches its end destination.

The second issue i have is the programe seems to freeze at times. The LCD does not update and the programe does not recognise any change in input for a while before suddenly snapping back into life.

Attached below is my code


'************************************************* **********************
'*college project to control 2 servo motors from a 3 axis accelerometer*
'************************************************* **********************
'*****27/02/09************************************************ ***********
' V 0.2
' For loop responding to input of ADC
' active ADC inputs displayed on line 2 of lcd
' servo position shown on line 1 of LCD
'************************************************* **********************
'** Shows the Connections on the ports of the PIC **********************
'************************************************* **********************
'
'A0 = X-AXIS
'A1 = Y-AXIS
'A2 = Z-AXIS
'A3 =
'A4 =
'A5 =
'
'BO = LCD INTERFACE
'B1 = LCD INTERFACE
'B2 = LCD INTERFACE
'B3 = LCD INTERFACE
'B4 = LCD INTERFACE
'B5 = LCD INTERFACE
'B6 = LCD INTERFACE
'B7 = LCD INTERFACE
'
'C0 = SERVO 1
'C1 = SERVO 2
'C2 =
'C3 =
'C4 =
'C5 =
'C6 =
'C7 =


'************************************************* **********************
'****************** DEFINE ADCIN PARAMETERS*****************************
'************************************************* **********************

DEFINE ADC_BITS 8 'SETS NUMBER OF BITS IN RESULTS
DEFINE ADC_CLOCK 3 'SET CLOCK SOURCE
DEFINE ADC_SAMPLUS 50 'SET SAMPLING TIME IN US

DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4
DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection
DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.



SERVOY VAR PORTC.0
SERVOX VAR PORTC.1

YAXIS VAR WORD
XAXIS VAR WORD
ZAXIS VAR WORD

XPRESET VAR WORD
YPRESET VAR WORD
ZPRESET VAR WORD

B0 VAR WORD
B1 VAR WORD
B2 VAR WORD
B3 VAR WORD


TRISA = %00000011 'SETS INPUTS/OUTPUTS FOR BANK A
TRISB = %00000000 'SETS INPUTS/OUTPUTS FOR BANK B
TRISC = %00000000 'SETS INPUTS/OUTPUTS FOR BANK C

ADCON1 = %00000110 'SETS THE ANALOGUE/DIGITAL INPUTS TO BANK A

PORTA = %00000000 'SETS THE INITIAL VALUE OF BANK A
PORTB = %00000000 'SETS THE INITIAL VALUE OF BANK B
PORTC = %00000000 'SETS THE INITIAL VALUE OF BANK C


'************************************************* *************************
' CENTER THE SERVO
' ****************
' Pause for one second to allow initalisations
' Clear the LCD display
' Center Servo 1 and then servo 2
'
'************************************************* *************************

PAUSE 1000
LCDOUT "STARTING"
pause 1000
LCDOUT $FE, 1

CENTER: 'NEW SUBROUTINE FOR SETTING THE SERVO
FOR B0 = 1 TO 100 'MOVES THE SERVO FROM ITS 0 TO ITS 100 MARK
PULSOUT SERVOY, 150 '
PAUSE 20 '
NEXT

FOR B1 = 1 TO 100 'Pans the servo from 0 to a halfway point of 100
PULSOUT SERVOX, 150 '
PAUSE 20 '
NEXT




'************************************************* *************************
' setup ADC
' *********
' reads the ADC ports and sets the initial values for calculations
'************************************************* *************************
STARTUP:

ADCIN 0, B2 ' reads in the ADC on PORT A.0 and sends it to memory location B2
ADCIN 1, B3 ' reads in the ADC on PORT A.1 and sends it to memory location B3


gosub servomove

'************************************************* *************************
' Servo calculations
' ******************
'
'
'************************************************* *************************

MAIN:

ADCIN 0, B2 ' Reads in the PORT A.0 ADC AND STORES THE VALUE IN B2
ADCIN 1, B3 ' READS IN THE PORT a.1 ADC AND STORES THE VALUE IN B3

XPRESET = B2 + 50

If Xpreset > 92 then
goto positive
endif

if xpreset < 92 then
goto negative
endif


positive:
FOR B0 = B0 TO XPRESET
PULSOUT SERVOY, B0
PAUSE 20
gosub servomove
NEXT

goto main



negative:
FOR B0 = B0 TO xpreset STEP -1
PULSOUT SERVOY, B0
PAUSE 20
gosub servomove
NEXT

goto main


'
'
''************************************************ ************************************************** *****************
' SERVOMOVEMENT CONTROL
' *********************
' MOVES BOTH SERVOS FOR BOTH X AND Y MOVEMENT
' CREATES THE NEW X AND Y PRESETS FOR THE CALCULATIONS
' UPDATES THE LCD DISPLAY
'************************************************* ************************************************** ****************
SERVOMOVE:
'
' PULSOUT SERVOY, B1 ' SENDS THE NEW VALUE FOR SERVO Y
'
'
' PULSOUT SERVOX, B0 ' SENDS THE NEW VALUE FOR SERVO X
'
'

ADCIN 0, B2 ' Reads in the PORT A.0 ADC AND STORES THE VALUE IN B2
ADCIN 1, B3 ' READS IN THE PORT a.1 ADC AND STORES THE VALUE IN B3



LCDOUT $FE, 2 ' SENDS THE COMMAND TO THE LCD TO MOVE TO THE START OF THE FIRST LINE

LCDOUT "Servo Pos= ",DEC3 B0 ' SENDS THE DATA FOR THE X AXIS TO THE LCD ON THE FIRST LINE

LCDOUT $FE, $C0 ' MOVES THE CURSUR OF THE LCD TO THE START OF THE SECOND LINE

LCDOUT "Y = ",DEC3 B2, " X = ",DEC3 B3 ' SENDS THE DATA FOR THE Y AXIS TO THE LCD ON THE SECOND LINE

RETURN ' RETURNS TO THE PREVIOUS BLAAAAAAAAAAAAAAAAAAAAAAH


GOTO MAIN



END

aratti
- 27th February 2009, 17:43
Tray this it should help.



positive:
While B0 <> XPRESET
B0=B0+1
PULSOUT SERVOY, B0
PAUSE 20
gosub servomove
wend

goto main



negative:
While B0<>xpreset
B0=B0-1
PULSOUT SERVOY, B0
PAUSE 20
gosub servomove
wend

goto main


Al.

chrisshortys
- 27th February 2009, 17:54
Nope this results in the servo panning uncontrolled trying to pass its limits. I havnt ever used a while loop before but assumed the piece of code you gave me should of fitted in where my current for loops where.

If so i shall have a play tommorow and see what i can come up with :)

Archangel
- 27th February 2009, 18:32
Hi Chris,
I have only a little experience with servos, and do not have my computer at hand, but the best I remember, if I sent a number to my servo it executed fully before accepting a new value, so I am thinking if you send a count to the servo something like 1500, 1510, 1520 . . . to cause movement you can snuggle an interrupt between the numbers.
EDIT: after reading your code, looks like pretty much what you are doing. I'm empty.



Now the problem I am having is the FOR loop doesnt seem to be interuptable. So the servo will only respond to a new input once it has reached its current destination. I want to find a way to have the servo change direction before it reaches its end destination.
I see no interrupt in your code, Why would you be able to stop it? I never have been able to hijack the count variable in a for next loop, you might try using an interrupt routine and clearing the variable in there, I do not know if it will work though.



The second issue i have is the programe seems to freeze at times. The LCD does not update and the programe does not recognise any change in input for a while before suddenly snapping back into life.

Could be latency, could be Breadboard issues where stray capacitance stops the oscillator, could be power supply causing PIC brownout reset, I see no config statement so I assume you are using default config, . . . could be GOTO MAIN at the end of servomove when you used gosub to get there, causing a stack overflow, and eventual reset. . . . On closer inspection looks like you have a return and goto main in there . . . I don't know how that would affect operation if at all since theoretically the code should never go past the return, but who knows? Computers (and PICs) are stupid, but not sloppy, they only do what you tell them to do, whether intentionally or not.
Keep us posted, I would like to see your Final Cut, looks like it would make a cool VR control for a camera in an RC heli.

Acetronics2
- 28th February 2009, 09:49
Hi, Chris

A servomotor has it's own signal limitations ...

from 800 to 2200 µs pulse ( STD ) ... so unpredictable behaviour can occur outside those limits ...



ADCIN 0, B2 ' Reads in the PORT A.0 ADC AND STORES THE VALUE IN B2
ADCIN 1, B3 ' READS IN THE PORT a.1 ADC AND STORES THE VALUE IN B3

XPRESET = B2 + 50



your accelerometer is an analog one, Ok ... but ADCIN can give a result between 0 and 256 ...

so, the servo signal range is not guaranteed to be in the " valid" range.

Now , you read Twice the accelerometer in one cycle ... not really a problem, but it's not compulsory here.

BTW ... Which Pic and Accelerometer do you use ???

Alain

chrisshortys
- 28th February 2009, 12:40
Thanks for all the replies i shall try and go through them now :)



your accelerometer is an analog one, Ok ... but ADCIN can give a result between 0 and 256 ...

so, the servo signal range is not guaranteed to be in the " valid" range.

BTW ... Which Pic and Accelerometer do you use ???

Alain
Firstly i understand that the ACDIN can give the range from 0-256 how ever the accelerometer is not capable of giving a value of 0-5v, I can't remember the exact voltages as theyre at work but the values i receive on the ACDIN when moving from one limit to the other are 45-128. This is the reason i add a value to the number to try and keep the server centeral(yes i know its not the correct value yet :P ).

The Pic I am using is a 16f876A
and the accelerometer is a prototyping board which i brought from sure electronics http://cgi.ebay.co.uk/3-Axis-low-g-Accelerometer-MMA7260-prototype-PCB_W0QQitemZ230327601157QQcmdZViewItemQQptZUK_BOI _Electrical_Components_Supplies_ET?hash=item230327 601157&_trksid=p3286.c0.m14&_trkparms=72%3A1701%7C66%3A2%7C65%3A12%7C39%3A1%7C 240%3A1318


Hi Chris,
I have only a little experience with servos, and do not have my computer at hand, but the best I remember, if I sent a number to my servo it executed fully before accepting a new value, so I am thinking if you send a count to the servo something like 1500, 1510, 1520 . . . to cause movement you can snuggle an interrupt between the numbers.
EDIT: after reading your code, looks like pretty much what you are doing. I'm empty.

I see no interrupt in your code, Why would you be able to stop it? I never have been able to hijack the count variable in a for next loop, you might try using an interrupt routine and clearing the variable in there, I do not know if it will work though.


Could be latency, could be Breadboard issues where stray capacitance stops the oscillator, could be power supply causing PIC brownout reset, I see no config statement so I assume you are using default config, . . . could be GOTO MAIN at the end of servomove when you used gosub to get there, causing a stack overflow, and eventual reset. . . . On closer inspection looks like you have a return and goto main in there . . . I don't know how that would affect operation if at all since theoretically the code should never go past the return, but who knows? Computers (and PICs) are stupid, but not sloppy, they only do what you tell them to do, whether intentionally or not.
Keep us posted, I would like to see your Final Cut, looks like it would make a cool VR control for a camera in an RC heli.

Yer i think that is the problem the FOR loop is not very interuptable. Thats somthing im going to change once i get time to play with it again.
Shouldnt be a problem with latency as i only ever use veroboard though i havnt placed any capacitors across the crystal so i shall do that asap to see if that helps.
Power supply wise i have tried the circuit on several different powersupplies both at work and at home, the only issue i had there was i had the current limiter at around 100 mA and the servo seems to draw a considerable amount to trip that on its first start up! But hat has now been rectified with a 470 uF across the power rails next to the servo and upping the current limiter.

I shall lso try removing the goto main which was left in from a older attempt but i cant see that command even being looked at but its worth a try!

Orriginally i had planned to make a Pan-Tilt head for a camera but im now looking at making this into a robotic arm kind of setup with possibly strain gauges to detect a hand closing..... i dont know that somthing for later :p

Acetronics2
- 28th February 2009, 13:00
Hi, Chris

Ok for MMA7260 ... I've got a bunch here , from Elektor magazine. ...


let's then suppose servo pulse kept into the "valid range"

Now, nothing "strange" in the program ... may be you left MMA sensitivy range selecting aside, for the moment.

I'd just recommend you to add :

LOW Servoxyz

just before

PULSOUT Servoxyz

Just to be sure the pulse will be positive. ( not only a view of mind !!! )



Next step to check ... the supply.

Of course, for tests you better use a separate battery for servo powering.

Here you could begin to find success ...

Alain

PS: http://itp.nyu.edu/physcomp/sensors/Reports/MMA7260Q

chrisshortys
- 4th March 2009, 21:18
Well i carried on with some work before checking back to this forum and i have a much more effective code now :) although i shall try some of the comments you made last Ace :)

Ive gone back to using a FOR loop but i have put in a maths calculation so that the servo was nt moving the whole way to the next destination but a 4th of the way before checking the data again. So now i have a fairly responsive system for one servo which seems to keep track pritty well with no more hang ups!

The next thing I intend to address is the speed of the panning of the servo. I intend to have the servo move more quickly when there is a larger change in the accelerometer the faster the servo moves.

If anyone would like to see the code just ask but beware its quite messy atm :)

chrisshortys
- 4th March 2009, 22:16
Well the speed control didnt take very long at all to implement so I have attached a fully working code below.

Now i have to wait for the servo motors i have ordered to arrive from HK before i move on to having 2 servos in control at once!

any advice on different ways of doing things are welcome.

also sorry for the untidyness of the code but i shall neatn it up in the near future with comments on code



'************************************************* *******************************
'* college project to control 2 servo motors from a 3 axis accelerometer *
'************************************************* *******************************
'* 04/03/09 CODE WRITTEN BY CHRIS HAMMERSLEY *
' FEEL FREE TO MAKE USE OF THIS CODE BUT PLEASE GIVE CREDIT TO WHERE IT IS DUE *
' V 0.4
' For loop responding to input of ADC
' active ADC inputs displayed on line 2 of lcd
' servo position shown on line 1 of LCD
' removed twitch by adding a minimum movement to adjust servo
' more reliable tracking
' QUICKER RESPONCE TO CHANGES IN AXIS BY REDUCTION OF FOR LOOPS
' SERVO MOVEMENT NOW REPRESENTS DIFFERENT SPEEDS IN MOVEMENT
'************************************************* **********************
'** Shows the Connections on the ports of the PIC **********************
'************************************************* **********************
'
'A0 = X-AXIS
'A1 = Y-AXIS
'A2 = Z-AXIS
'A3 =
'A4 =
'A5 =
'
'BO = LCD INTERFACE
'B1 = LCD INTERFACE
'B2 = LCD INTERFACE
'B3 = LCD INTERFACE
'B4 = LCD INTERFACE
'B5 = LCD INTERFACE
'B6 = LCD INTERFACE
'B7 = LCD INTERFACE
'
'C0 = SERVO 1
'C1 = SERVO 2
'C2 =
'C3 =
'C4 =
'C5 =
'C6 =
'C7 =


'************************************************* **********************
'****************** DEFINE ADCIN PARAMETERS*****************************
'************************************************* **********************

DEFINE ADC_BITS 8 'SETS NUMBER OF BITS IN RESULTS
DEFINE ADC_CLOCK 3 'SET CLOCK SOURCE
DEFINE ADC_SAMPLUS 50 'SET SAMPLING TIME IN US

DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4
DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection
DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.



SERVOY VAR PORTC.0
SERVOX VAR PORTC.1

YAXIS VAR WORD
XAXIS VAR WORD
ZAXIS VAR WORD

XPRESET VAR WORD
YPRESET VAR WORD
ZPRESET VAR WORD

B0 VAR WORD
B1 VAR WORD
B2 VAR WORD
B3 VAR WORD

STEPPING VAR WORD


TRISA = %00000011 'SETS INPUTS/OUTPUTS FOR BANK A
TRISB = %00000000 'SETS INPUTS/OUTPUTS FOR BANK B
TRISC = %00000000 'SETS INPUTS/OUTPUTS FOR BANK C

ADCON1 = %00000110 'SETS THE ANALOGUE/DIGITAL INPUTS TO BANK A

PORTA = %00000000 'SETS THE INITIAL VALUE OF BANK A
PORTB = %00000000 'SETS THE INITIAL VALUE OF BANK B
PORTC = %00000000 'SETS THE INITIAL VALUE OF BANK C


'************************************************* *************************
' CENTER THE SERVO
' ****************
' Pause for one second to allow initalisations
' Clear the LCD display
' Center Servo 1 and then servo 2
'
'************************************************* *************************

PAUSE 1000
LCDOUT "STARTING"
pause 1000
LCDOUT $FE, 1

CENTER: 'NEW SUBROUTINE FOR SETTING THE SERVO
FOR B0 = 1 TO 100 'MOVES THE SERVO FROM ITS 0 TO ITS 100 MARK
PULSOUT SERVOY, 150 '
PAUSE 20 '
NEXT

FOR B1 = 1 TO 100 'Pans the servo from 0 to a halfway point of 100
PULSOUT SERVOX, 150 '
PAUSE 20 '
NEXT




'************************************************* *************************
' setup ADC
' *********
' reads the ADC ports and sets the initial values for calculations
'************************************************* *************************
STARTUP:

ADCIN 0, B2 ' reads in the ADC on PORT A.0 and sends it to memory location B2
ADCIN 1, B3 ' reads in the ADC on PORT A.1 and sends it to memory location B3

STEPPING = 1

gosub LCDUPDATE

'************************************************* *************************
' Servo calculations
' ******************
'
'
'************************************************* *************************

MAIN:

gosub LCDUPDATE

ADCIN 0, B2 ' Reads in the PORT A.0 ADC AND STORES THE VALUE IN B2
ADCIN 1, B3 ' READS IN THE PORT a.1 ADC AND STORES THE VALUE IN B3

XPRESET = B2 + 50

If Xpreset > B0 then
goto positiveone
endif

if xpreset < B0 then
goto negativeone
endif

'************************************************* ******************
' SERVO MOVEMENT
' **************
'
' CONTROLS THE OUTPUTS TO THE SERVO
'
'************************************************* *******************
positive:
FOR B0 = B0 TO XPRESET STEP STEPPING
PULSOUT SERVOY, B0
PAUSE 20
gosub LCDUPDATE
NEXT

goto main



negative:
FOR B0 = B0 TO xpreset STEP - STEPPING
PULSOUT SERVOY, B0
PAUSE 20
gosub LCDUPDATE
NEXT

goto main


'************************************************* *****************************
' MOVEMENT CALCULATIONS
' *********************
'
' THIS SECTION COMPARES THE INPUT TO THE CURRENT LOCATION AND DECIDES WHETHER A
' POSITIVE OR NEGATIVE MOVEMENT IS REQUIRED
'
'************************************************* ******************************


positiveone:

xaxis= xpreset - B0

if xaxis > 3 then
goto positivetwo
endif
STEPPING = 1

goto main



negativeone:
xaxis= B0 - xpreset

if xaxis > 3 then
goto negativetwo
endif
STEPPING = 1

goto main

'************************************************* *************************************
' SERVO SPEED CONTROL POSITIVE
' ****************************
'
' THIS SECTION LOOKS AT THE INPUT DATA AND DECIDES HOW FAST TO MOVE THE SERVO DEPENDING
' ON THE VALUE OF THE CHANGE BETWEEN THE INPUT AND THE CURRENT POSITION
'
'************************************************* **************************************


positivetwo:

IF XAXIS > 18 THEN
STEPPING = 6
ENDIF

IF XAXIS > 15 THEN
STEPPING = 5
ENDIF

IF XAXIS > 12 THEN
STEPPING = 4
ENDIF

IF XAXIS > 9 THEN
STEPPING = 3
ENDIF

IF XAXIS > 6 THEN
STEPPING = 2
ELSE
STEPPING = 1
ENDIF

'************************************************* ************************************************** ***********
' THE FOLLOWING CODE DIVIDES THE CHANGE VALUE BY 4 SO THAT THE FOR LOOP ONLY CHANGES A 4TH OF THE VALUE BEFORE
' RECHECKING ITS INPUTS
'************************************************* ************************************************** ***********

if xaxis > 20 then
xaxis = xaxis / 4
XPRESET = B0 + XAXIS
ENDIF

goto positive

'************************************************* *************************************
' SERVO SPEED CONTROL NEGATIVE
' ****************************
'
' THIS SECTION LOOKS AT THE INPUT DATA AND DECIDES HOW FAST TO MOVE THE SERVO DEPENDING
' ON THE VALUE OF THE CHANGE BETWEEN THE INPUT AND THE CURRENT POSITION
'
'************************************************* **************************************

negativetwo:

IF XAXIS > 18 THEN
STEPPING = 6
ENDIF

IF XAXIS > 15 THEN
STEPPING = 5
ENDIF

IF XAXIS > 12 THEN
STEPPING = 4
ENDIF

IF XAXIS > 9 THEN
STEPPING = 3
ENDIF

IF XAXIS > 6 THEN
STEPPING = 2
ELSE
STEPPING = 1
ENDIF


'************************************************* ************************************************** ***********
' THE FOLLOWING CODE DIVIDES THE CHANGE VALUE BY 4 SO THAT THE FOR LOOP ONLY CHANGES A 4TH OF THE VALUE BEFORE
' RECHECKING ITS INPUTS
'************************************************* ************************************************** ***********

IF XAXIS > 20 THEN
XAXIS = XAXIS / 4
XPRESET = B0 - XAXIS
ENDIF

GOTO NEGATIVE

'
'
''************************************************ ************************************************** *****************
' LCDUPDATE CONTROL
' *********************
' MOVES BOTH SERVOS FOR BOTH X AND Y MOVEMENT
' CREATES THE NEW X AND Y PRESETS FOR THE CALCULATIONS
' UPDATES THE LCD DISPLAY
'************************************************* ************************************************** ****************
LCDUPDATE:


ADCIN 0, B2 ' Reads in the PORT A.0 ADC AND STORES THE VALUE IN B2
ADCIN 1, B3 ' READS IN THE PORT a.1 ADC AND STORES THE VALUE IN B3



LCDOUT $FE, 2 ' SENDS THE COMMAND TO THE LCD TO MOVE TO THE START OF THE FIRST LINE

LCDOUT "Servo Pos= ",DEC3 B0 ' SENDS THE DATA FOR THE X AXIS TO THE LCD ON THE FIRST LINE

LCDOUT $FE, $C0 ' MOVES THE CURSUR OF THE LCD TO THE START OF THE SECOND LINE

LCDOUT "Y = ",DEC3 B2, " X = ",DEC3 B3 ' SENDS THE DATA FOR THE Y AXIS TO THE LCD ON THE SECOND LINE

RETURN ' RETURNS TO THE PREVIOUS BLAAAAAAAAAAAAAAAAAAAAAAH


'GOTO MAIN



END*

flipper_md
- 12th May 2009, 23:18
positivetwo:

IF XAXIS > 18 THEN
STEPPING = 6
ENDIF

IF XAXIS > 15 THEN
STEPPING = 5
ENDIF

IF XAXIS > 12 THEN
STEPPING = 4
ENDIF

IF XAXIS > 9 THEN
STEPPING = 3
ENDIF

IF XAXIS > 6 THEN
STEPPING = 2
ELSE
STEPPING = 1
ENDIF

'************************************************* ************************************************** ***********


Hi Chris

I am looking to do something similar (soon I hope) and as I was scrolling thru your code, I saw that this whole section could be resumed by this.

STEPPING = XAXIS /3

and maybe add a IF statement for low values of xaxis..

IF XAXIS < 5
STEPPING = 1
END IF


I don't know if that can make the whole thing more reponsive...since all the IF have to be processed.

anyhow, thanks for sharing your code!

chrisshortys
- 13th May 2009, 08:40
Cheers for that flipper, I shall try that when I get back from the business trip I'm on.
Anything to make it simplier will help with the two servo motors!