multiple instances of object in an object
HI
is there any way to use two instances of Full Duplex Serial called from seperate objects without them conflicting? I have FDS runing in my top level object to comunicate with a host pc and then in another object I want to call FDS to comunicate with a controller peripheral. This will want to use the smae variable space in both instances of FDS right? Is there anyway to us an array of FDS objects and call one of them from another object other than the top level where the array of FDS would be created? Maybe I'm missing an easy solution here.
Thanks,
Owen
is there any way to use two instances of Full Duplex Serial called from seperate objects without them conflicting? I have FDS runing in my top level object to comunicate with a host pc and then in another object I want to call FDS to comunicate with a controller peripheral. This will want to use the smae variable space in both instances of FDS right? Is there anyway to us an array of FDS objects and call one of them from another object other than the top level where the array of FDS would be created? Maybe I'm missing an easy solution here.
Thanks,
Owen
Comments
subobjects, or declare two instances (either using two declarations or an array). Either way should work.
It's difficult to declare objects at one level of the object structure and have them used at another level. If you really have to do it, there's a discussion and examples of the technique posted in this forum. It requires that the setup routine modify some of the byte codes of the compiled program.
thanks for the help
Owen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
That's correct.
In my current project - a three wheeled holonomic robot - I need to control three motors simultanously using a PID speed control algorithm.· I invision a wheel control method that constantly reads a specific memory location that contrains the desired speed and makes sure the motor stays at that speed.· I would then load three "copies" of this method into three cogs to just run all by themselves without any need for the main routine to worry about them.· The main routine just stores the desired speeds into the memory locations and the wheels magically respond.
So, can someone give me skeleton code or draw me a diagram to show the relationships between the methods so that I have one copy of the wheel control method running with three sets of variables.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
Post Edited (originator) : 3/10/2007 1:07:14 AM GMT
OBJ
mctrl[noparse][[/noparse]3] : motor_control
Then use the indice to access methods:
mctrl[noparse][[/noparse]0].start(x,y,z)
mctrl[noparse][[/noparse]1].start(a,b,c)
mctrl[noparse][[/noparse]2].start(m,n,o)
One thing to note about multiple instances, anything placed in the DAT section is common to all instances. This·can be handy if you want them to have a means of doing communication but anything that is volatile and instance specific should be placed in the VAR section.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 3/10/2007 7:58:17 AM GMT
Main Program:
Motor object:
This is a very cool discovery! Thanks Paul!
Post Edited (originator) : 3/10/2007 8:51:36 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 3/10/2007 8:10:48 AM GMT
Also you need to change the following line:
····mtr[noparse][[/noparse]3]···:··"mtrTestObjectLower"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
I notice that the above coding follows a slightly different style from that provided in the Prop manual (Chapter 3, p134-136), in which the Start routine in the Motor object would do the cognew call, using a local definition of the stack in a VAR block. This frees the main driving module from having to know too much about the innards of the cogged code, eliminates having to define separate stacks for each instance, and to my mind makes cleaner code.
Is this just a style question, or are there any practical implications, one way or the other?
Cheers!
Paul Rowntree