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.

Measure Pulse Width / Duty Cycle of an Injector to drive a pump

Status
Not open for further replies.

rodp

New Member
Hi All,

First post here so apologies if I've started this thread in the wrong section. I would like some electronics advice and programming help to help me build a device that will measure the Pulse width / duty cycle of a car injector. This signal then needs to be either converted into a steady or pulse width DC current that will drive a geared motor that will drive a mini peristaltic pump.

Specifically, I have a prinns LPG system installed on my car but the system that delivers the Valve Saver fluid (flashlube) relies on the vacuum of the inlet manifold and a needle valve. The flow is very inconsistent and I could also do with some sort of feedback loop in the car to keep an eye on the flow (a simple flashing light perhaps)

I'm an electronic hobbyist up for a challenge. I've read various posts and messages on the internet around this subject and feel it's within my grasp but need some help putting it all together.

eg. **broken link removed**
Talks about using a comparator circuit to create a nice clean square wave.

eg. https://www.electro-tech-online.com/custompdfs/2012/04/pic16f627a.pdf
Is a PIC controller that I think would provide the necessary speed and control all in one. I'm very familiar with VBA programming and so feel confident in reading up on and understanding PIC language if I'm given some pointers.

I've also done some preliminary analysis on the pulse that the injectors receive and have attached an example. The portion that is of interest is close to the 8th horizontal division which goes from 15v to about 45v peak. The rev range is 0-6k rpm.

With this info, please can anyone help?

Many thanks in advance

RodP
 
Are the valves that poor a quality in your engine to require this system. I have 2 vehicles that run on LPG without these ad on systems & they have done over 300,000Kms & still going. Any vehicle thats desighned to run on Unleaded petrol should have valves hard enough to run on LPG.
 
Hi debe,

Thanks for the reply, the flash lube system was installed at time of installing after various investigations and technical independant advice. I've stuck with the manual vacuum system long enough and feel i can improve things doing such a project build.

Hoping someone can help.

Thanks

Rodp
 
I have re-read your post several times and am still not clear on what you want to measure.

If you just want to measure pulse width, that is quite easily done with a timer. If you want to measure duty cycle on a cycle-by-cycle basis, that can be a little more difficult and may involve a relatively slow division, depending on the precision you need. It can also be done with a simple analog integrator followed by an A/D converter. There are several options.

First, your voltages are generally not compatible with PIC inputs that are generally limited to 5V. So, you will need some form of pre-processor signal conditioning whether it be comparator, op-amp, voltage integrator, or voltage divider.

Second, do you need cycle-by-cycle control, and what level of precision do you need (i.e., how many steps). If not cycle-by-cycle, how often or after what events do you need updates?

Third, please clarify exactly what you need to measure. Maybe a drawing would show that more clearly.

John
 
Last edited:
Are you attempting to pump fluid at a rate proportional to (a) rpm or (b) LPG flow rate (i.e. rpm x injector open time)?
 
Hi All,

Thanks for the replies,

Re Alec-t's question, I'm attempting to pump fluid in relation to the flowrate of the LPG which as mentioned is linked to the rpm and the pulse time of the injector, so it's 'b'. I need to measure the number of pulses per minute and the pulse time whcih can then be used to control the rate at which a fluid is pumped.

Re jpanhalt's queries, thanks for providing various options. I've attached a simple process chart to illustrate what I'm trying to do and have also overlapped the two scope charts to show what I think needs to be measuerd / registered as the pulse time. As you suggest a simple integrator circuit might do the trick and so would be grateful for any links to example circuits and pointers regarding voltage conditioning.

Re the 'duty cycle' query - sorry - bit of a red herring, no I don't need to caculate it. My project doesn't need to provide an actual readout of the injector's pulse time (although that would be nice!! ;) )

Re precision: It doesn't need to be every cycle but... I don't really know what is capable so would appreciate some advice on this (with reference to cost). Flashlube needs to be delivered on a μl scale, approx 50ml per 50L fuel consumed, (currently with the old kit it's about 1 drop in the sight glass every 10-15 seconds at idle!).

To help, I'm basically trying to make a Home DIY version of this: https://www.tinleytech.co.uk/acatalog/FlashLube.html... but with something that has a little more control.

Hopefully the attached pdf illustrates what I'm trying to measure and control but do let me know if you need any more info.

Many thanks in advance

Rodp
 
So it's option b. In that case one approach would be, as Jpanhalt suggested, to use an analogue integrator. The integration result could then be used to develop a PWM signal for controlling pump speed.
An alternative would be to use the injector driving pulse to drive, via a buffer circuit, a second injector to deliver the (pressurised) fluid.
 
Here's a link to an application note for a device (accelerometer) that converts duty cycle to voltage (page 5/7): https://www.electro-tech-online.com/custompdfs/2012/04/an-00mx-001-1.pdf There are of course many variations of that, including various off the shelf frequency to voltage converters.

As an alternative, I think you might be able to get a usable integration as a function of load quite easily by setting the trip point of a comparator to the voltage at half-height. That time could be easily measured with an MCU. That assumes the pulse width doesn't change with RPM.

The decision for you is whether you want a digital or analog solution.

John
 
Last edited:
Hi Both,

An Analogue integrator driving a PWM sounds goods. If there are some off the shelf devices, I might want to take a look at them too... Any suggestions?

Re your comment 'That assumes the pulse width doesn't change with the RPM'. It's made me rethink what I perhaps said in the PDF. I think you are right and the pulse width won't change simply due to the revs but will change due to the load.

Re, the digital / analogue solution. Are you talking simply about the output (PWM vs constant DC current)? My choice is PWM as that is better controlled. Sorry - perhaps I've miss understood, perhaps you are talking of a complete digital solution, ie using a PIC (providing you reduce the input voltage etc.).

I can understand more the Analogue solution in my mind at the moment and so have put down below what I think I need to consider with some weblinks with example circuits. Can you let me know if I'm on the right track? As for digital, this might be alot tidier and something that can be done all in one chip in which case I would be rather interested in that as changing a program can often be quicker than having to redo the circuit board!


Circuit 1: Pulse Width to voltage converter: Intergrator: eg. https://www.sccs.swarthmore.edu/users/06/adem/engin/e72/lab1/ [scroll down to 3. integrator.. just got to work out the C and R values]. Comparator: eg. https://www.sccs.swarthmore.edu/users/06/adem/engin/e72/lab1/ [scroll down to 4. comparator. How would I combine this within the Integrator circuit or would I simply adapt the Integrator circuit itself?]

Circuit 2: Frequency to voltage converter: Had a look at the accelerometer page, are you talking about the section on Page 6? (Figure 9: Frequency Response Extension Circuit). Are there any kits out there already you could provide links to?

Circuit 3: Outputs of Circuit 1 and Circuit 2 need to be multiplied and used to drive a Pulse width modulator circuit (is this another op amp circuit?)

Circuit 4: PWM controller for the DC motor, eg. **broken link removed**


Talk soon and thanks

Rodp
 
In the Memsic note, I was referring to Figure 8, low-pass filter (i.e., a resistor with a capacitor to ground) . It basically converts duty cycle or pulse width at a fixed frequency to a proportional voltage. There are numerous examples of that approach in electronics. I was just lazy and picked something I had in my files. The examples you posted are similar and use op-amps.

The second step would be to convert that voltage to a control signal for your pump. One could use a PIC with an ADC to convert it to PWM. That would be a mixed analog-digital solution. Or, there are voltage controlled analog chips that can use a 0-to-5V input to produce 0 to100% PWM. The TPIC2101 is one such chip.* That would be a fully analog approach.

Third, after proper conditioning of the signal, your PIC could take that signal, measure the peak width, and produce an appropriate PWM output. I would call that a fully digital solution.

In your initial post, you mention that the signal should be, "a steady or pulse width DC current that will drive a geared motor." If you are sure the motor is DC, then PWM is probably the best way to go for control. However, there is a chance a stepper motor is used. If it is a stepper, that would require a different control.

Assuming the motor is DC, my preference would be either the completely analog method (i.e., integrator or low-pass filter + dedicated chip) or a completely digital approach (i.e., input to the PIC's comparator, time the peak width, convert that to a PWM output). Either method may require a separate driver chip for the motor. The analog approach will probably require some scaling, which may be as simple as resistors (e.g., doubling of the peak width may not mean the pump speed should double). The digital approach will inherently allow scaling and even complex response curves, but it will also require programming.

That is what I meant about your decision to go digital or analog.

John

Just did a quick search of DigiKey for "PMIC Motor & Fan Controllers." There were 509 hits, which was easily filtered to "only" 252 . http://search.digikey.com/us/en/cat...tor-and-fan-controllers-drivers/2556626?k=pwm
 
Last edited:
If you get a system going you probably could market it. The manifold vacume system is very poor system. It feeds most flash lube at low throttle openings with high vacuume, & next to nothing at higher RPM with a wider throttle opening & hardly any vacuume.
 
Hi John,

Thanks very much for the reply again - that's helped me understand my options a little further.

RE the PIC route, one issue I thought of regarding the digital route is it might be hard to see the intermediate results of the code where as via the analogue route (ie using an oscilloscope quite easily shows you what's happening at various parts of the circuit). Would this be of a concern to you if you were building this? I will have a hunt around the forums in hope of finding some PIC code which will measure the peak width and frequency of pulse (as from what I've understood I will need both to generate the final signal to drive the PWM output). It's then playing around with some scaling factors in the code to get it to pump about 50ml per 50L fuel I presume, (or infact it might be more simple to alter some settings on the PWM motor driver card).

Could you recommend a PIC? I would also need some means to program it and so would need some advice on the kit to buy in order to do this (I hope this isn't too expensive). I'll plan to buy a PWM driver kit from our local electronic store (Maplin / Vellemen kit) when ready. One final question, you mentioned the PIC's input is 0-5v generally... in terms of scaling down the voltage, I presume I could use an op-amp circuit to scale down the voltage and at the same time control the threshold level. In which case, the signal going into the PIC might be pretty much a square wave after that. The PIC would then simply be used to measure the width and frequency of this clean(er) waveform. Would this route be a good route or would you suggest that in actual fact I should let the PIC do most of the filtering and control and simply use a simple voltage divider (2 x 10k resistors for example with one to ground) at the PIC's input?

Re the analogue route, although this might be the easier path to take as there would be no programming involved but there are lots of steps and variables to take into account what with all the calculations I'd need to make to figure out the low pass filter settings etc. so maybe the PIC route is better. Any thoughts?

I'd be grateful for a reply to these final few queries, and then I think I'll be in a position to start planning things in a little more detail.

Thanks again

Rodp
 
With the digital route, you can easily simulate the code. To measure peak width, all you need to be able to do is differentiate between when a pin is "low" and "high". Low is usually a voltage less than 1/3 Vcc.When the pin goes high, you start a timer. When it goes low, you stop the timer. The time is the width. If you want to measure both width and frequency, one way is to start the timer as before. When it goes low, you stop the timer, copy the register in which the time data is saved, and restart the timer for getting the total period. That loses about 4 or 5 clock cycles, which you can correct for, if you want. There are ways to do that without stopping the timer, but the error in stopping the timer is pretty small relative to what you are doing. Remember, your clock cycles will probably be about 0.5 to 1 uS (i.e., 1/4th of the oscillator frequency) compared to milliseconds for your pulse. The start and stop can be determined by polling or by using interrupts. There are also other ways to measure frequency and pulse width, but I think for pulse-by-pulse correction, what I described should work best.

As for which PIC to use, there are many people here with far more experience than I have who can advise you. What you are doing is fairly simple, so even an 8-pin 12F675 or 12F683 will work. Those chips have analog inputs, which include comparators, so you won't need one as a separate chip. Almost any of the 16F series will also work.

I suggest the PicKit3 for programming. There are cheaper programmers, but PK3 has worked for me without a problem and will handle all of Microchip's new chips too. As PK3 is designed for ICSP, you will need an adapter board or two or a finished PCB. I bought my PK3 form Microchip and the adapter boards off eBay. That was a mistake. There is a seller on ebay (j1sys.com) who sells the adapter boards and genuine PK3 for not much more than the PK3 alone. I would be leery of PK3 clones, as the money saved would not be worth the headaches if they don't work. For development, I just use the free MPLab from Microchip.

As you mention, one of the neat things about analog is you can actually see what you are doing. Maybe a good place to start would be to build a couple of the analog inputs we have discussed, hook an o'scope to them and get a feel for what happens with the signal under different load conditions and with different RPM settings. If the changes are not simple, for example if the slope of the load-induced change varies with RPM, then you will have a pretty good reason to use a PIC.

John
 
Last edited:
I've also done some preliminary analysis on the pulse that the injectors receive and have attached an example. The portion that is of interest is close to the 8th horizontal division which goes from 15v to about 45v peak.
From my limited research into injector driving that portion actually occurs when the injector drive is removed to close the injector and is the result of the back-emf generated as the coil current collapses. The waveform is what one would expect for the voltage at the drain of a power MOSFET driving the injector in a 'peak-and-hold' mode. The injector opening pulse actually starts at about 1.8 mS (where the waveform drops close to 0), continues during the peak phase to ~ 4.4 mS, then becomes a rapidly-oscillating PWM wave which reduces the coil current during the hold phase which ends at ~7.8 mS. The slight hump in the waveform between 8.6 and 9 mS is a result of the valve pintle closing. So the injector open time starts shortly (say 0.5mS) after 1.8 mS and ends at ~ 8.6 mS (i.e. open time = 6.3mS).
If I were building a circuit to produce a pulse of width = this particular injector open time I think I'd start my pulse at 1.8mS and end it at 7.8mS (both points easily identified), giving 'open time' = 6.0mS (with a 0.3mS error).
 
@alec_t
Thanks for the explanation. That makes it much clearer. Obviously, I was focused on the wrong part of the curve. Measuring the hold time as you describe it (see post#6) should not be too difficult, if that is what is related to the amount of lubricant needed.

John
 
Last edited:
Hi both,

That's great replies - and confirmation on the waveform is what I needed (and what I thought after revising my initial thoughts seen in post #1). So with all this info, I should in theory be able to start planning and designing a circuit. I'll let you know my findings once I get all the stuff I need... breadboard is probably the most important thing in order to test things out! My next post will probably be a list of components and a circuit diagram to check I'm going in the right direction (in a couple of weeks time no doubt)...

Last couple of questions Re. the back EMF, Do I need to protect against this? eg. diode across the injector coil pins (but might that mess up any feedback loop that the injector system may [I don't know if it does] use), OR eg. would the voltage divider handle this peak? I know about back EMF's on relays and that's the normal way I've handled it (using a diode) but would value your advice.

One other idea I thought I'd mention.... would the use of an 'optocoupler' help clean up the input signal or might it confuse things in terms of determining the pulse width we need to measure? This would in some sense provide a means to isolate my circuit vs the prinns circuit and so I thought I'd mention it.

Thanks

RodP
 
Of the cuff, I would lean toward using an optocoupler. It is a nice way to voltage shift and to isolate from the noisy automotive electrical system.

Will you need to measure the period of rapid oscillations too, or will just the opening pulse do?

John
 
I wouldn't need to measure the minuscule oscillations that you see (id'd by 'red b' or 'black b' in the pdf file) - if that was merged into one whole lump that would be fine but then how would the back emf be ignored, via the diode?

So from that point i gather the resolution that the optocouple can provide is limited. I'll just have to check the frequency spec of the optocoupler I buy then. Any recommendations? Considering revs are 0-6000rpm (so in terms of cycles 0-3000 cycles per min =50Hz, so lets say use an optocoupler that can handle at least 100Hz?)

Thanks

Rodp
 
I was referring to the graphs on the second page of post#6. You have the red_a and red_b periods. Red_b is the period of oscillations. Similarly, you have black_a and black_b periods.

I am not sure which period is important for determining the amount of lubricant to be injected. That is, is it "a" only, "b" only, "a+b," or just maybe, it is the number of oscillations in "b?" I have no idea what the right answer is. Of course, in the figure presented, it is obvious that period "b" changes more than period "a." However, it is not clear whether that is related to the amount of lubricant needed.

As for the high voltage spike, the optoisolator can handle that. Here is just one example (https://www.avagotech.com/docs/AV02-2373EN ). I haven't studied its datasheet; it was just the first one listed on Digikey.

Once we know which period or what you need to measure, then an algorithm can be written to detect and measure it. For example, if it is period "a", you could look for the first negative edge after a period of high's to start the timer. You could stop the timer at the first positive edge after that. Or, if it is the number of oscillations, you could count the number of oscillations, etc.

As for the optoisolator speed, I think they are plenty fast for this application.

John
 
Last edited:
Hi John,

Thanks for suggesting an optocoupler...

To confirm, Red_B and Black_B will be the periods of interest and will equate to the overall pulse width I'm wanting to measure. I don't think I need to worry about the minuscule oscillations within the period of Red_B and Black_B just the time it starts and ends. As alec_t mentioned, the injector is energised using a PWM signal rather than a constant current per cycle. The PDF shows just one cycle. Hope confirming that makes things clearer?

Thanks

Rod
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top