Problems with the usage of more cogs with coginit
nomad
Posts: 276
REF: Problems with the usage of more cogs with coginit
hi,
as attachment:
1 - leg1ServoSequencer11.spin
2 - leg1ServoSequencer110.spin
3 - leg1ServoSequencer111.spin
the 1. programm is the original-spin-program (historic-reasons)
(control of 6 servos with 6-pushButtons.)
timing: periode1 := ((clkfreq / 100_000) * 500) ' 5ms LEG 1
Running: all OK.
the 2. program: control of a Servos with methode: ShoulderServo1(3) ' pin 0 , pin 3
timing corect: 20ms = periode1 := ((clkfreq / 100_000) * 2000) ' 20ms LEG 1
Run: OK
the leg1ServoSequencer111.spin is my trial to every of the 6 servos is a cog
(cog2 to cog 7) with the help von COGINIT (as per PE-LAB -> methods & cogs)
to control the cogs (servos) i make this with the pushButtons
if ina[noparse][[/noparse]n] == 1
COGINIT(cog2_Leg1Servo1,ShoulderServo1(0), @cogstack[noparse][[/noparse]0])
the direction of the servos is controlled through pushButtons 14,15
the cog 0 should be the master cog not implemented, cog 1 is for the
communications not implemented
but now the problem:
the program don't run, nothing....
what's going wrong??
- is my usage of the cogStack correct???
- is my usage of the COGINIT correct ???
if ina[noparse][[/noparse]8] == 1
COGINIT(cog2_Leg1Servo1,ShoulderServo1(0), @cogstack[noparse][[/noparse]0]) ' pin 0
this is my first trial to usage more cogs, i dont no which mistakes i make.???
please help me (all hints and tip are helpful).
and excuse my bad english
regards
nomad
hi,
as attachment:
1 - leg1ServoSequencer11.spin
2 - leg1ServoSequencer110.spin
3 - leg1ServoSequencer111.spin
the 1. programm is the original-spin-program (historic-reasons)
(control of 6 servos with 6-pushButtons.)
timing: periode1 := ((clkfreq / 100_000) * 500) ' 5ms LEG 1
Running: all OK.
the 2. program: control of a Servos with methode: ShoulderServo1(3) ' pin 0 , pin 3
timing corect: 20ms = periode1 := ((clkfreq / 100_000) * 2000) ' 20ms LEG 1
Run: OK
the leg1ServoSequencer111.spin is my trial to every of the 6 servos is a cog
(cog2 to cog 7) with the help von COGINIT (as per PE-LAB -> methods & cogs)
to control the cogs (servos) i make this with the pushButtons
if ina[noparse][[/noparse]n] == 1
COGINIT(cog2_Leg1Servo1,ShoulderServo1(0), @cogstack[noparse][[/noparse]0])
the direction of the servos is controlled through pushButtons 14,15
the cog 0 should be the master cog not implemented, cog 1 is for the
communications not implemented
but now the problem:
the program don't run, nothing....
what's going wrong??
- is my usage of the cogStack correct???
- is my usage of the COGINIT correct ???
if ina[noparse][[/noparse]8] == 1
COGINIT(cog2_Leg1Servo1,ShoulderServo1(0), @cogstack[noparse][[/noparse]0]) ' pin 0
this is my first trial to usage more cogs, i dont no which mistakes i make.???
please help me (all hints and tip are helpful).
and excuse my bad english
regards
nomad
Comments
1) In the Init routine, you initialize the direction and output status of several I/O pins, then use these I/O pins in other cogs.
Each cog has its own OUTA and DIRA registers and they are effectively OR'd together. Your Init cog sets its own registers
for output mode, but the servo control cogs do not ... They're inputs for those cogs. You need to setup the OUTA/DIRA
registers as part of the initialization of the routines started by each COGINIT.
2) In the repeat loop in the main program ... where the COGINITs are done, you don't check to make sure that the cog is idle
before doing a COGINIT. As long as pin 8 is high, you will relaunch ShoulderServo1(0) in cog 2. That's not what I think you want.
If you're looking at a pushbutton press to start up a servo, at least look for the leading edge of the signal ... save the previous state
of the pin and look for previous state == 0 and current state == 1. That way, you will require a button release, then another press
to reinitiate the cog.
thanks for your help, today (sunday) i make trial with your stuff, and then
i make a call
regards
nomad
on the afternoon i make some tests:
the new program: leg1ServoSequencer112.spin
your no 1)
i hope i understand you right
i make the whole stuff from the init-methode into the different cogMethods
is this right direction?
must i use the boolean vars???
if i use this nothing goes.
my questions and my problems with your No. 2)
my pushButtons are microSchalter:
if press then the button is ON
else OFF (its a spike) look at spin-program version 11
in this program i can move different servos in the same time.
and then comes the problems:
i am not a electronicMan, only a softwareGuy (systemAnalytics)
i understand you not fully,
what you mean with:
<< look for the leading edge of the signal ... save the previous state
of the pin and look for previous state == 0 and current state == 1.
That way, you will require a button release, then another press
to reinitiate the cog.
>>
can i do this with boolean variables??? or what.
think on this:
i can press every buttons on the same time, and different cogs (servos) moving in
different directions...
for a future version the cogs will be controlled through variables and the
masterCog (0)
and the different cogs talks with the other cogs
it should possible that z.B.
cog2 (Servo11) swing forward and in the same time a another cog -> cog7 goes
down and cog3 goes up.
in the moment i dont use the 2erpushButton without the boolean vars
instead every servoCog
makes: repeat 10
pulsetime1 += (clkfreq / 100_000)
Result: running but not correct.
please excuse my confuse writing, but i have some problems
if i must explain complex things in english.
please help me
as attachment: leg1ServoSequencer112.spin
regards
nomad
1) There are 8 pushbuttons, divided up into a group of 6 and a group of 2
2) When you push one of the 6 pushbuttons, you select one of 6 servos to interact with. A control pulse is
sent to that servo every 20ms with a width initially of 1.5ms. Selecting a different servo stops the previous one.
3) Once one of the 6 pushbuttons has been pushed, the 2 pushbuttons either increase or decrease the width
of a pulse sent to the selected servo by 0.1ms.
I know you want to use this program as a basis for a more complex program, but I think the overall concept is faulty.
You should use the Servo32.spin object to control the servos and issue the timed pulses every 20ms. That object
runs in one cog and interacts with the rest of the program through some common Spin routines and a shared table of
pulse widths. For your current testing, you should use a single cog, particularly since you're only working with one servo
at a time.
The Attachment Manager doesn't seem to work for me (it gets an error), so here's my example:
thanks for your help...
on monday i testing your program.
look i have build bot with 4-servoLegs with 3servos in a leg.
to control the whole stuff
1- i have 3 propChips (1 is the master, 2 control leg1 + leg2, 3 control Leg3 + 4)
2- i build in software a WalkNets
(they are neuralNets which can control the gaits and the states of every leg, angles etc.).
3- on every chips are 2 walknets
(please google -> WalkNet from Prof.Dr.Cruse et al)
i think, that for this purpose i should control the servo (into a cog) in parallel and in realTime.
its possible that a servoCog (Leg1-ShoulderServo1) on Leg1 talks
with a servoCog (Leg4 - ShoulderServo1) and visiversa.
you know my problem now.
the attachted program are verry simple only to testing
the possiblity <<every servo is a cog>>
now you know my problem
if you have for this problem good ideas or tips,
i am verrry grateful.
thanks for your help
regard
nomad
Post Edited (nomad) : 7/15/2007 4:47:39 PM GMT
1) The servos require a control pulse every 20ms. You could certainly use this as the "heartbeat" or cycle time of your control loop for each servo.
The Propeller is fast enough so it can do a lot of processing in each cycle. On the other hand, this seems to be an artificial constraint of the system.
2) Do you really want to divide up the control function into individual servos? Would it be more useful to have a separate system for each leg?
thanks for the tips.
today (monday), i testing some various programs.
and call back
regards
nomad