Arduino go kart EMS

Free Open Source Firmware project discussion forum. Post your Free Open Source firmware projects here!
crazyafrican
DIP8 - Involved
Posts: 24
Joined: Fri May 10, 2013 5:43 am
Location: Auckland, New Zealand

Re: Arduino go kart EMS

Post by crazyafrican »

I tried your interpolation function with my firmware and I'm getting some strange results. Sometimes it works flawlessly but other times no interpolation is done. Here is a screen shot of mine where the required fuel is 10.0 and the pulse width should be 9.0, on arduino uno. As soon as MAP goes down to 94 the interpolation works. Any way good luck with your project!
4.7.2013.png
noisymime
DIP8 - Involved
Posts: 29
Joined: Wed Feb 06, 2013 4:12 am

Re: Arduino go kart EMS

Post by noisymime »

crazyafrican wrote:I tried your interpolation function with my firmware and I'm getting some strange results. Sometimes it works flawlessly but other times no interpolation is done. Here is a screen shot of mine where the required fuel is 10.0 and the pulse width should be 9.0, on arduino uno. As soon as MAP goes down to 94 the interpolation works. Any way good luck with your project!
Thanks for the feedback, really appreciate it! Could you please try the latest interpolation code at https://github.com/noisymime/Kartduino/ ... er/table.h and see if it works any better? If you're still seeing issues, could you please let me know exactly what RPM and MAP values are causing the problem?

You mentioned that you're running on an Uno, do you know how the scheduling is working in the code you're using? Just that the Uno only has a single 16-bit hardware timer which is very limiting. The scheduler I've written is currently using 2 timers, 1 for fuel and 1 for spark, but this will need to grow to 4 timers when I add support for up to 4 cylinder engines.

(I'm the first to admit that there's probably cleverer people than me out there that can safely reuse timers across multiple cylinders, but that's hurting my head at the moment :) )
crazyafrican
DIP8 - Involved
Posts: 24
Joined: Fri May 10, 2013 5:43 am
Location: Auckland, New Zealand

Re: Arduino go kart EMS

Post by crazyafrican »

I will give it a go thanks! I wrote a small scheduler for task scheduling and task timing.

https://sourceforge.net/projects/microdispatch/

It wont be very precise for event timing but should be ok for 0.1ms resolution for fuel injection. So I use timer0 to generate a 0.1ms interrupt that ticks the scheduler, and the 16bit timer1 that I use to calculate time between spark interrupts for rpm calculation. No plans for ignition control yet although the advance table is already created.

UART and ADC is all done automatically with the task scheduler and interrupts. There is also buffers for both RX and TX uart.

Have a look if you want:
efi-firmware.zip
(22.46 KiB) Downloaded 877 times
crazyafrican
DIP8 - Involved
Posts: 24
Joined: Fri May 10, 2013 5:43 am
Location: Auckland, New Zealand

Re: Arduino go kart EMS

Post by crazyafrican »

Here are the results from the new funtion

http://youtu.be/gFQdOlcSBac
noisymime
DIP8 - Involved
Posts: 29
Joined: Wed Feb 06, 2013 4:12 am

Re: Arduino go kart EMS

Post by noisymime »

That seems to be behaving about how I'd expect. It's certainly interpolating correctly between the 90 and 100 VE values once you reach 95kPa. The weirdness before then is 100% due to the accuracy loss that comes in when you lose the floats (At least, the way I've done it). I've had a play with it tonight and I can improve the accuracy a bit, probably within 1%, but it's always going to be off by a bit unless I find another float free method.
noisymime
DIP8 - Involved
Posts: 29
Joined: Wed Feb 06, 2013 4:12 am

Re: Arduino go kart EMS

Post by noisymime »

OK, been a while since I posted, but I have been making a little bit of progress.

I'm just awaiting a few bits of hardware then I'm hoping to actually try for a start on my test engine (single cylinder, 4 stroke) controlling ignition only. Fuel is getting there, but I haven't done all the enrichment code yet.

I've tested as much as I can at the moment and things seem to be looking good. RPM signal (including the missing tooth decoding) from the 12-1 wheel on the engine is very clean between at least 50rpm and 6000rpm (Just running on magneto and carb) and the scheduler seems accurate to 16uS whilst at high RPM.

Serial interface to TunerStudio is working, though I haven't setup pages for everything yet. Not sure if it will work out of the box with any of the other similar apps, but the ini is there and reasonably simple (Doesn't use anything funky that, say, an MS1 doesn't)

If anyone feels like taking a glance over the code to see if up going in completely the wrong direction, it's up at: https://github.com/noisymime/kartduino

I'll post again when (if!) I can get things up and running :lol2:
noisymime
DIP8 - Involved
Posts: 29
Joined: Wed Feb 06, 2013 4:12 am

Re: Arduino go kart EMS

Post by noisymime »

Just so I can tell whether I'm in the ballpark or not, how fast does a mainloop (Comprising of all required analog reads, the table lookups. timing calcs and scheduling) need to run? I'm currently getting around 1650 cycles per second of the mainloop, which includes just about everything, but not sure if this is fast enough or not. I've done a lot of work on speeding up things like the analog read system, replacing the standard division function with an unrolled asm version (About 2kb in size, but worth it for speed) etc, and this has brought the loop count up from about 1000/second to around this 1650 mark.

The only thing that's not running when I did this benchmarking was the serial comms, which will obviously cause a decent hit, but the system can be run without them if needed.

Is this going to be sufficiently fast in a real world situation?
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Arduino go kart EMS

Post by Fred »

Yes, by far. FreeEMS is much slower than that, and the only time it matters is during a change of state, and it's fine in FreeEMS.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
crazyafrican
DIP8 - Involved
Posts: 24
Joined: Fri May 10, 2013 5:43 am
Location: Auckland, New Zealand

Re: Arduino go kart EMS

Post by crazyafrican »

You can take some more load off the cpu by using uart receive and transmit interrupts. Take a look at "uart.c" in the zip file I posted up 6 comments above this one.
noisymime
DIP8 - Involved
Posts: 29
Joined: Wed Feb 06, 2013 4:12 am

Re: Arduino go kart EMS

Post by noisymime »

Thanks for the replies guys.

My understanding is that the Arduino Serial library is already using the hardware uart, so that should all be taken care of.

I've had a little success tonight in getting my test engine running with ignition control. It was pretty rough as the sync was dropping a little, but it ran! :D
Post Reply