pulsein and pulse out

I hate to keep saying this but think I better. I am brand new to all this so please be tolerant of my ignorance.

I have found the pulsein function but do not find a pulseout, or equivalent. Does one use analogwrite() to send a controlled pulse? I am looking at using the combination to work with an ultrasonic sensors that requires a pulse be received then it returns a pulse that may be used to determine a distance. The out-pulse is moderately critical in length.

One other thing, I DO try and find this stuff on my own but I am unable to make the search function in the forums work with getting an Internal Server Error. This may be a loose nut on the keyboard issue...if so, please tell me what to do to correct it.

TNX,

Jim, K6JMG

This forum is notoriously bad at big searches. Try using Google instead with a prefix of "site:arduino.cc" on your search terms.

E.g., enter the following in search box:

site:arduino.cc pulsein pulseout

Did you read what the pulseIn function does? It is intended to wait a limited period of time for a digital pin to change state.

So, of course there is no pulseOut function. You KNOW when you want them to change.

An ultrasonic sensor sends a pulse - a specific frequency wave, and measures how long it takes that pulse to return, after being reflected by some surface.

The ultrasonic sensor is not expecting you to generate the pulse that it reads.

PaulS,

This sensor works by you sending a pulse and it times from when the US sendor sends the pulse to when the US receiver receivers it. You might take a look at the Parallax Ping device.

Tahnsk,

Jim, K6JMG

Ok, I looked at the Parallax Ping sensor.

http://www.parallax.com/tabid/768/ProductID
/92/Default.aspx

The Ping sensor measures distance using sonar; an ultrasonic (well above human hearing) pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Output from the PING))) sensor is a variable-width pulse that corresponds to the distance to the target.

There are not separate sender and receiver units. There is a sender and a receiver in one unit. The sender part of the sensor continually pulses a signal. The receiver part of the sensor continually receives the bounced signal. The time between send and receive of a pulse is an indication of the distance to the reflector.

You don't need to send a pulse. The sensor does that. All you need to do is set a pin high, to turn the sensor on, if it is powered by a digital OUTPUT pin, and use analogRead to read the sensor's output.

PaulS,

I appreciate your efforts and am not trying to be argumentative but you DO send the Ping a pulse. Below is a sample of the BasicTAMP code. Even though it is STAMP code it is very clear that you send a pulse.

Get_Sonar:
Ping = IsLow ' make trigger 0-1-0
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale ' convert to uS
rawDist = rawDist / 2 ' remove return trip
RETURN

Jim

Do you have a Basic STAMP, or do you have an Arduino. If you have an Arduino, then you need do nothing more than digitalWrite(whateverPinTheSensorsOn, HIGH) to start the sensor doing it's thing, and analogRead to get it's output.

If you have a Basic STAMP, then, I'd suggest you ask your questions at BasicSTAMP.cc.

PaulS,

I have both. The sensor works with the BasicStamp and I was simply showing you a snapshot of the code from the STAMP.

My original question could have been worded better, I guess. How do I send a controlled length pulse to a pin? Is analogwrite() the proper tool for the job? I do not see a pulseout() function that is the reverse of the pulsein() function that exists.

Jim

Jim

How do I send a controlled length pulse to a pin?

pretty straight forward: Psudo code

digitalwrite (pin#, high)
delayMicroseconds(xxx) // for the pulse width you want
// For delays longer than a few thousand
//microseconds, you should use delay() instead.
digitalwrite (pin#, low)

Lefty

Retrolefty,

That is EXACTLY what I wanted to know! Thank you very much.

JIm, K6JMG