Author Topic: A few newbie questions  (Read 5585 times)

0 Members and 1 Guest are viewing this topic.

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
A few newbie questions
« on: April 02, 2012, 12:03:19 am »
Hi all...

I'm not exactly a beginner, but I have very little experience in designing and constructing circuits.

I'm working on a rather large (for me) project which is a ECU for my dads car (1980s Jaguar)... Some project details can be found at http://www.jaguarforums.com/forum/jaguar-engines-47/custom-jaguar-l-jetronic-5cu-ecu-70295/ but in a nutshell, its a programmable ECU so dad can get better fuel consumption out of his car...

I can do the programming (I'm using the arduino environment for the prototype)... I just need a little help with the circuit design.

I need to
* Read the Tacho pulse from the distributor/coil
* Have a 0 to 1 volt signal (from the Lambda sensor) amplified so the micros ADC can read it

Any questions, please ask... I know i may not have been very clear :(
« Last Edit: April 02, 2012, 12:19:33 am by agilly1989 »
 

Offline Spikee

  • Frequent Contributor
  • **
  • Posts: 568
  • Country: nl
Re: A few newbie questions
« Reply #1 on: April 02, 2012, 02:03:04 am »
1. voltage divider -> opto coupler ? or hall sensor
2. opamp whit a gain of 5 -> 0-5V for ur adc
Freelance electronics design service, Small batch assembly, Firmware / WEB / APP development. In Shenzhen China
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9951
  • Country: nz
Re: A few newbie questions
« Reply #2 on: April 02, 2012, 02:11:34 am »
Is the lamdba signal from ground to +1V ?
Because the ADC can read that. Assuming the ADC power is 5V then you have 1024 steps    5V / 1024 = 4.8mV for each step.
So 1V will be   1/0.0048  = 204 (adc value for 1V).

You can always run the ADC off 3.3V or 2V to get more resolution if needed.
But if the lamdba sensor is very low current you'd need an opamp anyway, so might as well up the voltage while you're at it.

To read the tacho pulses you'd want to
- Get the signal down to your ADC voltage with a resistor divider
- Feed it into a mcu pin that is an external interrupt.
- Then, in the interrupt handler, start one of the timers counting. On the next pulse read the timer value.
(The other way to do it is to clock the timer directly using the timer input pin, but that can cause issues and you lose some control of the counting)

When dealing with stuff in cars you want to add some protection from voltage spikes.
So on each input add a small TVS diode to ground. And another larger TVS from your 12v power input to ground
An optoisolator is also a good idea but not 100% necessary.
« Last Edit: April 02, 2012, 02:18:24 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
Re: A few newbie questions
« Reply #3 on: April 02, 2012, 02:18:21 am »
Yes it is from ground, so thanks Psi

I was thinking of using a Rail-to-Rail op amp with a gain of 5 (since it'll be running from 5 volts), but I'm not sure if the load will be too much for the lambda sensor, I believe its only very low current... Should I use a buffer?

I tried the interrupt thing with a computer fan, but the reading was erratic, Im thinking of using the LM2907 (or similar) and using one of the analog inputs for a more accurate reading of RPM

And thanks for the TVS diode tip, I'll incorporate that into my design
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9951
  • Country: nz
Re: A few newbie questions
« Reply #4 on: April 02, 2012, 02:24:59 am »
I was thinking of using a Rail-to-Rail op amp with a gain of 5 (since it'll be running from 5 volts), but I'm not sure if the load will be too much for the lambda sensor, I believe its only very low current... Should I use a buffer?

Na, the sensor output, (whatever it is) will be able to drive an opamp input, no probs.

I tried the interrupt thing with a computer fan, but the reading was erratic, Im thinking of using the LM2907 (or similar) and using one of the analog inputs for a more accurate reading of RPM
You can use a freq-voltage IC but the micro is completely capable of reading the tacho pulses directly without any erratic behavior.
My guess is your timer was overflowing or maybe you forgot to declare something volatile.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
Re: A few newbie questions
« Reply #5 on: April 02, 2012, 02:28:13 am »
Thanks for the quick replies Psi... I'll double check my code and see where i was going wrong.... I have a few more questions, but i'll post them when i get to that part of the project :)
 

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
Re: A few newbie questions
« Reply #6 on: April 03, 2012, 05:16:21 am »
I re-calculated my filter circuit (attached).. its supposed to have a 50hz cutoff (which is the frequency of the ignition pulses for a 4 cylinder motor doing 6000rpm).. could someone check this for me?

I also checked it (I hooked it up to my car) and the spread is from 800 to 1800 RPM (the engine is at 1000 RPM)... its better than my first attempt... but its not within my +/- 20rpm accuracy that I want... is there a better way to get it closer (use more filters, different values, ICs, DSP)?
 

Offline mc

  • Regular Contributor
  • *
  • Posts: 155
  • Country: scotland
Re: A few newbie questions
« Reply #7 on: April 03, 2012, 04:20:50 pm »
What kind of sensor does the Tacho signal come from?
And are you sure it only triggers once every 2 engine rotations?
(I could go and dig out a wiring diagram, but that invoves going outside!)

Also, what Arduino are you planning on using?
I'd doubt an Uno has anywhere near enough memory to do what you want. The SD Card libraries use alot of memory (I think I measured it at just under 1k at the time), leaving very little for whatever you're trying to do. I had a prototype that involved reading/writing to a RTC over I2C with RTC setting done via Serial, running a counter via one interrupt, and transmitting the counter contents/time via serial when another interrupt was triggered and also storing said values on the SD-card, and I just didn't have enough memory. The Uno would lock up pretty easily due to the memory spaces overwriting each other. I was however using a good few strings, which fill memory pretty quickly.
 

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
Re: A few newbie questions
« Reply #8 on: April 03, 2012, 11:30:18 pm »
The tacho pulse comes straight from the ballast resistor (the same lead that goes to your in-car gauges) and there is 2 ignition pulses per revolution in a 4 cylinder motor (3 in a 6 cylinder, 4 in an 8, etc) ... I'm currently in the process of using the nano (ATmega328)... The hand-controller has its own micro (another arduino nano) and ill have them communicate over serial (or I2C)...

The ECU does most of the ground work, converting inputs to values, calculating the pulse length and correcting it to get the desired air/fuel mixture... The calculation is at 4700 bytes (but that bit of code needs cleaning up)... Im sure I can fit everything I need to into the nano, if not, ill upgrade to the mega but i am storing everything i can in the smallest memory i can.. For example, the Air/Fuel ratio (being 13.0 to 20.0) will be stored as a byte (0 to 255) and then divided by 10 in the code (to get 00.0 to 25.5) etc...

SO.. as a guess... memory allocation is as follows (out of 30k)...
My Code: 15k
MAP table (10x20 values = 200 values, but stored as bytes) = 0.2k
SD card library = 1k

So the estimated is about 17k... which still leaves more than enough memory to add more stuff..

Were you using the ATmega128 (which has 12K of memory total)???
 

Offline mc

  • Regular Contributor
  • *
  • Posts: 155
  • Country: scotland
Re: A few newbie questions
« Reply #9 on: April 04, 2012, 03:21:12 pm »
The tacho pulse comes straight from the ballast resistor (the same lead that goes to your in-car gauges) and there is 2 ignition pulses per revolution in a 4 cylinder motor (3 in a 6 cylinder, 4 in an 8, etc)
You want to redo your maths then! ;)
At 6000rpm, the ignition pulse is running at 200Hz, not 50Hz.
6000RPM = 100 rev/sec -> 100 x 2 sparks per rev = 200 sparks per second = 200Hz.

Also, if the signal comes from the Low Tension side of the coil (aka switching/ballast resistor side), then you need to allow for the back emf spike everytime the coil is fired, which can be in the low hundred of volts range, and very capable of frying silicon. You also want some isolation incase of flashover on the coil due to dampness.
Quote
The ECU does most of the ground work, converting inputs to values, calculating the pulse length and correcting it to get the desired air/fuel mixture... The calculation is at 4700 bytes (but that bit of code needs cleaning up)... Im sure I can fit everything I need to into the nano, if not, ill upgrade to the mega but i am storing everything i can in the smallest memory i can.. For example, the Air/Fuel ratio (being 13.0 to 20.0) will be stored as a byte (0 to 255) and then divided by 10 in the code (to get 00.0 to 25.5) etc...
Where possible, avoid using floats. Just because the ratio looks nice to humans, doesn't mean you have to keep it as a ratio in the code. In the code, simply have an integer scale which will use less processing time and memory.
Also, the basic map should be that, basic. On modern ECUs the basic map is enough to ensure the engine starts and runs reasonably well, and sets output limits (i.e. maximum fuel at x revs, spark timing...), and then using inputs from various sensors, the ECU applies trims to that map to get the best performance, which are stored at shutdown.
Quote
SO.. as a guess... memory allocation is as follows (out of 30k)...
My Code: 15k
MAP table (10x20 values = 200 values, but stored as bytes) = 0.2k
SD card library = 1k

So the estimated is about 17k... which still leaves more than enough memory to add more stuff..

Were you using the ATmega128 (which has 12K of memory total)???
It was an Uno I was using, which uses the Atmega328P, and it was SRAM I ran out of.
The first you'll know you've ran out of SRAM is when it locks up, or does weird things.
 

Offline agilly1989Topic starter

  • Contributor
  • Posts: 36
  • Country: au
Re: A few newbie questions
« Reply #10 on: April 05, 2012, 07:51:33 am »
Quote
You want to redo your maths then! ;)
At 6000rpm, the ignition pulse is running at 200Hz, not 50Hz.
6000RPM = 100 rev/sec -> 100 x 2 sparks per rev = 200 sparks per second = 200Hz.

hehehe, I thought something was wrong :) must have had one of those "That calculation is right" moments... Thanks mowicu

Ill try a new filter to that frequency and ill report back :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf