Ok, just to prove that the pulsin idea does work.........(within certain parameters anyways, I know it takes a finite amount of time for an injector to open and close and this amount would have to be accounted for in final calculations, and I also know that fuel rail pressure, system voltage, and injector/fuel temperature also have an effect on open/close times. I never said this method would be 100% accurate, but I'm sure the results can be tweaked thru software to get something fairly accurate.)
Do you have working hardware? In other words, do you have an input wire that could be or is connected directly to a PIC input pin? And if you connected an o'scope to that pin/wire, would the resultant signal on the 'scope follow/match the signal on the wire to the injector?
Without working hardware, further discussion would be fruitless...
So if you're just talking in theory, an idea you have...say so now so I (others?) don't use up too much time on this.
@skimask you are right ,
I work on proteus before ,
Now Im just build circuit on breadboard.
And Im take some shoot.
This is "duty cycle meter" working circuit ,I say before ..
Its working good on bench and my car ..
This is duty cycle shema
![]()
Last edited by MaxiBoost; - 27th December 2006 at 20:28.
PWM generator ,this simple circuit come with duty cycle meter .
Its use for test.
PWM generator shema ,simple 555 pwm generator .
Starting circuit on breadboard,
16F84A ,10mhz osc
![]()
Last edited by MaxiBoost; - 27th December 2006 at 20:29.
Here simple "pulsin" code ,
yes its not finish .Only run for test .
'DEVICE 16F84A
DEFINE OSC 10
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
TEST1 VAR WORD
PULSIN PORTA.0,1,TEST1
Lcdout $fe, 1,"Puls :" ,#TEST1
PAUSE 200
lcd picture
This is proteus circuit,
![]()
Last edited by MaxiBoost; - 27th December 2006 at 20:38.
whats wrong ?
'DEVICE 16F84A
DEFINE OSC 10
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
TEST1 VAR WORD 'PULS_LOW
TEST2 VAR WORD 'PULS_HIGH
TEST3 VAR WORD 'ADD TWO RESULT (PULS_LOW+PULS_HIGH)
TEST4 VAR WORD 'MULTIPLY 100 (TEST3 * 100)
TEST5 VAR WORD 'DIVIDE PULS_HIGH
PULSIN PORTA.0,0,TEST1
PULSIN PORTA.0,1,TEST2
TEST3=TEST1+TEST2
TEST4=TEST3 * 100 'WHATS WRONG ??
TEST5=TEST4 /TEST2
LCDOUT $FE,$80,"1:",#TEST1 'puls_low
LCDOUT $FE,$88,"2:",#TEST2 'puls_high
LCDOUT $FE,$C0,"3:",#TEST3 'puls_low + puls_high
LCDOUT $FE,$C8,"4:",#TEST4 '
'LCDOUT $FE,1,"5:",#TEST5
PAUSE 200
![]()
What's wrong? What's wrong is a little thing that trips me up once in awhile...
Overflow...
Take a number that's larger than 8 bits, multiply it by another number larger than 8 bits, and the result won't fit in 16 bits! It'll look like it works, but if you take (for example), 12000 (fits in 14 bits), multiplied by 100 (fits in 7 bits), the result is 1,200,000 (fits in 21 bits). The result doesn't fit in a 16 bit word, and instead of 1,200,000, all you see is 20,352...because the extra 5 bits got lopped off by the math routines.
But first, are the pulsin (test1 and test2) numbers correct from the circuit? If they are good numbers, then the rest should work ok...
And your math was a bit backwards...you had the total pulsewidth divided by the pulsehi. That math doesn't give percentage. You've got to divide the part by the whole to get a percentage (44/100, 44%, 44parts divided by 100 whole, etc. and so on, easy to get tripped up by that too).
Give this a try and see what happens:
'same defines as you had before
PLO VAR WORD 'PULS_LOW
PHI VAR WORD 'PULS_HIGH
PWIDTH VAR WORD 'ADD TWO RESULT (PULS_LOW+PULS_HIGH)
DTYCYC VAR WORD 'DIVIDE PULS_HIGH
PULSIN PORTA.0 , 0 , PLO : PULSIN PORTA.0 , 1 , PHI
cutdown2:
PWIDTH = PLO + PHI
if PWIDTH > 655 then 'divide by 2 until 'TEST4' result 3 lines below won't overflow
PLO = PLO / 2 : PHI = PHI / 2 : goto cutdown2
endif
DTYCYC = ( PHI * 100 ) / PWIDTH
LCDOUT $FE , $80 , "PLO:" , DEC5 PLO 'puls_low
LCDOUT $FE , $88 , "PHI:" , DEC5 PHI 'puls_high
LCDOUT $FE , $C0 , "PW:" , DEC5 PWIDTH
LCDOUT $FE , $C8 , "DC:" , DEC5 DTYCYC
Of course, with all this dividing, you will lose some resolution (i.e. you'll see 10%, but the real result might be 9, 11, 10.1, whatever, don't know how far off it'll be).
But, read the PBP manual and there is some 16/32 bit math handling functions in there that'll help you get better resolution of the final Duty Cycle measurement.
Bookmarks