rushpro
Posts: 7
Joined: Wed Jan 25, 2012 7:02 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Wed Feb 08, 2012 5:37 am

Hello all,

First off, I must say that this is a pretty slick project, and I can't wait until I can get my hands on one!

(Warning, auto mumble jumble ahead)

My question is with regards to the speed of the GPIO ports, I am looking at my options for building a somewhat redneck EFI setup for a smaller gas engine (Either a 3 banger from a firefly or a 4 cylinder motorcycle engine) for a dune-buggy or the like. I am looking at doing throttlebody injection with an Arduino Nano as a test, and the Arduino is just fast enough to pull it off (people have done it before, linkage below)

The big thing is, an Arduino is fast enough to turn a single fuel injector on for 5ms, and off for 20ms and run a small serial based LCD (looking at an example from here: http://www.arduino.cc/cgi-bin/.....1275359057 )

The problem is that it runs off a table based on the throttle position and RPM. While this works fine for a small 12hp engine, I would prefer to run an O2 sensor and mass airflow sensor in order to get the right mix of gas and air automatically rather than using a static table.

So, my question is how fast are the GPIO ports in terms of milliseconds or are they faster/slower?

Thanks!

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Wed Feb 08, 2012 6:11 am

You're not really asking the right questions. Raspberry Pi is designed to run Linux. Linux is not a hard realtime operating system. Your application needs hard realtime operation. Yes, the GPIO on Raspberry Pi is probably faster than Arduino, but the GPIO performance of Arduino isn't the limiting factor anyway, as an ATmega can toggle its I/O at a few MHz. ms-accurate timing isn't difficult at all.

With careful coding (ie. not using the Arduino crap) I don't think it would be at all difficult to do what you propose with the chip on the Arduino board, and IMO it is much more suitable for this sort of thing. If you end up needing something faster, I'd say the appropriate upgrade would be to something based on ARM Cortex-M3 (e.g. ST STM32 Value Line Discovery Kit [$10]) or PIC32 (e.g. ChipKit [$27]), not a full-fledged Linux board.

rushpro
Posts: 7
Joined: Wed Jan 25, 2012 7:02 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Wed Feb 08, 2012 7:30 pm

Thanks for the reply,

First, I understand that Linux is not a real time operating system, if I was to use a linux distro, it would be a custom job stripped right down to just the core(I used to run a gentoo server with a xen based kernel to host virtual machines, configuring a linux kernel is nothing new to me) I believe however for the amount of work that needs to get done, it should still be able to get the job done.

The main reason I want to use a raspberry pi is for the fast cpu, large amount of ram and easy SD card integration (for storing dynamic fuel tables, stats, and logs of the current trip), cheap price, and the possibility to plug a monitor and keyboard in or some kind of serial console, and change all my code out in the middle of nowhere.

As for the ARM based dev boards that you mentioned, I wasn't aware such critters existed for that price. I spend a good few hours looking for ARM based devboards for this project, but they were all out of my budget. I am definitely looking at picking up one of those boards instead of fighting with my Arduino Nano. Thanks for the suggestion!

Yeah, I'm thinking I need to go to the tree of the Internet and regain my google-fu

btw, I'm from BC too, although I am from a bit farther north, as in, Dawson Creek!

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Wed Feb 08, 2012 8:01 pm

rushpro said:


First, I understand that Linux is not a real time operating system, if I was to use a linux distro, it would be a custom job stripped right down to just the core(I used to run a gentoo server with a xen based kernel to host virtual machines, configuring a linux kernel is nothing new to me) I believe however for the amount of work that needs to get done, it should still be able to get the job done.


You might be right, but I still don't think I'd trust it for something like engine control. A process goes awry and eats up RAM, the system decides to swap, and this blocks your engine control process long enough that something bad happens. And since this has the potential to actually cause physical damage, I would really avoid it. If you want Linux, I'd say do the Pi and and separate board that runs the realtime control and have them communicate over SPI/serial (or CAN ).


As for the ARM based dev boards that you mentioned, I wasn't aware such critters existed for that price. I spend a good few hours looking for ARM based devboards for this project, but they were all out of my budget. I am definitely looking at picking up one of those boards instead of fighting with my Arduino Nano. Thanks for the suggestion!


If you have experience with Arduino chipKIT is particularly interesting since they have ported the Arduino environment to that platform - but it is a 32bit MIPS core running at 80MHz, and with more RAM! Learning curve should be pretty small on it, but it's a lot more capable.


btw, I'm from BC too, although I am from a bit farther north, as in, Dawson Creek!


I was up there for a few days for work some years back. Colllld!

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Wed Feb 08, 2012 8:09 pm

Bloody database errors ate my post. Let"s try again.

The transmic.net ignitor is enough to do 20krpm on a 4-cylinder 4-stroke, or 80krpm on a single cylinder. That uses a measly pic. The arduino"s processor should be more than enough to do what you want, and if not there"s the various cortex-m3 boards, the propellor, and lord knows how many other lightweight dev boards out there.

The Pi is probably not your friend for this task, though. Linux (even rtlinux) is a poor substitute for a proper rtos, and the pi has very limited I/O compared to the rest of "the pack". Hell, even timer-wise, the pi is very underspecified compared to ARMs aimed at the control market - the humble stm32 has 26 timer channels, IIRC. And, not wanting to denigrate the newlyreleased broadcom datasheet, the stm32 has documentation and example code to get you up and running "on the metal", which is where you need to be.

rushpro
Posts: 7
Joined: Wed Jan 25, 2012 7:02 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 1:36 am

@error404

I really think your on to something with the dual setup (Arduino/chipKit  for real time, Raspberry Pi for the math/tables) At the same time, I really need to get a prototype going with just the chipKit to see how fast it can perform the math. Chances are, a chipKit programmed properly should be able to pull off multi-port injection while taking the O2 and Mass Airflow Sensor into account and changing the fuel mix accordingly.

As for damage, any slight glitch in the system that is only controlling fuel at worst would cause the engine to stall, either from lack of gas, or getting flooded. Over time however, running the engine too lean can cause some major damage.

@tufty

Hopefully the database is full so it doesn't try to eat my post...

What you have linked to is somewhat different than fuel injection, it is the electronic ignition which controls the spark. For my first project, I am going to use just the stock manual distributor for the spark. Stage two however, I hope to integrate the ignition control into the system (with spark advance once you get into the high rpms)

Thanks for the link anyways, I am sure it will prove very useful in the future when I plan on taking on electronic ignition

updatelee
Posts: 11
Joined: Wed Sep 14, 2011 6:04 am
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 6:08 am

defn worth a try, but I wouldnt be surprised if you end up finding the timing isnt as accurate as you'd like. multitasking enviroments tend to mess that up. once you get one you'll soon find out when you attach it to an oscilloscope wether the timing will work or not.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 8:21 am

rushpro said:


What you have linked to is somewhat different than fuel injection, it is the electronic ignition which controls the spark.


Yeah, I know.  It is a problem of more or less the same order of difficulty as EFI, though (albeit with more calculation required), and has very similar timing requirements.  Not to mention that that particular ignition system happens to be one I've used.  For "homebrew" EFI there's the MegaSquirt, which is based, IIRC, on a 680x0 derivative and a newer version based on (mis) use of a 16-bit automotive ABS controller, and the EFI332, which also appears to be 680x0-based.

http://www.diy-efi.org/efi332/.....gorith.htm may well be of use to you if you haven't hit it already.

Anyway, what I was trying to get at is that, in terms of hard realtime, "less is more". I think you'll find that, even with lxrt patches, the latencies you're going to hit with linux are going to hurt you.  I'd probably go with something like a cortex-m3 processor myself, have the injector code running on a high priority exception – i.e. give the injection process absolute priority over everything else.

Another thing you might want to consider is how you're gonna hook up your various sensors and inputs.  Pi has no analogue in and a relative paucity of GPIO.

Simon

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 9:05 am

I wonder what the weather is where this car will be operating. IIRC, some parts on the RPi are not specified to operate at below zero Celsius.

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 12:04 pm

rurwin said:


I wonder what the weather is where this car will be operating. IIRC, some parts on the RPi are not specified to operate at below zero Celsius.



As long as you do not use the LAN chip (so no USB/Ethernet) the BCM2835 can go to -40C.

Docteh
Posts: 32
Joined: Tue Jan 31, 2012 6:20 am

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 3:03 pm

Or just put it in a small sealed container and run it all the time, generate enough heat to keep things above zero
Stick the little box inside the cab and might not need to worry about the "wind chill factor"

good to know it is the ethernet that will conk out first tho!

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 3:30 pm

Gert said:

As long as you do not use the LAN chip (so no USB/Ethernet) the BCM2835 can go to -40C.
I wonder what the BCM2835 will do when the Ethernet chip goes insane...

Best get a model A, I think.

mole125
Posts: 228
Joined: Tue Jan 10, 2012 2:01 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 3:55 pm

rurwin said:


Gert said:


As long as you do not use the LAN chip (so no USB/Ethernet) the BCM2835 can go to -40C.


I wonder what the BCM2835 will do when the Ethernet chip goes insane...

Best get a model A, I think.


It depends what the failure mode is I would imagine, I'm no electronic (or physical) engineer but as long as no ice crystals are forming on it the only likely issue I can perceive is that low temperatures may make the crystals timing to shift which could cause problems on data transmission/reception if you had a network cable plugged in (unlikely I would hope while driving!). If you go down a lock lower I can see there could be mechanical stress from different components shrinking at different speed or even superconductivity but that is likely to be much lower than zero I would have thought?

Also these are min support tollerances not actual tollerances which vary part by part but could be much lower!

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 4:07 pm

rurwin said:


Gert said:


As long as you do not use the LAN chip (so no USB/Ethernet) the BCM2835 can go to -40C.


I wonder what the BCM2835 will do when the Ethernet chip goes insane...

Best get a model A, I think.



Sorry, but I thought that was obvious: you disable the USB port all together. Just remove/disable the driver.

rushpro
Posts: 7
Joined: Wed Jan 25, 2012 7:02 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Thu Feb 09, 2012 11:39 pm

@tufty

I hear you man! I was looking into the megasquirt, and it looks pretty good, but at the same time, it is somewhat overkill for a smaller engine and is way out of my budget. After giving it some more thought, I completely agree with you, in that "less is more". Now I am really considering getting some small ARM board, and doing all the real time stuff on that, and via a serial connection of some kind, using the Raspberry Pi to do all the math. At this point though, I have no idea how much math is required so it is hard to say if I will need a Raspberry Pi in the first place.

What I kinda want to do with this project is build a easy to use, throttle body EFI system that can be bolted on to any old motor and it just works with minimal tweaking.

As for the weather, in my experience, most electronic things work in -30C to -40C range, they just don't work well. I once powered up an old dell laptop that was left out in my car overnight. It was about -32C outside and I powered it up just before I started my car, and besides the LCD taking FOREVER to update and the battery registering 0% charge, it ran fine.

For this project though, I have access to a large number of 12 volt heater elements that were pulled from some outdoor wifi gear. If I ever power this beast on in the -30 to -40C range, it will be heated before I start. Although, the only reason I could see my self doing this is if I put a plow on the front and use it to clear snow

victhor393
Posts: 4
Joined: Tue Jan 31, 2012 10:35 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 2:25 am

A 700 MHz ARM11 for "maths" is too much. I have a MegaSquirt 1 with ignition control running on a 4 cylinder engine extremely well, O2 correction and all. It's powered by a measly MC68HC908GP32 microcontroller at "8 MHz bus speed" and 512 bytes(!) of RAM. A Cortex-M3 would be overkill for a 2 cylinder engine, I don't see why a low-end micro wouldn't do well.

In short: Pi is completely unsuited for this application regardless of what it is supposed to do (unless you attach a screen to it and use it to program the hardware), any reasonable microcontroller should work.

rushpro
Posts: 7
Joined: Wed Jan 25, 2012 7:02 pm
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 3:19 am

@victhor393

I completely agree with you, any reasonable microcontroller should work fine. The initial reason why I considered using a Raspberry Pi is because it offers enough more than enough performance and at price that I can afford.

The main reason now that I would want a Raspberry Pi to tag along is for programing purposes and complete data logging. I also have a few mikrotik routers that would be really easy to slap on to the unit creating a wireless bridge so I can ssh into the raspberry pi from a laptop while it's running and tweak stuff on the fly.

Needless to say, this thread has been a greatly appreciated eye-opener

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 3:41 am

Given that the R-Pi is so cheap, it is certainly worth investigating whether running "bare metal" is sufficiently easy for this kind of job.  You won't need USB, probably don't need a display, the GPU firmware will set up all of the really nasty stuff beforehand, and the GPIOs and timers are documented.

You should be able to set up timer interrupts and input-triggered interrupts and do virtually everything from those.
The key to knowledge is not to rely on people to teach you it.

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 8:05 am

You could try grabbing a cheap microcontroller to do what you want, one that does RS232. Then you can communicate with the micro from the Pi, and use the Pi as an in-car computer for GPS and such, as well as displaying engine stats.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 9:19 am

Oh, shitbiscuits.  Bloody forum logged me out while I was posting and I just lost a massive post.  Here's the gist of it.

1 - Pi is cheap, but STM32VL-Discovery is cheaper (free, if you know how to go about it)

2 - Pi has few GPIOs, no analogue in, and you have to solder to fiddly little holes on the board. STM32VL-Discovery has loads of GPIOs and analogue channels, and every pin on the controller is brought out to a header

3 - ARM1176JZF-S is an applications processor, Cortex-M3 is a microcontroller.  The difference is in how much effort you have to make to get real time behaviour.  At 10,000rpm, 60us of 'slop' in injector firing can be enough to hole your pistons

4 - The math is not hard.  Even a Cortex-M3 can do it in its sleep

5 - Logging is not hard.  With a Cortex-M3, in the time you've saved not having to tit about manually handling interrupt priorities and keeping your timers square, you can take some off-the-shelf code to write to an SD card (which is a very easy interface job, code and wiring examples abound)

6 - The time and effort you save will leave you ample time to replace the pistons, valves, con rods, head gaskets and cranks you're gonna destroy.  I went through 4 FZR400 top ends and one crank when prepping my bike for an (abortive) TT effort (and we weren't messing with the timing too much).

Simon

tritonium
Posts: 79
Joined: Tue Jan 03, 2012 7:10 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Fri Feb 10, 2012 1:47 pm

OK here goes - time to make a fool of myself....

At 10,000 rpm ~ 166 revs per second (10000/60)

1rev~6ms = 6000us
1 rev = 360 degrees so (lets say) 16.6us per degree.
to resolve say 0.1 of a degree requires resolution of 1.6us. (clock 666kHz)
So a programmable timer with clock say twice that ~ 1.3Mhz

(roughly)

I'd have thought most micro's could do that and with 6ms between (cylinder) ignitions (or is it twice that for four stroke (12ms)) LOADS of time for the sums.

The propeller microcontroller has a standard clock of 80 Mhz and is often driven above 100Mhz. (thats 20-25 Mips)
It has EIGHT processors each with timers able to resolve at full clock speed.
EACH processor can generate a vga output of good text quality. Using multiple processors and 'tile' methodology allows colour gameplaying  abilities.
32 I/O pins accessable by all the processors.
Few built in periferals other that the timers, the philosophy is to do everything in software using one of the 'cores' or 'cogs'.

So with this you can assign a processor to do the timing - even one for each cylinder -  another for coms and another for visual display for real time adjusting, and then some to spare.

Also
They are I believe about $7 and in dil package.

http://www.parallaxsemiconduct.....oreconcept

the very active forum has lots of helpers and examples.

http://forums.parallax.com/forum.php

Personal I would like to team one up with the 'pi - all sorts of possibilities.

dave

(Oh and there is a new super prop in the wings - any day now)

FiftyOne
Posts: 12
Joined: Wed Sep 07, 2011 11:22 am
Contact: Website

Re: Speed of the GPIO ports? (For electronic fuel injection)

Tue Feb 14, 2012 1:51 pm

Hey rushpro,

Love the idea's your throwing around. I'm in to motorsport myself & a simple setup on a pi with a gertboard for full logging (gps, accelerometers, control input, revs, temps, vid) in such a small package which would be FAR! cheaper than any Motec unit or similar.

Given that its not 100% suited to the application on face value, I wouldn't let it put you off. There is so much that people will be able to do with these things over the next 6 months, no one thought possible (or even thought of)

Have a look for tunerPro software, theres some good stuff there that might give you ideas.

plugwash
Forum Moderator
Forum Moderator
Posts: 3526
Joined: Wed Dec 28, 2011 11:45 pm

Re: Speed of the GPIO ports? (For electronic fuel injection)

Tue Feb 14, 2012 4:28 pm

Devices like the Pi aren't a good fit for stuff where you need precise timing because there is a lot of stuff you can't see or control between your code and the perhipherals. Something like a PIC has FAR tighter control over it's IO timing than the poweful but complex SOCs seen on the Pi.

That doesn't mean a Pi couldn't be used as part of such a system, to run a UI or to run complex longer term calculations (for example the Pi could work out what timings are best and then a PIC could apply those timings). The key is the fine timing work should be done by a chip that is simple and predictable.

Return to “General discussion”