Newbie - CAR MAF Project
jbalat
Posts: 96
Hi, Im new to Stamp. I have a kit but havent even plugged it in yet.
Please let me know how hard this would be to do so I know if it is worth the pain of learning all about this stamp stuff ?
I need to modify the CARS MAF (Mass Airflow Signal) to the computer for a HHO installation I am testing.
It is a perfect square wave signal at 3.8v Peak to Peak
At 600 rpm the frequency is 36 Hz
at 2500 rpm it is 111 Hz
Voltage stays constant
I need to modify the frequency by a factor ie. 80 % (or whatever I decide or dial in)
eg. 29Hz at 600 rpm and 89Hz at 2500rpm
The link to the HHO forum is here with more details of my little project
http://www.fuel-saver.org/Thread-HHO-woes?pid=29192#pid29192
Thanks in advance !!!!
John B
Please let me know how hard this would be to do so I know if it is worth the pain of learning all about this stamp stuff ?
I need to modify the CARS MAF (Mass Airflow Signal) to the computer for a HHO installation I am testing.
It is a perfect square wave signal at 3.8v Peak to Peak
At 600 rpm the frequency is 36 Hz
at 2500 rpm it is 111 Hz
Voltage stays constant
I need to modify the frequency by a factor ie. 80 % (or whatever I decide or dial in)
eg. 29Hz at 600 rpm and 89Hz at 2500rpm
The link to the HHO forum is here with more details of my little project
http://www.fuel-saver.org/Thread-HHO-woes?pid=29192#pid29192
Thanks in advance !!!!
John B
Comments
A Propeller would be able to do it all by itself since it has 8 separate processors on the chip. One would constantly measure the input frequency. One would generate the output square wave applying the adjustment factor to the measured input frequency. One could scan the thumbwheels to provide the adjustment factor, and one could produce a video output for a small TV screen with monitoring information (like the input frequency, adjustment factor, and output frequency). The Propeller's supply voltage is normally 3.3. It can operate as high as 3.6V, but 3.8V is too close to the absolute maximum permitted supply voltage, so you'd need the Propeller's output to drive an external transistor which would switch the 3.8V signal.
So the stamp can only do one thing at a time..
Can I assume with some clever programming you could switch to the input and store the value of the frequency then switch to the output to spit out the modified frequency..
The processor is many times quicker than my maximum frequency of maybe 150 Hz. A small time delay would not matter too much even if it were half a second or so ?
I will have a read about the propeller system when I get a chance.
Use the PWMPAL to generate the output pulses: www.parallax.com/Store/Accessories/MotorServoControllers/tabid/160/CategoryID/35/List/0/Level/a/ProductID/67/Default.aspx?SortField=ProductName%2cProductName
With the PWMPAL, the Stamp can set the on and off time of the output. The Stamp would use its PULSIN statement to measure the width of the input square wave and use that to compute the frequency (assuming that you have a true square wave).
The problem with "switch to the input" is that, without some kind of external square wave generator, the frequency output pulses would stop while the Stamp is counting input pulses or measuring the pulse width. From your original description, it seemed like you need an ongoing pulse train. It's not allowed to stop and start and "dance about".
Hi mike, my electronics skills are pretty limited.. The more I can do on the programming side the better.
If you think its a better option to buy the propeller kit then let me know.. If the car accepts a 3.6v signal then I assume the propeller can regulate it to 3.6v ? Does the propelloer use a Basic language ?
I want the completed unit to look like a simple breadboard, the chip and a digital pot for adjustment..
Not sure which bits I need to purchase. Very happy if you can point me in the right direction for development and then the final standalone unit that I will install in the car
Download the PWMPAL documentation and the Nuts and Volts Column both with links on the PWMPAL product page, then have a look at them.
Download the Basic Stamp Syntax and Reference Manual from Parallax's Stamp Documentation Download page and look at the chapter on the PULSIN statement (to measure the width of the input pulses from which you calculate the frequency).
You can use the Board of Education for the final product by glueing the wiring and parts on the breadboard so vehicle vibration won't loosen them. Alternatively, after you debug the hardware and software, you can buy a Super Carrier Board which is very close to the layout of the Board of Education and move the parts over from the Board of Education, but have them soldered into place.
You might look into using a 12-key keypad and a MemKey encoder. This would let you easily enter numbers as well as some control characters
Look at the documentation on the product pages: www.parallax.com/tabid/768/txtSearch/memkey/List/0/SortField/4/Default.aspx
There are also some articles on using keypads with other kinds of encoding.
Browse the Nuts and Volts Columns index: www.parallax.com/tabid/272/Default.aspx
Consider a simple LCD for a status display: www.parallax.com/Store/Accessories/Displays/tabid/159/CategoryID/34/List/0/Level/a/ProductID/50/Default.aspx?SortField=ProductName%2cProductName
Since its going in the car I was just going to set it up with an oscilliscope and install it permanently with a surface mounted digital pot. So I wanted just a bare bones solution at minimal cost.
The BS2P and board of education is something I can play with but I will need to replace if it goes in the car so..
... If I buy the PWMPal with a Basic2 Stamp and super carrier board should I be ok ?
Are there any distributors in Australia ?
Thanks again for your input
John B
Hey I just figured out a way to do it without a pwmpal..but going ahead with pwmpal anyway since it will come in handy for a PWM to regulate the HHO cell temperature in the future..
Sinse pulsin,pulsout require the program to wait we cant afford to do this so..
...inside a loop
measure input state high or low.. If high then count number of highs, if low count number of lows
upon an input state change set the maxoutputhighs as 120% (equiv to 80% of freq) of the high count and similarly for output low counts
When in highstate output a high until maxhighcount is reached
This way you are outputting a high or low in the clock speed of the stamp. May need a small capacitor to smooth the voltage as it does a quick input check..
Actual period or timing is not important since the output will only be running at 1 to 1.5 waves behind the input at all times !!
UPDATE 8-JUL
Wow that was quick, got the Stamp bits from Ron.. Will have a play soon
Post Edited (jbalat) : 7/8/2009 7:58:19 AM GMT
Not sure if PULSIN will work out the duty cycle ?
All done and ready to fit on the car
Added a pot for 50% to 99% adjustment factor -> freq out = factor * freq in
also a bypass switch should anything go wrong
and had to use a 2.5kohm pot for my voltage divider (actually 2k resistor and 500 Ohm trimpot) to get the right output voltage 3.9v
Ready to fit to car.. Fingers crossed..
Still dont know hot to use the pwm input channels.. If anyone has any better documentation on the pwmpal then please point me in the right direction.
When trying to check the output I got nothing, then a single pulse, then a real low freq pulse. then a series of extremely high freq pulses. The stamp was possesed....
Trying a more simpler program without the pwmpal
This was my code...
' PULSIN2.BS2
' This program counts the incoming pulse
' and outputs the pulse with a lower frequency
' using the PWM Pal Motor 1
' It also adjusts the amount of offset
' maximum at the lofactor frequency
' and no offset at the hifactor frequency
' The factor is set by a pot on Pin 9 which
' can vary from 50% to 99%
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
PpPin PIN 0 ' PWMPAL Serial I/O
Pulse PIN 7 ' pulse input pin
'
[noparse][[/noparse] Constants BS2 Only ]
W CON 2 ' -- 2.0 us per unit
F CON 0 ' -- 0 fractional units
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
PpBaud CON T38K4
MotorNum CON 1 ' PWMPAL motor output PIN 12
'
[noparse][[/noparse] Variables ]
time VAR Word
freqIN VAR Word 'Frequency of incoming pulse
mfactor VAR Word 'Maximum Output factor 0-100
rfactor VAR Word 'Adjusted Output factor for freq 0-100
OnTime VAR Word 'On/Off time 25us units
prevOnTime VAR Word 'compare with current on time
status VAR Byte 'motor control status
lofactor VAR Word 'lo frequency for max mfactor% Offset
hifactor VAR Word 'hi frequency for 100% - No Offset
potValue VAR Word 'Pot
potCounter VAR Byte 'Only check pot every 100 cycles
'
[noparse][[/noparse] Initialization ]
mFactor = 70 '50 to 100 % Grab from RCTIME Later on
rFactor = 90 'adjusted factor
OnTime = 556
prevOnTime = 555
loFactor = 33 'minimum frequency for mFactor
hiFactor = 300 'maximum frequency after this rFactor=100
potCounter = 99
Setup:
SEROUT 0, PpBaud, [noparse][[/noparse]"!PWMM0"] ' reset all pwm pins
PAUSE 10
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSP", %00010001] ' set phase, counter 1 enabled
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSS", %00010000] ' enable PWM1 software control
Main:
'RCTIME Read Pot on Pin9 - adjustment 50% to 99% for freq
potCounter = potCounter + 1
IF potCounter > 5 THEN ' only check every 5 cycles
HIGH 9
RCTIME 9, 1, potValue ' measure RC discharge time
potValue = 50 + ( potValue / 16 ) MIN 50 MAX 99
potCounter = 0
mfactor = potValue ' mfactor is the adjustment
ENDIF
'Measure incoming pulse from MAF Sensor Pin 12
PULSIN Pulse, 0, time ' measure positive pulse
IF (time > 0) THEN ' if not 0
'DEBUG HOME,
' DEC time, " units ", CLREOL ' display raw input
'DEBUG CR,
' DEC potValue, " pot value "
time = (time * W) + (time ** F) ' adjust for Stamp
'DEBUG CR,
' DEC time, " us " ' display microseconds
freqIN = 1000 /(2 * time / 1000) ' Only on Time calculated (x2)
'DEBUG CR,
' DEC freqIN , " Hz Input " ' display Total Input freq
OnTime = time / 25
SELECT freqIN
CASE <= loFactor
rFactor = mFactor 'use full mfactor below lo value
CASE >= hiFactor
rFactor = 100 'use no factor above high value
'Offset mFactor less for higher frequencies - high rpm
CASE ELSE
rFactor = (100 - mFactor) * (freqIN - loFactor)
rFactor = rFactor / (hiFactor - loFactor) 'Calculate resulting factor
rFactor = rFactor + mFactor
ENDSELECT
OnTime = OnTime * 100 / rFactor
'DEBUG CR,
' DEC (rfactor * freqIN / 100) , " Hz Output " ' display Total Output freq
'DEBUG CR,
' DEC mfactor , " mFactor " ,
' DEC rFactor , " adjusted " ' display factors
IF prevOnTime <> Ontime THEN GOSUB SetPWM
ELSE
'DEBUG CLS, "Out of Range" ' else error message
ENDIF
PAUSE 1
GOTO Main
'Subroutine to set new Frequency
SetPWM:
'DEBUG CR, "CHANGE FREQ ", DEC OnTime , " "
'Set for 50% duty cycle
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMM1", OnTime.BYTE0, OnTime.BYTE1, OnTime.BYTE0, OnTime.BYTE1]
prevOnTime = OnTime
RETURN
END
www.fuel-saver.org/Thread-ECU-behaviour?pid=29457#pid29457