Tachometer project

Discussion in 'The Projects Forum' started by splendid-electron, Mar 10, 2014.

  1. splendid-electron

    Thread Starter New Member

    Jan 26, 2014
    14
    0
    Hello !
    Code ( (Unknown Language)):
    1.  void main()
    2.    {
    3.       CMCON = 0x07;   // Disable comparators configuration comparateur
    4.       ADCON1 = 0x0F;  // Disable Analog functions
    5.       //TRISC = 0x00;
    6.       TRISC = 0x80;        // Port C output except RC7 RX (input)
    7.       TRISB = 0x00;        // Configuration du portB en sortie
    8.       PORTA = 0x00;
    9.       TRISA = 0b00010000; // Configuration du bit 4 en entrée
    10.       T0CON = 0b01101000; // TMR0 as 16-bit counter
    11.       Lcd_Init();        // Initialize LCD
    12.       Lcd_Cmd(_LCD_CLEAR);             // CLEAR display
    13.       Lcd_Cmd(_LCD_CURSOR_OFF);        // Cursor off
    14.       Lcd_Out(1,1,message1);            // Write message1 in 1st row
    15.       //----
    16.        UART1_Init(9600);                         // initialize UART1 module
    17.        Delay_ms(100);
    18.       //----
    19.       do
    20.        {
    21.            T0CON.TMR0ON = 1; //  Run Timer
    22.            TMR0L = 0;    //
    23.            TMR0H = 0;
    24.            IR_Tx = 1;
    25.            Delay_ms(1000); // Wait for 1 sec
    26.            IR_Tx = 0;
    27.            T0CON.TMR0ON = 0;    // Stop the timer
    28.            RPM_Value = (256*TMR0H + TMR0L)*60;
    29.            Display_RPM(RPM_Value);
    can you help me to understand how this code count the number of slots
     
  2. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,509
    2,369
    I would have though a more practical solution would be a Capture T1 etc.
    I only use assembly but that is the way it appears to me.
    Max.
     
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Did I not already do that here?:confused:
     
    spinnaker likes this.
Loading...