Looking for an example of lock useage
Hi guys.
I have a RPM gage that I am trying to build.
I got it all working, but I get some crazy number inttermittly. I did some looking around and I now figure that it is because I am trying to read a varuble with my display cog that is in the mist of being written by my monitoring cog.
Just trying to learn to use two cogs, These locks seem like they will be handy.
If someone can point me to some good examples and or explanations I would appreceate it.
Thanks from a amature
I have a RPM gage that I am trying to build.
I got it all working, but I get some crazy number inttermittly. I did some looking around and I now figure that it is because I am trying to read a varuble with my display cog that is in the mist of being written by my monitoring cog.
Just trying to learn to use two cogs, These locks seem like they will be handy.
If someone can point me to some good examples and or explanations I would appreceate it.
Thanks from a amature
Comments
I should have time to return to this next week. If you haven't worked this out by then, maybe I can help more.
Your symptoms should like a good candidate for this.
Good luck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
propmod_us and propmod_1x1 are in stock. Only $30. PCB available for $5
Want to make projects and have Gadget Gangster sell them for you? propmod-us_ps_sd and propmod-1x1 are now available for use in your Gadget Gangster Projects.
Need to upload large images or movies for use in the forum. you can do so at uploader.propmodule.com for free.
For example, if there is only one COG writing a string or complicated data structure and only one COG reading said data then a simple flag in HUB will do.
Basically the writer waits in a loop looking for the flag to be 0 whenever he wants to write data.
When he sees the zero he can write the data and set the flag to 1.
The reader COG waits in a loop for the flag to become 1 whenever he wants to read the data.
When he sees the 1 he reads the data and set the flag back to 0.
This can be extended to one writer and many readers with a flag for each reader but at this point locks may be more convenient.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.