How does one stop a cog in Tachyon NEON 5r6?
Steve_Hatch
Posts: 19
in Propeller 1
I am just starting to experiment with Tachyon Forth NEON 5r6. In the glossary it says there is a word STOP ( cog ---) that is supposed to stop a cog once it is running a word. When I try to use stop I get an error:
STOP ??? like it isn't in the dictionary. I wanted to know how to stop a cog once it is executing a word and return it to the task list so it can be restarted again. Can anyone help me with that? Also, is there a word like .S to show the stack? Where can I find an accurate glossary, or other documentation?
Steve
STOP ??? like it isn't in the dictionary. I wanted to know how to stop a cog once it is executing a word and return it to the task list so it can be restarted again. Can anyone help me with that? Also, is there a word like .S to show the stack? Where can I find an accurate glossary, or other documentation?
Steve
Comments
And you do not have to stop a Tachyon cog at all. Just give it another task to do.
A bit late here to elaborate now.
.S should be there to show the stack
There are other words such as LOADCOG etc that can load a cog from named binaries in upper EEPROM, treating these as if they were ROMs.
Here is a section of code from EXTEND that allows "TASKS" to be run in cogs which have been preloaded with the Tachyon kernel and sitting in an idle loop, waiting for a job. If your job or task exits then it will simply return to the idle loop.
However if you are simply testing bits of code you are better off just running that in the main Tachyon console. If your code locks up in an endless loop you can also send a terminal break which is recognized by the serial receive cog and reboots Tachyon.
I'm evaluating whether I can use Tachyon for other projects/ I am used to using polyFORTH, from FORTH, Inc. and Tachyon is sufficiently different due to the architecture of the Propeller for one thing. Also, Peter does things differently than I am used to. Just trying to get up to speed with his way of doing things. Yes, I found your comment about .S was there. I was trying to do it in lower case. I am used to not being case sensitive.
I want to know how to start and stop cogs in order to change the tasks they do. I opened the glossary and couldn't find the answers to the question, since many of the commands listed didn't work as advertised. STOP ( cog --- ) being one of them. I could kill the routine with COGSTOP, but then it wouldn't start up again with a RUN command.
As explained previously there are Tachyon cogs sitting idle ready to receive a task. This is not the same as coginit since the cogs have already been preloaded with an instance of Tachyon.
The idle loop as shown below is very simple and calls the user code. It is up to the user code to return control back to the idle loop. The only way to otherwise override a non-compliant task is to reload that cog with an instance of Tachyon.
As for many other Forths, I find that they are PC-centric, especially if they adhere to the "standards", since the standards themselves are PC-centric. Forth's greatest strength lies in providing a high-level interactive development environment on embedded micros, not in optimizing target compilation from a PC. Anyone working with the Propeller is already aware that they are not in Kansas anymore, and Tachyon does things not only the Propeller way, but also geared for real commercial turnkey products since that is what I developed it for.
The other way to drive an analog meter is to simply use a hardware counter duty mode (not PWM) and an RC filter via the DAC word.
TASK IDLE
Here is the demo code for the 32 channel PWM from the EXTEND source which sets up P0..P15 up as pwm outputs at 7600Hz.
In my current work I really would like to use Tachyon, but if you have a multi process application, you can not just switch this to Tachyon, being a novice. There is this damned learning curve.
But with the event of P2 things will change, as Tachyon can be used to explore the P2 and many people will become acqainted.
Whenever I have the P2D2 on my table, this journey for me will start. But I see the need to have a common mechanism to connect different processes transparently, may they be coded in any language. I will start over to show, how I do this in SPIN and ASM and how to improve my solution to make a common interface.
The VOLTS word will use the currently selected counter which defaults to A but you can change that by using "B" somewhere before the VOLTS word. If 5 and 6 were RC outputs I could output 1V and 2.5V like this:
One cog is setup as a background timer that every millisecond maintains the runtime counter, the time of day (which is loaded from a real RTC at reset), and user counters. These user counters normally countdown and optionally execute a user vector. If every 100ms you wanted to check a switch and perform some action, then this is how you could do it:
When mytimer is first invoked through a TIMEOUT operation (automatically set with ALARM:) then it is linked into a list of background timers that are maintained every millisecond. The timer cog then scans this list and looks up the timer, and if it is non-zero, it will decrement it, and if it becomes zero it will check for and execute an alarm vector. The timers can be passive countdown or countup. Browse the EXTEND source for more information.
BTW - The decimal point embedded in a number is simply for aesthetics although the position of the dp is available. A dp at the end of a number signifies that it is a double long or 64-bits.
To improve readability I prefer to use lower case for variables and passives and uppercase for active words that do something other than push a value.