Jump to content

Wideband + Datalogging Q


ThePog

Recommended Posts

Have any of you smart peeps had any experience with this?

I am probably getting a boost compensator for my TD42 engine from an OSGC, but once this is installed there is obviously a bit more in the way of fuel adjustment.

So rather than just looking at the EGT's and the amount of black smoke pissing out I thought that hooking up a wideband and logging it along with RPM/boost pressure/possibly throttle position would be a lot better.

Does anyone have any experience or advice? cheap but useful bits of kit to use? Am I missing something?

Revs is easy, this is an AC signal from the engine sensor.

Boost pressure will need a sensor of some kind, I'm sure they exist.

The throttle position might be hard, but I can always use a potentiometer I guess?

Chur.

Link to comment
Share on other sites

I wrote a python script for tuning the Niva, used a potentiometer for TPS, 0-5v output from the wideband controller and a digital to analogue converter for RPM.

Worked really well apart form the messing around getting the script correct if thats your kind of thing?

Was going to hook up an arduino with SD card to log without the computer but that never happened, having the laptop and liveview of each plot was really efficient.

That was my method, hopefully someone has found an easier plug play unit?

 

Link to comment
Share on other sites

Does a wideband actually tell you anything useful for a diesel though? 
I've never tuned diesels but my understanding is that you're not necessarily targeting an air/fuel ratio like you do with petrol etc.
Hooking up the sensors to log these things is easy, but what will you be logging them all to? Or not sure? 

Boost pressure you can just use a map sensor from either a factory turbo car, or buy one from somewhere like this 
https://www.nzefi.com/products/engine-management/engine-management-sensors/map-pressure-sensors/

But your main thing, will be how you're logging this data to a device. Using an arduino or similar will probably work fine but you need to write the code to make it work.

  • Like 1
Link to comment
Share on other sites

Just now, NickJ said:

I wrote a python script for tuning the Niva, used a potentiometer for TPS, 0-5v output from the wideband controller and a digital to analogue converter for RPM.

Worked really well apart form the messing around getting the script correct if thats your kind of thing?

Was going to hook up an arduino with SD card to log without the computer but that never happened, having the laptop and liveview of each plot was really efficient.

That was my method, hopefully someone has found an easier plug play unit?

 

Possibly, I am no coder but might be able to make sense of it depending on the complexity/probably not.

I imagined a live display on a laptop would be the best but I am guessing you still need a box to interpret the signals?

Link to comment
Share on other sites

Just now, Roman said:

Does a wideband actually tell you anything useful for a diesel though? 
I've never tuned diesels but my understanding is that you're not necessarily targeting an air/fuel ratio like you do with petrol etc.
Hooking up the sensors to log these things is easy, but what will you be logging them all to? Or not sure? 

Boost pressure you can just use a map sensor from either a factory turbo car, or buy one from somewhere like this 
https://www.nzefi.com/products/engine-management/engine-management-sensors/map-pressure-sensors/

But your main thing, will be how you're logging this data to a device. Using an arduino or similar will probably work fine but you need to write the code to make it work.

Of course it is a map sensor, I am a dick.

From what I have read a wideband is still right in the spot for a diesel, so will get useful info.

Link to comment
Share on other sites

Just now, ajg193 said:

You'd almost be hitting the limits of what a lot of wideband controllers can register with how lean a diesel runs

I haven't read this source, but it looks like it could be of value:

https://www.4btswaps.com/threads/diesel-tuning-a-f-ratios-etc.28841/

3EP6NXFwYVRZzliF19dtYFsX8oQJz_axNICACptz

 

I have read this page, a lot of good info.

According to the internets, 550deg is the sweet spot for TD42's, I am getting 600deg under medium acceleration load but running out of fuel if I back it off. There is probably a sweet spot but I have not hit it yet, so clearly the fuel metering isn't great.

 

Link to comment
Share on other sites

Just now, ThePog said:

Possibly, I am no coder but might be able to make sense of it depending on the complexity/probably not.

I imagined a live display on a laptop would be the best but I am guessing you still need a box to interpret the signals?

Was nothing too tech, I just lost patience with developing further once it printed graphs that were useful.

Used an arduino as the serial interface, from memory the hardest part was telling the script which port to read from.

There was 1sec lag from foot to screen, but more than enough info to get to where I wanted to be, happy to share the files if you want to give it a shot?

Link to comment
Share on other sites

Just now, NickJ said:

Was nothing too tech, I just lost patience with developing further once it printed graphs that were useful.

Used an arduino as the serial interface, from memory the hardest part was telling the script which port to read from.

There was 1sec lag from foot to screen, but more than enough info to get to where I wanted to be, happy to share the files if you want to give it a shot?

Yea man, I'd be keen. Be a good thing to get my head into anyway I imagine.

Link to comment
Share on other sites

I recently bought the new spartan wideband that uses the lsu-adv sensor. It can read to something silly like 50:1 but to get good resolution on the 0-5v output it defaults to maxing at 20:1 or something like that. But you can adjust the scale or output to canbus where you get full range.

I havent tested it yet, but supposedly the sensors are a lot more hardy than bosch 4.9 or 4.2 based setups. So might last a bit better with diesel soot. Although I think there is a diesel specific version of the 4.9

  • Like 1
Link to comment
Share on other sites

4 minutes ago, NickJ said:

i'll have a dig after dinner and see if I can remember how it runs to get you started, here's the pics from my budget set up.....

IMG_5150.jpg.91d03905c0ef8b3fd897b0b7e915eed3.jpg

TPS

IMG_5155.jpg.ce355626055f2a099292976706c9ff43.jpg

Laptop, arduino, wideband590846ec5252c_longslowaccelartion3rdgear.jpg.d0aba77c8f1611cc2958af058b830ec6.jpg Screen output

Red= throttle, green = ratio?

Link to comment
Share on other sites

Just now, Roman said:

I recently bought the new spartan wideband that uses the lsu-adv sensor. It can read to something silly like 50:1 but to get good resolution on the 0-5v output it defaults to maxing at 20:1 or something like that. But you can adjust the scale or output to canbus where you get full range.

I havent tested it yet, but supposedly the sensors are a lot more hardy than bosch 4.9 or 4.2 based setups. So might last a bit better with diesel soot. Although I think there is a diesel specific version of the 4.9

Ok, when I buy one I will check the spec. I imagine I will use it for a few hours max so I don't imagine longevity will be an issue..

Link to comment
Share on other sites

Just now, ThePog said:

Red= throttle, green = ratio?

Green is for sure AFR, red RPM and blue throttle looks about right. 

You can see its not super stable, but was good enough for me to figure out what was goin on.

I've found the scripts but buggered if i can remember how to get them to run, will have to dig out an arduino

Link to comment
Share on other sites

To get the ball rolling i'll post the code I used, disclaimer, I'm no code wizard, I just used basic knowledge and googled what I was after and stitched shit together to get a result, there will 100% be a better way and anyone is welcome to offer improvements.

First step, Arduino code, this was loaded onto an Arduino uno

Quote

// analog-plot to serial - datalog
// 
// Read analog values and print to serial.
//

//#include "Arduino.h"

void setup()
{
  // serial comms
  Serial.begin(9600); 
}

void loop()
{
  // read A0 Wideband - Analogue pin 0
  float val1 = ((analogRead(0)*0.80/1024)+0.6);
  // read A1 Engine Speed - Analogue pin 4
  float val2 = ((analogRead(4)-200.0)/10);
  // read A2 tps - Analogue pin 2
  float val3 = ((analogRead(2)-450.0)*1023/1600);
  // print to serial
  Serial.print(val1);
  Serial.print(" ");
  Serial.print(val2);
  Serial.print(" ");
  Serial.print(val3);
  Serial.print("\n");
  // wait 
  delay(50);
}

 

 

Python code - will need to download suitable software - on my Mac I have Anaconda, save this as a .py file somewhere handy.

Quote

import sys, serial, argparse
import numpy as np
from time import sleep
from collections import deque

import matplotlib.pyplot as plt 
import matplotlib.animation as animation
import csv

    
# plot class
class AnalogPlot:
  # constr
  def __init__(self, strPort, maxLen):
      # open serial port
      self.ser = serial.Serial(strPort, 9600)

      self.ax = deque([0.0]*maxLen)
      self.ay = deque([0.0]*maxLen)
      self.az = deque([0.0]*maxLen)
      self.maxLen = maxLen

  # add to buffer
  def addToBuf(self, buf, val):
      if len(buf) < self.maxLen:
          buf.append(val)
      else:
          buf.pop()
          buf.appendleft(val)

  # add data
  def add(self, data):
      assert(len(data) == 3)
      self.addToBuf(self.ax, data[0])
      self.addToBuf(self.ay, data[1])
      self.addToBuf(self.az, data[2])

  # update plot
  def update(self, frameNum, a0, a1, a2):
      try:
          line = self.ser.readline()
          data = [float(val) for val in line.split()]
          # print data
          if(len(data) == 3):
              self.add(data)
              a0.set_data(range(self.maxLen), self.ax)
              a1.set_data(range(self.maxLen), self.ay)
              a2.set_data(range(self.maxLen), self.az)
      except KeyboardInterrupt:
          print('exiting')
      
      return a0, 

  # clean up
  def close(self):
      # close serial
      self.ser.flush()
      self.ser.close()    

# main() function
def main():
  # create parser
  parser = argparse.ArgumentParser(description="LDR serial")
  # add expected arguments
  parser.add_argument('--port', dest='port', required=True)

  # parse args
  args = parser.parse_args()
  
  #strPort = '/dev/tty.usbserial-A7006Yqh'
  strPort = args.port

  print('reading from serial port %s...' % strPort)

  # plot parameters
  analogPlot = AnalogPlot(strPort, 1000)

  print('plotting data...')

  # set up animation
  fig = plt.figure()
  
  ax = plt.axes()
  plt.grid(True)
  ax2 = plt.Axes.twinx(ax)
  a0, = ax.plot([], [], 'g') # Lambda
  a1, = ax2.plot([], [], 'r') # Engine Speed
  a2, = ax2.plot([], [], 'b') #tps
 
  anim = animation.FuncAnimation(fig, analogPlot.update, 
                                 fargs=(a0, a1, a2),
                                 interval=50)
  ax.set_ylim(0.60, 1.40)  
  ax2.set_ylim(0, 100)
  ax.set_xlim(0, 1000)
  ax.set_ylabel('Mixture')
  ax.set_xlabel('Time (s)')
  ax2.set_ylabel('Throttle (%)')
  
  plt.axhline(y=50, linewidth=1, color='y')
  plt.Axes.invert_xaxis(ax)
  
  # show plot
  plt.show()
  # clean up
  analogPlot.close()

  print('exiting.')
  

# call main
if __name__ == '__main__':
  main()

Then used this command in Terminal to call the python script saved earlier. (If using mac, might need more help with windows)

Quote

Computer:Engine Management$ python LivePlot3b.py --port /dev/cu.usbmodem14101

First you need to find which port the Arduino is on and replace "/dev/cu.usbmodem14101" with whatever your computer says.

And of course the whole command line depends on the file location and name of file, in this case, I called the file "LivePlot3b.py"

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...