A bit late, but I have just got a DSM-IO Ultrasonic module which also has
one pin for a combined output and input.
I have also tried to connect with a DigitalOutput tied together with a
PulseInput (waitPulseGetDuration()) as many others have done, and it did
not work.
As I have understood, a PulseInput requires two edges in order to fire, and
the DSM-IO only needs a negative pulse in order to start, then the line is
high until either an echo is received or a time-out reached.
According to the specs I have found, when a target is detected, a negative
pulse of about 150 us is used to indicate a target is found whereas a 10ms
pulse means no target within range.
One solution is to use 3pins, two PulseInput plus one DigitalOut.
Presumably the DSM-IO is triggered on the positive going edge of the
trigger pulse, hence it should not matter if is 10us or several ms.
As I use a bluetooth connection, the length is probably as above, around
40ms.
To make it working, here is a cut from the code I have used for testing a
sonar-like implementation.
sonarTrigger is the DigitaOut.
echoEnd is the PulesInput in NEGATIVE mode.
sonarEcho is the PulesInput in POSITIVE mode.
sonarTrigger.write(false);
TimeUnit.MICROSECONDS.sleep(10); //I know, not needed
sonarTrigger.write(true);
//Wait for echo end pulse
echoCheck = echoEnd.waitPulseGetDuration() * 1000 * 1000;
//Then get last echo length
echoSeconds = sonarEcho.getDuration() * 1000 * 1000;
echoDistCm = echoSeconds / 29 /2;
The waitPulseGetDuration() should always be released as the DSM-IO module
always returns a negative pulse at the end.
In the meantime, getDuration() has been triggered on the positive edge of
the trigger pulse and the timing stops at the negative edge of the start of
the end pulse. This is stored in a double, echoSeconds.
Obviously, there is a start delay, presumably 250us, which should be
subtracted from the result before calculating the distance.
The value in echoCheck might be used to accept/reject the distance.
However, using the debugger in eclipse for check, the results have varied
so I am not sure how it works.
Den torsdag den 20. juni 2013 07.15.07 UTC+2 skrev Ytai:
>
> BTW, there are equivalent sensors with separate pins for input and output
> or, even simpler, with a single analog pin that presents a voltage that's
> proportional to the distance from the target, which can be read with an
> AnalogInput.
>
>
> On Thu, Jun 20, 2013 at 5:13 PM, Ytai Ben-Tsvi <[email protected]<javascript:>
> > wrote:
>
>> If you're talking about the parallax module that has a single pin for
>> both input and output, this might be a bit tricky...
>> You may pull this off by connecting two pins together, one working as a
>> PulseInput and the other as a DigitalOutput.
>> Read the wiki for beginBatch() / endBatch().
>>
>>
>> On Thu, Jun 13, 2013 at 2:30 AM, Vic Wintriss
>> <[email protected]<javascript:>
>> > wrote:
>>
>>> I'm using a parallax ultrasonic sensor on our robots. It requires a
>>> short pulse to start the ultrasonic ping.
>>>
>>> Do you have an example of how to use the beginBatch()/endBatch() with a
>>> digital output write(true), write(false) sequence?
>>>
>>> On Jun 12, 2013, at 4:42 AM, Ytai Ben-Tsvi <[email protected]<javascript:>>
>>> wrote:
>>>
>>> Over Bluetooth, this number is not unreasonable.
>>> You can get a much smaller width (a few usec) if you wrap these
>>> instructions with a beginBatch() / endBatch() loop.
>>> What is *really* the question here? There might be a better way to do
>>> what you're trying to do.
>>>
>>>
>>> On Wed, Jun 12, 2013 at 4:49 PM, Vic Wintriss
>>> <[email protected]<javascript:>
>>> > wrote:
>>>
>>>> What is the minimum pulse width I will get with the following
>>>> DigitalOutput code:
>>>>
>>>> rightStrobe.write(true);
>>>> rightStrobe.write(false);
>>>>
>>>> It looks like I am getting 40 millisecs with an android phone.
>>>>
>>>> --
>>>> 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?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> 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/YeZxBUL_Uto/unsubscribe?hl=en
>>> .
>>> To unsubscribe from this group and all its topics, 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?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>>
>>> --
>>> 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?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>
--
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/groups/opt_out.