Shop OBEX P1 Docs P2 Docs Learn Events
The BS2 as a fuel injection ECU? — Parallax Forums

The BS2 as a fuel injection ECU?

WynandWynand Posts: 39
edited 2012-11-20 20:48 in BASIC Stamp
I am a newbie, but having said that have some experience with programming and electronics. I have an idea to use the Basic Stamp·2 as a Electronic Control Unit to·drive·a fuel injector on a small gasoline engine. I would have to interface it with a (home built) air mass sensor, RPM sensor, and the·fuel injector itself.·I was thinking that the process control would run something like this :

·· Check engine running
···Wait for valve open indication (crankshaft at right position to inject fuel)
·· Read Air·mass sensor (to determine how long to open fuel injector)
···Read·engine load sensor (to determine if more fuel is needed)
···Look up fuel injector timing according to mass sensor data and engine load (data table made up from physical experiments with engine to get·stoichiometric data)
···Send pulse to fuel injector

I have most of the stuff in my head, and am trying to get it onto paper, so that I can start to fabricate and engineer.

So sorry, I have a BSP2, with the board of education.

I would appreciate to hear from the community, and I welcome any and all suggestions, comments and criticism
«1

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-05-11 15:41
    It does only cycle at 2000 Basic Instructions Per Second, AND there's no interrupts, AND it's "single-tasking".

    If you can live with all of that, you can do it, but I doubt you can live with all of that. An ECU is kind of a real 'real-time' application. Probably requires WAY more processor speed than the BS2 has.

    The SX52 processors can be used, though.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-11 15:50
    If you can offload the higher speed functions like the fuel injector timing and the valve open timing to some kind of external circuitry like an SX processor, the Stamp should be fine for the higher level control functions. Presumably, the air mass sensor and engine load sensor produce analog signals and would need to be run through a multi-channel ADC. The BS2p is faster than the BS2, so that'll help, but it's still not fast enough to do the timing for the fuel injection.
  • WynandWynand Posts: 39
    edited 2007-05-11 16:09
    Wow, well I asked for it.

    Ok, so here is my feedback to your comments.

    1.) the BS2 runs at 4000 instructions per seccond, or so I am to believe from their website and data sheets.

    2.) the engine only operates at 3000 rpm (max) and that means that the time between fuel cycles is 0.04 secconds. (40 ms).

    3.) the injector timing could be doen with the pulsout command, since we are looking at milliseccond timing due to the pressure in the fuel line and the size of the injector.

    4.) I am sure that the entire program can cycle in 0.04 secconds, after all, it is a point to point instruction set to be followed.

    5.) valve open timing is just a simple hall efeect sensor on the fly wheel f the engine, to tell the stamp when to start the whole cycle.

    6.) yes, and no. I was thinking, how fast can a RCtime command be run? That should do for both the air mass and for the egine load.

    Ok, so that is me all done, but please, keep the comming......

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-11 16:21
    The main issue for you is that the Stamp is "single threaded" in that nothing is buffered or "latched", etc. If an injector is being timed, the Stamp can do nothing else. If you're trying to read an analog voltage or a resistance value with an RCTIME, the Stamp cannot do anything else.

    The instruction execution speed is not based on statements. A given statement may result in any number of instructions depending on the complexity of the statement. That reduces the effective statement execution speed that you might be thinking in terms of.

    There is a significant downside to missed events or mis-timed events. The engine can misfire or run rough at the least.

    The Propeller has enough processing power to do this sort of thing very well. It can do the analog to digital conversions by itself (with a couple of passive components) and do extremely accurate multiple timings. The Stamp is marginal at best unless you offload the more demanding functions.
  • WynandWynand Posts: 39
    edited 2007-05-11 16:36
    Mike.

    OK, I understand your comments. I did a little reading and I think it could work. (a project to be done just because it is there)

    I totally agree with you on the timing issue, but with at the least 40 milliseconds to work with, and a straight forward top to bottom approach to programming, I think that it could be done.

    Sorry that it sound as if I am just spouting the same lines over and over again, but I really believe that the Stamp2 can do it for a one cylinder engine running up to a maximum of 3000 rpm.

    I thank you for your comments, but I think I will foolhardy stammer into the continuum that is stamp programing. Later, wen I have hit my head more that the prerequisite amounts of time I think I will bow down to your knowledge of trail and error and experience, and follow to the propeller chip. If the stamp doesn't work.

    But like I said, if any body (including you Mike) have any suggestions and comments and criticisms, please let me know.....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • jasonsp6jasonsp6 Posts: 2
    edited 2007-05-12 00:40
    The lack of interrupts would be a problem.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-12 03:13
    Jasonsp6,
    Actually, the lack of interrupts shouldn't be a problem. The engine cycle is just that. It repeats constantly with events occurring in order. There's really nothing to interrupt this cycle. Any events that might force some action can be worked into the same cycle and need not be serviced instantly. My main concern is that some kinds of actions (like issuing a control pulse or reading various sensors as resistors) take considerable time to perform if the Stamp does them itself and there might not be enough time left in the cycle for other control code to execute. This is easily solved by offloading the timekeeping for the pulses and/or using a simple external analog to digital converter for the sensors (like an ADC0834).
  • WynandWynand Posts: 39
    edited 2007-05-12 08:54
    Mike,

    I like the way you are thinking, that is exactly what I had in mind, the stamp is just the brains behind the whole operation, and the menial stuff like the reading of sensors can be left to 'dumb' (not literary, but in terms of the BS2) devices such as the ADC0834. Then all that is left for the stamp is to decide exactly how long the injector should be held open. So all the stamp has to do is to read the ADC0834 when it needs, and then continue with the rest of the cycle. Based on preliminary calculations, the longest time the injector would have to be open is 0.005 seconds, giving the engine the most gasoline that it can stoichiometrically use.

    So gents (and ladies) that is my plan, please don't stop with the suggestions, and comments, I need all the constructive criticism that I can get......

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-13 19:50
    Wynand,
    You could use a external PWM curcuit to drive your injector and then have the stamp sed it update signals only when a change is needed so the BS2 is not slowed down by the Pulseout or PWM command. It should only cost a little to build a PWM curcuit and then use another Micro like the SX to control it or a simpler design you could use a digital pot to control the PWM curcuit to control the injector. I have some simple curuits I can suggest..also I would like to build a EFI engine here at my shop so let me know what type of engine you plan to use...
  • WynandWynand Posts: 39
    edited 2007-05-13 20:17
    Hi bennettdan

    I want to use a Honda GX160 engine for my initial experiment, just because it is a very easy engine to take apart. Actually, any old single cylinder engine would do, I happen to have a new GX160 lying around doing nothing (except tempting me). It is rated at 3000 RPM (optimum) and to tool a new intake manifold to accept the air mass sensor will be easy to make. The injector I have is from a Toyota 2.7i 4x4 truck, so it should do nicely, not have to be open for very long, because the makers tell you have to have a 50% duty cycle (50% of the time open and 50% of the time close) otherwise the injector overheats and damages the internal coil.

    Enough about my parts pile. A soon as I have the GX160 working, I would like to update my quad bike to EFI, just because it can be done.

    So o summarize, the Honda engine will be the prototype to bigger and better things, and I will share any and all knowledge with you. I was thinking of using a ATmax48 as the muscle, and he stamp just as the brains of the operation.

    All ideas welcome people........

    Wynand.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-13 23:42
    I like the SX and the BS2 myself and will look for an old lawn mower engine to play with give me a couple of days.
  • Nick WaldvogelNick Waldvogel Posts: 71
    edited 2007-05-15 16:58
    I have thought about this type of project before also.· My thoughts were that you could possibly use a 555 timer to trigger the injector with appropriate hardware and the stamp could control a digital pot to adjust the timing of the 555??· I'm by no means an expert in this and I haven't tried it yet as well.· I'm very open to your thoughts!!· Lets keep this one going!· I also agree with Capt. Quirk.· Some of the best running fuel injected engines that come into our shop are the simplest ones!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • bennettdanbennettdan Posts: 614
    edited 2007-05-15 22:25
    Nick Waldvogel,
    I have some 555 curcuits that work like that but a dual nand gate curcuit Beau gave me works very well for Digital pot and PWM and is 100% duty capable. The Sx could be used the same way and it could talk to the BS2 with serial instead of the digital pot having to be used which is just more parts..
    If I was going to make this work I would use a MAP sensor for manifold pressure readings and a hall effect sensor for RPM. Then make a table to have the PWM change compared to data the sensors read. This is want Chevy used on its TBI systems.
    They also use temperature sensors to change Idle quality at different temps which could be added later.
    Do you plan to use something like a IAC (Idle air Control) to change the minimal throttle setting? on the cheap you might use a servo..
    I like this project keep it comming...I am still looking for a cheap motor.
  • Nick WaldvogelNick Waldvogel Posts: 71
    edited 2007-05-16 00:24
    I'm still also looking for a cheap motor to try this on....· I'm almost tempted to go to Sears and buy one of them cheap $200.00 mowers just for the engine.....· Most of the parts that I have here at my place are of the Arctic Cat snowmobile style.· I have a throttle body from one of there sleds and they don't use a map sensor.· Instead they use a throttle position sensor, barometric sensor that is mounted in the ECU, air temp, water temp, and a hall effect sensor for crank position.· They also don't use an IAC valve.· Instead the butterfly is held slightly open with a throttle stop adjustment screw.· More then likely my version will only use the TPS and a hall effect for crank position at first.· I’m sure it won’t run very good but it will set the foundation at least!!· I have never used the SX before.· I might have to get one and play a little with it!!· jumpin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Nick WaldvogelNick Waldvogel Posts: 71
    edited 2007-05-16 00:46
    I have the fuel pump from one of the sleds as well.· Stock pressure is 42 PSI and we have adjustable pressure regulators at work for them if it's needed to go up or down.· The nice thing about this pump is that it can be mounted in pretty much any plastic container you have.· It can even be a standard gas can from the hardware store.· This pump is also a one line system where the regulator is mounted on the pump and it dumps the extra pressure before it ·leaves the pump.· Here is a picture of one.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    400 x 300 - 12K
  • dbc1218dbc1218 Posts: 33
    edited 2007-05-16 01:37
    I have thought about doing this too. I have an old 3hp, horizontal shaft, briggs that would be perfect. It was my understanding that you would need to use a oxygen sensor on the exhaust, but no one has mentioned it. Its it not really needed? Check out this site www.ecs.umass.edu/ece/sdp/sdp05/hollot/ Its for a college competition know as Super mileage, teams use new 3hp briggs and a lot of them come up with some sort of fuel injection system. I'm sure if you did some searching you could find a bunch more sites like this one.
  • Nick WaldvogelNick Waldvogel Posts: 71
    edited 2007-05-16 02:23
    Total Powersports in Gaylord, MI· I’m the Parts and Service Director.· I get the feeling that you are at a powersports dealership as well.· May I ask where and what as well??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • bennettdanbennettdan Posts: 614
    edited 2007-05-16 04:08
    Capt. Quirk,
    I think Nick and the other in here are just interested in making it work on a small engine first then working to a larger scale with a better charging system and more cylinders with maybe even upgraded electronics on the way to an open source EFI. I have a we sight you can get a motor from on the cheap if you plan to spend 200 dollars Nick..
    http://www.surpluscenter.com/sort.asp?UID=2007051523063801&catname=engines&keyword=NEGH
    Good luck...
  • mobile_bobmobile_bob Posts: 50
    edited 2007-05-16 04:31
    i am not an expert at fuel injection, but

    the simplest form is alpha n, which basically i a throttle position and fuel pressure system, they work fairly well for flat out power (racing), but require
    all sorts of tweaking to tune in for temp changes, baro pressure etc. they also are not known for good and reliable idle or part throttle .

    the map system is a step up in my opinion, basically with a manifold pressure sensor you can determine engine load and tailor the fuel rate for
    idle, part throttle and full throttle and various loads.

    mass air flow systems are a step above the map systems, and more complex.

    if it were me i would work toward the map system, using as many of the gm components as you can, they are readily available and cheap
    and work off of a 5 volt system

    the ford style mass air systems use pwm schemes and work well but are more complex in my opinion.

    i guess it all comes down to what you want to do.

    several years ago i worked up an alpha n system (full mechanical) to fuel a caddy 500, but lost interest because of the complexity and a divorce [noparse]:)[/noparse]

    with the stamp or maybe a couple of stamps i might revisit the possibility of finishing the project

    ideally i would love a system useing 4 single throat tbi off of 4 bangers on a sheetmetal intake for the 500
    that would be killer [noparse]:)[/noparse]

    if i could get it to great wot performance i would happily sacrifice some idle quality or mid range drivability.[noparse]:)[/noparse]

    neat project

    bob g
  • LawsonLawson Posts: 870
    edited 2007-05-16 05:03
    Interesting topic. I've got some interest in doing fuel injection for 2-cycle engines. I've got an old bike I'm using for a project, love the engine it has (power everywhere!) but the old carberator slows the throttle response.

    Anywho, I've used a BS2 for a high speed servo loop before. It was just running relays to provide crude positioning while checking for a stalled motor. I eventually got the servo loop running at 70Hz. The code is NOT pretty. every cycle through the loop checks one of two RC command pulse inputs, (the sync point) does a quick RC time, does a 1ms count of pulses from a hall sensor, then updates the state machine and relay outputs. (it also toggles a pin so I can measure the execution rate) So, I'd say that if an external ADC is used for sensors a BS2 will be able to keep up with what you've described.

    Even with all that I still second Mike's recommendation to use a Propeller. Processor overkill is a GOOD thing. Having everything work the first time at full speed would've saved me a lot of time wasted developing code.

    my two cents,
    Marty
  • bennettdanbennettdan Posts: 614
    edited 2007-05-16 22:04
    Bob G
    I am with you I have a V8 truck I would like to make a custon EFI on. I also have Visual studio and could work up a GUI interface to tune our EFI.

    I like the SX and think it could be used as a coprocessor working with a BS2 or another SX as the main CPU. A propeller is still real new to alot of the guys interested in this project.

    Post Edited (bennettdan) : 5/16/2007 10:10:16 PM GMT
  • WynandWynand Posts: 39
    edited 2007-05-17 07:06
    Wow, gues you are all champions in my book, what started out as a idae has blossomed into a full scale movement. Bennettdan, I have started working on code today (Holiday in Namibia), so I will keep you guys updaes as I progress....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-17 20:59
    Wynand,
    Please take some pictures of you Honda motor and post them. I have a pretty good fab shop and might help out with an aluminum intake just buy the EFI bung and send me your old intake and what you plan to use as a throttle body and then we can go from their.
    What do you plan to use as a throttle body? Something small like off a EFI motorcycle? anyone know of any small throttle bodies out their?

    I will post some code that works with the PWM circuit I have and will also post the diagram of the hardware it uses a digital pot and a couple of nand gates to make the PWM and it will maintain its position untill the BS2 tells it to change so you only update it if it needed instead of generating the pulses all the time.

    Post Edited (bennettdan) : 5/17/2007 9:04:12 PM GMT
  • WynandWynand Posts: 39
    edited 2007-05-18 05:15
    BennettDan,

    I was planning on using the existing butterfly from the carburator installed in the new intake as the throttle body. Since it is already the perfect size, and all that is needed is to position it in the center of the new intake with two bushes. I will post the pictures of the engine a little later today (straight after work). It is realy a very small and simple little engine. easy to work on. I am very interested in your code............

    Wynand.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-18 17:54
    Wynand,
    ·· Here is a curcuit that you can use the BS2 to set the digital pots wiper to maintain the PWM duty cycle on the injector this is a modified motor circuit running at 20khz you really dont need that to drive the injector you the cap values could be less..
    The code I have not rewrote to work but the WAM text has examples on how to control the Digital Pot which controls the PWM.
  • bennettdanbennettdan Posts: 614
    edited 2007-05-19 00:08
    I found a motor today its a BS off a murry pushmower a freind had and gave me. I plan to cut down the deck and build me a small test stand for it to sit on for testing. I will need a flywheel that is close to the same weight as the mowerblade so it will be safe to be around and run..."I found out the hard way along time ago that a push mower wont crank without a blade..HA" I will send pics when I get the stand made.
  • WynandWynand Posts: 39
    edited 2007-05-19 06:56
    Thank you Capt. Quirk, I will be sure to check out those two sites!!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-19 13:23
    Wynand,
    It will be hard to find an Injector to run a real small engine like the honda you have and the BS I have but you can run it at a lower duty cycle and lower gas pressure and it still might get by. I have found some 9.6lbs/hr fuel injectors from Bosch part# 0-280-150-997 so if you figure a (9.6lbs/hr*.85)/.50 then it is for a max of 16.32hp I think my 5hp motor might not be big enough to run with even the smallest injector I can find but I might cut back on the fuel pressure and run a less than 85% duty cycle and if it wont work I have an old riding lawn mower with a 18hp BS engine on it I might use....
  • WynandWynand Posts: 39
    edited 2007-05-21 06:00
    Bennettdan,

    I guess you are right, my injector was made for a 675cc (2.7liter / 4 = 0.675 liter) engine, and now I will be running it on a 160cc engine, one quarter of original, so I guess I will have to cut back on the duty cycle and the fuel pressure. I have to admit that I haven't yet looked at the specs (Japanese brand injector, me a little lazy [noparse]:([/noparse] ) so Do not as yet know the flow capacity of the injector. I will make work of it today, just as soon as blue monday-work-headaches pass....... In my fever to get this project going, I clean forgot about the fuel pump, as soon as I am home I will rummage in the scrap yards to find a cheap seccond hand one, since new ones run to about (N$3500.00) in my country. Since you are mentioning it, I might also get my hands on a 18hp engine from a Hobart welding machine. Those engines are almost indestructible!!!!!!

    I was absolutely facinated by your circuit diagram, so simple, so practical.....

    Wynand.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • bennettdanbennettdan Posts: 614
    edited 2007-05-21 15:59
    Wynand,
    The circuit to make the PWM with the 74hc132 nand gates was give to me by Beau and I added the digital pot I had in a WAM parts kit and then used it to control a DC motor but the injector will work fine off this I believe.

    I have an old Chevy truck with a TBI injection system I am going to tr this comming week to get my oscope hooked to the injectors all look at the signals. I also plan to look at the map sensor readings and see how it works. I have a good set of prints on this pickup so this might help us ou and I can take live voltage
Sign In or Register to comment.