Cog question
DiverBob
Posts: 1,116
I've been puzzling over this problem for a bit, came to the forum and didn't see anything under the search that told me anything I haven't done/tried so I'll throw the question out to the experts!
I've attached a portion of code used for displaying a series of count up and count down timers on the uOLED-96. There are 3 buttons attached to the uOLED on 18, 19 and 20. When I was checking for a pin to go hi (if dira[noparse][[/noparse]18] == 1) and had this in the main loop it worked. In order to improve the response of the main loop I removed the button check and added a flag instead. The idea is to use a seperate cog to just monitor the button states and set the appropriate flag. The flag is then checked in the main loop and acted upon with the flag being reset at the end of the process.
Now that I started a new cog (I have checked the success flag and it shows cog 2 running) but the SetTimerFlags does not appear to run.
Maybe someone else sees what I am missing.
Thanks for your help in advance!
Bob
I've attached a portion of code used for displaying a series of count up and count down timers on the uOLED-96. There are 3 buttons attached to the uOLED on 18, 19 and 20. When I was checking for a pin to go hi (if dira[noparse][[/noparse]18] == 1) and had this in the main loop it worked. In order to improve the response of the main loop I removed the button check and added a flag instead. The idea is to use a seperate cog to just monitor the button states and set the appropriate flag. The flag is then checked in the main loop and acted upon with the flag being reset at the end of the process.
Now that I started a new cog (I have checked the success flag and it shows cog 2 running) but the SetTimerFlags does not appear to run.
Maybe someone else sees what I am missing.
Thanks for your help in advance!
Bob
Comments
This should be simple, I'm missing something basic here. I can get the examples in the manual to run but this has been a pain
Bob
·
I downloaded your code from above to try it out and to see if I could help you. When I first went to compile your code and load it on my uOLED I had to find the other objects. I recommend using the file | archive feature when posting code so that all objects are included. Once I got the objects straight when I compiled the program I got several errors for variables that were undefined. Is this a code snippet because I do not see where it writes to the uOLED display?
This doesn't help your core problem, but I see one efficiency. I see you have a waitcnt being used to pause program execution. You have already defined the "clock" object. You could use DELAY.PauseSec(1) to pause execution. This would take advantage of the object you are using and it makes the pause not processor speed dependent.
There may be a problem with the way the buttons/flags are working between the cogs. What I have done in the past is used a COG to read button input. In that same cog the buttons are debounce and both the raw and debounce data is written to "registers" in the HUB RAM. Another COG that handles the program flow checks those registers when it is appropriate. On a second look, maybe that is what you are doing.
What I would do next is go back to one COG. Have the uOLED screen display the actual I/O. Use INA to read your three pins into a byte and draw that byte on the screen. Press the buttons and see the byte change. Then jump back to two cogs and get the same behaviour to work.· From there implement the flags.· Becareful doing the "print statement" across cogs because you need to make sure everything is defined correctly, the objects may not be talking·to·one another as thought.
Oh - I would also see if increasing the stack helps. I was going to try this with the downloaded code, but it doesn't compile properly.
Good luck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
www.brilldea.com·- check out the uOLED-IOC, an I/O expansion for the uOLED-96-PROP
www.tdswieter.com
One little spark of imagination is all it takes for an idea to explode
Post Edited (Timothy D. Swieter) : 4/8/2008 12:58:56 AM GMT
Tim - I will try the pausesec(1) out but I was going to get rid of the Clock object and just use the internal clock. It seems fairly accurate over the type of time spans I need (up to 3-4 hours) so why use up any more memory than I have to? You are right, I am using the cog just to trigger flags that the main program resets when it gets around to them. I didn't post all the code but cut out the various parts that weren't applicable to the problem, I guess I wasn't expecting anyone to actually try to compile it! The timer will consist of 3 timers, the top one just counts up. The middle one will be user programable to count down up to 10 sequential events with the user able to either have each time period to be consecutive or manual start. The bottom timer is a on-the-fly countdown timer where the user can enter up to 999 minutes and count it down from there. Each counter has a start/stop, reset function and the last button is used to select the timer that the buttons will work on.
Once the code is completed I will post it if anyone else is interested.
Bob
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
www.brilldea.com·- check out the uOLED-IOC, an I/O expansion for the uOLED-96-PROP
www.tdswieter.com
One little spark of imagination is all it takes for an idea to explode