# Automotive Generator Universal Digital Voltage Regulator

#### KeepItSimpleStupid

##### Well-Known Member
Whichever MCU you use, I'd add a precision voltage reference (2.5V ?) so the ADC readings are consistent rather than being proportional to the device supply voltage.
Most automotive sensors are ratiometric which is, in effect, better. You just have to be aware and be ratiometric to the right voltage.

#### CK3

##### New Member
I found a little more information about the Clover Systems regulator, which no longer is available, as far as I can tell.

From the DRM Electronic Dynamo Regulator INSTRUCTION MANUAL:

In the DRM, the output voltage of the generator is compared to a precision
voltage reference. When the generator output exceeds this reference, the
current to the field coils is cut off. This causes the generator output to fall.
When the output falls below the reference voltage, the field current is turned
back on. In this way, the field current is modulated at a rate of 50 – 125 Hz.
These rapid changes are smoothed out by the inductance of the field coils, thus
maintaining a constant output voltage.
Current limiting is accomplished in the same way. Output current is sensed
with a Hall-Effect device that detects the magnetic field created by the output
current. When the output current exceeds a preset limit, the field current is
turned off. Just as with the voltage regulation, the field current is modulated to
maintain a constant output current.
Instead of a cut-out relay, DRM uses a MOSFET “ideal diode”, which is much
more efficient than Schottky diodes. Power is supplied whenever the dynamo
output voltage is greater than the battery voltage, rather than a pre-set voltage as
in the mechanical regulator.

So, they used a Hall-Effect current sensor and a MOSFET “ideal diode”.

#### CK3

##### New Member
...

Personally, I'd use a mid-range PIC as the controller; they have all the facilities needed and you can get a PCB made at JLCPCB, with a surface mount PIC ready assembled (along with any other surface mount parts).
...
JLCPCB looks like a great service! Do you use EasyEDA?

#### CK3

##### New Member
Going back to the design, I think it makes sense to start by picking the MCU, since some of the peripherals might depend on that. (However, I'd like to keep the design modular enough that it could [relatively] easily be ported to another MCU.)

I've looked at a few options, and I'm still open to suggestions. Here is what I've looked at so far:

STM32G431KB (Datasheet):
• More than enough processing power and memory: Arm® 32-bit Cortex®-M4 CPU
• Plenty of GPIOs: Up to 86 fast I/Os
• Plenty of ADCs: 2 x ADCs 0.25 µs(up to 23 channels). Resolution up to 16-bit with hardware oversampling, 0 to 3.6 V conversion range
• 4 x ultra-fast rail-to-rail analog comparators
• 3 x operational amplifiers
• Internal voltage reference buffer (I'm not sure what this is. Can it provide a reference voltage for the ADCs?)
• Good price: $5.50 in quantity 1 from Mouser • Operates in the -40 to +85 °C (+105 °C junction) and -40 to +125 °C (+130 °C junction) temperature ranges from a 1.71 to 3.6 V power supply • Development board: STM32 Nucleo-32 development board with STM32G431KB MCU, supports Arduino nano connectivity. ($12)
• The STM32 Nucleo-32 board does not require any separate probe as it integrates the ST-LINK debugger/programmer.
• The USB port could be used for attaching a terminal for configuring the voltage regulator.
Teensy 3.2:
• 32 bit ARM processor.
• Plenty of flash and RAM
• 2 x ADCs, 21 channels, 16 bit
• 3 comparators
• All programming is done via the USB port.
• Compatible with Arduino Software & Libraries
• This might be an advantage for other hackers that are familiar with Arduino
• Reasonable price: $19.80 • Temperature range? Chip says "MX20DX256"; not sure what that is. PIC18F26K80: • 8 bit processor • 12-bit ADC, 8-11 channels • Very low price:$3.01 in quantity 1
• Two built-in precision voltage references
• Requires a probe for programming
• Temperature measurement using on-chip diode channel
• Ambient temperature under bias: -40°C to +125°C
• Development board? (PIC18 Explorer Board) (PICDEM 2 Plus)
To me, the STM32G431KB looks like the Cadillac, but it is very affordable. For the first iteration, I'd like to use that STM32 Nucleo-32 development board (User Manual), since it has the USB port, oscillator, and other supporting electronics. I like the idea of getting a PCB made at JLCPCB, but I'm considering starting with one that has a socket for the NUCLEO-G431KB board, just to make it easier to get started. Heh, the NUCLEO-G431KB has an Arduino™ Nano V3 expansion connector; maybe one could plug a Teensy 3.2 into the same socket.

I also have been working a lot with ARM Cortex-M4, so it is familiar to me. I built a datalogger on one (carlk3/FreeRTOS-FAT-CLI-for-PSoC-63 ), and I have some ideas about putting an SD card into the voltage regulator so that I could collect data from real-world testing. Which leads to even crazier ideas, like adding more sensors to make a sort of flight data recorder (black box).

#### Nigel Goodwin

##### Super Moderator
Fairly obviously the 18F PIC you've listed there is a LOT cheaper than the others, a LOT easier to use (as it's presumably through hole), but also still has far more power than you need for such a low requirement as this project.

My 18F of preference is the 18F27K42, which has plenty of peripherals, loads and loads of memory, is cheap, and comes in 28 pin skinny DIP for easy use.

32 bit ARM processors seem somewhat massively over kill

#### CK3

##### New Member
Fairly obviously the 18F PIC you've listed there is a LOT cheaper than the others, a LOT easier to use (as it's presumably through hole), but also still has far more power than you need for such a low requirement as this project.
Well, I'm looking at extremely low volume production here. To use the PIC, wouldn't I need something like the MPLAB ICD 4 In-Circuit Debugger? That's $57.95 USD. The STM32 Nucleo-32 development board has the ST-LINK debugger/programmer on board, so all I should need is a PC and a USB cable. Also, (something I should probably add to my high level design) I'll need some kind of user interface for configuration of the voltage regulator (and maybe diagnostics, etc.) The Nucleo-32 has a UART and the USB port, so, again, all I need is a PC and a USB cable. My 18F of preference is the 18F27K42, which has plenty of peripherals, loads and loads of memory, is cheap, and comes in 28 pin skinny DIP for easy use. 32 bit ARM processors seem somewhat massively over kill That 18F27K42 does look like a very capable device. I agree that a 32 bit ARM processor is massive overkill, but it's easy to use (in the form of the Nucleo-32) and I can afford it. #### Nigel Goodwin ##### Super Moderator Most Helpful Member Well, I'm looking at extremely low volume production here. To use the PIC, wouldn't I need something like the MPLAB ICD 4 In-Circuit Debugger? That's$57.95 USD.
No, just a PICKit3 or PICKit 4.

Also, (something I should probably add to my high level design) I'll need some kind of user interface for configuration of the voltage regulator (and maybe diagnostics, etc.) The Nucleo-32 has a UART and the USB port, so, again, all I need is a PC and a USB cable.

That 18F27K42 does look like a very capable device. I agree that a 32 bit ARM processor is massive overkill, but it's easy to use (in the form of the Nucleo-32) and I can afford it.
You could use an Arduino Nano, for small and cheap, and no programmer required.

#### CK3

##### New Member
No, just a PICKit3 or PICKit 4.
Well, that's still $57.95. You could use an Arduino Nano, for small and cheap, and no programmer required. Both the NUCLEO-G431KB and the Teensy 3.2 have an an Arduino Nano V3 connector, so maybe they could be (somewhat) swappable with a real Arduino. But the NUCLEO-G431KB is$12, cheap enough, and roughly the same form factor. I've been programming in C/C++ for decades, and I don't really want to use the Arduino scripting language, but I could see where others might prefer that.

Now, for a crazy idea: there is the Cypress PSoC 6 BLE Prototyping Kit (CY8CPROTO-063-BLE) which is again Arm® Cortex®-M4F, includes a royalty-free BLE stack compatible with Bluetooth 5.0, and contains an on-board Programmer and Debugger, for $20. I wonder if Bluetooth Low Energy could radiate through the metal can of the stock voltage regulator? I guess it wouldn't be too hard to replicate the cover in plastic, or stick a little antenna somewhere. It would be neat to be able to configure the regulator with your phone; view statistics, etc. #### rjenkinsgb ##### Well-Known Member Most Helpful Member Well, that's still$57.95.
You are looking in the wrong places! Try ebay..
eg.