Need some help on a ultrasonic sensor problem

Hi,

Thank you for taking your time to read my topic. I am building a device which will trigger when a cat passes and will not trigger when a human passes.

The Setup: For this I use 3 sensors, one photoelectric sensor and two ultrasonic sensors. The PE sensor is on cat-level and when the beam is broken the arduino will trigger a relay which has a solenoid valve connected to it. I use two ultrasonic sensors on human-level to "disarm" the system when a person passes and a bright LED will start blinking for 15 sec. As a power supply I use a 24V 1A supply. The sensor and the valve need 24V. I have a voltage regulator (pre-built) set to approx. 6 volts.

The problem: As soon as I plug in the power supply the disarm LED starts blinking, so my conclusion is that the arduino gets a signal seeming like there is an object infront of one of the ultrasonic sensors. However, I am quite possitive that I have rigged up the sensor correctly because when I unplug the power from the voltage regulator and use a separate source (power supply or computer USB) everything works like it is supposed to be. I can read the sensor distances on my PC and the status of the PE sensor and it triggers the relay when the beam is broken.

So I am really confused as of what is going wrong. The only difference I make is taking the power plug from the regulator out of the arduino and plugging in a "3rd party" plug then everything works.

Really hope someone can help me out. Thank you in advance!

What does your setup code do? How is the circuit handling the inputs before setup has correctly configured pins? Does all this different powersupply include if the Arduino USB is connected or not? (this makes the timing for powerup change as the bootloader does some probing) How do you power the circuits (not the Arduino)?

And last but not at least : is this a real problem? Rephrasing: what would be wrong in supressing any sensor input for a short while (f.ex. the first round of the loop() ?) Having written that, I want to contradict myself by pointing out, that finding the root cause of any "suspicious" behaviour in a program or system is good. Ignoring or supressing it hides some other error, that may be worse.

Thank you for your response. My setup simply declares some pinmodes, opens a Serial and set's the initial state for my relay.

pinMode(relay_1, OUTPUT); pinMode(relay_2, OUTPUT); pinMode(PESensorPin, INPUT); pinMode(led, OUTPUT); Serial.begin(9600); digitalWrite(relay_1, HIGH); digitalWrite(relay_2, HIGH);

The circuit works with and without USB connected as long as I use a different power source than the one from my voltage regulator. Part of my circuit is powered by the 5V from the arduino and the 24V parts are directly powered by the 24V power supply.

Yes it is a real problem because supressing sensor input for a short while won't work, the arduino reads a continues sensor input so it is really stuck in the blink loop as the sensor is always registering an object. Could there be something wrong with the regulator. A thing I noticed is that as soon as I use the regulator there is an unexplained voltage on the echo pin (even with the sensor disconnected) and when I use a different supply and disconnect the sensor there is just no voltage as it is supposed to be, could there be something wrong with the regulator that makes the arduino fail to register the pin as input or something?

Time to look at the circuit. Somewhere there is a ground missing or you are picking up (electrical) noise. If you have schematics fine, but a phone-snap ofa handdrawn one can do. Also perhaps a picture of the physical setup, particular the problematic power supply wiring.

The Arduino either needs the USB or 5V regulated, clean on the VIN pin, or 7v to 12V on the barreljack (where it goes through the onboard regulator). You wrote 6V ... which goes where?

I did not see the setup for the ultrosonic sensors in your code. How are you reading them (analog or I2C or SPI ...). Analog pins are default input, which may start explaining your difficulty - the analog read needs a reference and if you do not have the correct supply voltage it will derive the wrong reference from VIN.

Hi, when you ping your ultrasonics you cannot do both at the same time, because you cannot check to see which reflection is from which transmitter. I suggest you ping one , wait and get a reading, then ping the other, that way you will be sure that you are only receiving the relevant reflection.

Please can you post a copy of your complete sketch, use #code tags, a picture of your project and a CAD or picture in jpg,png, or pdf of your circuit. You have the project in front of you, we don't, so we need as much information as possible to get up to speed, this way we will be making suggestions that may save you and us time and replies.

Thanks.. Hope to help

Tom..... :)

Thank you guys for your response! Never knew the problem was this simple, it was the 6V I supplied to the barreljack, thinking it also needed 5V instead of 7V. So I set my regulator to 9V and it all works like a charm now! Thank you very much for your help. Oh and I declare my ping sensor before the setup.

NewPing sonar1(trigPin1, echoPin1, maxDistance); //NewPing setup of pins and maximum distance for //the first ultrasonic sensor NewPing sonar2(trigPin2, echoPin2, maxDistance); //NewPing setup of pins and maximum for the //second ultrasonic sensor

Again, thank you for your help, I was stuck with this for so many hours...