HC-SR04 Ultrasonic sensor distance as analog value

Hi everyone,

I'm working with an Arduino MEGA 2560, an HC-SR04 Ultrasonic sensor and a softPLC (ProviewR SCADA).
Could someone please give me some hint about how to connect an Arduino to the HC-SR04 and convert the distance from the Echo pin to an analog value with the arduino to be sent to the softPLC afterwards?

Any help greatly appreciated

/Maverick

You could convert the distance to a PWM value (map distance to 0 to 255) then low pass filter the PWM to get an analog voltage from 0 to some voltage. Or use Arduino with a Digital to Analog (DAC) controller either built in or external.

Hi,
Thanks a lot for your reply, I just want to ask some more questions to clarify things... the PWM is a digital output, right? So as you said, we get a digital input from the echo pin of the HC-SR04 in one digital pin, then we make a PWM output from another digital pin, and finally, we convert this signal into analog pin through a DAC, then we could take this signal back into an analog pin as an analog input into the Arduino, or a PLC... Is that correct?

/MaverickRF

MaverickRF:
Hi,
Thanks a lot for your reply, I just want to ask some more questions to clarify things... the PWM is a digital output, right? So as you said, we get a digital input from the echo pin of the HC-SR04 in one digital pin, then we make a PWM output from another digital pin, and finally, we convert this signal into analog pin through a DAC, then we could take this signal back into an analog pin as an analog input into the Arduino, or a PLC... Is that correct?

/MaverickRF

Just a clarification: what you get from the echo pin is a pulse that indicated the sensor received and echo. That is all.

Paul

Reportedly that PLC has the ability to communicate with other computers via serial. Wouldn't it be a lot simpler to just connect the Arduino to the PLC via serial and send the distance that way?