Using CCP1 and CCP2 to measure instant fuel consumption


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Question I too am trying to use capture mode with hall sensor on cap1 2 an3

    Code:
    duty var word
    ansel0=%00000000 'all digital 
    'ansel1=%00000000
     
     
    trisa=%11111111 'set all port a pins to input cap1,cap2,cap3
    trisb=%00000000 'set all port b pins as output
    portb=%00000000 'set port b to all zero
    trisc = 2 ' rc1=flta input(ground pin 16 to stop) pin 16 high to run
     
    'capture mode
    intcon =0 'interrupts off
    tmr5h = 0 'clean high byte of tm5 counter
    tmr5l = 0 'clean low byte
    t5con = %00000001 ' prescale 1:1, int clock, tmr5 =on
     
    cap1con=%01000101 ' enable caputure,pulse width measurement mode, 
    'every rising o falling edge
    cap2con=%01000101 
    cap3con=%01000101 
     
    where is the capture data go from here
     
    ' ovdcond=%00010010 'turn on / off pwm pins
    'ovdcons=%00000000 
     
    'pcpwm init
    dtcon = %00000101 'set deadtime to -500ns
    ptcon0 =%00000000 ' 1:1 postscaale,fosc/4 1:1 prescale, free run mode
    ptperl =0
    ptperh=1
    pwmcon0= %01010000 'pwm[5:0] output enabled 0100pwm4,5 independent,
    'pwm0,1,2,3 complementary
     
    pwmcon1=1 'update enable,overrides sync w/time
     
    ptcon1=%10000000 'pwm time base is on, counts up
    fltconfig = %00000011 ' enable fault a, cycle-by-cycle mode
     
    duty =100 ' 50% =800
    PDC2L = duty.lowbyte 'main a fixed 50% duty cycle on pwm4,5
    PDC2H = duty.highbyte 'independent pwm outputs.
     
    main:
    for duty = 900 to 100 step-1 ' 10% to 90%
    PDC0L = duty.lowbyte 'register controls pwm1/0
    PDC0H = duty.highbyte
    PDC1L = duty.lowbyte 'register controls pwm3/2
    PDC1H = duty.highbyte
    PDC3L = duty.lowbyte 'register controls pwm6/7
    PDC3H = duty.highbyte
    pause 50
    next duty
     
    pause 500' 1/2 second delay between ramp up / down
     
    for duty = 100 to 900 ' 90% to 10%
    PDC0L = duty.lowbyte
    PDC0H = duty.highbyte
    PDC1L = duty.lowbyte
    PDC1H = duty.highbyte
    PDC3L = duty.lowbyte
    PDC3H = duty.highbyte
    pause 5
    next duty
     
    pause 500' 1/2 second delay between ramp up / down
     
    goto main
     
    end
    Last edited by ScaleRobotics; - 25th July 2010 at 16:47. Reason: added code tags

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default Instant Fuel Consumption

    Here's how I monitor instant fuel consumption...


  3. #3
    Join Date
    Aug 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default hall senors

    trying to us motion feedback module with capture on state mode on pins 3,4,5

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mystified View Post
    trying to us motion feedback module with capture on state mode on pins 3,4,5
    What's the question/problem?

  5. #5
    Join Date
    Aug 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default brushless motor control

    i want to set up a brushless dc motor control,I need to setup capxcon to input state change, (hall sensor as the inputs)
    rest tmr5 if a change on cap1 or cap2 or cap3, us a ic interupst and ovdcond regisiters to turn on or off pwn channels (pins)in a sequence for rotation for the motor. How do I check the flags to turn on or off the channels ?(doc an899)

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Here's how I monitor instant fuel consumption...

    Looks great Jeremy, more on screen than my snap on scanner, what kind of display is that, a monitor? What are you measuring the fuel flow with? ( the mpg goes over 60 due to the computer shuts off the fuel completely when decellerating. Impressive work.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Looks great Jeremy, more on screen than my snap on scanner, what kind of display is that, a monitor?
    http://www.sparkfun.com/commerce/pro...roducts_id=569
    It's the same screen that I posted the color lcd code to here awhile back.

    What are you measuring the fuel flow with? ( the mpg goes over 60 due to the computer shuts off the fuel completely when decellerating. Impressive work.
    Straight OBD2 data, mass air, temp, pressures, etc.etc.etc. Do enough math, mainly unit conversions and a bit of integration, and you can get almost anything you want out of OBD2...although the outputs are all 'estimated' because they're all derived from formulas with a few generic numbers (i.e. fudge factors) thrown in. But based on my driving over the past 8,000-ish miles, that 'estimation' seems to be quite accurate.
    And when the mileage goes over 60...
    The Nissan I've got ('98 200SX) isn't very aggressive at decel fuel cutoff like todays vehicles are. Based on my datalogging and calculations, if I'm doing 65mph and I let off the gas, I only get complete cutoff under certain conditions (above 2000 rpm, above 25mph, closed throttle, MAF below 500grams/sesc, MAP below 6 in/hg, calc.load.val below 10%). Other than that, I figure it goes open loop and tries to hit an A/F of about 25:1. Apparently, today's vehicles go to decel cutoff as soon as you think about slowing down (which accounts for some of todays vehicles being a just a little bit jerky at lower throttle settings in my experience).

Similar Threads

  1. CCP1 and CCP2 to measure 2 frequencies together
    By bobonapoletano in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th December 2005, 07:34

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts