Are there any examples of an IOIO app that waits for two digital inputs at the same time. I would like to count the pulses on two digital inputs. I’d like to use two "in.waitForValue(true/false)” method calls. Can I instantiate two “loop()” methods? Should I create a second execution thread? What happens when the IOIO disconnects/connects while I’m blocking on the second thread?
Curt
Are there any examples of an IOIO app that waits for two digital inputs at the same time. I would like to count the pulses on two digital inputs. I’d like to use two "in.waitForValue(true/false)” method calls. Can I instantiate two “loop()” methods?
Should I create a second execution thread?
What happens when the IOIO disconnects/connects while I’m blocking on the second thread?
--
Curt
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.
Excellent! Thanks for the tips. I’ll let you know how it goes.
Curt
Ytai,
That works pretty well. Modified setValue() in the library to count the number of digital input state changes. I have sensor probes wired to the front and back wheel of my car. I can count wheel movement and derive the odometer value. I did a couple of tests over the same 3 mile course. Ended up with the same odo value within about 2 meters. I tried to go at two different speeds to see if I might be missing pulses at the higher speed – it looks very good.
I also have it timing the duration between four digital input state changes (one tire revolution). I get the car speed from this. It’s a little noisy. I think this is because the SystemClock.elapsedRealtime() call that I’m using probably isn’t reporting time continuously (updating its millisecond value by something other than every millisecond).
Wondering if I could use a Digital Input and a Pulse Input at the same time on the same pin? Then I could let the IOIO firmware measure the duration between pulses (Pulse Input) and then count the Digital Input state transitions at the same time.
Thanks again.
Curt
p.s. Just got a PICkit3. Might try my hand at some IOIO firmware hacking.
--
Ideally, there would be an encoder function that can give you both.
For now, you can wire the same line to two pins and then open one for digital input and the other for pulse input.
I should have thought of that. You are the best!
Thanks,
Curt
From: ioio-...@googlegroups.com [mailto:ioio-...@googlegroups.com] On Behalf Of Ytai Ben-Tsvi
Sent: Tuesday, April 10, 2012 8:53 PM
To: ioio-...@googlegroups.com
Subject: RE: Any examples of blocking on two digital input signals?
Ideally, there would be an encoder function that can give you both.
Ytai,
I wired a DigitalInput and a PulseInput to the same wheel sensor. That works great. The car odometer and speed are very stable now.
Calls to the read functions like getFrequency() seem to block until I get the first digital signal transition. Is there something I call (poll the first time) so the code doesn’t hang there when I start up with the car stopped?
Is there any way to have the pulse input stop counting when it reaches its max count? Maybe even reporting its frequency as zero when that happens? When the counter rolls over after its max count it causes grief as I get a bogus frequency value and display a weird speed value for a few seconds.
Curt
From: ioio-...@googlegroups.com [mailto:ioio-...@googlegroups.com] On Behalf Of Curt Thompson
Sent: Tuesday, April 10, 2012 9:01 PM
To: ioio-...@googlegroups.com
Subject: RE: Any examples of blocking on two digital input signals?
I should have thought of that. You are the best!
Thanks,
Curt
From: ioio-...@googlegroups.com [mailto:ioio-...@googlegroups.com] On Behalf Of Ytai Ben-Tsvi
Sent: Tuesday, April 10, 2012 8:53 PM
To: ioio-...@googlegroups.com
Subject: RE: Any examples of blocking on two digital input signals?
Ideally, there would be an encoder function that can give you both.
For now, you can wire the same line to two pins and then open one for digital input and the other for pulse input.
--
On Apr 11, 2012 8:30 PM, "Curt Thompson" <charliev...@hotmail.com> wrote:
>
> Ytai,
>
>
>
> I wired a DigitalInput and a PulseInput to the same wheel sensor. That works great. The car odometer and speed are very stable now.
>
>
>
> Calls to the read functions like getFrequency() seem to block until I get the first digital signal transition. Is there something I call (poll the first time) so the code doesn’t hang there when I start up with the car stopped?
>
>
You could wrap getFrequency() with your owm method that sets a timer task to interrupt the calling thread after some timeout, and return 0 in this case.
>
> Is there any way to have the pulse input stop counting when it reaches its max count? Maybe even reporting its frequency as zero when that happens? When the counter rolls over after its max count it causes grief as I get a bogus frequency value and display a weird speed value for a few seconds.
>
>
Are you using double precision? If so, you can interrupt as mentioned above after a certain timeout and consider this a 0 freq. No? Only possible problem is that your next read might be off. I don't remember this code so well, but this is likely fixable.