AFR display

204 views
Skip to first unread message

Nicki Baker

unread,
Jun 22, 2018, 9:38:14 PM6/22/18
to 14Point7
I just finished the code to display AFR with the 14.7 products using the 16x2 LCD on an arduino Mega, nano / UNO. the mapping is perfect and calculated to display from the analog out on the Idash. Im working on the pcb now, however, if anyone wants the code for their arduino project, just shoot me a text. 803-917-9852

Nicki Baker

unread,
Jun 22, 2018, 9:39:34 PM6/22/18
to 14Point7
mine is written to display actual AFR as opposed to the lambda that their display uses.

Bryan Smith

unread,
Aug 26, 2020, 12:05:26 PM8/26/20
to 14Point7
Hey @Nicki

Would you be willing to just post the maths you used for the 5v conversion? 

I have something in the area of a normal AFR calc 

(voltagepin*2) + 10 = Display_AFR;

or 

(Voltage * 2) + 10 = AFR 



I have also seen a style like this:
  (2.3750 * Volts) + 7.3125 = AFR

Gabriele Di Lorenzo

unread,
Aug 28, 2020, 10:25:10 AM8/28/20
to 14Point7
on Arduino, i did a MAP from the analog value (0 to 1024) and "10 to 20" that is the AFR range... i'm reading now about these other formulas, i dont know now if is better to use the MAP feature of arduino, or these other formula i'm finding here

David Hook

unread,
Sep 4, 2020, 4:58:49 AM9/4/20
to 14Point7
I'm also using an Arduino with a small display and CAN shield so I can put the AFR/Lambda on the bus.  My code is on another computer but from memory the MAP feature on the Arduino can only deal with integers so you will see big steps in AFR if you use it.  I just did a manual calculation.

Gabriele Di Lorenzo

unread,
Sep 8, 2020, 8:54:18 AM9/8/20
to 14Point7
yes MAP function works only with integers, but i did it like this:

AFRval = map(AFRval, 30, 1024, 1000, 2000);
AFRval = AFRval/100;

this way, i've AFR values with one decimal
does it sounds right?

David Hook

unread,
Sep 10, 2020, 4:54:55 AM9/10/20
to 14Point7

This is my code which I've tested and works.
    
a7InputValue = analogRead(A7); 
lambdaVoltageRaw = (a7InputValue / 1023) * 5.0;
AFR = (2 * lambdaVoltageRaw) + 10;
lambda = (0.136 * lambdaVoltageRaw) + 0.68;

Gabriele Di Lorenzo

unread,
Sep 16, 2020, 5:39:58 AM9/16/20
to 14Point7
i compared my formula with yours, using same analog input data, results are quite identical, 14,4 compared 14,5 (some roundings probably involved, here)
i'll stick to my MAP function, solve all with one row, but was helpful to compare results with your formula too, thx!

David Hook

unread,
Oct 5, 2020, 1:50:47 AM10/5/20
to 14Point7

I thought I'd mention, it's worth doing the correction described in the megasquirt article to improve accuracy. It's quite straight forward to implement in the arduino code. 

Arindam Ghatak

unread,
Jun 15, 2021, 4:55:36 AM6/15/21
to 14Point7
David, Gabriele,

How would your respective formulae change if I were to use LSU 4.9 to measure O2 % in flue gas generated from combustion of natural gas (CH4) ?

Arindam Ghatak

unread,
Jun 16, 2021, 12:09:35 AM6/16/21
to 14Point7
Ok, I think I know how to get the O2 % from the lambda value.

Here it goes: % O2 in dry gas = 12.5 (lambda - 1)/(8 + 12.5 (lambda - 1) + 3.76 x 12.5 lambda)
                        % O2 in wet gas =12.5 (lambda - 1)/(17+12.5(lambda - 1) + 3.76 x 12.5 lambda)

where lambda is as found from one of your respective formulae. This formula should work for flue gas from any hydrocarbon. The real percentage of O2 in the flue gas will be somewhere between those two values, depending upon how much condensation takes place upstream of the sensor.

Btw, where can I buy Spartan 3 Lite with LSU 4.9 ? It seems difficult to find a source.
Reply all
Reply to author
Forward
0 new messages