0
$\begingroup$

I have three HC-SR04 sensors connected to a PIC18F4431 with the schematic provided below. Before building the PCB I've tried testing all three sensors with a bread board and they worked fine. But now I have my PCB and when I connect them to that and tried testing, they work only for a few seconds and then stop working.

I set timers and a set of LEDs to lit if an item is in between 40cm from each sensor. As I've tried from the bread board, when I cross my arm withing that range, the appropriate bulbs are lit and when I take my arm off the other bulbs are lit. But using the PCB, when I upload the code through a PICKIT2 they work fine for a few seconds and then they freeze. If I reset the MCLR pin it works again for another few seconds and freeze again. And sometimes randomly if I touch the receiving part of the sensor it works but that happens randomly. Not always working. What could be the issue?

Is my oscillator burnt while I was soldering it? Once I connected two 0.33uF polar capacitors and found out that for one second, it takes one minute or more to blink a bulb.

enter image description here enter image description here

$\endgroup$
5
  • $\begingroup$ That is not a schematic, it is a board layout, and an illegible one at that. Can you post a picture of the solder at the sensor(s) that aren't working? A cold solder joint may cause intermittent connection issues. $\endgroup$
    – Chuck
    Commented Dec 19, 2015 at 4:02
  • $\begingroup$ @Chuck I've added a picture of the pins under the board.They seems ok and conduct current when I checked from a multi-meter. $\endgroup$
    – Padmal
    Commented Dec 19, 2015 at 5:01
  • $\begingroup$ In the ICSP block (the 5-pin row to the right of the circled 6-pin row) the two left pins appear to be solder-bridged. On purpose, or not? $\endgroup$ Commented Dec 19, 2015 at 17:30
  • $\begingroup$ No no it's just a styrofoam piece. I covered the underside with a sheet of styrofoam. Today I tried the sensors with the breadboard again and found out that they are not working as they used to be. I have to reset the board to make it work. Are those sensors fried? :( $\endgroup$
    – Padmal
    Commented Dec 20, 2015 at 6:03
  • $\begingroup$ I regard styrofoam as problematic with electronics because of the static charge it can hold. I don't know of a good test for whether HC-SR04's are working ok. If you have a known-good sensor and known-good development system, use that to develop working software before building a board, then try substituting, one at a time, the suspect sensors. $\endgroup$ Commented Dec 20, 2015 at 20:06

1 Answer 1

1
$\begingroup$

In the PCB copper-side picture and the board layout picture, three pins have been left unconnected. If your code has those set as inputs you are likely to get random inputs. Check what your program does with those pins. You can set them to low outputs and leave them low if they are causing problems.

For the other pins (ie those with with traces) if there is nothing yet connected to an input pin that you are reading, you may get intermittent problems like those mentioned in the question. As an interim measure you might tie such pins high or low through 10 KΩ to 40 KΩ resistors.

$\endgroup$
3
  • $\begingroup$ But @jwpat7 When I tried the same pin layout in a bread board, it worked. The only difference I can think of is the oscillator but the Pololu QRT 8RC IR sensor works perfectly fine with this board so it can't be the oscillator too. :/ The non-soldered pins are not used in my code. I'm drawing current from the USB port. Is that current enough? $\endgroup$
    – Padmal
    Commented Dec 19, 2015 at 15:10
  • $\begingroup$ I was experimenting and found something like this. I tried connecting the Vcc pins of my three sonar sensor to a breadboard and had another pin connected to that so I can disconnect the Vcc when ever I want. So when the sensors are frozen I disconnect the power to the sensor and reconnect in a second or two and they work. Is there and noise issue here? Note that I don't have any decoupling capacitors connected. $\endgroup$
    – Padmal
    Commented Dec 20, 2015 at 12:33
  • $\begingroup$ On-board capacitors (eg a 10μF to 100μF in parallel with a 100 nF) are a good idea if you have those sensors on the same board as the micro; or a 10μF cap at the sensor if they are remote. ¶ You should get a logic analyzer and/or oscilloscope to diagnose this issue – eg to find out whether the pulse is going out when you think the sensor's "frozen", but not being detected on its return, or whether the sensor is completely working but your micro isn't working $\endgroup$ Commented Dec 20, 2015 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.