Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Automotive Generator Universal Digital Voltage Regulator

Status
Not open for further replies.
I think I have smoked the MCU input that I was using for tach input. I made a mistake in my wiring:

Screenshot from 2022-01-23 21-34-40.png

That D9 input is supposed to be 5 V tolerant, but I guess it can't tolerate 6-7.5 V at unlimited current.

I was hoping to use that input and a timer as a frequency counter to determine RPM. This worked fine with a signal generator on the bench. However, I'm picking up the signal from the line that goes from the contact points in the distributor to the spark coil, which I was thinking this would be a 0-6 V (nominal) square wave. But, now I'm wondering if there might be some high voltage there as the points open and the field collapses, and if my little 10 nF bypass capacitor and the Zener will be sufficient.
 
That D9 input is supposed to be 5 V tolerant, but I guess it can't tolerate 6-7.5 V at unlimited current.
You need a high value series resistor at the input, eg. 100K or so - the points could have pulses of hundreds of volts...
The HT coil and distributer "condenser" form a resonant circuit that rings at rather extreme levels when the points open.

Add schottky clamp diodes to both power and ground, plus a small filter cap to ground at the MCU side.

I'd then also add another series resistor from the clamp/filter to the actual MCU pin, probably 10K, as belt-and-braces protection to avoid any possibility of excess pin current under fault conditions.

eg. Forming a "T" filter; resistor from input, clamp and cap, resistor to MCU.
 
a small filter cap to ground at the MCU side.
Like, how small? I think the smallest I have on hand is 10 nF. 100K x 10 nF gives a time constant of 1 ms. I'm looking at 20-200 Hz, I think. 3.3v digital input; logic high would be 2v. If I'm switching 6v, I guess I'll get to 2v in half a millisecond, so 200 Hz is no problem, right?
 
Like this?
Screenshot from 2022-01-24 10-44-05.png

or perhaps
Screenshot from 2022-01-24 10-50-45.png


The BZX55C3V3 is a 3.3v Silicon Planar Zener Diode. I guess you know the 1N5817 is a 1.0 AMP Schottky Barrier Rectifier.
 
Last edited:
Almost; not zeners, just schottky diodes to the MCU 0V and positive supplies, to limit the voltage to that range.
 
...
The HT coil and distributer "condenser" form a resonant circuit that rings at rather extreme levels when the points open.
...
Wow, you weren't kidding:
points.png

I just got a new (virtual) oscilloscope (owon VDS1022I) and decided to do some probing. That's at 50 V/div!

The generator field coil looks calm in comparison. I couldn't get much of a waveform, just a line going up and down. I did get this with AC coupling:
field2.png

(that's with the original voltage regulator back on the car).

Test conditions:
PXL_20220124_223141897.jpg
 
Arrrrgh.

This whole RPM input thing has been a lesson to me. It was an afterthought; something I added just before sending the board off when I was trying to think of things I might wish I had allowed for. I even marked it "Possible RPM input". I probably hadn't really thought it through, but as time went by the idea of having RPM as an independent variable in my datasets grew on me. Weeks went by, I got the boards, brought one up and bench tested it, and the RPM input looked OK with a signal generator even though it was a straight line to the MCU GPIO. So, when I put the thing on the car for the first time, I hooked up that wire to the ignition points, and since it was a straight line to a 3.3v (5v tolerant) GPIO it blew up that input. Once I realized that the input was blown, I cut the pin off and reworked the board and firmware to use another input with rjenkinsgb's (thanks!) circuit. I even took the board (without the MCU daughter board) and the scope out to the car and the signal looked good even without the 3.3v upper limit in place (it comes from the daughter board). Everything looked good on the bench except that the MCU was running very hot (~120 °C) and drawing a lot of current. Reluctantly, I switched to my one spare MCU eval board. Today I put it on the car and immediately fried that chip the same way I had fried the other. I had forgotten to cut off the pin. I think I considered it once, but thought that it would just be acting as an analog input anyway, so what's the harm; forgetting that there was still a straight line from the ignition points to the pin. So, now I have cut the PCB land so I don't make that mistake again.

That leaves me with two boards with one blown input that is about 7.5 Ω from ground and about 4 Ω from 3.3V. Amazingly, both still run, but I don't know for how long. (The chip on the eval. board is the cheap version that's only rated to 85°.) When I damaged the first one I immediately went to order a new board or two, but, of course, with the chip shortage... I finally found a couple today at Verical (for $22 each), and I should have those in a week or so.

I might try to limp along with one of the damaged boards to at least get in a first test drive or two. So close! The only thing that has really gone wrong (at least so far) was a late feature addition, but that has caused me a lot of grief.
 
The tachometer almost works. Sometimes it gets good readings, but sometimes they are absurd. This is what I'm seeing at the MCU pin now:
A4.png

and at a higher RPM:
a4.2.png

Do I need another capacitor? Smaller? I have some spare SA18A transient suppression diodes. Would it help to add one of those on the front? I already have the STM32 TIM2's "Input Filter" set to the maximum.
 
OK; I think the extreme voltage is messing up the filter effect, as the "cutoff" is a proportional reduction of the input.

Add a second series resistor (47K?), after the clamp diodes but before the filter capacitor.
If the response is then too slow, try reducing the input resistor that feeds the clamp to 47K.

With the input to the second resistor & cap filter limited to 3.3V, it should work much better.

Also, is the pin you are using on the MCU set as a schmitt trigger? That would reduce any side effects or spurious triggers from the slow ramp that appears in the waveform.
 
Here's what I'm seeing on the D+ generator terminal:
D+.png


This is what I have now for protection/conditioning:
Screenshot from 2022-01-29 16-36-49.png

(Here it is in context: https://easyeda.com/editor#id=|98310162beb34c76a49f2d1b0163180b)

I don't think it is doing much good. I guess the spike from the commutator brushes is always going to be negative. Would a Shottky diode be a better choice? Is there any point in having a bypass capacitor? Will this have any impact on the lifetime of the brushes?
 
OK; I think the extreme voltage is messing up the filter effect, as the "cutoff" is a proportional reduction of the input.

Add a second series resistor (47K?), after the clamp diodes but before the filter capacitor.
If the response is then too slow, try reducing the input resistor that feeds the clamp to 47K.
Like this?
Screenshot from 2022-01-29 16-53-38.png

With the input to the second resistor & cap filter limited to 3.3V, it should work much better.
Makes sense.
Also, is the pin you are using on the MCU set as a schmitt trigger? That would reduce any side effects or spurious triggers from the slow ramp that appears in the waveform.
I don't think I have any option for that. The timer/counter has a digital filter:
Input capture 1 filter
This bit-field defines the frequency used to sample TI1 input and the length of the digital filter applied
to TI1. The digital filter is made of an event counter in which N consecutive events are needed to
validate a transition on the output:
0000: No filter, sampling is done at f DTS
0001: f SAMPLING =f CK_INT , N=2
0010: f SAMPLING =f CK_INT , N=4
0011: f SAMPLING =f CK_INT , N=8
0100: f SAMPLING =f DTS /2, N=6
0101: f SAMPLING =f DTS /2, N=8
0110: f SAMPLING =f DTS /4, N=6
0111: f SAMPLING =f DTS /4, N=8
1000: f SAMPLING =f DTS /8, N=6
1001: f SAMPLING =f DTS /8, N=8
1010: f SAMPLING =f DTS /16, N=5
1011: f SAMPLING =f DTS /16, N=6
1100: f SAMPLING =f DTS /16, N=8
1101: f SAMPLING =f DTS /32, N=5
1110: f SAMPLING =f DTS /32, N=6
1111: f SAMPLING =f DTS /32, N=8
where I am using 1111 and f DTS is 500,000 Hz (the counter frequency) at the moment. Looking this up, I see that I can divide that by 2, 4, or 8 (without affecting the counter frequency), which might help.

Thanks for your help!
 
Like this?
Exactly like that.

OK on the digital filter, that's fine, better than a schmitt trigger!

With the settings you have, and if I'm understanding it correctly, the input has to be stable for 512uS (2uS * 32 * 8) for the level to be recognised, which I think should be OK.
 
Exactly like that.

OK on the digital filter, that's fine, better than a schmitt trigger!

With the settings you have, and if I'm understanding it correctly, the input has to be stable for 512uS (2uS * 32 * 8) for the level to be recognised, which I think should be OK.
I calculated the same. I thought about doubling it to 1 ms, but that could be a little marginal at high RPM, since it is not a 50% duty cycle but depends on the dwell angle of the points. [I never had a good way to measure the dwell; it's hard to find good tools for 6V systems these days. I just set the gap and left it at that. But now I can measure the dwell very accurately!] I might give it a quick try anyway, since it only takes a few minutes to update the firmware. With the unit still mounted in the car I can use my laptop to flash it over USB.

Meanwhile, I am having problems with the SD card. I added a 100 nF capacitor right on the Vcc & Gnd pins, and Vcc looks flat on the 'scope (and it's dead nuts on 3.33V), so I don't think it's that. Now, I'm suspecting bad connections due to vibration. I currently have the daughter board header stuck into a header socket on the main board, and it seems like a pretty loose fit. I'm going to try soldering the daughter board pins directly to the main board and see if that helps. For the next rev. I think I will use a hinged microSD socket like this Clamshell SMD SD Card Connector.
 
I breadboarded the filter and I think it will do the job:
points filter breadboard.png

CH1 is a square wave + 10 kHz sine, CH2 is the filter output. I tried various other inputs, but it's hard to simulate that ringing from the ignition circuit.

PXL_20220130_195737288.jpg
 
Good news: the rev. counter is working beautifully, on the car! Thanks rjenkinsgb.

Bad news: still having problems with the SD card. Apparently, the problem was not bad contacts & vibration. I did solder the daughter board directly to the main controller board, and even gave it a vibration test on the bench:
PXL_20220131_223458615.jpg


So, I took a closer look at Vcc on the SD card socket, and found there is a periodic short, sharp spike. Blown up, it looks like this:
sd vcc noise.png


It correlates nicely with the spikes on D+ (from the generator armature brushes) that I posted about a few days ago:
vcc d+.png

CH1: the Vcc pin on the SD card socket
CH2: D+ terminal on voltage regulator
The spikes vary in size; this is one I happened to get while trying to keep the scope wires out of the fan belt while revving the engine with one hand and hitting the (virtual) Single Trigger button with the other hand on the PC touchpad.

My 100 nF bypass capacitor, which you can see in the top photo, doesn't seem to be doing the job. My 3.3v supply is dropping to below zero. The spike seems to be, maybe, 20 ns, with some (28 MHz?) ringing. I saw similar spikes looking at the data lines.

The 3.3v supply is two LDO regulators downstream from B+, which is a fat wire to the car battery. D+ feeds B+ through the big 82CNQ030 diode.

How can I fix this? Would another, smaller (?) capacitor help? E.g., I could put a 10 nF in parallel with the 100 nF. Do I need a ferrite bead or something?

It's interesting that the MCU doesn't seem to be bothered by this, but of course it steps down the voltage once again to something like 1.7 V. SD Cards are capable of some very high speeds these days, so these pulses are probably more than enough to confuse one.
 
Last edited:
Are you getting any voltage on the SD ground/0V compared to the MCU ground? If the top board is connected to the power circuit ground at more than one point, it could be voltage drop in the power wiring being transferred through and messing things up.

If the ground is clean, try a combination of capacitors, one at least ten times the other.
(I don't have time just now to go back through the thread and work out the interconnections etc.)
 
Are you getting any voltage on the SD ground/0V compared to the MCU ground? If the top board is connected to the power circuit ground at more than one point, it could be voltage drop in the power wiring being transferred through and messing things up.

If the ground is clean, try a combination of capacitors, one at least ten times the other.
(I don't have time just now to go back through the thread and work out the interconnections etc.)
I did look at the grounds. The ground at the SD card is about 40 mV above the battery ground, but looked fairly clean (from a quick look). At the moment, there is only a single wire connecting ground to the controller board (I think it is 18 gauge), and there is only one pin from the ground plane in the controller board to the SD card board (now soldered on both ends). I will have to look at the SD ground - MCU ground. The MCU is socketed, but it does have two ground pins and both go to copper pours at GND on both the top and bottom layers of the controller board.
PXL_20220201_162830031.jpg

Black wire is the ground that goes to the header on the controller board. There is a stainless steel star washer between the ring terminal and the frame. This frame is bolted to the generator.

To me, it's pretty impressive that the inductive kick from the generator (I think that's what it is) is able to suck all that heavy 6 V stuff below zero. Naively, I though that B+ would be immune, being connected straight to the big car battery and all.

Luckily, I have a two pin header with a jumper just downstream from the MIC2937A-5.0WT 5 V LDO regulator, before the LD39050PU33R 3.3 V regulator on the MCU eval. board, which is what provides power for the SD card. I'm thinking that might be a good place to try some inductors*. This seems to be the kind of thing that's hard to solve analytically, so I was thinking of ordering a few different ferrite beads and experimenting. I'm looking at these:
These things don't cost much, so I'm thinking they might be worth a try.

Meanwhile, I will try adding some caps. I have plenty of 10 nF, so I'll stick one of those on. These are the only other smallish caps. I can scrounge up at the moment:
PXL_20220201_171548192.jpg

(I'm not sure what these are. 5 nF, 103 nF, and 473 nF?)

Maybe that .005 disc capacitor looks promising?

If I'm ordering some ferrite beads anyway, what caps should I throw in?

* EDIT: Come to think of it, it would be even easier and maybe more strategically located to just stick them in the fuse holder that is upstream of everything on the controller board.
 
Last edited:
Either a choke, low value resistor or both to isolate the B+ from the regulator input should help.

Also a large, eg. 10uF, multilayer ceramic across the input to the regulators, as well as 0.1uF ceramics across each regulator output.
 
Either a choke, low value resistor or both to isolate the B+ from the regulator input should help.

Also a large, eg. 10uF, multilayer ceramic across the input to the regulators, as well as 0.1uF ceramics across each regulator output.
Thanks!

I have decided I'll wait a while for the new MCU boards to show up. The weather's too cold for working on the car anyway. Given the damage to the MCU, who knows what that might be doing. For sure, it has increased the current draw from 40 mA to 400, which is bound to affect the required capacitance. And that's on the B+. The LD39050PU33R 500 mA low quiescent current and low noise voltage regulator on the MCU board is tasked with powering the smokin' hot MCU as well as the SD card at 3.3v, so I'm probably exceeding its rating. Hopefully things will look a lot better with a new MCU board.

I did order some ferrite beads. If I still have a problem I'll pull the fuse and try sticking in those, a low value resistor, and a 1N5817-T schottky (I'm thinking the switching time of the big 82CNQ030 SCHOTTKY RECTIFIER Cut Out Diode is far too slow to check this pulse, and maybe it goes further below zero than I can see with my 'scope). And, of course, adding caps.

You mentioned a choke; are you thinking pure inductance would be more appropriate than a ferrite bead? I guess the theory with the beads is that they dissipate energy (to avoid ringing?). But they seem to be targeted to upward spikes (or actual RF interference). In this case maybe it's better to have a reserve of energy stored to supply current (in both directions) during the negative spike? This is all uncharted waters to me.
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top