CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interresting counting problem for an experimental ECU

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
davidbue



Joined: 05 Nov 2007
Posts: 28
Location: Denmark

View user's profile Send private message Visit poster's website

Interresting counting problem for an experimental ECU
PostPosted: Wed Nov 07, 2007 3:17 pm     Reply with quote

Hello everybody!

Now... I've got a problem that I don't really know how to solve. Any suggestions are appreciated!

I'm currently developing an engine control unit (ECU) for an eco-car. It currently runs on a fuel called dimethyl-ether. If you compare the released energy from burning dimethyl-ether with gasoline, it goes what corresponds to 306 km/l (720 mpg) (http://www.ecocar.dk/)

I'm using a pic18F2220 at 36Mhz to time an injector that delivers the fuel to the engine.


When running the engine at full speed I recieve a 72 khz (TTL like) signal from a rotary encoder.

Once pr. engine revolution I recieve another TTL like signal.


Here's my problem:

- A main routine runs within a while(1) loop, performing all sorts of stuff.

Parallel with this, I want to:

- Count up in a variable, the 72 khz signal starting from when I recieve my "once-pr.revolution pulse"

-After a certain number of pulses from the 72 khz signal, I need to engage the injector.


I've thought about using interrupts, but I fear that 72 khz is to fast.

Maybe one could put an interrupt on the "once pr. revolution" signal, resetting a timer with an external clock that is fed by the 72 khz signal?

Maybe you've got a much better idea?


Thanks in advance! Wink
David
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Wed Nov 07, 2007 4:06 pm     Reply with quote

Yes, that's pretty fast, < 14 usec. You might have a fast interrupt which increments a counter and then opens/closes the injector, with some tight (likely asm) coding.

Aternative, measure the time between the "once per rev" pulses, and set a timer to do the injector. This will lag (only slightly) the engine accel/decel, but might be ok?

Ken
Guest








Thanks for your input Ken
PostPosted: Wed Nov 07, 2007 4:11 pm     Reply with quote

Good suggestions, Ken.

Unfortuenatly sampling only the "once pr. rev" sgnal is not good enough. It is a requirement that I use the 72 khz signal :-(

Maybe a setup with two microcontrollers, where the one only does the counting... hmmm.. But that's not pretty...
Ttelmah
Guest







PostPosted: Wed Nov 07, 2007 4:12 pm     Reply with quote

Feed the 72KHz signal into Timer1, or Timer3.
Have an interrupt from the 'other pulse', in which you program a CCP channel, set to count the required number of pulses from the timer you are using. Program this to set or clear it's output pin on the required count (direction will depend on what the injector wants). Connect the injector to the output pin, or if the injector needs a precise pulse width, feed this into a non-retrigerable monostable multivibrator, programmed to give the required width. Poll the pin at intervals in the main, and clear it once it is set.

Best Wishes
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Nov 07, 2007 5:16 pm     Reply with quote

I did something similar to this several years ago but I was using 80C51's. I used a 360 pulse encoder with a 'home' pulse output to signal TDC. Each signal was feed into an interrupt input. The 'home' pulse was fed into int0 and the 360 line was fed into int1. On the 80C51 the int0 could be set to a higher priority. I used a 360 pulse encoder to track each degree of the distributor shaft.

I simply counted pulses and then triggered the injector at the appropriate count. Worked flawless for me. Since I was controlling both the injectors and spark I used a separate controller for each and fed the same encoder signals into each.

Ronald
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Interresting counting problem for an experimental ECU
PostPosted: Wed Nov 07, 2007 5:55 pm     Reply with quote

davidbue wrote:
Hello everybody!

I've thought about using interrupts, but I fear that 72 khz is to fast.

David



I use 18F series PICs at 40MHz with a 1.25MHz interrupt rate. This is achieved by coding the interrupt handler in assembler and using a high priority interrupt. The compiler is unaware that a HP interrupt handler is present - it does require you to set up the PIC interrupt priority and enable high priority interrupts manually.

Provided you have a relatively short interrupt handler I do not see any problem with this long hand method.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group