Troubles with ServoControl with PushButtons & RCTIME
nomad
Posts: 276
hi
I have this problem with control 3 Servos with
6-Push_Buttons and additionally i want the
values of 2 Pressure-Sensors.
Errors:
If all 4 functions run thus:
- ShoulderServo1
- ShoulderServo2
- KneeServo3
- RCTime_Read
Does not react the program any longer no servo
actions, no output of the pressure sensors.
Are if however the servo functions switched off
The output of RCTIME is OK
If RCTIME is switched off,
those run Servos.
I already used the normal RCTIME function
(without BS2-Funktionen).
Same result.
I do not have notion which am there the matter.
Are grateful around each assistance .
Regard
nomad
the program:
I have this problem with control 3 Servos with
6-Push_Buttons and additionally i want the
values of 2 Pressure-Sensors.
Errors:
If all 4 functions run thus:
- ShoulderServo1
- ShoulderServo2
- KneeServo3
- RCTime_Read
Does not react the program any longer no servo
actions, no output of the pressure sensors.
Are if however the servo functions switched off
The output of RCTIME is OK
If RCTIME is switched off,
those run Servos.
I already used the normal RCTIME function
(without BS2-Funktionen).
Same result.
I do not have notion which am there the matter.
Are grateful around each assistance .
Regard
nomad
the program:
{ test.spin for test-program with PropellerProtoBoard - Version 10 for ProtoBoard - ServoControl of 1 Leg with 3 Servos - with Adjustments for Neutral-Standings - with PropTerminal witch PC_Text for Output Contributions: - parallax.com : http://www.parallax.com PropTerminal : www.insonix.ch (c) dd. 20.08.2008 ---------------------------------------------------------------------------- } CON _CLKMODE = XTAL1 + PLL16X ' Set to ext crystal, 16x PLL, 80MHz Clock _XINFREQ = 5_000_000 ' Frequency on XIN pin is 5 MHz ' for BS2-Functions RC1 = 6 ' PressureSensor Pin 6 for Leg1 sensorPin BS2 red RC2 = 7 ' PressureSensor Pin 7 for Leg2 black OBJ BS2 : "BS2_Functions" ' Create BS2 Object for Pressure TV : "PC_Text" 'You can also use TV_Text or VGA_Text objects VAR LONG pulsetime1, pulsetime2, pulsetime3 LONG periode1, periode2, periode3 LONG new_periode1, new_periode2, new_periode3 LONG timebase LONG RCVal_1 ' rawForce Leg1 LONG RCVal_2 ' rawForce Leg2 PUB Main ' Initialize BS2 Object, Rx and Tx pins for DEBUG BS2.start(31,30) 'start the terminal TV.start(12) Init Adjustments repeat ShoulderServo1 ShoulderServo2 KneeServo3 RCTime_Read PUB Init ' 20ms NOK not smoothly -> periode1 := ((clkfreq / 100_000) * 2000) periode1 := ((clkfreq / 100_000) * 500) ' 5ms LEG 1 periode2 := ((clkfreq / 100_000) * 500) periode3 := ((clkfreq / 100_000) * 500) pulsetime1 := ((clkfreq / 100_000) * 150) ' 1,5ms pulsetime2 := ((clkfreq / 100_000) * 150) pulsetime3 := ((clkfreq / 100_000) * 150) dira[noparse][[/noparse]0]~~ ' Pin00 set output servoSignal 1 Leg_1 outa[noparse][[/noparse]0]~ ' Pin00 set low dira~~ ' Pin01 set output servoSignal 2 outa~ ' Pin01 set low dira~~ ' Pin02 set output servoSignal 3 outa~ ' Pin02 set low dira[noparse][[/noparse]8]~ ' Pin08 set input (taster s1) Shoulder1_Servo1 Swing dira[noparse][[/noparse]9]~ ' Pin09 set input (taster s2) dira[noparse][[/noparse]10]~ ' Pin10 set input (taster s3) Shoulder2_Servo2 Up/Down dira[noparse][[/noparse]11]~ ' Pin11 set input (taster s4) dira[noparse][[/noparse]12]~ ' Pin12 set input (taster s5) Knee3_Servo3 (Up/Down) dira[noparse][[/noparse]13]~ ' Pin13 set input (taster s6) timebase := cnt PUB Adjustments ' Leg1 pulsetime1 := 120_000 - 9_000 ' IS KNEESERVO_3 NOT SHOULDERSERV0_1 pulsetime2 := 120_000 + 4_800 ' is shoulderServo2 pulsetime3 := 120_000 + 4_800 ' IS SHOULDERSERVO_1 PUB RCTime_Read 'repeat dira[noparse][[/noparse]RC1]~~ ' RC output outa[noparse][[/noparse]RC1]:=1 ' Set High BS2.Pause(10) ' Allow charge RCVal_1 := BS2.RCTime(6,1) ' Get RC Time BS2.Pause(100) dira[noparse][[/noparse]RC2]~~ ' RC output outa[noparse][[/noparse]RC2]:=1 ' Set High BS2.Pause(10) ' Allow charge RCVal_2 := BS2.RCTime(7,1) ' Get RC Time TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(7) 'ypos TV.str(string("PressureLeg1:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(7) TV.dec(RCVal_1) TV.out(" ") TV.out($0D) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(8) 'ypos TV.str(string("PressureLeg2:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(8) TV.dec(RCVal_2) TV.out(" ") TV.out($0D) BS2.Pause(100) PUB ShoulderServo1 ' generate servopulse Servo1 (swing) 1 Leg outa[noparse][[/noparse]0]~~ waitcnt (timebase += pulsetime1) outa[noparse][[/noparse]0]~ if ina[noparse][[/noparse]8] == 1 pulsetime1 += (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(0) 'ypos TV.str(string("Pulsetime1:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(0) TV.dec(pulsetime1) TV.out(" ") TV.out($0D) if ina[noparse][[/noparse]9] == 1 pulsetime1 -= (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(0) 'ypos TV.str(string("Pulsetime1:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(0) TV.dec(pulsetime1) TV.out(" ") TV.out($0D) new_periode1 := periode1 - pulsetime1 'periodendauer - pulsdauer waitcnt (timebase += new_periode1) 'wait for periode end PUB ShoulderServo2 ' generate servopulse Servo2 outa~~ waitcnt (timebase += pulsetime2) outa~ if ina[noparse][[/noparse]10] == 1 pulsetime2 -= (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(1) 'ypos TV.str(string("Pulsetime2:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(1) TV.dec(pulsetime2) TV.out(" ") TV.out($0D) ' $0D = return if ina[noparse][[/noparse]11] == 1 pulsetime2 += (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(1) 'ypos TV.str(string("Pulsetime2:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(1) TV.dec(pulsetime2) TV.out(" ") TV.out($0D) new_periode2 := periode2 - pulsetime2 waitcnt (timebase += new_periode2) PUB KneeServo3 ' generate servopulse Servo3 outa~~ waitcnt (timebase += pulsetime3) outa~ if ina[noparse][[/noparse]12] == 1 pulsetime3 -= (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(2) 'ypos TV.str(string("Pulsetime3:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(2) TV.dec(pulsetime3) TV.out(" ") TV.out($0D) if ina[noparse][[/noparse]13] == 1 pulsetime3 += (clkfreq / 100_000) TV.out($0A) '$0A = set X position (X follows) TV.out(0) ' xpos TV.out($0B) '$0B = set Y position (Y follows) TV.out(2) 'ypos TV.str(string("Pulsetime3:")) TV.out(" ") TV.out($0A) TV.out(16) TV.out($0B) TV.out(2) TV.dec(pulsetime3) TV.out(" ") TV.out($0D) new_periode3 := periode3 - pulsetime3 ' periodendauer - pulsdauer waitcnt (timebase += new_periode3) ' wait for periode end {--------------------------------------------------------------------------------------}
Comments
You could always use another cog to manage your servos, but if you want to keep·the servos, and sensors under the same "roof", then what you might consider is combining all of your servo functions, so that they all send a·pulse at the same time, then as there value dictates, each one would drop off in turn.· (A maximum of 2ms) ... Then, go ahead and pre-calculate the next period 50ms away, but don't wait for it at the end of the servo routine.· Instead use that time to read your sensors,·etc.· .... At the 'beginning' of your servo routine is then where you should wait for the next servo interval.· The initial loop through the routine·should be padded with some arbitrary number ahead of the clock counter that would equate·to something close to 50ms.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
thanks for your answers.
today i make some experiments with your ideas.
excuse my bad english
thanks
regards
nomad
Duplicate threads were removed (you had three). Please post follow ups in the same thread. It detracts from the flow of the thread if you keep starting over and it is against our forum guidelines.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
excuse my fault
regards
nomad