Maximum sample rate on digital input

470 views
Skip to first unread message

JP

unread,
Dec 17, 2011, 3:39:26 AM12/17/11
to ioio-...@googlegroups.com
Hi!

I'm going to attach a sensor to one of the digital input ports and need to sample the input at approx. 50 Hz. Will this be possible? What is the maximum sample rate possible to obtain?

Best regards,
JP

Ytai Ben-Tsvi

unread,
Dec 18, 2011, 2:14:48 AM12/18/11
to ioio-...@googlegroups.com
50 Hz is a very low frequency. However, the digital inputs work based on change and not periodically sampled. If you need measurements at precise intervals of 20ms, the current firmware won't let you do it.
Can you give more details on what you need exactly? Perhaps there's something else you can use that will give you what you need.


JP

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/V3Qlhdgf4WwJ.
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.

JP

unread,
Dec 18, 2011, 10:07:53 AM12/18/11
to ioio-...@googlegroups.com
Hi!

I want to build a GSM/GPRS-based anemometer using an Android mobile phone and an IOIO board to interface the anemometer hardware which uses a three-cup rotor with magnetic reed switches. When the rotor turns, pulses are created and I need to count the number of pulses during a specific period of time (say 2 seconds).

Any suggestions are most welcome!

Best regards,
JP



JP

unread,
Dec 18, 2011, 10:24:34 AM12/18/11
to ioio-...@googlegroups.com
I just ordered my IOIO board and have not begun to study the documentation yet (I been working on setting up the Eclipse and Android development first). I just realized that there is a Pulse Input functionality which I think is a possible solution!? :)

Best regards,
JP

Ytai Ben-Tsvi

unread,
Dec 20, 2011, 12:46:24 AM12/20/11
to ioio-...@googlegroups.com
PulseInput will not count the pulses, but rather time the pulses, which is not quite the same.
For counting without ever missing a pulse, I think the best way to go would be implementing this functionality in firmware (i.e. counting and reporting counts periodically). If your pulse rate is very low I think you can get away with modifying the DigitalInput.setValue method to count the pulses. If they are very fast, this method will saturate your connection probably.



Best regards,
JP

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/GjWAEXppyqEJ.

JP

unread,
Dec 20, 2011, 3:10:36 PM12/20/11
to ioio-...@googlegroups.com
Hi!

I want to log the instantaneous wind speed at on regular basis, say every 5th second or something like that. I will use the information to plot the wind speed, calculate mean wind speed over a longer period of time (perhaps 10 min) and also calculate the trend using least square polynomial fitting.

It does not matter if I miss some pulses. If I understand the documentation correct, it should be possible to use pulse.getDuration() to measuring the duration between two pulses (e.g. the time between two consecutive positive flanks). Correct?

Best regards,
JP



Ytai Ben-Tsvi

unread,
Dec 22, 2011, 1:42:44 PM12/22/11
to ioio-...@googlegroups.com
PulseInput is definitely what you want for this application. Make sure you read this:
For getting speed, you probably want to use getFrequency() and you may want to apply scaling to average out noise.
Let me know if you have further questions.



Best regards,
JP



--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/pI-TZJc43PQJ.

JP

unread,
Dec 26, 2011, 10:02:00 AM12/26/11
to ioio-...@googlegroups.com
Hi Ytai!

In the wiki documentation it is stated that durations shorter than 20 us (50 kHz) should be avoided. In the next section, it is stated that the capture rate is limited to 200 Hz which seems contradictory. I think I misunderstand something here so could you please explain where these limitations come from and how they work together?

I want to be able to measure wind speeds between 0-90 mph (0-40 m/s). According to the anemometer's specification this corresponds to 0-72 pulses/s. What configuration (precision, clock rate and scaling) would you recommend?

One problem seems to be when it's completely calm weather and the anemometer shaft is not turning. In this case the pulse width timer will eventually roll over and create erroneous values. Is it possible to detect time roll over in order to discard this value?

Best regards,
JP

Ytai Ben-Tsvi

unread,
Dec 26, 2011, 2:42:55 PM12/26/11
to ioio-...@googlegroups.com

There's no contradiction: you can measure period as short as 20us post scaling. You'll get updates no more than 200 times a sec. That is, not each and every pulse is reported. The idea is to measure their width and not their count.
If you use a double precision counter you don't have to worry too much. On a 2MHz clock it'll still be able to measure 2000 seconds before roll over so you can easily handle this in your app and treat it as 0 speed possibly ignoring the next pulse. If you block waiting for a pulse, you can interrupt this thread safely anytime if you need to. It will be unblocked once your app exits or the IOIO is disconnected.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/UTiMQzTb8FkJ.

siqi wang

unread,
May 27, 2014, 9:33:15 AM5/27/14
to ioio-...@googlegroups.com
Hello everyone,

Now I am working on measuring the speed of a robot car which is connected with Android through IOIO. As i have 2 speed sensors on the car wheels, the pulses will be sent from the sensors when the wheel roll. The question is that if I use the PulseInput functions, will all pulses from the sensor pass to the Android device? As IOIO is connected with Android by USB/OTG cable, I am scared of the damages on the cable caused by high frequency pulses. If the pulses pass only to the IOIO card and IOIO send only the datas(i.e. the average frequency of pulses) to Android, that would be fine.
Is there anyone who can tell me? Thank you very much!

SIqi

Ytai Ben-Tsvi

unread,
May 28, 2014, 11:58:20 AM5/28/14
to ioio-...@googlegroups.com
PulseInput is what you want to use. This module limiting the bandwidth to up to 200 messages per second from the IOIO to the Android regardless of how fast the pulses are.
The Pulse Input page on the Wiki and the Javadocs should have detailed explanations.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.

To post to this group, send email to ioio-...@googlegroups.com.

siqi wang

unread,
Jun 2, 2014, 9:16:59 AM6/2/14
to ioio-...@googlegroups.com
Thank you very much ytai!

siqi wang

unread,
Jun 3, 2014, 6:06:31 AM6/3/14
to ioio-...@googlegroups.com
I'd like to produce a PWM pulse at pin 5 and receive the pulses at pin 11 in the same time. But after using "float freqHz = pulse.getFrequency()", there is no pulse produced at pin5. The PulseInput mode is set as FREQ. What's the problem of it?

siqi wang

unread,
Jun 3, 2014, 8:37:21 AM6/3/14
to ioio-...@googlegroups.com
After having tested with full patience, I find out in fact there is output pulse at pin 5 but 1 min after having run the program. Is it normal that PulseInput sentence make a long delay like this?

Siqi

Ytai Ben-Tsvi

unread,
Jun 3, 2014, 6:57:33 PM6/3/14
to ioio-...@googlegroups.com

Can you share the code? Please strip it down to the bare minimum to make reading it easier.

On Jun 3, 2014 5:37 AM, "siqi wang" <wangsi...@gmail.com> wrote:
After having tested with full patience, I find out in fact there is output pulse at pin 5 but 1 min after having run the program. Is it normal that PulseInput sentence make a long delay like this?

Siqi

--

siqi wang

unread,
Jun 4, 2014, 9:29:27 AM6/4/14
to ioio-...@googlegroups.com
I solved the problem by adding a thread. Thank you for response!

Ytai Ben-Tsvi

unread,
Jun 4, 2014, 11:05:27 AM6/4/14
to ioio-...@googlegroups.com

You shouldn't have to in the general case.

On Jun 4, 2014 6:29 AM, "siqi wang" <wangsi...@gmail.com> wrote:
I solved the problem by adding a thread. Thank you for response!

--

v...@wintrisstech.org

unread,
Jun 19, 2014, 9:11:14 PM6/19/14
to ioio-...@googlegroups.com
Do you have an example of how to use pulseInput with the input pulled down.  Will this work:

frontInput = ioio.openPulseInput(new DigitalInput.Spec(35, DigitalInput.Spec.Mode.PULL_UP),PulseInput.ClockRate.RATE_2MHz,PulseInput.PulseMode.POSITIVEfalse);

Ytai Ben-Tsvi

unread,
Jun 22, 2014, 8:44:00 PM6/22/14
to ioio-...@googlegroups.com
This would work. Not sure if it does what you want. What it does do is open pin 35 for pulse input using the internal pull-up and counts width of positive pulses on that line, i.e. how long it has been between when whatever is connected to the pin pulled it low (as opposed to for how long it was pulled low).

Vic Wintriss

unread,
Jun 22, 2014, 9:12:01 PM6/22/14
to ioio-...@googlegroups.com
I understand what the PulseInput does, I just wanted to be sure that I can also specify either pull-up or pull-down as an input spec.  Also, what does the false mean at the end?

You received this message because you are subscribed to a topic in the Google Groups "ioio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ioio-users/QfQJBmPPF_s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ioio-users+...@googlegroups.com.

Ytai Ben-Tsvi

unread,
Jun 22, 2014, 9:23:38 PM6/22/14
to ioio-...@googlegroups.com
The last argument stands for whether to use a double precision (32-bit) module.
Not that I mind doing it for you, but just in case you haven't noticed, the API is pretty well documented (at least up to my standards) in the Javadoc format. You can read it from the code or from the generated HTML that is included in the software bundle under /IOIOLib/doc/

Vic Wintriss

unread,
Jun 22, 2014, 10:04:37 PM6/22/14
to ioio-...@googlegroups.com
Got it…won’t be so lazy next tine.

New subject…I would like to read some audio files into the ioio and feed them out to a d/a to drive an amplifier.  Anybody written that yet?

Ytai Ben-Tsvi

unread,
Jun 23, 2014, 3:44:40 AM6/23/14
to ioio-...@googlegroups.com
I don't imagine this would be possible using the existing firmware, unless you have some serious buffering on the DAC side. Should be doable with custom firmware, where the IOIO does the buffering and emits samples with precise timing.
Reply all
Reply to author
Forward
0 new messages