Can I close the input while I am doing the strobe so that the input is not 
being exposed to both pulses?

On Saturday, April 26, 2014 4:23:51 PM UTC-7, Ytai wrote:
>
> @Duane
> At this point I'm convinced that there is no reason why this *should* work. 
> If it used to work in the past it is probably coincidental and you can of 
> course downgrade if you prefer.
> I'm not going to spend any time supporting one specific sensor that has a 
> weird interface. You have several viable options for solving your problem:
>
>    - Use a different sensor as recommended above.
>    - Filter out the trigger pulse using simple discrete logic as 
>    recommended above.
>    - Change the firmware to support your use-case, for example, to filter 
>    out pulses shorter than a certain limit or even having a dedicated PING 
>    interface that can do both the output and input. 
>
> @Vic
> While you're generating the output with one pin and reading the input with 
> another, the latter pin is being exposed to both signals.
>
>
> On Sat, Apr 26, 2014 at 4:20 PM, Vic Wintriss 
> <[email protected]<javascript:>
> > wrote:
>
>> The output pulse and input pulse are not on the same pin.  I assume by 
>> line you meant pin.  Output is on one pin and input is on another pin.
>>
>>
>> On Saturday, April 26, 2014 4:04:51 PM UTC-7, Ytai wrote:
>>
>>> PulseInput is primarily designed for:
>>>
>>>    1. Measuring rate or pulse-width of a pulse train signal, where it 
>>>    is not necessarily important to get a result for each and every pulse. 
>>> This 
>>>    is useful, for example, to measure speed of a wheel or to decode a servo 
>>>    signal. 
>>>    2. Measuring width of individual pulses that occur relatively 
>>>    sporadically, like outputs from ultrasonics.
>>>
>>> In your case, we have two kinds of pulses (in/out) on the same line in 
>>> close proximity, and you're trying to extract one but not the other. Not 
>>> that there is anything particularly hard to implement such a feature, only 
>>> that it is not generic enough to be addressed in the standard interfaces 
>>> that I've developed.
>>>
>>>
>>> On Fri, Apr 25, 2014 at 9:50 PM, Vic Wintriss <[email protected]>wrote:
>>>
>>>> I am just trying to put out a pulse on one pin and then read a  pulse 
>>>> width on a different pin 750 microsecs later. Why do you say that it was 
>>>> not designed for such a use?
>>>>
>>>>
>>>> On Wednesday, April 23, 2014 9:21:54 PM UTC-7, Ytai wrote:
>>>>
>>>>> Nope. The PulseInput module was really not designed for such a 
>>>>> use-case. If you had only the output pulses on the input things would 
>>>>> "just 
>>>>> work". Try the AND gate trick.
>>>>>  
>>>>>
>>>>> On Wed, Apr 23, 2014 at 9:15 PM, Vic Wintriss <[email protected]>wrote:
>>>>>
>>>>>> 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]>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) 
>>>>>>>>>>>>>> throwsConnectionLostException 
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  this.leftInput = ioio.openPulseInput(LEFT_ULTRA
>>>>>>>>>>>>>> SONIC_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) 
>>>>>>>>>>>>>> throws ConnectionLostException, 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/topic/ioio-users/3MDLEEKtejY/uns
>>>>>>>>>>>> ubscribe.
>>>>>>>>>>>>  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].
>>>>>>>> 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