Need help with voltage spike prevention in a car application

I'm having trouble with voltage spikes due to noise that resets the Arduino Mega 2560. I have 2 analog inputs that are attached to an AS5600 magnetic encoder that has 5v, ground, and a 0-5v analog signal output. The cable is 3' long and is shared with 12v power supplied to a motor. When the motor hits a limit switch, the spikes occur. On the desktop using a 12v DC adapter, a simple 10k resistor on the signal line prevented the Arduino from rebooting, however once in the car with 13-14.5v the reboots came back. I'm certain the signal input is causing the reboot. If I detach it and spoof the signal, the problem goes away. (or if I stay off the limit switches)

I can't replace the cable so I need to come up with a solution to prevent the arduino from rebooting due to the analog signal input. I know very little about electronics so determining which parts to use / purchase are beyond my knowledge. Some kind folks tried to point me to some articles on how to fix the issue in general, but it's just beyond me to know what parts to get in my application. Can anyone here please help me with a setup? TY!

Note: this is for an active wing application used at the track. See my IG link in bio for pics.

[u]Here are some voltage-protection circuits[/u].

DVDdoug:
[u]Here are some voltage-protection circuits[/u].

After the 100 ohm resistor, I would connect the following zener diode between my signal and ground? So my output signal would still show 0-5v based on encoder position, but if it hits 5.1v, it'll cap there?

NTE Electronics 1N5338B Zener Diode, Axial Lead, 5W, 5% Tolerance, 5.1V

The article mentions a capacitor. What size, etc? Could you recommend a part number?

"I show 100 Ohms at R1. This is just a default value. You want as high a value as you can use, given the bandwidth of the signal you're sampling and the input current needs of your ADC."

When he says a high value - does that mean a 10k resistor or a 1 Ohm resistor. High meaning more ohms or larger number? TY

Use the internal voltage reference , and potential dividers in the inputs to get the voltage down to 1v .
This has the advantage that it is more accurate and, as the inputs are still protected to 5v , that means an input voltage of around 60 volts won’t over load the input giving good spike rejection.

hammy:
Use the internal voltage reference , and potential dividers in the inputs to get the voltage down to 1v .
This has the advantage that it is more accurate and, as the inputs are still protected to 5v , that means man input voltage of around 60 volts won’t over load the input giving good spike rejection.

My signal input is 0-5v. If I do this, wouldn't my input lose 80% resolution when calling analogRead since it would only show 0 to (1024/5)? Ty

I tried using 104 capacitors I had, and the zener I listed earlier.

Is this set up properly? The wires to the left are input from each encoder and the wires on the right go to A0 and A1.

Ty

Google Photos

If you are sure you cannot properly separate the signal and power wiring, then an option is to regenerate the signal at the location you are going to use it. Perhaps a Schmit trigger circuit or something similar would regenerate the signal.
Paul

An analog signal? :astonished:

Internal 1.1V reference is not based on Vcc so will not effect accuracy if Vcc <5V.

raschemmel:
Internal 1.1V reference is not based on Vcc so will not effect accuracy if Vcc <5V.

Wow, ok. I have no idea how this is set up. Do you have an example I can use? Thanks!

Since our AS5600 output is proportional to Vdd and the Arduino external reference is Vdd then if they are both the same the error will cancel.

JohnRob:
Since our AS5600 output is proportional to Vdd and the Arduino external reference is Vdd then if they are both the same the error will cancel.

I'm totally lost here. Sorry.
I have the AS5600 encoders connected to 5v and ground pins on the mega 2560. Is that wrong? I do see on the AS5600 datasheet it lists Vdd. Is that not what I've connected to? Ty!

To use the internal reference voltage

What are you doing to suppress voltage surges from the motor? How about a wiring diagram?

JCA34F:
What are you doing to suppress voltage surges from the motor? How about a wiring diagram?

The motor is isolated on the motor controller. It has its own 2 dedicated wires connected to a 12v accessory line and ground, however they are unshielded in the same harness as the encoder wires. Noise when the motors hit the internal limit switches is getting through and causing the spike that resets the arduino I originally mentioned.

CrossRoads:
To use the internal reference voltage

analogReference() - Arduino Reference

So, after setting the analogreference to INTERNAL1V1, I need to use resistors via voltage dividing to get the encoder signal 0-5v down to 0-1.1v and when I use analogread on the encoder input (A0 & A1), it will return 0-1023 for 0-1.1v?

Looks like 270 and 75 ohm resistors will give 1.09v is that ok?

You don’t lose any resolution by using a voltage divider then also the internal reference.
You get 0-1023 for 0-1.1volts. Because of the divider , that corresponds to the range of your input .

THANKS EVERYONE!

Using the analogReference seems to have worked. Using 270 & 75 ohm resistors will work once I get a voltage regulator that holds exactly 5v - the arduino on the desktop via USB is currently only putting out about 4.56v so I had to add a software scalar to bring the range back to 0-1023 when using the 270 & 75 ohm resistors.

Voltage Dividers - SparkFun Learn is what I used to calculate the resistors to use.

Thanks again!

Wanted to followup.

Everything is great - thanks again all! I've had 2 track events now including F1 Circuit of the Americas and I have no spike / reset issues with the wing.

Here's a couple clips of it in action.

Serious question (or at least not sarcastic). I don't follow this type of event and am curious about the dynamics.

What might make you spin out? I see 1.43 G's in a (modified) Mustang chassis?