Cog Objects
EdKirk
Posts: 27
Guys,
I have met with some success in programming my robot with spin code.
I am now ready to start another cog, so that I can read commands from the radio receiver and overlap output to the robot motors at the same time.··After many trials I am asking for help.
I would slightly prfer to use CogInit rather than CogNew so that I will feel that I know what is happening.· Perhaps I need to review object programming.
But how do I know which objects are actually loaded into a given Cog?·
Will the code need to be in a different place?·
In which object should the ConInit command be placed?
Where do I specify local ram?· Global ram?
Ed
·
I have met with some success in programming my robot with spin code.
I am now ready to start another cog, so that I can read commands from the radio receiver and overlap output to the robot motors at the same time.··After many trials I am asking for help.
I would slightly prfer to use CogInit rather than CogNew so that I will feel that I know what is happening.· Perhaps I need to review object programming.
But how do I know which objects are actually loaded into a given Cog?·
Will the code need to be in a different place?·
In which object should the ConInit command be placed?
Where do I specify local ram?· Global ram?
Ed
·
Comments
The COGINIT should be placed in the object containing the initial method to be called. COGINIT in SPIN requires you to know what cog you want to use. Since they're all identical, many existing objects use COGNEW. You'd have to keep track of what cogs are available if you're using any library routines that start up a cog. Better to let the hardware do it and use COGNEW.
A wise man once wrote, "I apologize for making this letter so long.· I did not have time to write a short one."
So I am forced to document my planned use of my PropStick using several cogs; I really needed to do that anyway instead of working from my head with its many faults.
It will take a few days to do so.· I plan to then submit my cog questions in a broader context.
OK?· No reply needed now.
EdKirk
The attached drawing shows what I am planning to get· more complete control of my VEX robot.· The short low levels shown cause the motor to reverse; long ones cause motor to spin forward.· I need to control how the joy stick inputs are shared and mixed·to control how the three wheeled robot can move forward and back, left and right, rotate cw or ccw, or travel in a curve.· That mixing may require some approximate trig functions.
If the operator watches the robot he gets all mixed up since his left and right keep rotating relative to those of the·robot.· The onboard camera is independent of the controller and sends a forward looking picture to a monitor so that the operator can see what the robot "sees" thus keeping his left and right coordinated with those of the robot.
Now for my cog question.·
I am using Martin's BS2 to observe the time of the low level pulses·received and sent by the Prop Stick.· That uses·some additional Cogs.
I plan to used 1 Cog to continuously monitor the incoming·pulse widths·from the radio receiver and another to issue a continuous stream of output pulses to the VEX controller which contains the power amplifiers for the PWM control of each motor.· I guess I can have about a 50% overlap in the received and sent streams which will cause a delay of about 10 msec for the Prop Stick to add its brains to the control.
Although I thought I had studied the spin chapters of the·very fine Prop manual·thoroughly, I still have questions:
The VAR object given in the examples never have a name attached.· Does that mean that there can be only one such object which defines the·names of global varialbles?· Or can VAR be repeated·with in·each Cog for local variables?
ln the examples the local variables dedicated to a given Cog are in an array.· Does that mean that·local variables·can only be given subscript numbers and not· meaningful names?
In Pascal 7.0 with which I am quite familiar variables can have several subscripts so that two, three,·and·even four dimensional arrays can be used.· Is that possible in SPIN?· That would be convenient here since the global variables will·contain the·modified pulse widths for each motor but the use of those widths be each motor are identical.
Would it be better to use a sepearate Cog for each motor?
I still cannot discern whether the COGNEW or COGINIT commands should be contained within the Cog object or· must·they be specied·earlier?
I am certain my questions are of the kindergarten variety·but I would·like some hints.
Thanks,
EdKirk
edk@wi.rr.com
And now you know!
marty
Thanks for the more complete report on RC's in general.
EdKirk
I apparently terminated this thread Unintentionally.
I thanked Marty for enlarging my knowledge, but I did not intend for the long list of questions contained in my request of 11/18 to be forgotten.
Here they are again.
Although I thought I had studied the spin chapters of the very fine Prop manual thoroughly, I still have questions:
The VAR object given in the examples never have a name attached. Does that mean that there can be only one such object which defines the names of global varialbles? Or can VAR be repeated with in each Cog for local variables?
ln the examples the local variables dedicated to a given Cog are in an array. Does that mean that local variables can only be given subscript numbers and not meaningful names?
In Pascal 7.0 with which I am quite familiar variables can have several subscripts so that two, three, and even four dimensional arrays can be used. Is that possible in SPIN? That would be convenient here since the global variables will contain the modified pulse widths for each motor but the use of those widths be each motor are identical.
Would it be better to use a sepearate Cog for each motor?
I still cannot discern whether the COGNEW or COGINIT commands should be contained within the Cog object or must they be specied earlier?
I am certain my questions are of the kindergarten variety but I would like some hints.
Thanks,
EdKirk
edk@wi.rr.com
Although I thought I had studied the spin chapters of the·very fine Prop manual·thoroughly, I still have questions:
The VAR object given in the examples never have a name attached.· Does that mean that there can be only one such object which defines the·names of global varialbles?· Or can VAR be repeated·with in·each Cog for local variables?
ln the examples the local variables dedicated to a given Cog are in an array.· Does that mean that·local variables·can only be given subscript numbers and not· meaningful names?
In Pascal 7.0 with which I am quite familiar variables can have several subscripts so that two, three,·and·even four dimensional arrays can be used.· Is that possible in SPIN?· That would be convenient here since the global variables will·contain the·modified pulse widths for each motor but the use of those widths be each motor are identical.
Would it be better to use a sepearate Cog for each motor?
I still cannot discern whether the COGNEW or COGINIT commands should be contained within the Cog object or· must·they be specied·earlier?
I am certain my questions are of the kindergarten variety·but I would·like some hints.
Thanks,
EdKirk
edk@wi.rr.com