rehsinup
Posts: 1
Joined: Fri Sep 24, 2021 3:26 am

PulseIn on Raspberry for Radar-Sensor

Fri Sep 24, 2021 3:42 am

I'm trying to build a speed-o-meter.
I have a radar sensor for this. However, I can only find examples of Ardiuno.
Now the question:
How can i obtain the value of variable T on this example:

Code: Select all

T = pulseIn(pin, HIGH) + pulseIn(pin, LOW);
Something like:

Code: Select all

vmax=0
for i in range(16):
	T = pulseIn(pin, HIGH) + pulseIn(pin, LOW) <= Change in Pyhton for Raspberry
	f=1/T
	v=int((f*1e6)/44.0)
	vmax=max(v,vmax)

print(vmax)
I connected the sensor on GPIO18

At the moment i obtain only HIGH or LOW inputs

Code: Select all

radar_pin = 12

try:
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(radar_pin, GPIO.IN,GPIO.PUD_UP)
    while True: 
        input_value = GPIO.input(radar_pin)
        time.sleep(0.5)
        print(input_value)
       
        
except KeyboardInterrupt:
    pass

GPIO.cleanup()
But I need the time in microseconds between HIGH and LOW 16 times in a row..
Do you have an idea?

jayben
Posts: 352
Joined: Mon Aug 19, 2019 9:56 pm

Re: PulseIn on Raspberry for Radar-Sensor

Fri Sep 24, 2021 1:50 pm

Search for pulse width measurement, e.g.
viewtopic.php?t=105274

Return to “Automation, sensing and robotics”