--
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.
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()?
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.
--
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 blocke.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) {}}
--
--
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?
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.
For sake of debugging of this particular issue, would you please remove 7 out of the 8 channels and report the behavior?
And tip: use arrays and loops to avoid code duplication.
You're using getDuration() instead of waitPulseGetDuration().
--
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?
Sorry, memory glitch... The method you're looking for is getFrequencySync().
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!
--
Upgrade. This is s good idea regardless. You're using an version.
--