Solenoid power source fried RTC circuit

Hi there, first time on the forums here. I am building a project that has MOSFET-controlled solenoids and a RTC chip (DS1307). I wired up and got both parts working separately, but when I combined them on the same breadboard and turned on the 12V supply, the RTC stopped reporting the current time. It is now stuck on the exact time I switch the 12V on. I believe the chip itself is still fine (as the Arduino is still able to communicate with it), but I think it may have fried the 32.768K crystal.

Here is my setup:
-Everything is setup on a double power rail breadboard. One rail is 5V supplied by the Arduino, the other is fed by an external 12V power supply. Both ground rails are connected together (since the MOSFETs require a shared ground between the 5V and 12V sources).
-The RTC is setup exactly like this guy's: DS1307 Real time clock on breadboard - Exhibition - Arduino Forum It is feeding off the 5V board power.
-For the solenoids, I am using 2N7000 MOSFETs to control the 12V supply they need. I have a diode across the leads of the solenoid to prevent backflow due to the impedance of the coil. The MOSFETs have pulldown resistors to ensure that they turn off. Attached is a picture of just the solenoid setup:

I am concerned that the shared ground has somehow destroyed that sensitive crystal. Any ideas/suggestions on how to protect it? I am a relative noob to microcontrollers/sensitive components.

Thanks!

Looks like you've learned the hard way that power grounds should be separated from signal grounds. Most if not all Arduinos have more than one ground pin. Use them as follows:

  • One to connect the source terminals of the mosfets and the gate pulldown resistors (and the -ve side of the 12V supply unless you are feeding it through the barrel jack, which is best)
  • One to connect the RTC and other logic devices
  • One to connect the ground sides of any analog sensors you are using.

The issue is that the resistance and inductance of a shared ground wire can lead to voltage spikes on it when the solenoids switch on or off. That said, I doubt that the crystal had been damaged. Possibly the one of the 2 pins connected to the crystal has been damaged. On some chips, one of the crystal oscillator pins doesn't have any antistatic protection, because to do so would increase the current consumption - but I don't know whether this applies to the DS1307.

How much current do the solenoids take? The 2N7000 is rated at only 200mA.

Ah, that makes a lot of sense. I just assumed (incorrectly) that all of the grounds on the board were the same. So are you saying that you think the RTC is fried or that something can be done to recover it?

The solenoids are 12v 200ma and are being used in what I would consider to be a "pulsed" manner. I realize they push the limits of the 2N7000, but I figured I would give them a shot since 6 of those were US$1.20 and my next option (at my local hobby store) would have been $16. I have let them run their test cycle for a couple of hours without any issue (including no perceptible heat). Am I risking anything more than those MOSFETs?

Thanks for all of your help!

ugoleftillgorite:
Ah, that makes a lot of sense. I just assumed (incorrectly) that all of the grounds on the board were the same. So are you saying that you think the RTC is fried or that something can be done to recover it?

I suspect the RTC is fried, but check that the crystal wires are a firm push fit in the breadboard before you give it up. If the crystal wires are too fine for the breadboard, you may have to solder thicker wires to them.

ugoleftillgorite:
The solenoids are 12v 200ma and are being used in what I would consider to be a "pulsed" manner. I realize they push the limits of the 2N7000, but I figured I would give them a shot since 6 of those were US$1.20 and my next option (at my local hobby store) would have been $16. I have let them run their test cycle for a couple of hours without any issue (including no perceptible heat). Am I risking anything more than those MOSFETs?

When breadboarding or prototyping with non-SMD parts, for switching 200mA I would have used NPN transistors such as BC337 and a 470 ohm base series resistor, instead of the 2N7000. You only need mosfets if you are switching more than about 400mA from an Arduino.

Thanks for the suggestion, I will try that when I get home. My transistor/MOSFET choice was based on what was available at my local store. Their biggest NPNs were rated for 100ma, and the next level up on MOSFET was a NTE2985 (way overkill). I'll keep an eye out for that BC337, seems like it would be a great one to keep around.

Edit:
Also, another dumb question I'm sure, but will it be safe to eventually power both the Arduino and the solenoids off of the same 12v power supply? Right now I am using USB for the Arduino. I am worried about power fluctuations in both directions when the coils turn on and off. What can I do to ensure a steady voltage supply to the Arduino while the solenoids are cycling?