I am trying to code a fuel injector an optical encoder and a flow sensor for my water injection project.
I am trying to code the optical encoder to imitate a crank position sensor so I can program an injector to shoot water in a clear cylinder at the degree on the encoder when theoretically a piston would be at the top of the cylinder. The clear tube will act as the cylinder and the water injected will be the fuel. For the fuel injector I am not sure how to code the logic. I tried just doing a pmw write but am not sure if I need a digital write to the pwm so that I can incorporate my logic of when to inject water. Finally, the flow sensor puts out 1200 pulsed per liter. I am not sure how I would approach this either. I am using makerhub linx logic to write the program. I have no experience in labview and only have the student 45 day trial. Attached is what I have done so far.
I'll do my best to respond to your questions.
First, to track engine position, I would recommend downloading and installing the NI Powertrain Controls device drivers through the JKI VI Package Manager. These drivers contain VIs that will interface with NI Powertrain Controls modules, and they have some other features also. One of those features is a set of Engine Position Tracking, or EPT, VIs which will calculate the angular position of a reciprocating internal combustion engine based upon input from crank and, if necessary, cam position sensors. You can use either the EPTx VIs, which are our newest version of VIs and are highly adaptable to various crank and cam position signal patterns, or you can use the EPT Rev C VIs, which are older but offer support for encoders and simple production signal patterns.
Regarding your fuel injector, what do you know about how it is intended to operate? Do you have any idea what the current and voltage waveforms that are supposed to command it are? Typically, automotive fuel injectors are driven by a current waveform featuring a peak-and-hold profile, where the current level is initially set to a high peak to open the injector and the falls to a lower level to keep the injector open and flowing fuel. They typically do not use a standard PWM signal as might be seen in a motor control application.
Do you know what type of fuel injector it is? Is it a solenoid or piezoelectric injector? If you aren't sure, you can measure both its inducatance and capacitance with an LCR meter. What type of application is it originally from (gasoline direct injection, common rail diesel injection, etc.)? NI offers the NI 9751 Direct Injector Driver C-series module for use in Compact RIO chassis; it is the best solution NI offers for driving automotive fuel injectors.
Regarding the use of your flow sensor, you'll need to find or write some code that counts the number of pulses being sent by your sensor in a set amount of time. In general, frequency-based signals like the one your sensor outputs are superior to analog outputs because they have significantly higher immunity to noise; however, their downside is that they do require additional effort to process their data.