Pic Speed / Instruction Speed etc


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2005
    Posts
    44

    Default Pic Speed / Instruction Speed etc

    Hi all,

    I've got some code im testing, basically to decode a trigger wheel, and output 3 pulses per rotation of the wheel which has 35 teeth.

    Code:
    
    CMCON = 7						' set portA to digital
    TRISA = %00100000				' Port A all output but MCLR
    TRISB = %00001000				' Port B all output but 3 (CCP)
    InPIN	VAR	PORTB.3				' Define input pin
    OutPIN 	VAR	PORTB.5				' Define output pin
    LastState   VAR	BIT				' Last Pin State
    PulseCount	VAR BYTE			' Number of input pulses
    	
    
    PulseCount = 0
    Low OutPin
    
    MainLoop:
    if InPIN <> LastState then  ' If Input State Changed 
    
    	LastState = InPIN    
    	
    	PulseCount = PulseCount + 1
    					
    		Select Case PulseCount
    		
    			Case 1
    			High OutPin
    			Case 4
    			Low Outpin
    			
    			Case 12
    			High OutPin
    			Case 15
    			Low Outpin
    			
    			Case 24
    			High Outpin
    			Case 27
    			Low Outpin
    			
    			Case 35
    			PulseCount = 0
    			Low OutPin
    			
    			Case is > 35
    			PulseCount = 0
    			Low OutPin
    			
    			Case Else
    			
    		End Select
    
    endif
    GOTO MainLoop

    at maxium wheel rotation speed, the pic input frequency is approx 5khz,
    now, at 4mhz, should the pic be able to keep up, or does anyone have any alternative code ideas to help improve the performance?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Jamie

    @ first ... there is a small thing I do not understand so well ...

    you count the teeth ... oK ... but the way you use rising AND falling edges make 2 transitions per tooth ... or 70 transitions per turn ...

    the way the program is written - and taking 70 transitions into account ... I get a 13200 rpm counting limit @ 4 Mhz...

    Alain
    Last edited by Acetronics2; - 27th April 2010 at 13:54.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Use a hardware counter like Timer0.

    Here's one example; http://www.picbasic.co.uk/forum/showthread.php?t=10608

    If you get 2 pulses per tooth just set a 1:2 prescaler for 35 counts per rev.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Aug 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    alain - yeah i found that out when i tested with the scope - i just doubled the numbers in the case statements and it worked fine. As the max speed is around 8500rpm, testing it seemed fine on the bench.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Cool

    Hi, Jamie

    ... having 3 pulses per turn and a 8500 rpm limit ... make me think of a somewhat "unusual" engine ...

    could you tell me which engine it is ... may be I can be VERY interested in ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Aug 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    suzuki v6, and i want to decode a crank trigger to run an aftermarket tacho.
    it probably will never see 8500rpm, but i want to ensure the pic is stable at least to 7000rpm

  7. #7
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Pic Speed / Instruction Speed etc

    I know this is an old post but I made a tach adapter using a PIC 16F1824. It basiclly takes a single cylinder engine signal (1 pulse /720 degrees) and multiplies it by 4 to use a 4 cylinder tach. Works real well if you are interested, I can send you the code. It can be adapted to other situations as well. I also designed a real stable interface to the coil if you don't have a crank trigger.

Members who have read this thread : 1

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