Engineering Limits Challenged: Metering Device Project

AI Thread Summary
The discussion revolves around designing a metering device with an electromagnetic coil for precise control of fuel injection in a diesel engine. Participants emphasize the importance of a PID control loop, suggesting that a PI controller may suffice due to the inherent delays in the mechanical system. There is a consensus on the need for mechanical damping to enhance response time and stability, with recommendations for using op-amps and MOSFETs in the circuit design. The conversation also touches on the challenges of integrating software control with hardware components, particularly regarding the need for quick response times and effective tuning of the control system. Overall, the project presents significant engineering challenges that require careful consideration of both electronic and mechanical aspects.
Rx7man
Messages
425
Reaction score
189
TL;DR Summary
looking for ideas for an analog PID loop
Once again I'm looking at a project that is challenging my engineering limits!
I have a type of metering device that has an electromagnetic coil that actuates it, it's designed to be relatively linear motion depending on amperage applied through it, and it has a variable resistor as a sensor for the actual position. It should be able to respond to changes in inputs quickly, which is one reason I'm considering to at least have part of it analog (Perhaps just a P-D loop, the integral could be software controlled)
I know it's possible to do everything in software, but if I can save processor power and code simplicity with a couple op-amps, I think it's a good move.
The microcontroller will either be a 3.3 or 5V unit (probably 3.3 because of processing power)
I found this image which may work with some minor modifications (supply rails would be 0 and +5V or +12V)
pid-analog-controller.jpg


the second part is the output stage, wondering what sort of transistor and design would be well suited for it..there will be a low side current sense resistor, and low side switching would definitely simplify things.. I think 10A peak current is a reasonable starting point (I'm getting more detailed specs soon hopefully)

Here's a sketch of the physical portion, sorry for the terrible artistry
1596076811660.png


Block diagram of the electrical side of it

1596077735293.png
 

Attachments

  • 1596077547406.png
    1596077547406.png
    7.8 KB · Views: 334
Engineering news on Phys.org
I would use the output voltage of the PID controller to control the duty cycle of a low-side N-channel MOSFET. A Schottky flyback diode across the inductor will protect the driver from flyback, and provide a path for flywheel current through the inductor while the MOSFET is off.

Choice of component rating will depend on solenoid specifications.

You must find a voltage to PWM controller. The simplest solution would be an LM555 timer, or a microcontroller with A-D inputs and a PWM output.
 
  • Like
Likes Rx7man and Averagesupernova
I'm certainly not an expert on control loops but I do know that delay in the feedback signal will cause instability. Your coil/spring gadget has this type of delay built in. I suspect you need only concern yourself with a PI controller. Drop the D.
 
Your controller must be able to outrun the dynamics of the physical system, so the “high-pass” differential part will be essential to stability. The “low-pass” integral part of the PID corrects only the long term error in position.

You will probably need an error amplifier with a controlled gain between the PID output and the PWM controller.
 
  • Like
Likes Averagesupernova
@Rx7man, how quick does it need to change? After my post I started thinking about it and @Baluncore posted what I second guessed. As I said, I'm not an expert in control loops. Fascinating stuff and I'll be watching this.
 
Averagesupernova said:
how quick does it need to change?
It is not the speed you need to move that is important. It is the speed the load can move while you are trying to control it that is important.

It would be easier to control if the solenoid was filled with silicon grease, or an attached dashpot with oil. Then the electronics would not need to respond as quickly, but you would be limited in how quickly you could then move the load.
 
  • Like
Likes Averagesupernova
Baluncore said:
You will probably need an error amplifier with a controlled gain between the PID output and the PWM controller.
In the pic of the schematic I posted, isn't the first op-amp the error amp with a controlled gain?

I'd like to stick to 4 op amps since I can easily get those on a single chip and it doesn't take too much space, so I'd drop the integral,

Averagesupernova said:
@Rx7man, how quick does it need to change? After my post I started thinking about it and @Baluncore posted what I second guessed. As I said, I'm not an expert in control loops. Fascinating stuff and I'll be watching this.
The faster the better! If I can make it so that my code can assume it "just does" what it's told, that would simplify things a lot
This is going to control the fuel control mechanicals on a diesel injection pump, 6 cylinder, 4000 RPM = 200 injections per second or 5 millisecond between events, I think if it took about 10 events for a 90% response that would be adequate. the system has two such devices, one controls the fuel quantity, and the other controls the timing.. they're functionally the same

I know the physical system is designed and engineered for the application, it's just I have no "brain box" for it.. I'm going to have to have enough to worry about with a PID loop for engine speed/load I don't want to have to worry about what the pump itself is doing
 
Here's the pump, it's a real unicorn, it's from the left bank of a Komatsu V12 and I'm thinking of repurposing it into a 5.9 Cummins
H pump.jpg
 
Your sketch indicates that is going to be a challenging project. You have a mass/force/spring oscillator whose force is a non-linear function of position.

I second the recommendation made by @Baluncore that some form of mechanical damping be liberally applied if you want fast response. This of course implies a more powerful positioner (solenoid).

The first steps to designing your device are to find:
  • the mechanical resonate frequency
  • decide what accuracy you desire
  • decide the minimum response time from a step input

Here are a few links you may find useful:
https://www.omega.com/en-us/resources/tuning-a-pid-controller
https://www.csimn.com/CSI_pages/PIDforDummies.html

(above found with:
https://www.google.com/search?&q=pid+controller+tuning
https://www.google.com/search?&q=pid+controller+tuning+for+dummies)

(as I was responding) re your post about diesel injectors, try:
https://www.google.com/search?&q=control+law+for+diesel+injectors

That may substantially reduce the control constraints due to the long time constant of the engine and its tolerance to non-perfect control performance. But you don't want the control loop to oscillate, that wears out the injectors to quickly.

Cheers,
Tom
 
  • Like
Likes Rx7man
  • #10
I don't have much control over the physical parts in the system, the pump must have been designed to be friendly to this type of control system.. I have faith in Bosch and german engineering!

I have read a fair bit about PID loops and tuning.. Unless there was something specific you were trying to point out in the last google link, I don't think it applies to this, since this is still a mechanically injected system, not a common rail electronic injector system like in new diesels
 
  • #11
Rx7man said:
this is still a mechanically injected system, not a common rail electronic injector system like in new diesels
Then what is the solenoid in your first post?
 
  • #12
Tom.G said:
Then what is the solenoid in your first post?
It's internal to the pump
 
  • #13
So, basically you are building a governor?
 
  • #14
Averagesupernova said:
So, basically you are building a governor?
Yeah, I suppose so.. it'll have a CAN bus link to an accelerator pedal position sensor and a few other devices (variable vane turbo controller and such)
 
  • #15
Many mechanical injection pumps have a governor that controls fuel input based on the difference between RPM and accelerator position. Have you checked if your pump includes a governor? Have you checked if there is a dashpot built into the solenoid/rack to prevent oscillation flogging the six fuel control valves?

When matching pumps to engines you will need to set the maximum fuel injection limit to get full power without black smoke. The turbo will make that setting more complex.

You show a common ground reference at zero volts. Since control signals move equally above and below ground you will need to use a common reference voltage at about half the supply. Maybe +12V as positive supply, 0V for negative supply, with say +5V as your local analogue common.

Looking at the schematic of the PID I see your error amp at the input. If the error is zero, the output of the PID will also be zero, maybe that will give 50% duty cycle. There needs to be an integral component in the PID so the error can be zero while the output to the PWM can be anywhere between 0% and 100% depending on the force needed to hold the rack and spring in that position.
 
  • #16
I don't have the pump in my possession yet, I've just been involved in a lot of discussions about it and one of two known pumps (that aren't in use) came up for sale.

I was thinking the I term could be software mapped, or at least closely approximated.. let's say you output a 25% duty signal, and that leads to 20% solenoid travel, 50% gives 40% travel, etc.. I don't think I'll be needing 100% travel for a very long time, this pump is capable of 1000HP of fuel, and unless I dump a whole lot of money into the engine internals and transmission, about 600-800HP will be my limit.. The good thing about this is I can reduce the torque at lower RPMs when torsional vibration is very high (the drivetrain killer)

Looking for Analog to PWM chips, I found this one which looks compact and simple with a 0 to 1V analog input which makes for pretty easy sensitivity adjustment
https://www.analog.com/media/en/tec...ata-sheets/LTC6992-1-6992-2-6992-3-6992-4.pdf

For the output, an MCP14A1201 gate driver with a IRFIZ34N Mosfet (integrated flyback, 55V/21A, .04Ohm) transistor..

For the current sense, I looked back at the Dave's EEVblog on choosing a low offset precision opamp for his current sense project, the MAX4238 (1mhz GBWP) or Max4239 (6.4mhz) seems to be the cats meow
I'm told the solenoids take 6 amps peak, so designing it for 10 amps is probably good and makes easy math
using a 0.01ohm shunt resistor at 10 amps yields a .1V drop and 1W power dissipation if I'm doing Ohm's law right, I think 3W resistors in that value are readily available.. to get good resolution on a 3.3V ADC I'd probably go with a 30-33x gain and a lowpass filter in front of it so I don't see the individual switching of the mosfet... I don't think I'd need the extra bandwidth of the 4239 for this.

I'm thinking out loud at this point

To help the P term, could I put a resistor from the "set" pin directly to the PID output? if I choose the value right, it should help keep a constant duty flowing to the output even without a setpoint error... Something like this.. I'm looking at the MCP 6294 quad op amp for this

1596148768365.png
 
  • #17
Rx7man said:
To help the P term, could I put a resistor from the "set" pin directly to the PID output?
Your real problem is R2 across the capacitor that makes it forget the integral component in the capacitor.
 
  • Like
Likes Jody
  • #18
It's not what the middle op-amp is already doing though, the middle op amp goes off setpoint error while putting a resistor from the setpoint to the output would be adding a linear component to it regardless of setpoint error.
 
  • #19
You have a good point about R2, it's probably to prevent integral windup, or in some literature they call it the reset time I think? don't think you'd want too low a value there for sure
 
  • #20
Rx7man said:
You have a good point about R2, it's probably to prevent integral windup, or in some literature they call it the reset time I think?
Correct.

You seem to be making things progressively more complex, harder to understand, and more difficult to change. You should rationalise the control program down to a simple algorithm. I expect the microcontroller has A-D inputs and a PWM output. Why do you need any analogue?

If you did it all in software the microcontroller would zero the duty cycle when it wakes up, and you could have a digital emergency stop button.

Why do you need to monitor the solenoid current? Is position insufficient? A simple RC LPF connected to the solenoid terminals could feed back to A-D, so integrity/health of the driver loop could be monitored.

You will need to tune the controller once it is running. That is best done by keeping coefficients in microcontroller EERAM. What microcontroller will you use? Can it be reloaded over a USB link or updated over CAN bus?
 
  • #21
I forgot to mention; The IRFIZ34N has an integral parallel diode that might be useful in a bridge, but a low-side MOSFET switch does not need a parallel diode. For MOSFET voltage protection it requires a freewheeling diode in parallel with the solenoid, so solenoid current does not stop flowing completely during the PWM off state. That also gives better efficiency. The diode should be a fast schottky diode, continuously rated to the maximum solenoid current.
 
  • Like
Likes Rx7man
  • #22
Baluncore said:
Correct.

You seem to be making things progressively more complex, harder to understand, and more difficult to change. You should rationalise the control program down to a simple algorithm. I expect the microcontroller has A-D inputs and a PWM output. Why do you need any analogue?

If you did it all in software the microcontroller would zero the duty cycle when it wakes up, and you could have a digital emergency stop button.

Why do you need to monitor the solenoid current? Is position insufficient? A simple RC LPF connected to the solenoid terminals could feed back to A-D, so integrity/health of the driver loop could be monitored.

You will need to tune the controller once it is running. That is best done by keeping coefficients in microcontroller EERAM. What microcontroller will you use? Can it be reloaded over a USB link or updated over CAN bus?
The main reason is I don't want to have to dedicate so much processor time to the calculations.. If you want decent response, I'd figure you'd have to do it every millisecond or so, and it's a fairly intensive operation between the ADC reads, etc.. Yeah, you'll run it on an interrupt, but there are other things that will be interrupt driven as well and managing those priorities is not going to be an easy task either
 
  • #23
Then dedicate a microcontroller to the job of control.

You can set up a real time clock interrupt at 1 kHz. The first task is to update the PID and will take less than 10 usec. Most of the time the processor is asleep.

I agree that writing time critical code in a high level language is a challenge, but it is easier to hand craft assembly code for a microcontroller RTOS kernel than to design, build, debug and tune the analogue PCBs needed for a PID.

The I/O modules are autonomous so you can order an A-D conversion, it will be ready by the next interrupt. A message on CAN bus will call when it arrives, or when it has departed. The PWM will keep running until you update the duty register. The tasks needed can all be independent of program flow.
 
  • Like
Likes Rx7man
  • #24
I've done a lot of this stuff in the past, and here is my most generally useful, crude advice.

1) P (Proportional feedback) is your friend. It is the most stable and easiest to design and use. However, it will have some DC errors left behind.

2) I (Integral feedback) is what you use to fix the DC errors. It can be slow and should be added after you have figured out the P part.

3) D (Derivative feedback) is probably unnecessary and a PIA. Only use it if you have to, and after talking with someone experienced with feedback compensation. It's the best way to make your system oscillate. I would wager that 99% of PID controllers in use have the "D" coefficient set to 0.

BTW, "PID" has always bothered me, like is a special method, gospel, or universal system. In the real world of control systems, we ignore that and talk about poles and zeros in the compensation network in whatever pattern serves your needs. For example how about an IPDPI compensation scheme, which I have done more than once.
 
Last edited:
  • Like
Likes anorlunda, Averagesupernova and Rx7man
  • #25
A couple comments.

1)
Danger, Will Robinson! Danger!
Baluncore said:
you could have a digital emergency stop button.

What does Danger Will Robinson mean?
It is a reference to a common bit of dialogue spoken by the robot in the 1960's TV series, "Lost in Space" . The robot often served as young Will Robinson's companion and guardian. The phrase made it into the culture, and still serves as a warning that someone is probably about to make a mistake.


www.quora.com/What-does-Danger-Will-Robinson-mean

In industry an Emergency Stop is required to directly, physically, remove power to a circuit, or directly mechanically disengage or prohibit physical movement.

By definition something is not doing as expected and it is required to take the simplest, most effective means to avoid danger or damage.

In a car the ignition key serves this purpose. (At least it used to until people were more worried about theft than about safety.)

If you need an Emergency Stop button, have it directly disconnect the power source from whatever is being controlled. Do NOT count on ANY semiconductor, or even a relay, to do this.

2)
I don't think you will need a fancy PID controller for this project if it is on a vehicle that a human is driving. The Human has learned in Driver Education training how to implement that algorithm to maintain speed. It seems to have worked rather well over the decades that carburetors were used. A small Derivative term did get added as an 'Acceleration Pump' to keep the engine running for sudden WOT (Wide Open Throttle) activity. (like beating that Yellow light up ahead. :rolleyes: )

Cheers,
Tom
 
  • #26
I read did not read the whole thread. I am just looking at the schematic of the first post on the opamps. I question what is the circuit doing as it looks to be a straight pass gain of 2 circuit. The top one is low pass with pole frequency of about 154Hz. The bottom opamp is high pass with zero frequency of 154Hz. Middle one is straight pass. So the input to output is just straight pass with gain of 2.

I ran LTSpice and that verify my suspicion
PF1 circuit.jpg

PF1 Plot.jpg
I know I don't understand all the details, but a straight pass is a straight, you can see amplitude and phase response are just simply straight pass with gain of 2. The simulation agree with me.

I use OP27 so the performance is out of the picture. I left off the resistors to the +ve input because it's irrelevant. I use single end driving at the input to simplify the circuit. These should not affect the result.
 
Last edited:
  • Like
Likes Rx7man
  • #27
@yungman
I would like to run and modify your model. Can you please post your Ltspice.asc and Ltspice.plt files.
Give them an extra extension.TXT so they can be attached to PF as;
Ltspice.asc.txt and Ltspice.plt.txt
 
  • Like
Likes Rx7man
  • #28
Baluncore said:
@yungman
I would like to run and modify your model. Can you please post your Ltspice.asc and Ltspice.plt files.
Give them an extra extension.TXT so they can be attached to PF as;
Ltspice.asc.txt and Ltspice.plt.txt
Yes, I was wondering how I can attach the file.
 

Attachments

  • #29
A brief comment about the schematic above (post #26 et. al.). First @yungman is correct, this has a flat frequency response with a gain of -2 (not counting the high frequency issues with op-amp gain-bandwidth limits). Thus it is a "P" controller, and would work just as well if you eliminated amplifiers U1, U2, U3, and U4 (and their associated components) and changed R1 to 50K. You can see this by inspection as @yungman described, it doesn't need a simulator.

However, my real point is that in analog circuits, differentiators only work at low frequencies. The desired frequency response (like H(s) = H0⋅s ) requires infinite gain at infinite frequencies, i.e. an amplifier with infinite gain-bandwidth. You can't buy those. However, the bad part is that the transition from an effective differentiator at low frequencies (where the amplifier works well) to high frequencies (where it doesn't) will essentially guarantee an unstable circuit. This is how you can build an oscillator, if you want. Be very careful with this part of the design.

In practice differentiators are always converted, at higher frequencies, to proportional (i.e. flat frequency response) or integral (decreasing gain with increasing frequency) BEFORE you exceed the amplifier's gain-bandwith product. That's what R12 does in this design.

I have no idea why R5 is included in this design. There may be a good reason, but I don't know what it is.

Finally, op-amps are really good these days, you probably don't need a separate amplifier for each of these different functions, just lots of well chosen R's and C's around one op-amp.
 
  • Like
Likes Rx7man
  • #30
DaveE said:
I have no idea why R5 is included in this design. There may be a good reason, but I don't know what it is.
R5 supplies DC feedback around the Integrator. Without R5 any DC input to the circuit, or any input offset in U1 will quickly drive U1 into saturation because it is operating open-loop for DC.

R5, in conjunction with C1, also determines the corner frequency of the integrator (low pass filter as you call it).

In PID controllers the Integrator corner frequency is much lower than that of the Differentiator. Its purpose is when there is a small setpoint error (which there always is do to the finite Proportional gain), the Integrator will accumulate that small error and drive the output to the setpoint.

Cheers,
Tom
 
  • Like
Likes Rx7man
  • #31
Tom.G said:
R5 supplies DC feedback around the Integrator. Without R5 any DC input to the circuit, or any input offset in U1 will quickly drive U1 into saturation because it is operating open-loop for DC.

R5, in conjunction with C1, also determines the corner frequency of the integrator (low pass filter as you call it).

In PID controllers the Integrator corner frequency is much lower than that of the Differentiator. Its purpose is when there is a small setpoint error (which there always is do to the finite Proportional gain), the Integrator will accumulate that small error and drive the output to the setpoint.

Cheers,
Tom
Not much of an integrator, R5 should be a lot higher to be an integrator.
 
  • #32
Tom.G said:
R5 supplies DC feedback around the Integrator. Without R5 any DC input to the circuit, or any input offset in U1 will quickly drive U1 into saturation because it is operating open-loop for DC.

R5, in conjunction with C1, also determines the corner frequency of the integrator (low pass filter as you call it).

In PID controllers the Integrator corner frequency is much lower than that of the Differentiator. Its purpose is when there is a small setpoint error (which there always is do to the finite Proportional gain), the Integrator will accumulate that small error and drive the output to the setpoint.

Cheers,
Tom
The thread is about PID controllers. This circuit is intended to be a feedback compensation network, so (nearly) infinite DC gain is acceptable, even common. There will be external negative feedback that isn't shown to control the integrator.

I do completely understand what R5 does, I can sketch the bode plot without a simulator. But, I still don't know why it's there. As I said, maybe there is a good reason; in practice these designs are more complex than the canonical forms.

However, I do agree that it is good practice to clamp the integrator to keep it within a reasonable range to facilitate quick recovery from saturation (anti-windup). This clamp would typically be something non-linear, like a zener. I like to do this, but it is way beyond the scope of this thread. We are also lacking much of the system level information required for detailed design.
 
  • Like
Likes Rx7man
  • #33
Got to be an easier way to do the circuit, I wasn't even trying to get involve in the discussion, just open the thread and the circuit was just so glaring to me, such a big complicate circuit, something must be really wrong, so I stop and look and it's more glaring. I even had to spent 10 minutes putting in LTSpice to make sure before I posted. Whatever integrator or differentiator, this can be done a lot simpler.
 
  • #34
Tom.G said:
A couple comments.

1)
Danger, Will Robinson! Danger!What does Danger Will Robinson mean?
It is a reference to a common bit of dialogue spoken by the robot in the 1960's TV series, "Lost in Space" . The robot often served as young Will Robinson's companion and guardian. The phrase made it into the culture, and still serves as a warning that someone is probably about to make a mistake.


www.quora.com/What-does-Danger-Will-Robinson-mean

In industry an Emergency Stop is required to directly, physically, remove power to a circuit, or directly mechanically disengage or prohibit physical movement.

By definition something is not doing as expected and it is required to take the simplest, most effective means to avoid danger or damage.

In a car the ignition key serves this purpose. (At least it used to until people were more worried about theft than about safety.)

If you need an Emergency Stop button, have it directly disconnect the power source from whatever is being controlled. Do NOT count on ANY semiconductor, or even a relay, to do this.

2)
I don't think you will need a fancy PID controller for this project if it is on a vehicle that a human is driving. The Human has learned in Driver Education training how to implement that algorithm to maintain speed. It seems to have worked rather well over the decades that carburetors were used. A small Derivative term did get added as an 'Acceleration Pump' to keep the engine running for sudden WOT (Wide Open Throttle) activity. (like beating that Yellow light up ahead. :rolleyes: )

Cheers,
Tom
I will certainly have AT LEAST one positive shutdown method.. definitely the key will kill all power, and in "testing" mode I will probably have a big red E stop button as well
This is a diesel, so what I'm looking for is that the fuel rack does what I'm telling it too with reasonable accuracy despite temperature changes, G force changes, etc
Also, since it's a diesel, if there's a physical failure of the solenoid actuator mechanism, cutting electrical power will do nothing to stop it, you need a butterfly in the intake system to starve it of air. Vehicle will be manual, so you'd have a clutch to prevent physically accelerating, but serious engine damage is still no fun..
Here's a great example of what happens!
 
  • #35
yungman said:
Got to be an easier way to do the circuit, I wasn't even trying to get involve in the discussion, just open the thread and the circuit was just so glaring to me, such a big complicate circuit, something must be really wrong, so I stop and look and it's more glaring. I even had to spent 10 minutes putting in LTSpice to make sure before I posted. Whatever integrator or differentiator, this can be done a lot simpler.
I'm all ears for a simpler analog PID circuit.. The ones that came up when I googled it were all approximately like this though
 
  • #36
Something like this is a simpler version of the compensation network. Fewer components for the same function as the previous posts. But these designs aren't that simple in practice, you do have to know what you want.

edit: BTW R2 and C3 aren't part of "PID". They are there to make it actually work (stability).
img002 (2).jpg
 
Last edited:
  • Like
Likes Rx7man and yungman
  • #37
Diesel trucks are slow compared to the world of electronics. In practice (modern times) this would be a software implemented controller.

All of the ancillary features like start-up, shut-down, response to large transients, tuning, user interface, etc. are about a million times easier with software. The feedback controls could be a one IC solution if you choose the right micro-controller.
 
  • #38
This feels more like a total analog closed loop feedback project. Remember, if you put MPU into the loop, you have to have an ADC to convert the voltage into digital, work on the data, then put it out to a DAC to transform back to analog. Maybe you have much faster ADC inside the MPU now. When I was designing all the MPU controllers, they use Successive Approx ADC inside, it can get slow. You might add an extra pole you don't want and make life much more difficult. I was going to suggest a simple circuit like what DaveE drew in post #36. You have zeros, you have poles in case you need it or leave it if you don't.

In this kind of circuit, the electro mechanical part is the slowest, it can serves as the dominant pole. But it's hard to characterize the exact pole or zero or whatever. I am not an expert on closed loop control system, but I did a few in my career. In this situation, I use faster components( opamps) to make sure they stay out of my way. Use DaveE's type of circuit, start out with R1 and C1 that forms a lag-lead network. I want to lower the gain of the opamp as soon as it's out of the control frequency ( in this case, looks like it's in below 200Hz). I would use C1 to reduce the gain of the loop starting from say 1KHz or so, then adjust R1 to bend the bode plot up to get a smooth single pole crossover....R2 C2 to me is for emergency fix if still want to be more stable.

I don't go any further after this, I observe. If I power up, and I see the mechanical motion just ease to to the resting point, this is over compensate, all you have to do is make sure the response is fast enough, if so, you are done.

If the motion overshot and ease back to resting position one time, you are still ok. It just have one ring.

If it overshoot, then back under shoot a few times, you still have work to do. Look at the frequency of the oscillation and look at putting a zero to straighten it out.

The characterization of the electro mechanical component is very hard, I found it easier to do it this way. You start out with a sound basic closed loop stability design then try and see. The circuit daveE posted in #36 is a very good start.
 
  • #39
Having witnessed a diesel engine attempt to run away, I would take this project very seriously. Before any more effort is put into this I would determine if you actually need to incorporate a governor into this or just control the position of the rack. We haven't actually been told if this is an automotive project or not. What type of machine will this be powering?
 
  • Like
Likes DaveE
  • #40
If it is some sort of engine control for truck, I won't mess with it. I personally would NOT do anything to experiment on my car for sure, this is dangerous. It's fun and game over here, like pet project, homework that doesn't make any difference to real live. I won't mess with a car where your life depends on it. Last thing you want is your stuff fighting with what's in the car.

That said, there's another even bigger problem with using MPU inside the feedback loop. If the ADC inside the MPU is successive approx type, you have a more serious problem. Inside is doing a whole bunch of comparisons...bigger...smaller...It relies on the input analog signal is stable, not changing. If there's no sample and hold circuit, it tries to compare while the signal is moving...Huston, we got a problem! You literally can fail to acquire the data and have long dead time and can vary from time to time. You cannot model this as poles and zeros. Read the datasheet on the MPU you are using. I doubt it would have a flash ADC inside. Those MPU are meant for monitor voltages so successive approx is good enough.
 
  • Like
Likes Rx7man
  • #41
yungman said:
This feels more like a total analog closed loop feedback project. Remember, if you put MPU into the loop, you have to have an ADC to convert the voltage into digital, work on the data, then put it out to a DAC to transform back to analog. Maybe you have much faster ADC inside the MPU now. When I was designing all the MPU controllers, they use Successive Approx ADC inside, it can get slow.
Control of the solenoid is by microcontroller PWM, which is autonomous, energy efficient and replaces the DAC. The controller does not have to compute faster than the injector rack control.

Microcontrollers for motor control typically have two or more internal A-D converters, with 8 or more MUX inputs. There is plenty of time to do the ADC, it will take less than 20 usec in the background. SAR A-D converters are faster than quad slope by a factor of 1000.

Take at look at an AC motor microcontroller. It is over 100 times faster than is needed for diesel injection rack control. The internal computations can all be 16 bit integer. The PID requires 3 multiplies, one subtraction and 4 additions, which now takes less than 10 usec.

The software solution is the minimum chip count solution. The hardware required is 1. A microcontroller; 2. A low-side gate driver; 3. N-chan MOSFET; 4. Freewheel diode.
 
  • Like
Likes Rx7man and Averagesupernova
  • #42
yungman said:
if you put MPU into the loop, you have to have an ADC to convert the voltage into digital, work on the data, then put it out to a DAC to transform back to analog. Maybe you have much faster ADC inside the MPU now. When I was designing all the MPU controllers, they use Successive Approx ADC inside, it can get slow.
Old school. This part costs $2 and can sample 12bits at 1Ms/sec. There are lots and lots of other choices. IMO, the speed is probably really limited by extra sw features and poor code/algorithms. However, even with a few floating point MACs in each sample period, you can still run much faster than a truck.
https://www.digikey.com/product-detail/en/silicon-labs/EFM32TG11B120F128GM32-B/336-5683-ND/9677675
 
  • #43
I am out of date.
 
  • #44
yungman said:
If it is some sort of engine control for truck, I won't mess with it. I personally would NOT do anything to experiment on my car for sure, this is dangerous.
Then some of the things I do would make you squirm. Not limited to passenger vehicles.
 
  • Like
Likes Jody and Rx7man
  • #45
yungman said:
I am out of date.
LOL, me too.
BTW, I've never met anybody that is really good at doing this with analog circuits or digital controls (including me). It is really two very different disciplines. There are control system types (like me) that can do the modeling with Laplace transforms or Z-transforms, and can design algorithms, but they either can't do analog design, or they can't write good code (like me).
 
  • Like
Likes Rx7man
  • #46
yungman said:
If it is some sort of engine control for truck, I won't mess with it. I personally would NOT do anything to experiment on my car for sure, this is dangerous. It's fun and game over here, like pet project, homework that doesn't make any difference to real live. I won't mess with a car where your life depends on it. Last thing you want is your stuff fighting with what's in the car.
In any case, don't drive it on the streets. Consider your liability exposure if things go wrong. Like the cost of rebuilding the front of someone's house, replacing a Porsche, or negligent homicide, for example. You just can't do the kind of testing, engineering procedures, and QA that a real car manufacturer is required to do; that the judge/jury at your trial will expect.
 
  • Like
Likes yungman
  • #47
That was a lot of good reading, thanks for the replies.
This isn't designed to control the SPEED of the engine (that's a slow process and will be done digitally for sure), it's intended to make sure the fuel (or timing) racks are in the position they're commanded to be, which happens pretty quick.

There is hardly anything original on my truck, and being a manual, if something does fail, I can always hit the clutch

Here's what I'm reading right now on analog PID controllers (starts at page 8) https://www.dialog-semiconductor.co...of_a_dc_motor_using_analog_pid_controller.pdf
 
  • #48
I think you can find better references on the web than this one. I have some serious problems with how they've described Integrators. They don't require an error, and they typically don't overshoot. Although how anyone could make a statement about the transient response (overshoot, for example) without fully describing the system dynamics and the gains chosen is beyond me.
 
  • #49
DaveE said:
I think you can find better references on the web than this one. I have some serious problems with how they've described Integrators. They don't require an error, and they typically don't overshoot. Although how anyone could make a statement about the transient response (overshoot, for example) without fully describing the system dynamics and the gains chosen is beyond me.
I'm no expert on this, but just going by the circuit diagram it appears that they all require an error in order to be active, with the exception of the D term which requires a change in error, rather than an absolute error. And the integrator usually would cause overshoot because of windup.. yes, the entire system does need to be taken into account though, but a poorly tuned I term would certainly cause it.

Going back to circuit analysis, I noticed with the electrolytic caps, they have them in serial with backwards polarities.. is this common and good practice for systems where you can have either polarity? Should there be a bypass diode to prevent reverse charging ?
1596384310718.png
 
  • #50
Using electrolytic caps in that way is not a good design practice IMO. There are better ways to get long time constants without them. There are also ways of adding a DC bias into the circuit to ensure the correct polarity at all times if you do use them.
 
  • Like
Likes Rx7man
Back
Top