Robin Lovelock
Senior Member
Thanks Martin and Hippy. Definitely making progress.
Hippy - could you clarify exactly what you think I need in that modified protol from AUTOP on PC or GPSSppc on iPAQ. Presently I'm only sending one extra blank byte before the sync. Latest version of program seems not always to catch the RS232 commands. I think that was why you thought something was needed - to program around timing problems related to IF PIN3 etc.
My latest version of the program is much smaller and based on your code, with minor typos corrected, etc. Let's see if I can insert it here....
You see I've removed the PAUSE allowing the servos to move
because this should not be needed. I can obviously put it back.
However, I'm guessing you may suggest more blank bytes before sync output from AUTOP and GPSSppc.
Martin: I did not miss your polite and subtle hint about doing my own experiments. But as you know, that could be a very slow process when trying to programme around the sort of limitations uncovered on this thread. That's why your picaxe experience is so valuable on this forum. I'm sure I must be telling grandma how to suck eggs
Robin
1550 Wed
www.gpss.co.uk/autop.htm
>>>>>>
Hippy - could you clarify exactly what you think I need in that modified protol from AUTOP on PC or GPSSppc on iPAQ. Presently I'm only sending one extra blank byte before the sync. Latest version of program seems not always to catch the RS232 commands. I think that was why you thought something was needed - to program around timing problems related to IF PIN3 etc.
My latest version of the program is much smaller and based on your code, with minor typos corrected, etc. Let's see if I can insert it here....
Code:
'SC1.BAS servo controller for robot boat
'input is RS232 group of 3 bytes:
'127=sync, 0,1 or 2=servo number, 0 to 126 servo position
'the input servo position from RS232 is 0 to 126, 64=centre
'position sent to servo system is 100 to 191, 146=centre
#Picaxe 08M
SETFREQ M4 'standard 4MHz
SERVO 1,146: SERVO 2,146: SERVO 4,146 'middle positions
PAUSE 3000
'test pattern on startup
for b0 = 0 to 126 step 63
b13 = b0 * 91 / 126 + 100
b1=b13: b2=b13: b3=b13
SERVOPOS 1, b1 'move servo 0
PAUSE 1000
SERVOPOS 2, b2 'move servo 1
PAUSE 1000
SERVOPOS 4, b3 'move servo 2
PAUSE 3000
next b0
PAUSE 3000
'remember servo positions and initiate
b1 = 146 : SERVOPOS 1, b1
b2 = 146 : SERVOPOS 2, b2
b3 = 146 : SERVOPOS 4, b3
'wait for 3 bytes from RS232,sync, servo N, position P
Sync:
If pin3 = 1 Then
SetFreq M8
Low 1 : Low 2 : Low 4
SerIn 3, N4800_8, (127), b12, b13
b13 = b13 * 91 / 126 + 100
Select Case b12
Case 0 : b1 = b13
Case 1 : b2 = b13
Case 2 : b3 = b13
End Select
SetFreq M4
Servo 1, b1 ' *
Servo 2, b2 ' *
Servo 4, b3 ' *
End If
Goto Sync 'back to serial input
because this should not be needed. I can obviously put it back.
However, I'm guessing you may suggest more blank bytes before sync output from AUTOP and GPSSppc.
Martin: I did not miss your polite and subtle hint about doing my own experiments. But as you know, that could be a very slow process when trying to programme around the sort of limitations uncovered on this thread. That's why your picaxe experience is so valuable on this forum. I'm sure I must be telling grandma how to suck eggs
Robin
1550 Wed
www.gpss.co.uk/autop.htm
>>>>>>
You can use [code]...[/code] tags which will keep your code formatted correctly.
You need to keep the right frequency at the right time, so I would recommend trying this. I used b0, b1, b2 as the previous servo positions as easy to remeber.
You may be able to change all the SERVO commands marked * to SERVOPOS and the first as SERVO and next two as SERVOPOS would be the next best thing if it works. I haven't used servos enough nor have any to test to see if that will work in practice.Code:b0 = 150 : Servo 1, b0 b1 = 150 : Servo 2, b1 b2 = 150 : Servo 4, b2 Sync: If pin3 = 1 Then Low 1 : Low 2 : Low 4 SetFreq M8 SerIn 3, N4800_8, (127), b12, b13 b13 = b13 * 91 / 126 + 100 Select Case b12 Case 0 : b0 = b13 Case 1 : b1 = b13 Case 2 : b2 = b13 End Select SetFreq M4 Servo 1, b0 ' * Servo 2, b1 ' * Servo 4, b2 ' * Pause 3000 End If Goto Sync