I have tried all combinations of opening pulse input after sending the 
trigger pulse...no luck.  I am reading both the output (trigger pulse) and 
the echo (return) pulse...alternately.  About 5 trigger pulse readings to 
each echo pulse reading.  Any work around ideas?

On Wednesday, April 23, 2014 8:44:02 PM UTC-7, Ytai wrote:
>
> Opening the pulse input after sending the pulse should have done that. You 
> shouldn't be able to get a pulse from the past the way you're doing this. 
> Are you saying that what you're reading back is the output pulse?
> It is possible that there's a bug in the firmware side on the PulseInput 
> implementation in that case.
>
>
> On Wed, Apr 23, 2014 at 2:33 PM, Vic Wintriss 
> <[email protected]<javascript:>
> > wrote:
>
>> I'm using 0503.
>>
>> The problem is that the ping and the return are getting out of sync.  The 
>> getDuration() readings match exactly the times that I see on the scope.
>> How can I synchronize so that I only start listening after the ping pulse 
>> is complete?
>>
>>
>> On Wednesday, April 23, 2014 8:51:26 AM UTC-7, Ytai wrote:
>>
>>> Are you using the latest firmware?
>>> Also, cancellation is supported. Search the forum for TimerTask.
>>>
>>>
>>> On Tue, Apr 22, 2014 at 10:10 PM, Vic Wintriss <[email protected]>wrote:
>>>
>>>> I tried the following:
>>>>
>>>> public void read() throws ConnectionLostException, 
>>>> InterruptedException {
>>>>
>>>>  ioio.beginBatch();
>>>>
>>>>  leftStrobe.write(false);
>>>>
>>>>  leftStrobe.write(true);
>>>>
>>>>  leftStrobe.write(false);
>>>>
>>>>    leftInput = ioio.openPulseInput(LEFT_ULTRASONIC_INPUT_PIN,
>>>>
>>>>   PulseMode.POSITIVE);
>>>>
>>>>    ioio.endBatch();
>>>>
>>>>  leftDistance = (int) (leftInput.getDurationBuffered() * 1000000);
>>>>
>>>>  leftInput.close();
>>>>
>>>>  SystemClock.sleep(100);
>>>>
>>>>  dashboard.log(leftDistance + "");
>>>>
>>>> }
>>>> It makes one reading and then hangs up.  How do I time out if I want 
>>>> stop waiting?
>>>> I put the scope on the sensor and discovered that I am reading 
>>>> alternately both the trigger pulse and the echo pulse...most often the 
>>>> trigger pulse.
>>>>
>>>> On Tuesday, April 22, 2014 5:05:23 PM UTC-7, Ytai wrote:
>>>>
>>>>> No, there isn't, and even if there were, I'm not sure this will 
>>>>> actually do what you want.
>>>>> Have you tried the hack I recommended on the previous post?
>>>>>
>>>>>
>>>>> On Mon, Apr 21, 2014 at 8:36 PM, Vic Wintriss <[email protected]>wrote:
>>>>>
>>>>>> Good idea about the logic fix.  I’m redoing the interface boards, so 
>>>>>> I might add that logic.
>>>>>> If I am, in fact, reading part of the trigger pulse, is there any way 
>>>>>> of imposing a short, predictable delay…say 50 microsecs…after the 
>>>>>> trigger 
>>>>>> pulse but before the getDuration() read?
>>>>>>
>>>>>> On Apr 21, 2014, at 5:12 PM, Ytai Ben-Tsvi <[email protected]> wrote:
>>>>>>
>>>>>> Good catch, I forgot about this constraint.
>>>>>> In that case, this (similar to what you've proposed) approach might 
>>>>>> work:
>>>>>>
>>>>>> beginBatch();
>>>>>> generatePulse();
>>>>>> openPulseIn();
>>>>>> endBatch();
>>>>>> getDuration();
>>>>>> closePulseIn();
>>>>>>
>>>>>> I'd like to emphasize that the fact we have to jump through weird 
>>>>>> hoops to get is working is mostly due to the fact that this sensor has a 
>>>>>> weird interface. BTW, another thing you can do is use a discrete logic 
>>>>>> gate 
>>>>>> to filter out the ping input pulse from the output. Something like:
>>>>>> clean_out = ping_pin & !ioio_pulse_out_pin
>>>>>>
>>>>>> This will convert the Ping's interface to be similar to the one of 
>>>>>> the other sensor I referred you to.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Apr 21, 2014 at 3:23 PM, Vic Wintriss <[email protected]>wrote:
>>>>>>
>>>>>>>  I don't think that I can use getDurationBuffered() in this case. 
>>>>>>> The getDuration() Interface notes say: "...Note that once a pulse is 
>>>>>>> detected, the next one must have its leading edge at least 5ms after 
>>>>>>> the 
>>>>>>> leading edge of the current one, or else it will be skipped."  The ping 
>>>>>>> pulse is about 50 microsecs long, and the echo pulse comes about 750 
>>>>>>> microsecs after the ping pulse,  If I am getting the last part of the 
>>>>>>> ping 
>>>>>>> pulse, the echo pulse will come too soon for getDurationBuffered() to 
>>>>>>> acquire the echo pulse.  Am I understanding this right?
>>>>>>>
>>>>>>>
>>>>>>> On Sunday, April 13, 2014 7:22:39 PM UTC-7, Vic Wintriss wrote:
>>>>>>>>
>>>>>>>> I am trying to use the Parallax Ping))) ultrasonic sensor with a 
>>>>>>>> ioio V1 board, using the IOIO00503 library.  I get a good looking 
>>>>>>>> signal...see the attached scope view, but the input.getDuration() call 
>>>>>>>> returns 16.8 micro seconds most of the time, called 2 times per 
>>>>>>>> second. 
>>>>>>>>  Every once in a while I get the proper number. 
>>>>>>>>
>>>>>>>>  Any ideas? Here is the code:
>>>>>>>>
>>>>>>>> import ioio.lib.api.DigitalOutput;
>>>>>>>>
>>>>>>>> import ioio.lib.api.IOIO;
>>>>>>>>
>>>>>>>> import ioio.lib.api.PulseInput;
>>>>>>>>
>>>>>>>> import ioio.lib.api.PulseInput.PulseMode;
>>>>>>>>
>>>>>>>> import ioio.lib.api.exception.ConnectionLostException;
>>>>>>>>
>>>>>>>>
>>>>>>>> public class UltraSonicSensors 
>>>>>>>>
>>>>>>>> {
>>>>>>>>
>>>>>>>> private static final int LEFT_ULTRASONIC_INPUT_PIN = 35;
>>>>>>>>
>>>>>>>> private static final int LEFT_STROBE_ULTRASONIC_OUTPUT_PIN = 15;
>>>>>>>>
>>>>>>>> private final PulseInput leftInput;
>>>>>>>>
>>>>>>>> private DigitalOutput leftStrobe;
>>>>>>>>
>>>>>>>> private float leftDistance;
>>>>>>>>
>>>>>>>> private IOIO ioio;
>>>>>>>>
>>>>>>>>
>>>>>>>> public UltraSonicSensors(IOIO ioio) throws ConnectionLostException 
>>>>>>>>
>>>>>>>> {
>>>>>>>>
>>>>>>>>  this.leftInput = ioio.openPulseInput(LEFT_ULTRASONIC_INPUT_PIN, 
>>>>>>>> PulseMode.POSITIVE);
>>>>>>>>
>>>>>>>>  this.leftStrobe = ioio.openDigitalOutput(LEFT_ST
>>>>>>>> ROBE_ULTRASONIC_OUTPUT_PIN);
>>>>>>>>
>>>>>>>>  this.ioio = ioio;
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> public void read() throws ConnectionLostException, 
>>>>>>>> InterruptedException 
>>>>>>>>
>>>>>>>> {
>>>>>>>>
>>>>>>>>  read(leftStrobe, leftInput);
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> private void read(DigitalOutput strobe, PulseInput input) 
>>>>>>>> throwsConnectionLostException, InterruptedException 
>>>>>>>>
>>>>>>>> {
>>>>>>>>
>>>>>>>>  ioio.beginBatch();
>>>>>>>>
>>>>>>>>  strobe.write(true);
>>>>>>>>
>>>>>>>>  strobe.write(false);
>>>>>>>>
>>>>>>>>  ioio.endBatch();
>>>>>>>>
>>>>>>>>  this.leftDistance =  input.getDuration();
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> public float getLeftDistance() 
>>>>>>>>
>>>>>>>> {
>>>>>>>>
>>>>>>>>  return leftDistance;
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> 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 a topic in 
>>>>>> the Google Groups "ioio-users" group.
>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>>>> pic/ioio-users/3MDLEEKtejY/unsubscribe.
>>>>>>  To unsubscribe from this group and all its topics, 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.
>>>>>>
>>>>>
>>>>>  -- 
>>>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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.

Reply via email to