HC-SR04 and switching regulator issues

Hi, I used Pololu 5V Step-Up Voltage Regulator U1V10F5 to generate 5v regulated output to power my distance sensor HC-SR04 (http://www.micropik.com/PDF/HCSR04.pdf) via Atmega328p (also powered via the same regulator). Input to the regulator is from 2xAA batteries. The range for the output values of HC-SR04 seems to be decreased for the sensor from 400 cm to just over 70 cm. Lower input voltages to the regulator seems to lower the range as well. The output of the regulator is a little bit over 5volts (DVM measured) for all the input sources. When I switch over to the arduino board I get the full range for HC-SR04. Any thoughts about what type of source should be used for the regulator or should I add capacitors etc.. to provide input voltage to the regulator? Is the regulator not able to respond to 10 microsecond pulse at 5v required for HC-SR04 operation? Why the shorter range?

Thanks

I am puzzled by this

Is the regulator not able to respond to 10 microsecond pulse at 5v required for HC-SR04 operation?

Are you pulsing the sensor? If you are you should not be.

Switching regulators do generate more noise and do need a good layout and good decoupling.

Hi, I am providing a 10 us pulse for triggering the sensor (code below). Also, the same code and connections work when connected to the arduino board. The trigger is generated from atmega328p pins but the atmega and the ultrasonic sensor are sourced via the regulator.

  digitalWrite(ultrasonicPowerPin,HIGH); // turn ultrasonic sensor on
      delay(100);
 pinMode(trigPin,OUTPUT);
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 pinMode(echoPin,INPUT);
 duration = pulseIn(echoPin, HIGH);
 digitalWrite(ultrasonicPowerPin,LOW); // turn ultrasonic sensor off

Try a 10uf cap across the supply terminals for the HC SR-04. The rangefinder pulls more current when pinging.

Thank you for the capacitor idea. I will try that out. Should I plan for any reverse bias protection for the 10uF electrolytic capacitor when I am powering the hc-sr04 supply terminal from the atmega328p through a low voltage drop diode or a mosfet? I will also try using the linear regulator 7805 in place of the boost regulator to see if there is a difference in behavior.

Should I plan for any reverse bias protection for the 10uF electrolytic capacitor

No.
If you get a reverse voltage then the rest of the circuit is toast anyway.

I will also try using the linear regulator 7805 in place of the boost regulator to see if there is a difference in behavior.

Well you need a higher voltage, about 1.5V greater than the output voltage. And don’t forget the capacitors.

With the switching regulator, the max range gets reduced from 70 ~ 80 cm to 40 cm when I connect the 10uF capacitor. With 22uF the max range is ~35 cm. With 4 uF the max range is ~ 45 cm. So it has something to do with the current draw certainly… not sure what value of capacitor would be able to alleviate the problem. Will try a few other values out.
… just FYI that everything works like charm with the linear voltage reg. 7805, with input provided by 9V battery.
Still puzzled about the capacitor values to make it work for the switching regulator or if there are alternative options?

OK so that means that the problem is one of decoupling on the supply.
You need a 0.1uF ceramic capacitor in parallel with the electrolytic, fitted close to the regulator.
If that is not enough then use a pi filter like the last one on this page:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
Just use as bigger inductor as you can get hold of.