• AVR Freaks

Helpful ReplyHot!PIC32MX: Does overvoltage on an analog input cause reset?

Author
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
2021/02/26 12:14:42 (permalink)
4 (1)

PIC32MX: Does overvoltage on an analog input cause reset?

I think excess voltage on an analog input is causing my pic32mx130F to reset but I don't this behaviour documented anywhere.
 
This has come about bc I'm testing an H-bridge motor driver which will eventually be 12V battery powered.  I was testing using a bench PS set at 12V in case a software bug could cause shoot-thru.  However the regenerative braking was causing the motor emf to discharge into the PS and push the voltage close to 20V which leads to an input pin going above the PIC's 3.3V regulated PS.  
#1
NorthGuy
Super Member
  • Total Posts : 6589
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 12:41:29 (permalink)
0
Robin66
I think excess voltage on an analog input is causing my pic32mx130F to reset but I don't this behaviour documented anywhere.



Look at the "Absolute Maximum Rating" section: "Functional operation of the device at these or any other conditions, above the parameters indicated in the operation listings of this specification, is not implied."
#2
RISC
Super Member
  • Total Posts : 6067
  • Reward points : 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 12:44:57 (permalink)
0
Hi,
what is the full reference of your PIC32MX130F.....?
PIC32MX do not have any circuitry to reset in case of overvoltage on I/O pins.
First of all, if any pin has a risk of getting above Vdd+.03V or below Vss-0.3V you should plan for external protection.
Your reset is probably generated by one of the PIC32MX reset sources (see chapter 6 of the datasheet).
the good news is that PIC32MX architecture let you know which exception took place and which source : https://microchipdeveloper.com/faq:82
Regards
 
 

For support make sure to check first here : http://microchipdeveloper.com
There are hundreds of PIC, AVR, SAM...which one do YOU use ?
#3
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 13:19:11 (permalink)
0
full ref is PIC32MX130F256D-I/PT.
 
My margin on the potential divider used to measure battery voltage is tight.  I did this to compensate for the 10bit ADC resolution. I'll create more headroom and lose some resolution.  I run the PS at 8V and the resets disappeared so it's almost certainly not a code issue  
#4
ric
Super Member
  • Total Posts : 30244
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 13:55:36 (permalink) ☄ Helpfulby Robin66 2021/02/26 13:57:38
5 (1)
This has been documented in other PICs.
If any pin exceeds Vdd + 0.3V, then current will leak into parts of the die that it shouldn't, which can affect the reference for the Brown Out Reset, and BOOM chip resets...
Adopt the anti-Nike mantra, and "just don't do it".

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#5
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 13:57:37 (permalink)
0
Yeah of course. As I said, it was only happening due to a test rig.  Good to know it's something to consider in future if I get intermittent resets.  Thanks a lot
#6
Murton Pike Systems
Super Member
  • Total Posts : 247
  • Reward points : 0
  • Joined: 2020/09/10 02:13:01
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 14:56:53 (permalink)
0
I had an op amp outputting 8 volts but through a 1k resistor into a2d and that crashed it repeatedly.
BAT85 to +ve rail from a2d pin fixes it.
 
#7
boatbodger
Super Member
  • Total Posts : 167
  • Reward points : 0
  • Joined: 2011/03/27 15:39:07
  • Location: UK
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/26 15:01:53 (permalink) ☄ Helpfulby Robin66 2021/02/27 01:07:23
0
Thank you Ric for the detailed explanation of what's going on in the chip - it makes sense.
Robin,
I would always try very very hard to ensure that an input pin cannot possibly go above the supply rail - but that is quite hard to achieve in real life
One obvious way is to add a Schottky diode to "point" any excess voltage back to the supply line but:
  • Schottky diodes have quite a high reverse leakage current and this could affect your A-D accuracy
  • Their forward voltage can easily exceed 0.3V
Another 'Golden Rule' (IMHO) is always catch spikes before they can go anywhere - in other words, think about damping the source of the back-EMF by using a TVS diode (which is a glorified Zener) to 'catch' the spike.
A standard Zener diode has quite a high dynamic resistance, so is not all that good at catching the spikes.  TVS diodes are better, and you may also want to use the TVS to catch the first few nanoseconds, and parallel that with a MOV component to mop up more of the energy (to avoid having to spend a lot of money on a heavy duty TVS.
I realise all the above sounds rather elaborate, but bear in mind that whilst your circuit presently "just" resets the microcontroller, that is only one short step away from frying it - and that will damage bottom line far more than spending a couple of dollars per unit now on bullet-proof back-EMF damage limitation.
I recently did a 'post mortem' on an application which involved some 24V relays.  The headline is that a small relay was generating back EMFs of over 500V if there was no snubber diode in place as of course there should always be.
If anybody is interested, I could post the 'scope captures - which were more extreme than I'd expected.
#8
GeeWhizz
Junior Member
  • Total Posts : 25
  • Reward points : 0
  • Joined: 2020/07/12 03:44:26
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 00:09:29 (permalink)
5 (1)
Robin66
This has come about bc I'm testing an H-bridge motor driver which will eventually be 12V battery powered.  I was testing using a bench PS set at 12V in case a software bug could cause shoot-thru.  However the regenerative braking was causing the motor emf to discharge into the PS and push the voltage close to 20V which leads to an input pin going above the PIC's 3.3V regulated PS.  

If the motor is pushing up to 20V back at the power source (which is shared with the PIC), then you have to start by fixing the hardware.  Something is drastically wrong if you are not restricting back-emf to within the immediate vicinity of the motor. 
  • Do you have a bridge rectifier mounted close to the motor with a hefty electrolytic capacitor on the +/- pins?
  • Does the h-bridge/motor wiring independently go back to the power supply (No shared paths)?
Help us to help you: what current does the motor draw?  What are you using as an H-bridge?
#9
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 01:06:18 (permalink)
0
GeeWhizz
Robin66This has come about bc I'm testing an H-bridge motor driver which will eventually be 12V battery powered.  I was testing using a bench PS set at 12V in case a software bug could cause shoot-thru.  However the regenerative braking was causing the motor emf to discharge into the PS and push the voltage close to 20V which leads to an input pin going above the PIC's 3.3V regulated PS.  

If the motor is pushing up to 20V back at the power source (which is shared with the PIC), then you have to start by fixing the hardware.  Something is drastically wrong if you are not restricting back-emf to within the immediate vicinity of the motor. 



The fix is ensure the regenerative braking has something substantial to discharge into like a battery rather than the electrolytic in the bench PS. I could in software monitor the voltage across the battery during braking and ease off if it’s excessive but in the real world scenario this will not be necessary. It’s a 12Ah lead acid that can accept several amps for a few seconds. The motor is rated 12V 10A and the bridge is 4 NMOS FETs (rated 80A max). I have a relatively small capacitor (220uF) across the h bridge to prevent any spikes due to stray inductance.
#10
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 01:16:54 (permalink)
0
boatbodger
Thank you Ric for the detailed explanation of what's going on in the chip - it makes sense.Robin,I would always try very very hard to ensure that an input pin cannot possibly go above the supply rail - but that is quite hard to achieve in real lifeOne obvious way is to add a Schottky diode to "point" any excess voltage back to the supply line but:
  • Schottky diodes have quite a high reverse leakage current and this could affect your A-D accuracy
  • Their forward voltage can easily exceed 0.3V
Another 'Golden Rule' (IMHO) is always catch spikes before they can go anywhere - in other words, think about damping the source of the back-EMF by using a TVS diode (which is a glorified Zener) to 'catch' the spike.A standard Zener diode has quite a high dynamic resistance, so is not all that good at catching the spikes.  TVS diodes are better, and you may also want to use the TVS to catch the first few nanoseconds, and parallel that with a MOV component to mop up more of the energy (to avoid having to spend a lot of money on a heavy duty TVS.I realise all the above sounds rather elaborate, but bear in mind that whilst your circuit presently "just" resets the microcontroller, that is only one short step away from frying it - and that will damage bottom line far more than spending a couple of dollars per unit now on bullet-proof back-EMF damage limitation.I recently did a 'post mortem' on an application which involved some 24V relays.  The headline is that a small relay was generating back EMFs of over 500V if there was no snubber diode in place as of course there should always be.If anybody is interested, I could post the 'scope captures - which were more extreme than I'd expected.


These solutions are to fix transient noise spikes. My problem was that the 12V line was going to 20V for a few seconds as the motor discharged into the power supply. The power FETs are driven from the PIC32 directly so the switching is relatively slow. And I don’t want to dump the motor’s inertial energy as heat on the board. Pushing it back into the battery is ideal. I should have anticipated that my test rig would allow the power PS V to exceed design tolerances (which were too tight anyway).
#11
blue_led
New Users
  • Total Posts : 146
  • Reward points : 0
  • Status: online
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 02:19:17 (permalink)
5 (1)
The back EMF is faster than any software or PIC, even Intel Xeon can't have that speed.
Without additional diodes on your circuit, the H-bridge itself passes EMF back into the battery or source through reverse intrinsic diodes on any mosfet.
At any time during regenerative braking you will have 2 of these diodes directly polarized and you will have 2 x Vf_reverse_diode + I_brake_motor x R_int_ battery added to the battery voltage. The bench power supply cannot swallow this energy and it is overcharged and a lead acid battery, even discharged, especially discharged, can exceed 15 volts at high currents, it does not behave like a Zenner diode. Making some rough estimates and starting from a battery with a voltage of 13.5 - 15 V gathering only 2 Vf I approach or exceed 20 V.
The power supply to the PIC should withstand sudden increases in voltage at the input, you should insulate the FET grid control as well as possible and improve the battery voltage measurement circuit not injecting current into PIC imputs. I think even a humble 100k resistor on divider can do that.
If you want to recover energy by regenerative braking, quite complex circuits must be used and a battery is not suitable.
Only supercapacitors are suitable for this by withstanding very high currents and having symmetrical charging and discharging behavior. They are already used for this purpose in electric forklifts, battery and supercaps complementing each other.
 
post edited by blue_led - 2021/02/27 02:22:26
#12
Robin66
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2016/05/24 12:04:24
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 02:41:54 (permalink)
0
Thanks for the advice. It makes sense for a commercial application but this is for a kids motorised dumper truck so it’s overkill. I’m not going to invest in super caps. The purpose of discharging into the battery is to dissipate energy, not to meaningfully recover energy. And the peak currents are modest and easily controllable. The braking does not need to be harsh. During braking current is built up in the motor’s inductance by turning on both lower FETs. Then one of the FETs switches off and the inductance discharges via the upper FET into the battery. The PWM duty cycle on the lower FET will govern the rate of braking.

The potential dividers on the PIC inputs are already high impedance (now 100k+470k, was 100k+330k) so I think it unlikely a few uA will fry anything on the inputs. The offset error due to input leakage current is acceptable .
#13
GeeWhizz
Junior Member
  • Total Posts : 25
  • Reward points : 0
  • Joined: 2020/07/12 03:44:26
  • Location: 0
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 09:19:19 (permalink)
4 (1)
One option is to use optoisolators on affected digital input pins.  If an ADC reading is required, after calculating the worst case scenario, use a resistor voltage divider with a capacitor to create an integrator to calm the worst of the voltage spikes.
#14
boatbodger
Super Member
  • Total Posts : 167
  • Reward points : 0
  • Joined: 2011/03/27 15:39:07
  • Location: UK
  • Status: offline
Re: PIC32MX: Does overvoltage on an analog input cause reset? 2021/02/27 12:32:04 (permalink)
4 (1)
Just be aware that the damage to the PIC is not necessarily caused by the microamps flowing from your circuit - the danger is that those microamps turn on parasitic transistors which could allow much higher currents to flow - and cause damage.
 
Given you already have a potential divider, and that it is pretty high impedance, I would split the upper resistor in two, and use a Zener to control the upper limit at that point, choosing the resistor value split such that you can use a commonly available diode e.g. 7.5V
 
Some capacitance at that point would take the sting out of any remaining transients, but how much 'C' you can add will depend on how much delay you can tolerate on the A-D readings.
With all that said, if this is essentially a hobby project, and replacement of the PIC would be "a bit of a nuisance" rather than destroy the reputation of a product, you probably don't need to worry as much as one would have to if the reverse were the case :)
 
Wish my Dad had made me a dumper truck...
#15
Jump to:
© 2021 APG vNext Commercial Version 4.5