Hello Guest it is April 25, 2024, 10:58:37 AM

Author Topic: How to do a Counter in Brains.............  (Read 11409 times)

0 Members and 1 Guest are viewing this topic.

Re: How to do a Counter in Brains.............
« Reply #10 on: February 07, 2008, 05:59:21 AM »
Thanks both.

So the Brain (at least as far as inputs are concerned) is not only polling every 100 milliseconds but is acting as a positive going edge triggered interrupt. Sort of:-) That would certainly explain the action of input#2 resetting the dro.
As I see it now, the moment input#1 is pressed, a flag is set in Mach. Within the next 100 ms the Brain is started, which, seeing the flag, carries out the logic of incrementing the DRO. The timer part is acting outside of the Brain, holding the input high for another 100 ms. The Brain, of course, clears the flag. On the next running of the Brain, although the input#1 is still high (held by the timer), it is ignored because the flag is still clear. When the timer times out input#1 is forced low, and if the finger is still on the button the flag will be set again, leading to another increment on the next running of the Brain.

Or, instead of using a flag, the positive action on the input switch could start the Brain immediately.

Am I getting closer?

Regards

Dave Hookings



Re: How to do a Counter in Brains.............
« Reply #11 on: February 07, 2008, 06:16:30 AM »
Oh dear!

On re-reading Brett's posting I'm back in the dark.

The bit about the brain missing a quick press without the timer does not equate with an edge triggered interupt.
But then, that means that the timer must be operating outside of the Brain and reintroduces my problem with input#2.

Dave

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How to do a Counter in Brains.............
« Reply #12 on: February 07, 2008, 08:58:48 AM »
Dave,

   The action is in the timer, it is acting as a "One Shot", it will ONLY pulse ONCE for only the pulse duration as long as the input is held down, it will NOT pulse again even if held down all day. BUT, once you release the input (finger OFF the button), and then you repress it, it triggers a ONE SHOT 100ms pulse. 

From my perspective, I know longer know what to tell you, someone else will have to step in here, Perhaps Brain or Art who knows the inner workings of Mach. I don't know the inner workings, I just know what works with Brains to do what I want it to do.

Scott
fun times