timer task with multiple pulse input pins

88 views
Skip to first unread message

Paul Johnson

unread,
Feb 25, 2015, 2:52:51 PM2/25/15
to ioio-...@googlegroups.com
I'm using a timer task as suggested by an earlier post to set my frequency from PulseInput back to zero when the frequency is zero or a pin is disconnected. (Actually using 1/waitPulseGetDuration() to calculate the frequency. I am having two issues.

1) I have a 14 Hz signal from a 555 to test the accuracy. It works fine with the getFrequency() method and the Pulse Mode is set to freq. But when I switch to pulse mode positive and use 1/waitPulseGetDuration() it always reads 21 instead of 14. I'm not using any scaling.

2) Also as you can see in this screen cast the top line cycles really fast even though I have the timer task at 1 second. It does however go back to zero as I want when I disconnect. The next line however displays the data every second as I intended with the 1 second timer task, BUT it never goes back to zero when unplugged. 

Please see this video:

http://youtu.be/QOSpOELQgx8


Here is my code:

@Override
public void loop() throws ConnectionLostException {
          float freqHz1 =0;
        float freqHz2=0;
float freqHz3 =0 ;
float freqHz4 =0;
float freqHz5 =0;
float freqHz6=0;
 
TimerTask t = new TimerTask() {
 public void run() {
    interrupt();
 }
};
Timer timer = new Timer();
timer.schedule(t, 1000); 
try {
freqHz1 = 1.0f / pulse1.waitPulseGetDuration();
t.cancel();
} catch (InterruptedException ex) {
freqHz1 = 0;
try {
freqHz2 = 1.0f / pulse2.waitPulseGetDuration();
} catch (InterruptedException ex) {
freqHz2 = 0;
setText(freqHz1, freqHz2, freqHz3, freqHz4, freqHz5, freqHz6);
}
}


So in summary how do I make the first line only display in 1 second increments? How do I keep the second line to keep displaying in 1 second increments? And why does the second line not go to zero when interrupted? Thanks!

Paul Johnson

unread,
Feb 25, 2015, 3:22:52 PM2/25/15
to ioio-...@googlegroups.com
I should note that I am opening the Pulse Input with:

                        pulse1 = ioio_.openPulseInput(new DigitalInput.Spec(1), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);
pulse2 = ioio_.openPulseInput(new DigitalInput.Spec(2), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);

And that I have configured it to use all single precision modules.


Ytai Ben-Tsvi

unread,
Feb 25, 2015, 3:44:00 PM2/25/15
to ioio-...@googlegroups.com
1) PulseMode.POSITIVE measures the width of the positive side of your pulse (the duration between rising edge to falling edge) as opposed to the cycle duration (the duration between rising edge to the next rising edge).

2) That's because you didn't set a timer on it. One simple way to have all channels read concurrently is to create one thread per PulseInput that just loops and does what you do. Some points to pay attention to:
  • Remember to insert sleeps() between the readings, or else they'll be as fast as your pulse rate which means the load on the Android would increase linearly with the pulse rate, which is not what you want.
  • In order to close cleanly, interrupt() your threads from the disconect() call and then join() them. Have your threads exit in response to InterruptedException.
  • You can use the same Timer for all threads, creating a Timer per thread is wasteful.

--
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.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Paul Johnson

unread,
Feb 26, 2015, 10:46:21 AM2/26/15
to ioio-...@googlegroups.com


Hello,

Thank you for your response. I really appreciate the good support that this IOIO community has.

1.) So it is okay to assume if the wave is consistent that the value produced by Positive mode would be 50% more than the value of getFrequency()?

    2.) I added threads as shown below, however, when I unhook my cable from pin1 numbers continue to display on my screen well after disconnect and it eventually sets to 0. Also the numbers appear to be displaying rapidly almost like my timer task isn't working properly. I have placed a sleep at the bottom of the loop().

3.) My second pulse input doesn't seem to be doing anything as nothing is being displayed. Only the first pulse input channel seems to be working. Am I doing the threading incorrectly?

 class IOIOThread extends AbstractIOIOActivity.IOIOThread {
private PulseInput pulse1;
private PulseInput pulse2;
@Override
public void setup() throws ConnectionLostException {
try {
pulse1 = ioio_.openPulseInput(new DigitalInput.Spec(1), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);
pulse2 = ioio_.openPulseInput(new DigitalInput.Spec(2), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);
} catch (ConnectionLostException e) {
throw e;
}
}

@Override
public void loop() throws ConnectionLostException, InterruptedException {
final TimerTask t = new TimerTask() {
 public void run() {
    interrupt();
 }
};
Timer timer = new Timer();
timer.schedule(t, 1000); 


Thread thread1 = new Thread() {
    @Override
    public void run() {
        while(true) {

try {
try {
freqHz1 = 1.0f / pulse1.waitPulseGetDuration();
} catch (ConnectionLostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t.cancel();
catch (InterruptedException ex) {
freqHz1 = 0;
setText1(freqHz1);

}
    }
};

thread1.start();




Thread thread2 = new Thread() {
    @Override
    public void run() {
        while(true) {

try {
try {
freqHz2 = 1.0f / pulse2.waitPulseGetDuration();
} catch (ConnectionLostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t.cancel();
catch (InterruptedException ex) {
freqHz2 = 0;
setText1(freqHz2);

}
    }
};

thread2.start();

sleep(1000);
}
}
@Override
protected AbstractIOIOActivity.IOIOThread createIOIOThread() {
return new IOIOThread();
}

Paul Johnson

unread,
Feb 26, 2015, 12:51:22 PM2/26/15
to ioio-...@googlegroups.com


Update:

I noticed I placed both results in the same setText method. I fixed that and now both pins are displaying, however both are displaying at the frequency rate and not as timed and neither are going back to zero when unhooked.

Ytai Ben-Tsvi

unread,
Feb 26, 2015, 7:45:17 PM2/26/15
to ioio-...@googlegroups.com
Conceptually (i.e. do not expect this to actually compile), what you want is along the lines of:

class PulseInputThread : public Thread {
  private final PulseInput input_;
  private final Timer timer_;
  private float last_;

  public PulseInputThread(PulseInput input, Timer timer) {
    input_ = input;
    timer_ = timer;
  }

  public synchronized float getLastReading() {
    return last_;
  }

  private synchronized void read() throws ConnectionLostException {
    TimerTask task = new TimerTask() { ... }
    timer_.schedule(task, ...);
    try {
      last_ = input_.waitPulseGetFrequency();
      task.cancel();
    } catch (InterruptedException e) {
      last_ = 0;
    }
  }

  public void run() {
    try {
      while (true) {
        read();
        Thread.sleep(...);
      }
    } catch (ConnectionLostException) {
    }
  }
}

...

public void setup() throws ... {
  input1_ = ioio_.openPulseInput(..., PulseMode.FREQ, ...);
  input2_ = ...;

  Timer t = new Timer();
  thread1_ = new PulseInputThread(input1_, t);
  thread2_ = new PulseInputThread(input2_, t);
  thread1_.start();
  thread2_.start();
}

public void loop() throws ... {
  // ... call getLastReading() on each thread and do something with
  // the result...

}

public void disconnected() {
   try {
     thread1_.join();
     thread2_.join();
   } catch (InterruptedException e) {
   }
}

I hope this makes some sense to you.

On Thu, Feb 26, 2015 at 9:51 AM, Paul Johnson <coconu...@gmail.com> wrote:


Update:

I noticed I placed both results in the same setText method. I fixed that and now both pins are displaying, however both are displaying at the frequency rate and not as timed and neither are going back to zero when unhooked.

--

Paul Johnson

unread,
Feb 27, 2015, 11:13:29 AM2/27/15
to ioio-...@googlegroups.com

Thanks again. I've edited this in my IDE, however on the .start() and .join() it says for example "The method start() is undefined for the type SimpleDigitalInputActivity.IOIOThread.PulseInputThread"

I'm also getting a similar message for waitPulseGetFrequency(). "The method waitPulseGetFrequency() is undefined for the type PulseInput." I couldn't find it anywhere in the PulseInput.java library file.


class IOIOThread extends AbstractIOIOActivity.IOIOThread {
private PulseInput input_ =null;
 private Timer timer_ = null;
 private float last_;
 
class  PulseInputThread{
 
PulseInputThread  thread1_;
PulseInputThread  thread2_;

public PulseInputThread(PulseInput input,Timer timer) {
input_ = input;
   timer_ = timer;
}

Thread thread = new Thread() {

 private synchronized void read() throws ConnectionLostException {
   TimerTask task = new TimerTask() {public void run() {
    interrupt();
 }};
 
   timer_.schedule(task, 1000);
   try {
     last_ = input_.waitPulseGetFrequency();
     task.cancel();
   } catch (InterruptedException e) {
     last_ = 0;
   }
 }
 
 public void run() {
   try {
     while (true) {
       read();
       try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
     }
   } catch (ConnectionLostException e) {
    e.printStackTrace();
   }
 }


public void setup() throws ConnectionLostException {
PulseInput  input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input2_ = ioio_.openPulseInput(new DigitalInput.Spec(2), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);;

 Timer t = new Timer();
  thread1_ = new PulseInputThread(input1_, t);
  thread2_ = new PulseInputThread(input2_, t);
 thread1_.start();
 thread2_.start();
}

public void loop() throws ConnectionLostException, InterruptedException {
 setText1(thread1_.getLastReading());
 setText2(thread2_.getLastReading());

}

public void disconnected() {
  try {
    thread1_.join();
    thread2_.join();
  } catch (InterruptedException e) {
  }

}

Ytai Ben-Tsvi

unread,
Feb 27, 2015, 5:40:58 PM2/27/15
to ioio-...@googlegroups.com
class  PulseInputThread extends Thread {
...

This might be fairly hard, since it seems like you're missing some Java basics. I strongly recommend Oracle's online tutorials. They'll get you up to speed very fast:

On an unrelated note, I've noticed that you're using AbstractIOIOActivity / IOIOThread which has been deprecated for years. I recommend you to move to IOIOActivity / IOIOLooper. See HelloIOIO as an example.

--

Paul Johnson

unread,
Feb 27, 2015, 6:39:49 PM2/27/15
to ioio-...@googlegroups.com
Thanks!
Message has been deleted
Message has been deleted

Paul Johnson

unread,
Feb 27, 2015, 8:58:45 PM2/27/15
to ioio-...@googlegroups.com
One more question. When I connect to the IOIO board with this code both lines of text show the same numbers and do not return to 0 when the wire is unhooked from the pin. Also numbers continue to display for probably 10 times the amount of time the pin was connected. 

Please see the video. The pin was just plugged in for a second. (only one pin). Anyone see what I am missing?


Thanks for the help with the code. I think its starting to come together.

class  PulseInputThread extends Thread {
 private final PulseInput input_;
  private final Timer timer_;
  
public PulseInputThread(PulseInput input,Timer timer) {
 input_ = input;
    timer_ = timer;
}

 
 private synchronized void read() throws ConnectionLostException {
    TimerTask task = new TimerTask() {public void run() {
     interrupt();
  }};
  
    timer_.schedule(task, 1000);
    try {
      last_ = 1/input_.waitPulseGetDuration();
      task.cancel();
    } catch (InterruptedException e) {
      last_ = 0;
    }
  }
 
  public void run() {
    try {
      while (true) {
        read();
      
        try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
      }
    } catch (ConnectionLostException e) {
     e.printStackTrace();
    }
  }

public synchronized float getLastReading() {
    return last_;
  }
}
class Looper extends BaseIOIOLooper {
PulseInputThread thread1_;
PulseInputThread thread2_;
@Override
protected void setup() throws ConnectionLostException {
PulseInput   input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);
PulseInput  input2_ = ioio_.openPulseInput(new DigitalInput.Spec(3), ClockRate.RATE_62KHz,  PulseMode.POSITIVE, false);

 Timer t = new Timer();
   thread1_ = new PulseInputThread(input1_, t);
   thread2_ = new PulseInputThread(input2_, t);
  thread1_.start();
  thread2_.start();
}

@Override
public void loop() throws ConnectionLostException {
 setText1(thread1_.getLastReading());
  setText2(thread2_.getLastReading());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
public void disconnected() {
   try {
 
     thread1_.join();
     thread2_.join();
   } catch (InterruptedException e) {
   }
}
}



@Override
protected IOIOLooper createIOIOLooper() {
return new Looper();
}

private void setText1(final float freqHZ1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
row1.setText("Seeds per second: " + freqHZ1);
}
});
}
private void setText2( final float freqHZ2) {
runOnUiThread(new Runnable() {
@Override
public void run() {
row2.setText("Seeds per second: " + freqHZ2);
}
});
}

Ytai Ben-Tsvi

unread,
Feb 27, 2015, 10:17:46 PM2/27/15
to ioio-...@googlegroups.com
  1. You've missed my comment about using FREQ mode instead of POSITIVE.
  2. You cannot assume anything about a pin's state when it is disconnected, unless you're pulling it. You can open the PulseInput with PULL_DOWN or PULL_UP instead of using the default pin spec (which doesn't pull either way). What you're seeing might simply be cross-talk resulting of leaving the pins floating.

--

Paul Johnson

unread,
Feb 27, 2015, 10:40:42 PM2/27/15
to ioio-...@googlegroups.com
Thanks again.

I didn't use FREQ because I couldn't find the method waitPulseGetFrequency(). I searched for it and found this post from 2013:

"
Looking at the code again, I see that I haven't added support for blocking in frequency mode. I don't remember what was the reasoning behind this"

I'm assuming I must be using an out of date IOIO library.

Ytai Ben-Tsvi

unread,
Feb 27, 2015, 10:46:19 PM2/27/15
to ioio-...@googlegroups.com

This is unrelated. You still want to open PulseInput in frequency mode in order to count the time between consecutive riding edges as opposed to width of the pulse.
Did enabling pull solve the bogus number issue?

Paul Johnson

unread,
Feb 28, 2015, 12:23:31 AM2/28/15
to ioio-...@googlegroups.com

Ok, the frequency is displaying accurately.

I used :
 
                         PulseInput  input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input2_ = ioio_.openPulseInput( new DigitalInput.Spec(3,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);

I tried it in PULL_UP and PULL_DOWN and the numbers no longer run on. That's good. Final question though, the value of the frequency stays on the screen after unhooking my wire. How do I take advantage of the pull to make the frequency appear as 0 when the wire is unhooked? Also both pins continue to show the same values. 

Ytai Ben-Tsvi

unread,
Mar 4, 2015, 12:34:12 AM3/4/15
to ioio-...@googlegroups.com
Inline.

I tried it in PULL_UP and PULL_DOWN and the numbers no longer run on. That's good. Final question though, the value of the frequency stays on the screen after unhooking my wire. How do I take advantage of the pull to make the frequency appear as 0 when the wire is unhooked?

I don't think this has anything to do with the pull configuration. More likely has to do with your TimerTask code not executing as it should to abort the read and consider the frequency 0. Add Log.d(...) statements in your code to get some more visibility into what's happening there exactly.
 
Also both pins continue to show the same values. 

I think I got it. Where is your last_ field declared? Have you possibly not defined it inside the thread class, causing both threads to clobber each other? 

Paul Johnson

unread,
Mar 4, 2015, 10:55:27 PM3/4/15
to ioio-...@googlegroups.com
Thanks for the help. I changed the last_declaration to the thread from the top of the parent class and it is working good.

I used the Log.d and put it inside the catch beside the last_ = 0 . The log is printing a cluster of 4 of the tag every second whether or not anything is plugged in and the numbers continue to remain on the screen after disconnect. I have attached my current code. Is there another place I need to place the last_=0 ?

class  PulseInputThread extends Thread {
private final PulseInput input_;
 private final Timer timer_;
 public float last_;
public PulseInputThread(PulseInput input,Timer timer) {
input_ = input;
   timer_ = timer;
}

 
private synchronized void read() throws ConnectionLostException {
   TimerTask task = new TimerTask() {public void run() {
    interrupt();
 }};
 
   timer_.schedule(task, 1000);
   try {
     last_ = 1/input_.getDuration();
     task.cancel();
   } catch (InterruptedException e) {
     last_ = 0;
     Log.d("BACON", "BACON");
    
   }
 }
 
 public void run() {
   try {
     while (true) {
       read();
     
       try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
     }
   } catch (ConnectionLostException e) {
    e.printStackTrace();
   }
 }

public synchronized float getLastReading() {
   return last_;
 }
}
class Looper extends BaseIOIOLooper {
PulseInputThread thread1_;
PulseInputThread thread2_;
PulseInputThread thread3_;
PulseInputThread thread4_;
PulseInputThread thread5_;
PulseInputThread thread6_;
PulseInputThread thread7_;
PulseInputThread thread8_;
@Override
protected void setup() throws ConnectionLostException {
PulseInput  input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input2_ = ioio_.openPulseInput( new DigitalInput.Spec(2,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input3_ = ioio_.openPulseInput(new DigitalInput.Spec(3,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input4_ = ioio_.openPulseInput( new DigitalInput.Spec(4,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input5_ = ioio_.openPulseInput(new DigitalInput.Spec(6,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input6_ = ioio_.openPulseInput( new DigitalInput.Spec(7,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input7_ = ioio_.openPulseInput(new DigitalInput.Spec(10,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input8_ = ioio_.openPulseInput( new DigitalInput.Spec(12,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);

Timer t = new Timer();
  thread1_ = new PulseInputThread(input1_, t);
  thread2_ = new PulseInputThread(input2_, t);
  thread3_ = new PulseInputThread(input3_, t);
  thread4_ = new PulseInputThread(input4_, t);
  thread5_ = new PulseInputThread(input5_, t);
  thread6_ = new PulseInputThread(input6_, t);
  thread7_ = new PulseInputThread(input7_, t);
  thread8_ = new PulseInputThread(input8_, t);
  
  
  
  
  
 thread1_.start();
 thread2_.start();
 thread3_.start();
 thread4_.start();
 thread5_.start();
 thread6_.start();
 thread7_.start();
 thread8_.start();
}

@Override
public void loop() throws ConnectionLostException {
setText1(thread1_.getLastReading());
 setText2(thread2_.getLastReading());
 setText3(thread3_.getLastReading());
 setText4(thread4_.getLastReading());
 setText5(thread5_.getLastReading());
 setText6(thread6_.getLastReading());
 setText7(thread7_.getLastReading());
 setText8(thread8_.getLastReading());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
public void disconnected() {
  try {
 
    thread1_.join();
    thread2_.join();
    thread3_.join();
    thread4_.join();
    thread5_.join();
    thread6_.join();
    thread7_.join();
    thread8_.join();

Ytai Ben-Tsvi

unread,
Mar 4, 2015, 11:26:15 PM3/4/15
to ioio-...@googlegroups.com

For sake of debugging of this particular issue, would you please remove 7 out of the 8 channels and report the behavior?

Ytai Ben-Tsvi

unread,
Mar 4, 2015, 11:27:05 PM3/4/15
to ioio-...@googlegroups.com

And tip: use arrays and loops to avoid code duplication.

Paul Johnson

unread,
Mar 5, 2015, 11:44:53 AM3/5/15
to ioio-...@googlegroups.com
I commented everything else out, but for two pins.

When I start the activity the Log prints my "Catch O" message below in clusters of two every second. (This is without any input on the pins). When I connect to one of the pins the Log prints "Catch O" one time each second. The text on screen continues to hang after disconnect. I don't understand why the catch would execute, but the text remain the same.



class  PulseInputThread extends Thread {
private final PulseInput input_;
 private final Timer timer_;
 public float last_;
public PulseInputThread(PulseInput input,Timer timer) {
input_ = input;
   timer_ = timer;
}

 
private synchronized void read() throws ConnectionLostException {
   TimerTask task = new TimerTask() {public void run() {
    interrupt();
 }};
 
   timer_.schedule(task, 1000);
   try {
     last_ = 1/input_.getDuration();
     task.cancel();
   } catch (InterruptedException e) {
     last_ = 0;
     Log.d("CATCH", "CATCHO");
    
   }
 }
 
 public void run() {
   try {
     while (true) {
       read();
     
       try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
     }
   } catch (ConnectionLostException e) {
    e.printStackTrace();
   }
 }

public synchronized float getLastReading() {
   return last_;
 }
}
class Looper extends BaseIOIOLooper {
PulseInputThread thread1_;
PulseInputThread thread2_;
@Override
protected void setup() throws ConnectionLostException {
PulseInput  input1_ = ioio_.openPulseInput(new DigitalInput.Spec(1,Mode.PULL_DOWN), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);
PulseInput  input2_ = ioio_.openPulseInput( new DigitalInput.Spec(2,Mode.PULL_DOWN ), ClockRate.RATE_62KHz,  PulseMode.FREQ, false);

Timer t = new Timer();
  thread1_ = new PulseInputThread(input1_, t);
  thread2_ = new PulseInputThread(input2_, t);
 
   
 thread1_.start();
 thread2_.start();
 
}

@Override
public void loop() throws ConnectionLostException {
setText1(thread1_.getLastReading());
 setText2(thread2_.getLastReading());
 
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
public void disconnected() {
  try {
 
    thread1_.join();
    thread2_.join();
 
  } catch (InterruptedException e) {
  }
}
}



@Override
protected IOIOLooper createIOIOLooper() {
return new Looper();
}

Ytai Ben-Tsvi

unread,
Mar 5, 2015, 12:32:52 PM3/5/15
to ioio-...@googlegroups.com

You're using getDuration() instead of waitPulseGetDuration().

--

Paul Johnson

unread,
Mar 5, 2015, 2:45:54 PM3/5/15
to ioio-...@googlegroups.com


I switched to waitPulseGetDuration() a while ago but I couldn't get it working. The app suspends on the line  TimerTask task = new TimerTask() {public void run() {  when I use waitPulseGetDuration(). It doesn't do this with getDuration(). The documentation says that waitPulseGetDuration() can't be used while in FREQ mode. I need the FREQ mode as mentioned above, but I also need the set back to zero function to work. Any ideas? Can the waitPulseGetDuration be used in this mode with modification?

Thanks! 

Ytai Ben-Tsvi

unread,
Mar 5, 2015, 4:42:11 PM3/5/15
to ioio-...@googlegroups.com

Sorry, memory glitch... The method you're looking for is getFrequencySync().

On Mar 5, 2015 11:46 AM, "Paul Johnson" <coconu...@gmail.com> wrote:


I switched to waitPulseGetDuration() a while ago but I couldn't get it working. The app suspends on the line  TimerTask task = new TimerTask() {public void run() {  when I use waitPulseGetDuration(). It doesn't do this with getDuration(). The documentation says that waitPulseGetDuration() can't be used while in FREQ mode. I need the FREQ mode as mentioned above, but I also need the set back to zero function to work. Any ideas? Can the waitPulseGetDuration be used in this mode with modification?

Thanks! 

--

Paul Johnson

unread,
Mar 5, 2015, 5:47:25 PM3/5/15
to ioio-...@googlegroups.com
Ok, Thanks.

I don't have that getFrequencySync() in the version of the library I have. The newer version doesn't work with the IOIO boards (3.30) I have. I'm assuming I just need to use the IOIODude to upgrade the firmware on the IOIO. 

In the alternative I was copying the methods over from the latest version from the IncapImpl.java file. I can't seem to find the safeWait() method to copy into my library. Where is that found?

Ytai Ben-Tsvi

unread,
Mar 5, 2015, 5:48:24 PM3/5/15
to ioio-...@googlegroups.com

Upgrade. This is s good idea regardless. You're using an version.

--

Paul Johnson

unread,
Mar 6, 2015, 1:53:32 PM3/6/15
to ioio-...@googlegroups.com
Thank you for all your help.

Everything is working as needed. Thanks!
Reply all
Reply to author
Forward
0 new messages