Injector control question

Bruce Bowling bowling at cebaf.gov
Fri Aug 22 15:27:45 GMT 1997


> 
> In examining my Holley ProJection (model 502 analog) I find
> that the pulse width to the injectors is a constant (approximate)
> 1 millisecond with the rep rate varying by RPM, TPS and (maybe)
> temp.
> 
> I'm sure this question has been answered in various ways
> before, but it's popped to the fore for me and I'd like to
> hear some of your thoughts on it ...
> 
> Seems to me there's two ways to control an injector ..
> 
>  1 - run a constant rep rate (PRR) and vary the pulse width (PW)
> 
>  2 - run a constant PW and vary the PRR
> 
>  3 - all of the above  ;-)  (I know, I said two ...    8-)
> 

Yes, you can run either (1) or (2).

> 
> 
> NEXT ...
> 
>    Some time back (few weeks ago) there was a question
> about building a meter to monitor the PW of injectors
> 

About a year ago, I made such a meter out of a PIC 16C56 chip.
The circuit was incredibly simple: I took a 4N25 optoisolator,
with the LED driven across the injector. The transistor emitter
was grounded, and collector pulled up high thru a 1K resistor.
This junction was put into one of the PIC pins, configured as
an input. Another pin, config. as an output, directly drove
a 1 milliamp analog meter movement (other end grounded).
I timed the input pulsewidth, and generated a PWM signal which
drove the meter movement.

The meter works well if the injector driver is a saturated type,
and works most of the time for peak/hold drivers (the switch from
the peak current to the hold current sometimes causes a short spike,
which the PIC inteprets as an end-of-pulse). One day, I will fix
this effect in the software, but it is low on my list.

I know, I know - everybody wants to see the software. For free......

I think this is the latest version (I know the latest is on my home
PC):


-----snip-------------snip------------snip---------------------------

    TITLE        "PulseWidth Meter"
    LIST  P = 16C56
    ERRORLEVEL  0
;
;Define Equates:
;       
PIC56   EQU     H'03FF'
;******************************************************************************
;
;External Ossc. used = 3.579545Mhz. Prescaler of 8 used, which gives a
;??.?? microSec increment of the RTCC. If RTCC is intially loaded with 245,
;it would overflow to 0 in 0.098337 milliSecs. 
;
MSEC01   EQU     D'245'
FULLSCAL EQU     D'200'
FULLSM1  EQU     D'199'
;
;
;       Program:          pulsewidth.ASM 
;       Revision Date:   
;       12-18-96 B. Bowling      
;
;******************************************************************************
;
;
;Define RAM Locations:
INDF      EQU     0
RTCC      EQU     1
PC        EQU     2
STATUS    EQU     3
FSR       EQU     4
PORT_A    EQU     5
PORT_B    EQU     6
;
F         EQU     1
C         EQU     0
DC        EQU     1
Z         EQU     2
;
;
;Define Real Time Mode regs (RTM)
MMTMR     EQU     8       ;0.1 millisecond timer variable.
MSTMR     EQU     9       ;Millisec. Timer.
SUTMR     EQU     0A      ;0.1 seconds timer.
STMR      EQU     0B      ;Sec. Timer.
MTMR      EQU     0C      ;Min. Timer.
ERRRR     EQU     H'15'   ;Temporary  Var.
ROOL      EQU     H'11'   ;Roll over timer for PWM.
PWM       EQU     H'12'   ;Actual PWM variable.
SAMPLIN   EQU     H'13'   ;Flag for sampling mode 0 = no, 1 = yes.
SAMPTIME  EQU     H'14'   ;Measured pulse width in 0.1 microsec resolution.
;
;
; =========================================================
; <-- S T A R T   O F   E X E C U T I O N   H E R E -->
; =========================================================
;
       ORG     0
START
       CALL    INIT_CLK        ;Initialize clock and variables.
;
; Main loop section.
; Always go back to here each iteration.........
; Master timer loop.
TIMER_LOOP
;
       MOVF    RTCC,W          ;See if RTCC = 0.
       BTFSS   STATUS,Z        ;if zero flag set then skip one instruction,
       GOTO    TIMER_LOOP      ;otherwise loop to TIMER_LOOP.
;
       MOVLW   MSEC01          ;RTCC = 0.1 msec.
       MOVWF   RTCC            ;by setting the RTCC to this value each time
       INCF    MMTMR,f         ;Inc 0.1 millisecond variable (has occured here).
;
;      PWM mode here
;
       INCF    ROOL,f          ;rolling timer variable, used to time PWM.
;
       MOVLW   FULLSCAL        ;check for ROOL exceeding FULSCAL value
       SUBWF   ROOL,W          ;  by subtraction.
       BTFSC   STATUS,Z
       CLRF    ROOL            ;reset ROOL, because we are at fullscale.
;
       MOVF    ROOL,W          ;Check if the ROOL timer variable is zero,
       BTFSS   STATUS,Z        ; if it is, jump over one instruction.
       GOTO    BASH            ;It is not zero, go check if ROOL is greater than PWM.
       MOVLW   H'FF'           ;make port pin high, start of timer.
       MOVWF   PORT_A          ;output this to the pin.
;
BASH
       MOVF    ROOL,W          ;Get the current value of ROOL.
       SUBWF   PWM,W           ;Check if it is greater than PWM variable.
       BTFSS   STATUS,Z        
       GOTO    PULSE_CHECK     ;no, so go to next part of code.
       MOVLW   H'00'           ;It is, so output a low to the PWM pin.
       MOVWF   PORT_A
; ****************************************************************
; ***               Pulse Check Occurs Here                    ***
; ****************************************************************
PULSE_CHECK
       MOVLW   B'00000001'     ;Pin 8 of port B is input for pulse,
       ANDWF   PORT_B,W        ; get only this pin value.
       BTFSS   STATUS,Z        ;Skip over next instruction if the carry bit is clear.....
       GOTO    PIN_HIGH        ; go here is pin is high.
       GOTO    PIN_LOW
;
;Pin is low -> start of sampling
PIN_LOW
       INCF    SAMPTIME,f      ;Increment sampling time (will zero out later if need be).
;
       MOVLW   FULLSCAL        ;Check if samptime is greater than fullscale
       SUBWF   SAMPTIME,W      
       BC      PTL             ;It is, so branch to ptl
;       
       MOVF    SAMPLIN,W       ;get the sample mode flag.
       BTFSS   STATUS,Z        ;if zero, then not sampling yet, and need to turn on mode and reset time
       GOTO    MILLI_HAPPY     ; continue on to milliseconds updating.
       CLRF    SAMPTIME        ;reset the sample time (must be first time high).
       INCF    SAMPLIN,f       ;set sample flag to 1, indicating we are now sampling.
       GOTO    MILLI_HAPPY     ; continue on to milliseconds updating.
;
PTL
       INCF    ERRRR           ;error occured
       GOTO    MILLI_HAPPY
;
;Pin is high -> end of sampling -- check is pulse is too long
PIN_HIGH
       MOVLW   D'01'           ;Check if we are in sampling mode via. SAMPLIN=1.
       SUBWF   SAMPLIN,W
       BTFSS   STATUS,Z        ;Jump one instruction if we are in sampling mode (=1).
       GOTO    MILLI_HAPPY     ;No, just jump over all other tests.
; 
       CLRF    SAMPLIN         ;First, clear out SAMPLIN flag to allow next pulse detection.
       MOVF    ERRRR,W
       BTFSS   STATUS,Z
       GOTO    TOOLONG         ;Error occured somewhere.
;
       MOVLW   FULLSCAL        ;Check if we have pulse longer than FULLSCAL
       SUBWF   SAMPTIME,W      ; which is too long to display.
       BC      TOOLONG         ;We cannot display this, too long.
; 
       MOVF    SAMPTIME,W      ;Now we can update the PWM variable
       MOVWF   PWM             ; with the value of SAMPTIME.
       GOTO    MILLI_HAPPY     
;
TOOLONG
       MOVF    FULLSM1,W
       MOVWF   PWM
       CLRF    ERRRR

;       CLRF    PWM             ;Zero out meter, pulse was too long.
       GOTO    MILLI_HAPPY
;
;
;
MILLI_HAPPY
;
MORE_MILLI
       MOVLW   D'10'           ;Milliseconds checker.
       SUBWF   MMTMR,W         ;Can I update milliseconds.
       BTFSS   STATUS,Z        ;check the zero bit.
       GOTO    TIMER_LOOP      ;Check the loop again.
;
       CLRF    MMTMR   
       INCF    MSTMR,f 
;
       GOTO    TIMER_LOOP
;     
; Now check for 0.1 second update.
       MOVLW   D'100'
       SUBWF   MSTMR,W
       BTFSS   STATUS,Z
       GOTO    TIMER_LOOP

       CLRF    MSTMR
       INCF    SUTMR,f
;
; Now check for seconds update       
       MOVLW   D'10'           ; now check if 0.1 rolls
       SUBWF   SUTMR,W
       BTFSS   STATUS,Z
       GOTO    TIMER_LOOP
;
       CLRF    SUTMR
       INCF    STMR,f          ;Increment the seconds timer

; Now check for seconds rollover
       MOVLW   D'10'
       SUBWF   STMR,W          ;Can I update milliseconds
       BTFSS   STATUS,Z        ;check the carry bit
       GOTO    PLOP_DIGIT      ;Check the loop again
       CLRF    STMR
;
;
PLOP_DIGIT
       GOTO    TIMER_LOOP      ;LOOP 
;
;
;This routine sets up ports A,B,C and the internal
;real time clock counter.
INIT_CLK
       MOVLW   B'00000000'     ;MAKE ACTIVE low
       MOVWF   PORT_A          ;       /
       MOVLW   B'00000000'     ;SET PORT A AS OUTPUTS
       TRIS    PORT_A
;
       MOVLW   B'00000000'     ;SET LEVELS low
       MOVWF   PORT_B          ;       /
       MOVLW   B'00000001'     ;SET PORT B AS OUTPUTS, RB7 as input
       TRIS    PORT_B
;
;
       CLRWDT                  ;Must clear watchdog timer first
       MOVLW   B'00000010'     ;SET UP PRESCALER
       OPTION                  ;       /
;
       MOVLW   MSEC01          ;RTCC = 0.1 mSEC
       MOVWF   RTCC 
       CLRF    MMTMR           ;Clear 0.1 milliseconds
       CLRF    MSTMR           ;CLEAR MSTMR
       CLRF    SUTMR
       CLRF    STMR            ; & SEC TMR
       CLRF    MTMR            ;& MINUTES
       CLRF    SAMPLIN
       CLRF    SAMPTIME
       CLRF    ERRRR
       MOVLW   FULLSCAL
       MOVWF   PWM
       RETLW   0
;
;
;
;
; ----------> System reset section <---------------
;
       ORG     PIC56
SYS_RESET
       GOTO    START
;
       END


-----snip-----snip----snip---------------------------------

- Bruce

--
-----------------------------------------------------
<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------------------
                 Bruce A. Bowling
                 Staff Scientist
   Thomas Jefferson National Accelerator Facility
    12000 Jefferson Ave - Newport News, VA 23606
                 (804) 249-7240
bowling at cebaf.gov  http://devserve.cebaf.gov/~bowling
-----------------------------------------------------
<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------------------



More information about the Diy_efi mailing list