GPIO readAnalogInput

<strong>Hi,<br><br>I am writing an android app that would basically read the signal from a GPIO pin and plot it on a graph.<br><br>The issue i am having is that i can't get enough data samples for a clean plot of my input signal.<br><br>When my input signal is a sine wave of 1Hz, i get a clear graph of it, But when i increase the frequency of my input signal to 10Hz, the plot is distorted. <br><br>How often can i call the readAnalogInput function?<br>What do i need to configure to be able get enough data?<br><br>Thanks,<br>Abbas<br><a href="https://www.mbientlab.com/docs/metawear/android/1.3.3/com/mbientlab/metawear/api/controller/GPIO.html#readAnalogInput%28byte,%20com.mbientlab.metawear.api.controller.GPIO.AnalogMode%29"></a></strong>

Comments

  • Hi,<br><br>I am writing an android app that would basically read the signal from a GPIO pin and plot it on a graph. The issue i am having is that i can't get enough data samples for a clean plot of my input signal. When my input signal is a sine wave of 1Hz, i get a clear graph of it, But when i increase the frequency of my input signal to 10Hz, the plot is distorted. How often can i call the readAnalogInput function? What do i need to configure to be able get enough data? <br><br>Thanks,<br>Abbas<br>
  • Hi laura,

    Thanks for the reply. i am doing something along those lines. i have a function that i ran periodically, every millisecond, to get the data by calling GPIO readAnalogInput. However, what i found is that Metawear doesn't respond to each of my request to read the GPIO readAnalogInput. About every 100ms metawear responds with the values of the gpio pin. 

    How can i get more data points?
    how often can i call readAnalogInput?
    is there a way to configure the ADC?

    below is a sample data from my session.

    Thanks,
    Abbas


  • //function call every milisecond

    1422320712043        601  // voltage returned by metawear
    1422320712044   //no value returned.
    1422320712045
    1422320712046
    1422320712047
    1422320712049
    1422320712050
    1422320712051
    1422320712052
    1422320712053
    .//function call continues
    .
    .
    1422320712132
    1422320712133
    1422320712134
    1422320712136
    1422320712137
    1422320712138
    1422320712139
    1422320712140
    1422320712141        601   // after about 100ms, Metawear responds with another data point.

  • abbas8000,

    You should instead use the event module and set up the GPIO pin as a notification (callback)

    Polling the GPIO pin on a timer is not the best way to do this.
  • @Laura proper sample would be useful. Is there one? I had a thread started here about polling data, but with no luck. 
  • Igor,
    We are working on it. We were waiting for a nice 1.0 firmware release to put out examples (and it just came out!).
This discussion has been closed.