Shop OBEX P1 Docs P2 Docs Learn Events
Newbie with Question - Manifold Absolute Pressure Voltage — Parallax Forums

Newbie with Question - Manifold Absolute Pressure Voltage

Suzuki PhilSuzuki Phil Posts: 10
edited 2005-03-10 20:22 in BASIC Stamp
Hello All,

I'm a motorhead who's gone and turbo'd his car. What I've done is removed the stock MAF (mass airflow sensor) and replaced with a MAP (manifold absolute pressure) sensor. All this is controlled by a piggy back tuning computer wired to my stock ECM. I access the piggy back via a laptop and program the engine with it.

Here is the problem. The MAP sensor has twitchy voltage, meaning it's constantly varying (at idle or cruise) from a calculated average voltage. Can I use a Basic Stamp to read this voltage and set a zone that it cannot exceed from the average? Remember the voltage is changing to due various conditions, load, boost, throttle position etc. I want to reduce the amount of variation in the signal itself. Some electronic guys I've talked to say to add a capacitor but I don't think this will solve my problem.

This variation causes an erratic idle and cruise conditions, my stock ECM was not programmed to use the MAP.

The MAP sensors outputs a dc voltage from .1v to 5v max at full boost.

Thanks,

Philip

Post Edited (Suzuki Phil) : 3/9/2005 2:33:43 AM GMT

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-09 05:24
    yes this is easily accomplished using what is called a moving average filter, it is done by taking the sample and keeping a log of a set number of previous samples. For instance a 4 sample moving average, take a sample shift the value to the right by 2 and add it to the previous 3 samples whose values have also been shifted to the right by 2. This will filter out noise in your signal.

    The number of samples to use depends on the frequency of your noise and your sampling frequency. The tradeoff of the number of samples used is: too few and the noise isn't as filtered, too many and you reduce the responsiveness of the circuit.

    One means of compromise if you find the requisite number of samples to filter out the noise make the system too sluggish in response to large changes is to do what you sortof hit on, if the difference of the current sample and the previous sample exceeds a threshold, just use the current sample (don't forget to readjust the previous sample if you stored it in its shifted value before comparing it to the current sample. Also continue to fill the previous sample buffer during this mode, or you will get a ringing output from the old values in the buffer when you return to using the moving average filter). This mixed mode is where a stamp is superior to a capacitor (which acts like a moving average filter).

    Hope this helps,
    Paul

    Post Edited (Paul Baker) : 3/9/2005 5:32:11 AM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-09 14:06
    It has been drawn to my attention I was not as clear as I could have been, when I use the phrase "shifted to the right by two" I mean the bits in the number itself ie S >> 2 which is the same as S/4 it is done before the addition to prevent overflow issues when adding multiple values together, if you are taking 8 bit samples but using 16 bit variables, you can wait until after adding the numbers before dividing to obtain the average of the samples, this is also the reason why the number of samples used is typically a power of two since performing the nessesary division is quickly done by the >> operator as opossed to the / operator which takes much longer.

    Post Edited (Paul Baker) : 3/9/2005 2:35:17 PM GMT
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-09 15:32
    Which Basic Stamp would do the job for me?

    Thanks,

    Philip
  • KenMKenM Posts: 657
    edited 2005-03-09 15:45
    In the stamp world, things are happen pretty quick on your car, especially when you have the tach where you like it....~6500rpm.

    A BS2 is unlikely fast enough, the BS2SX or BS2P may do the job.

    Is 'smoothing' the map sensor signal the only thing you want to do with the stamp?

    If so, take a look at the SX, and there is a new compiler from Parallax making the SX easy to use, and there is no question about the SX being fast enought to do the job.

    The SX is about $45 cheaper than a BS2
  • steve_bsteve_b Posts: 1,563
    edited 2005-03-09 16:32
    Would the stamp need to check the sensor 6500x per minute....wouldn't think so!

    If you're using the 'sliding' average filter, then you can assume that, if you're sampling 10x per second but the readings are 20x per second, then you can get guess inbetween the ones you miss!· So, if the stamp sampled one reading at 100 and the next at 110, you could 'assume' the one missed in between was 105....yes/no?!?!

    If you're averaging, you might want to start with a "profile" that gets updated as you start.

    So, determine that ok, when I first start my car, the engine is cold and idle is high....so use this setting.· Then have it monitor as things warm up and settle.· Then go in to your actual 'on-the-fly' tuning.

    If you have a laptop connected and you are debug or serial'ing data out, you'll bog the stamp down too much to be of use!

    So keeping your code streamlined is what you want.

    If you have the stamp....then you're not out any $ and I'd say give it a try!· If you don't have a stamp....get one, if it doesn't work, they're great for lots of other fun things! lol· Certainly if you're new to Parallax's products, the Basic Stamp modules are fairly easy to program with their editor software....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-09 17:09
    I don't need the smoothing at full throttle, only idle and part throttle (cruise).· Could I program the SX to stop smoothing after a certain voltage is reached on the input?· Or how about a RPM input that could be used to turn the smoothing off?

    Philip

    Post Edited (Suzuki Phil) : 3/9/2005 5:12:01 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-09 17:13
    The scheme I disclosed would still work, say at full throttle your voltage is already smooth (4.8V 4.8V 4.8V 4.8V) using the average filter still produces the desired result (4.8V) adding a special condition would just add to program latency.

    Post Edited (Paul Baker) : 3/9/2005 5:16:06 PM GMT
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-09 19:34
    Just purchased the BS2SX starter kit with BOE.· I was looking at my datalog from the piggy back and it gives me 120 readings per second.· So every 8.3 micro seconds (1/120) it takes a voltage sample.·

    Philip



    ·
  • steve_bsteve_b Posts: 1,563
    edited 2005-03-09 20:13
    I'm not sure you'd be able to get that with the stamp.

    There are "access" times....basically, in PBASIC, when you put in a Pulsin or a serout command, that gets translated in to a Smile load of code and on the stamp it has to retrieve some items from it's EPROm...someone will word all this properly for me....but the jist is that it takes time to run commands/functions.·

    You could easily get 20/sec I'm sure.....not sure about 120/sec

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-10 00:42
    Even if I can get 20 pulses out per second and they are within the voltage zone I set it would be better then getting 120 pulses from the MAP that vary like crazy. The piggy back doesn't have any type of conditioning built in. Whatever it sees on the analog voltage input, it spits out the other side. I do have the ability to offset the voltage for conversions of this nature. My car has early 90's computer technology in it for a ECM, it's pretty stupid. As long as it sees a voltage it's happy.

    I appreciate the help and we'll see how it works out. I've been wanting to buy a Basic Stamp anyway to play with [noparse]:)[/noparse]

    Philip
  • KenMKenM Posts: 657
    edited 2005-03-10 02:41
    steve_b said...

    Would the stamp need to check the sensor 6500x per minute....wouldn't think so!

    If you want it to run well, I respectfully disagree.
    Ken
  • steve_bsteve_b Posts: 1,563
    edited 2005-03-10 03:17
    well....running well and running great aren't the same thing!

    He needs to send the signals to his 'tuning piggyback computer'....he can read the sensor whenever he can....but could he get away with constantly sending out the last read sensor reading.

    Could he fool the computer by sending 'last-read' data until he has a chance to read it again?!· With a timeout of course (in case things go wrong).

    This would create lag....but at 100x/sec or whatever, how obvious would it be?!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-10 05:46
    Actually a little lag wouldn't hurt. The MAP sensors reaction time is much faster then the stock MAF sensor. This is another problem I've had to deal with, luckily I've been able to adjust the piggybacks fuel map to compensate for the response issue. I still have a little problem (lean condition) in second gear under full throttle.

    I want to solve the voltage variation problem first then I'll tackle the reaction issue if it still exists. I purchased the SX lite kit today not the BS2SX kit.

    I've already confirmed the variation issue by using a precision dc power supply connected to the analog input of the piggy back which feeds the ECM. Setting the voltage at .75v (idle voltage for MAP sensor) with no variation produces a nice smooth idle and a steady wideband O2 reading.

    Philip
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 05:51
    If you got the SX then reponsiveness will be absolutley no problem.
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-10 17:07
    Paul,

    Do you offer programming services?

    Philip

    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 17:41
    I wish I could, but my regular job requires too much attention to permit it in such a way that I felt the customer would get thier value's worth. I am however capable of giving you guidance at no cost. I was rummaging around Atmel's AVR stuff (another microcontroller) last night, and remember coming across code and documentation for an 8 sample moving average filter. Ill fetch it sometime today and post it,·the·code provided will be in AVR assembly so you can't directly use it, but porting between the SX and AVR isn't too difficult, I just ported SX I2C code over to AVR code and it took one evening.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 18:00
    ok heres the doc: http://www.atmel.com/dyn/resources/prod_documents/DOC0940.PDF
    heres the link to the code: http://www.atmel.com/dyn/resources/prod_documents/avr222.zip

    If you need to know what an assembly command is, heres their doc on the instruction set: http://www.atmel.com/dyn/resources/prod_documents/DOC0856.PDF

    You'll note there is alot more commands in the AVR architecture than the SX, but don't worry there is always a means for writing code for the SX that achieves the same thing, and the speed of the SX results in faster code execution even though it on ocassion needs to execute more commands to achieve the same thing.
  • Suzuki PhilSuzuki Phil Posts: 10
    edited 2005-03-10 19:52
    Great,·thanks for your help. I'm sure I'll be needing advice in the future.

    Philip
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 20:22
    Just PM me if you find me not responding to your publicly posted questions
Sign In or Register to comment.