Is it possible
Is it possible to have the prop take input on one cog, and execute it on another. And if so where would I get guidance to get started. I have the input on one cog already, its just get the input from that cog, and having it excute on another is where I am coming up with problems. All ideas are greatly appreciated. Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Not knowing the ESC object, I simply assume it has an API which allows it to take the input value obtained by other means. So the easiest solution would be your main program reading the input value in whatever form it is delivered by the terminal and send it to the ESC object. You said that you have the input part ready. Is your current problem related to conversion (e.g. ASCII/binary) or more general? I mean once you started your objects (input, ESC) they (usually) run on their own cog anyway, so all you have to do is link them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
The main loop looks fine to me. You get a decimal value and deliver it to the ESC object.
You might want to check you repeat until condition. I assume you want to exit when throttle is 0 (throttle == 0). ATM you assign 0 (FALSE) to throttle which makes that an endless loop.
Also, in the ESC object, I assume the methods fullbrake/fullthrottle should use dira[noparse][[/noparse]pin]~~ rather than dira[noparse][[/noparse] 4 ]~~.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Instead of calling "throttle", you would use a COGNEW to call it. You would need some kind of interface routine
that would either check for an existing cog running throttle and stop it before starting a new one or you'd have to
slightly rewrite "throttle" so it gets its pulse width from a common variable and reinitializes itself if the pulse width
changes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
heres my·ESC object
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Basically, you can't do it the way you tried. The cog that you start has its own counter and I/O registers so all of the initialization and counter manipulation code has to be running in that cog.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Anyway, starting a cog for every function call is overkill (and adds unnecessary delay). You should exchange parameters through some defined hub location.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Get a Propeller controlling the rate of flashing a LED, put that in its own Cog and then control the rate of flashing from the main Cog. Upgrade that main Cog so you can change the rate of flashing via serial or whatever.
Once you've got the notion of parallel processing understood with data passed between the two working it will all become a lot easier than trying to crowbar what you have into shape.
Basically, you don't want to keep executing CogNew as has already been said. Get a second Cog running at the start of the program the hand the data it needs to it. That created cog should initialise once then run in a loop reading the data handed to it and doing whatever it needs to. Beyond that, there should be no other ongoing interaction between the two cogs.
Untested, but something like ...
Post Edited (hippy) : 6/2/2008 2:27:03 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Yes, you can run a master object that starts, modifies and send data to other objects. Take a look at my Pnav project. It is a work in progress
Maybe this will help you in the theory. I have been slow-rolling an autopilot (...for the last year...) and you are welcome to use any of my code for you project.
www.PNav.net I'll be posting a newer rev of code there on Friday ( Jury duty tomorrow!)
Please share - You seem to be coding much faster than me!
Paul
Post Edited (Paul_H) : 6/5/2008 5:23:27 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Main Object :
Sub Object :
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!