I haven't read all the code throughly. Some suggestions: - Do not call super.loop() from your loop(). - There is no reason to run this logic on the UI thread. It is better done inside loop(). - If you use getVoltageBuffered() you can scan through all the samples (exactly 1000 / sec), without missing any one and with precise timing (1 ms / sample) unlike relying on the system clock in a Java environment.
On Sat, May 3, 2014 at 1:01 AM, harshad <[email protected]> wrote: > hi, > > I am doing ECG plotting application using IOIO. Currently getting almost > proper realtime ECG wave.PFA for plot. But unable to retrive Heart Rate in > BPM. > > Thus,*I want to measure time difference between to successive analog > peaks (2.1 V)* > > > > * * > > This analog input voltage is varying between 1.5 V to 2.5V > > my code: i am using simpleIOIO app as reference > > *1) to get voltage from analog input pin 40,* > > public void loop() throws ConnectionLostException, InterruptedException { > > // TODO Auto-generated method stub > > super.loop(); > > v = 0; > > try { > > actualTime = System.currentTimeMillis(); // reading > system time in milliseconds > > newTime1 = actualTime; > > led_.write(!mEcgOn.isChecked()); > > v = inPin.getVoltage(); > > Thread.sleep(100); > > } catch (InterruptedException e) { > > inPin.close(); > > > // // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > *2) To compare the peak to peak voltage using an UI thread* > > runOnUiThread(new Runnable() { > > @Override > > public void run() > > if(v>2.1) > > { > > newTime2=newTime1; > > timeDiff1 = actualTime-newTime2; > > } > > voltsText = Long.toString(timeDiff1); > > voltsText1 = Long.toString(actualTime); > > mHRateDisplay.setText(voltsText); > > mTempDisplay.setText(voltsText1); > > } > > }); > > * Logic: i am capturing system time in millisecoonds. Then > as voltage is available , stored this time in newTime1. Now by running new > UI thread comparing new peak at 2.1V while storing new time2 and > calculating time the difference.* > > *But its not giving any output. * > > *Please help..* > > > *Regards,* > > *Harshad * > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/ioio-users. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/ioio-users. For more options, visit https://groups.google.com/d/optout.
