Page 2 of 8

Re: Open Source LSU4.9 Wideband Controller

Posted: Fri Aug 16, 2013 11:58 pm
by Fred
How does the teensy ADC module function internally? Some ADCs require a pin capacitance and low source impedance to read accurately. In any case, putting the low end of your filtering requirement in hardware is a Good Thing TM, tune above and beyond that in software, by all means.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 3:04 am
by Hell Fire
While I was out picking bits up for a CarPC thing, I picked up an Arduino Uno clone, so I'll be porting the code to that (ATmega328P based)

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 3:07 am
by Hell Fire
Teensy is a AT90USB128, so same as much of the AVR line, it runs a Sample and Hold circuit, which holds the sample at a constant level while the ADC runs the conversion.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 3:30 am
by toalan
Hell Fire wrote:I do the filtering in software, gives me control over the response time for very little extra processing cost (and reduces part count).

Nernst Cell Pulse is for measuring the internal resistance of the cell for heater control. The reason for R4 is to form a voltage divider through the cap so the pulse is only a ~2.5v swing instead of 5v, to keep the voltages within range of the ADC. R5 slows down the swing of the cap a little so that by the time the pulse is driven low again, there's not a large negative voltage swing from it. (The code compensates for the delay added by this).

The opamp part I'm using is the LMC6484IN (just one I had laying about), which while does have a 30mA limit on output, can handle shorting of the outputs for short periods of time, so startup capacitance isn't an issue, and once that's charged it's a stable state (doesn't seem to have issues keeping up with pump cell current pulling and pushing on it).

I've never seen a LSU4.2, let alone had one to compare against, and much of this circuit was tweaked by trial and error while looking at how it responded on the scope, then tested in the car comparing what I was reading to what I'd seen my car do with the other controller, I know a terrible way to reference on, but I don't have sample gases to test against :P.
The Aliasing is due to the sampling, it is an inherent problem that can not be fully compensated for via DSP techniques. Higher sampling rates and averaging/summing/filtering the ADC samples will help but atleast on paper you have a leaky boat. Just a simple RC filter will be enough, at the very least it shows your intent of building a boat that floats.

Is it just the Analog that runs at 2.5v max and the digital IO running @ 5v?

There is a really nice article in the June 2012 edition of Silicon chip magazine on lambda controllers and the bosch 4.9, it will fill in any knowledge gaps you have.

If you have an emissions test place around you, you might be able to stick your sensor in the gas they use to calibrate their emission sniffing equipment.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 3:36 am
by toalan
Hell Fire wrote:While I was out picking bits up for a CarPC thing, I picked up an Arduino Uno clone, so I'll be porting the code to that (ATmega328P based)
The 88/168/328 AVRs are a good choice, I have been out of the AVR world for a while but from what I remember some AVRs have an internal 16x gain amp on the ADC inputs, that would be quite useful in working with the small pump current and nernest AC voltages, you could get rid of the external amps and probably be more accurate to boot.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 3:51 am
by Hell Fire
Yeah, all IO runs 5v out of the Teensy, with VGND being at 2.5v, Nernst cell riding on top of that gives it a range of 2.5v to 3.5, and the pulse through the divider/cap arrangement will max out the ADC at 5v if the Nernst cell resistance is too high.

There's probably enough capacitance in the breadboard to be a filter which might be why it's working as it is, so I probably should put a filter on it.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 5:17 am
by toalan
With the R3 R4 divider, you will basically lose half the resolution on the nernest AC signal. I would get rid of r4, the point between C2 and R5 I would route it directly to the sensor nernest cell, the other end of R5 I would run it to the ADC port. R5 will act as a current limiting resistor for the internal clamping diodes on the AVR, you can make it safer by making R5 larger, I think around 7k is the max input resistance Atmel reccomends for the AVR ADC port, if you want to be super safe then you can put in an external zener or TVS after R5 but finding a high quality through hole zener/TVS is impossible for voltages as low as 5v for SMD there are lots of options.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 5:53 am
by toalan
In your first post the graph, the pink line "Heatout". I am not sure what it is since I expect the heater output to be a PWM signal and not a varying voltage, assuming that it is some linear representation of the heater power; the oscillations on the AFR seem coincidental with the oscillations on the heatout graph. Since the pump current and the heater control have their own PID loops, I would not expect the same frequency oscillations on both PID loops, one loop is for an electrochemical process the other is for a heater, they are very different animals with their own radically different P, I, and D gains. That and taking multiple reboots to get the unit to work strongly indicates some kind of common problem effecting both loops, my guess it the noise on the ADC or the algorithm used to to process the nernest data, it has to be some common point before the PID loops.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 5:56 am
by toalan
If you build me a prototype and send it to me, I can test it with my lab gas and post the results. Maybe in a month would be a good time as I am out of gas now and in the process of buying more lab gas.

Re: Open Source LSU4.9 Wideband Controller

Posted: Sat Aug 17, 2013 6:13 am
by Hell Fire
The unit that had the problem with the reboots wasn't this circuit. It was a kit unit that I'd bought and wasn't happy with.

heatOut is the value fed to the timer comparator for the PWM out, it's effectively the duty cycle.

The fluctuations from the sensor are actual readings, I had the circuit hooked up to the narrowband input on my stock ECU, the ECU would trim out the mix till the narrowband would tell it it was lean, then it would jump back to a rich mix and repeat. I could adjust where the stoich point is in the code and the ECU would eventually work around that point as the new middle for its trim, so much so that when I set it way too lean, it would start to cause issues, but you could balance it leaner than a regular narrowband sensor could :)

I should add that since I posted that graph, I tweaked it some, it's probably not perfect yet, but it's getting closer, still waiting on parts to arrive for other things before I get back to this one though.