Alternator control

It's all about the code!
Post Reply
sturovo
donator
donator
Posts: 32
Joined: Mon Feb 10, 2014 7:44 pm

Alternator control

Post by sturovo »

On many cars including my 99 mx5 the alternator charge circuit is controlled by the ecu.
Usually the circuit is disabled at low rpm so as not to charge during cranking. The stock alternator control works at around 14.5 V.

Some people have developed hardware boards that specifically handle this feature
Image

Others have developed a PWM solution
Image

And some have suggested using the L9911 chip for this purpose
http://www.st.com/web/en/resource/technical/document/datasheet/CD00046504.pdf

Is an alternator control function all ready planned for Rusefi? I am at the point where soon I will need to implement this feature so any guidance is appreciated.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Alternator control

Post by AndreyB »

Multiple options:

Phase 0: No alternator control - hard-wired alternator :) Just works. No software changes.
Phase 1: Simple RPM-based alternator control: just turn alternator circuitry once RPM threshold is reached. 30 minutes of software development, pretty lame implementation - but that would be a skeleton in terms that a pin would be assigned to that function and a file would be created in the source code. I can do this soon
Phase 2: sky is the limit: PWM control based on target voltage using a PID controller. It's probably not time for that yet.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

Do you have a schematic for the existing system? Are we talking a 0-5V analog signal to control the field, or is this something different? I would wager a bet the control can be be done with reasonably small amounts of changes to software. I suspect we want a circuit that accepts a PWM and generates an analog signal to control the field. I would think some kind of a small look-up table based on measured voltage and RPM would generate the base PWM duty cycle. Then the circuit attached to a GPIO would make that PWM into an analog voltage or current for the field winding. If you have knowledge of head lights, or other loads, you could manipulate the base duty cyle to account of additional loads.

Something like this,

Below say 800 RPM, PWM = 0%
At say 800 RPM and if the measured voltage is below 13.4V, then 100% PWM.
At say 800 RPM and if the measured voltage is above 14.4V, then 10% PWM, (assuming 10% is what the injectors and such loading is consuming)
At say 3000 RPM and if the measured voltage is above 14.4V, then 30% PWM, (assuming 30% is what the injectors and such loading is consuming)
Welcome to the friendlier side of internet crazy :)
User avatar
rus084
contributor
contributor
Posts: 678
Joined: Sun Dec 01, 2013 1:40 pm
Location: Russia , Stavropol

Re: Alternator control

Post by rus084 »

this is what I need. I just need yet dependent on engine speed.

i want step-down have more power whereby stock alternator controller . now its have 3a on dc 14v (there diode weak) ; but alternator can have 10a on short circuit and 30vac (45vdc) on 4000

until I pick up the thyristors to a voltage limiter to rectifier diodes not deteriorated: thyristors have too much variation of parameters, some do not work as expected, some are too museum to use them

Hurrah! thyristors were wrong, now it is 20 volts at idle and 31 volts from 3000.
I selected here is the voltage of the diodes that documentation is kept 100V reverse voltage and capacitor 50volt (thyristors I don `t know what to stress, there is a part of marking erased, but they are 16 amp)
now I need a PWM frequency of 20-50 kHz.
ir2101 to drive the mosfetov irf530n (2 shoulder put)

circut look like this
Image

what thoughts?
sturovo
donator
donator
Posts: 32
Joined: Mon Feb 10, 2014 7:44 pm

Re: Alternator control

Post by sturovo »

Thanks for the replies and suggestions. It sounds like in time a good solution will be implemented for rusEFI.

For now I will probably go with using an aftermarket alternator regulator. I got this one locally for 10$ which regulates to 14.1 v. This may be a good solution in my case as it would mean that 2 outputs would be freed up as the gen control light can also be controlled from this module. It is compact enough to fit inside my ecu case but I guess it is better to mount it on the outside in case it would generate noise .

Image

Image
User avatar
rus084
contributor
contributor
Posts: 678
Joined: Sun Dec 01, 2013 1:40 pm
Location: Russia , Stavropol

Re: Alternator control

Post by rus084 »

simplest way is schmitt trigger . it can work for first time .
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

I expect the P-Factor to be a constant variable :) AKA only one number set by TS.

I suggest a look up table that takes in RPM and desired watts, and generates PWM for the alternator. It probably doesn't have to be to fancy, I would think that a 5X5 would work well enough. When you get some minutes we can chat and get the initial values. I don't know what to expect for initial numbers, so I think we'll have to adjust electrical load and RPM on the test muel to get some data points, then generate the table data.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

Has Sturovo ever managed to get his '99 NB Miata control working with the rusefi?
Over on miataturbo.net is a discussion on alternator control specific to NB Miata. I believe this is what was eventually implemented in MS code as the "High Speed Feedback Field Control" feature and works a treat on my NB.

My understanding is that it essentially looks every few milliseconds (in my case 10ms) if the measured battery voltage is greater or lower than target voltage and turns the field on and off accordingly. That appears to be it.

You can find the posts by MT.net member JasonC SBB right here: http://www.miataturbo.net/megasquirt-18/alternator-control-modern-era-69803/#post955990
JasonC created a very reliable (I ran it for two years) hardware solution that implements the above strategy.

This appears to work for NB Miatas. I have no idea if it can be transferred to other alternators.

Right now I am running MS3 software control for my alternator, but in order to switch to rusefi I need another solution. Going back to the extra board would of course be possible, but it would also feel like defeat....
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Alternator control

Post by AndreyB »

@ did not control his alternator with rusEfi.
stefanst wrote:My understanding is that it essentially looks every few milliseconds (in my case 10ms) if the measured battery voltage is greater or lower than target voltage and turns the field on and off accordingly. That appears to be it.
Interesting! Too simple to be true, but I'll definitely try this since it's just 3 lines of code! 100Hz loop frequency is totally not a problem.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

russian wrote:...
Interesting! Too simple to be true, but I'll definitely try this since it's just 3 lines of code! 100Hz loop frequency is totally not a problem.
You may have to make it 5 lines- Jason is also using 50mV hysteresis.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

I see reference to a circuit, but it appears it may have been lost in posts as the thread was split from another thread. Does anyone know where this schematic can be found?

I also see it references 1mS to 1.5mS, that's 1kHz to 666Hz.

If the above noted "circuit" doesn't overheat, I really like the idea. To me it seems like this could be easily made into a self contained circuit. Perhaps 555 timer friendly, as those have hysteresis. Probably could be made to work with a 50mV of hysteresis.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

My MS3 only checks every 10ms (user setting - see image). And as Jason says, a magnetic field works as an integrator anyways, so we have a fairly long time constant. MS3 code works very well indeed, but we don't really know what they're doing.

Please note that the graphs on the right are not used. Essentially all we get is several different target voltages, based on operating conditions, and a timebase. No PID parameters.

Explanation text for the control interval is: "How often to run the control calculation".

Sounds like bang-bang control to me, otherwise we'd need more parameters.
Attachments
Alternator control.jpg
Alternator control.jpg (138.94 KiB) Viewed 22681 times
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

kb1gtt wrote:I see reference to a circuit, but it appears it may have been lost in posts as the thread was split from another thread. Does anyone know where this schematic can be found?
Jason's circuit can be found here: http://www.miataturbo.net/megasquirt-18/disable-alternator-field-75009/#post1054645
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Alternator control

Post by AndreyB »

I've tried plain on/off control on my Neon but it's not as precise as I would like. I would need to double-check how well has the 100Hz frequency worked just in case.

[video][/video]

https://svn.code.sf.net/p/rusefi/code/trunk/misc/logs/2003_dodge_neon/2016-02-27_12.52.42_on_off_alternator.msl
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

I see two options, one is to increase the speed from 100Hz to perhaps say 1kHz, or add a series resistor to limit the current. Right now it appears you are dumping in to much current too fast which is causing it over shot. The series resistor would limit how quickly it raises. Or if you increase the switching frequency, you'll increase the impedance which is basically the same thing, but at the expense of more CPU cycles consumed.

Jason's circuit appears to be a hardware only solution. I don't see a MCU input, other than a disable for cranking input. It appears he's using a voltage reference which then runs a PNP transistor in it's analog region. At the core of this circuit, I think he tuned it's response to be around 1kHz. Perhaps he had a different circuit at some point, but then eventually decided to make the circuit not rely on a MCU.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

kb1gtt wrote:Jason's circuit appears to be a hardware only solution. I don't see a MCU input, other than a disable for cranking input. It appears he's using a voltage reference which then runs a PNP transistor in it's analog region. At the core of this circuit, I think he tuned it's response to be around 1kHz. Perhaps he had a different circuit at some point, but then eventually decided to make the circuit not rely on a MCU.
Jason indeed claims that he's running around 1KHz. This is the circuit I used to run on my NB. And it worked well.
But once MS3 had the option to run the alternator field directly off the ECU, I started using that option. And that works really well too. But that one is running only 100Hz.

Please remember that both these options are only ever reported to work for NB Miata. I don't know if they work on other alternators. MS3 offers several other strategies for alternator control, none of which I ever used.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

stefanst wrote:But once MS3 had the option to run the alternator field directly off the ECU, I started using that option. And that works really well too. But that one is running only 100Hz.
What schematic do you use? Or what is the primary driving transistor? I"m guessing it's a reasonably high Rds MOSFET. The circuit used by russian can be found here http://rusefi.com/forum/viewtopic.php?f=4&t=747&start=36

It uses a FQB12P20TM which has an Rds of 0.47ohms, and a Ton and Toff times measured in nS range. If your Rds is say 3 ohms, your frequency can be much lower.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

kb1gtt wrote:What schematic do you use? Or what is the primary driving transistor? I"m guessing it's a reasonably high Rds MOSFET. The circuit used by russian can be found here viewtopic.php?f=4&t=747&start=36
I'm using one of the MS3Xs "spare" low-side pwm outputs (nitrous2) pulled up to +5V with a 1K resistor. How the MS drives the output is unknown, but MS also offers to option to select a non-pwm output for this task. Therefore I don't think PWM is used.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

Gotta love closed source projects. Perhaps it had a series resistor, or perhaps it had a reasonably high Rds, or perhaps they used small trace widths that made a resistor. Who knows, and more importantly is who knows if your trail be error efforts have produce a good solution. It could easily work at room temp, but at other conditions like elevated ambient temperatures it could fail. You wouldn't know until track day, then you wouldn't know why it failed, you would just know it failed. Also when the alternator control fails, it would likely cause other things to fail, which is what you'll notice. So it's hard to learn the root cause, and why it failed, and you'll likely have the same failure. I guess it's a good business model, make it break, so you have to buy a new one. Rumble groan moan.

Any how, if you have a circuit / schematic you plan to use with rusEFI, I can take a look a it and help identify if it's going to have issues, or not.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

It's kind of doubtful that we'll burn out traces with the solution implemented by MS. The wire (field) into the alternator has 0V or close to it when not being driven- the alternator is not driving any current here. And if my 5V 1KOhm pullup is sufficient to excite the field and make it go full output (which it is), then the most we could ever see is 5mA. Not a trace-burning amount of current.

So I'll just try the rusefi alternator control with a p-value of 100%. I assume the 'dtime' value sets how often it runs. So if I set this to 10ms, this would mimic my current best guess at what is needed for a Miata NB alternator.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Alternator control

Post by kb1gtt »

It would appear the Miata circuit is different than my truck. My truck field current peaks at 6A and typically draws about 1A, which is much more current than your suggest 20mA range.

I'd like to find a web page that describes the equations used in a alternators field winding. I understand the alternator is a kind of current multiplier, AKA put in 1A get 100A back kind of thing. I would guess the Miata alternator has internal circuitry that converts voltage signal to filed current.
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

I scoped the field output from the '99 Miata stock ECU (alternator is identical from '99 to '05). 250Hz PWM is confirmed.
Alternator PWM 99 Stock ECU.png
Alternator PWM 99 Stock ECU.png (49.76 KiB) Viewed 21725 times
It seems fairly aggressive- looks like we're going from 0% to 100% within about 0.03V and the change seems immediate. Certainly less than 500ms. So I'd guess that most of the reaction is P with some I thrown in.
Looks like rusefi shouldn't have a problem emulating that behavior.
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

Re: Alternator control

Post by stefanst »

More on the Miata NB alternator control. Found where Jason, they guy who developed the hardware circuit I've run for a few years, describes what the circuit does. As described earlier, it is indeed a simple hysteretic bang-bang control, albeit with a fairly fast reaction time of 1.5ms. The hysteresis is set at 50mV and the voltage gets filtered with a time constant of 100µs-300µs.

Here's the thread on the subject:
http://www.miataturbo.net/megasquirt-18/alternator-control-modern-era-69803/#post955990
Post Reply