Ytai:

With the sync() call after the endBatch() and before the getDuration() the 
program hangs up and I get no readings.

Vic

On Apr 15, 2014, at 5:32 PM, Ytai Ben-Tsvi <[email protected]> wrote:

> This code doesn't have the sync() call I proposed. It should come after the 
> batch.
> 
> On Apr 15, 2014 4:43 PM, "Vic Wintriss" <[email protected]> wrote:
> Ytai:
> 
> This code produces only 1.6875E-5...reading 2 times per second.
> 
> 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_STROBE_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.getDurationSync();
>       }
> 
>       public float getLeftDistance() 
>       {
>               return leftDistance;
>       }
> }
> On Apr 15, 2014, at 4:27 PM, Ytai Ben-Tsvi <[email protected]> wrote:
> 
>> Can you send me the most "correct" version of your code that demonstrates 
>> the issue?
>> I can probably make the necessary changes to sync () if this is indeed a 
>> problem.
>> 
>> On Apr 15, 2014 4:03 PM, "Vic Wintriss" <[email protected]> wrote:
>> Thanks for the ideas. I've tried many combinations of synch, 
>> readBuffered...etc, but unfortunately it still reads very small 
>> numbers...probably measuring the last part of the trigger pulse. Is there 
>> any way that I can delay the read by a couple of hundred micro seconds?  
>> Could you do the..... sync() call  "send" half inside the batch and "wait" 
>> half outside thing?
>> 
>> Thanks for all the help.  The kids are trying to use these sensors for iARoC 
>> 2014 (the International Autonomous Robot Competition) here in San Diego.
>> 
>> -- 
>> 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/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 a topic in the Google 
> Groups "ioio-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/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.

Reply via email to