I'm using Atmega128L controller. One of the primary tasks is to control a linear actuator. The actuator supply and controller supply are different(initially it was designed to share a common ground). The relays that are used to control the actuator uses the same supply as the controller. All other inputs and outputs are through isolation. The 3.3V line to the controller is not that noisy, even during relay turn on turn off.

The issue I'm facing is related to microcontroller reset. This reset occurs when the actuator hits the inbuilt electrical limit switch(which cuts off motor power). Apparently this is the time when the motor uses maximum power.

The code flow is in such a way that a normal reset wouldn't affect its functionality. It would recover seamlessly. However when the reset occurs, the controller seems to malfunction, skips done part of code, not following proper initialisation procedure, executes functions which are in memory but are not called anywhere in the current code. Because of this the controller shows some illogical error state (as per code), or corrupts the Ic's that it is interfaced with. Most of the time a proper power on reset or external reset makes the controller work properly.

How can I make sure that the controller gets reset properly?

Edit: Pardon me for the poor handwriting. overall circuit design

Edit: I don't deny that there is a noise in nanosecond range in 3.3V supply. I'm very much concerned about the controller's response to the noise. I expect a proper brownout reset or watchdog reset when the noise occurs, instead of PC jumping to random location or stack getting corrupted.

My controller works with 8Mhz external clock, Max speed is 8Mhz

  • 1
    \$\begingroup\$ Atmega128 cannot execute code from RAM (unless you run like an interpreter program). Check the supply voltage with a scope and turn the brownout fuse on. \$\endgroup\$
    – Turbo J
    Nov 1, 2017 at 18:22
  • \$\begingroup\$ Does the micro at the actuator share any part of the power supply? That is, is the 3V3 derived from the actuator's supply? Edit: I was going the same way as @TurboJ, sounds like brown out. \$\endgroup\$
    – awjlogan
    Nov 1, 2017 at 18:22
  • \$\begingroup\$ @TurboJ brownout is enabled for 2.7V. \$\endgroup\$ Nov 1, 2017 at 18:32
  • \$\begingroup\$ @awjlogan there's only a logic board in the actuator, and all interfaces are through option couplers. there is some noise during the limit switch activation. \$\endgroup\$ Nov 1, 2017 at 18:34
  • \$\begingroup\$ Do you have a flyback diode on your relay? If you could post a schematic, that would be helpful :) \$\endgroup\$
    – awjlogan
    Nov 1, 2017 at 18:39

1 Answer 1


You have given very scant information, so specific comments are not possible. Here are some general things to look at:

  1. Make sure the microcontroller and all other chips are properly bypassed. There should be a 1 µF or so ceramic cap physcially close to each part across the power and ground pins. If you haven't done this, all else is pointless.

  2. Look carefully at your ground. Ideally you have a ground plane under all the low power circuitry. This can be connected in at most one place to external ground if you want to. Make sure that the motor current, including its ground return currents, don't flow near the low power section.

  3. Look at the 3.3 V line with a scope right at the micro. Set the trigger to falling edge, and a little lower voltage than what it actually is, like maybe 3.1 V. If the scope triggers when the motor shuts off, then you messed up the separation of the ground and/or power between the low and high power sections.

  4. Consider that there may not be a electrical problem at all. You may have a firmware bug that causes strange things to happen when the motor is shut off. Replace the motor with a resistor that draws significantly less than the motor. If it still happens, then a power glitch from the motor shutting off is unlikely the cause.

  5. Your FET gate drive makes no sense. I can't even guess what you think a emitter follower does for you. What it actually does is reduce the maximum gate voltage by about 600 mV. The emitter follower gives you current gain, but there is no point to that since a few µs longer turning on the FET seems irrelevant from your description.

  6. Make sure the FET can work with the low gate voltage you are giving it, and the 24 V it has to withstand when off. You should be using a FET rated for at least 30 V D-S, and specified with sufficiently low Rdson at a bit below 3.3 V gate drive. This assumes you fix the gate drive circuit first.

  7. Make sure the reverse diode across the relay coil is functioning and really connected.

  • \$\begingroup\$ Except for point 2 everything I verified once again. There are nanosecond ripples in 3.3V during relay switching. And it's fine as long as brownout reset kicks in. The issue is instead of proper brown out reset, I feel PC is jumping to random location or stack is getting corrupted. Sorry for the delayed response. \$\endgroup\$ Nov 4, 2017 at 17:02
  • \$\begingroup\$ Updated the question details section. \$\endgroup\$ Nov 4, 2017 at 17:09

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.