Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > ASM y Microcontroladores
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-01-2013
Mikro-77 Mikro-77 is offline
Registrado
NULL
 
Registrado: ene 2013
Posts: 6
Poder: 0
Mikro-77 Va por buen camino
Duda con frecuencimetro y contador de revoluciones con Mikropascal

Hola tengo un codigo escrito en Mikropascal el problema es que no entiendo porque toma la lectura al principio y luego la pone en 0 , no entiendo cual es la variable que hace que la lectura no siga , entiendo que este foro tratan sobre este lenguaje tambien asi que les agradezco su ayuda !

Código Delphi [-]
program Frekvens_taeller;

{/******************************************************************************
* Project name:
EP6_freq.c EasyPIC5 and 6 using a LCD display
* Copyright:
Open-source - Oct 2009 - Roman Black and CRH
* Description:
The incoming frequency to be measured must be
connected to PORTC.F0 (T1CKI) pin. Max freq measured is 65000 Hz.
Note! If you don't have a freq signal connected, you can test it
by pressing the RC0 pushbutton REALLY quickly.

* Test configuration:
MCU: PIC16F887

Dev.Board: EasyPIC5 and 6

Oscillator: HS, 8.0000 MHz
Ext. Modules: - freq signal comes in on PORTC.F0
SW: mikroC PRO for PIC v3.20


******************************************************************************/}
Var
  // LCD module connections same as MikroPascal!
  LCD_RS : sbit at RB4_bit;
  LCD_EN : sbit at RB5_bit;
  LCD_D4 : sbit at RB0_bit;
  LCD_D5 : sbit at RB1_bit;
  LCD_D6 : sbit at RB2_bit;
  LCD_D7 : sbit at RB3_bit;

  LCD_RS_Direction : sbit at TRISB4_bit;
  LCD_EN_Direction : sbit at TRISB5_bit;
  LCD_D4_Direction : sbit at TRISB0_bit;
  LCD_D5_Direction : sbit at TRISB1_bit;
  LCD_D6_Direction : sbit at TRISB2_bit;
  LCD_D7_Direction : sbit at TRISB3_bit;
  // End LCD module connections

  int_sec_count: byte; // used to count ints/second
  new_second: boolean; // is set once per second

  //tchar: char; // text char used in LCD display numbers
  freq: word;  // 0-65000, holds freq value to display integer = heltal

  rpm: dword; // holds RPM for calcs AND display RPM= Revolution pr minute =  omdrejninger pr sekund

  txt: array[16] of char; // used to display number string
  //sec_count: char;

//----------------------------------------------------------------------------


// this is TMR2 overflow interrupt
procedure interrupt;
 begin
  Dec(int_sec_count);
  if int_sec_count=0  then // if reached 1 second!
   begin
    // get the TMR1 count!
    T1CON := 0; // TMR1 OFF
    Hi(freq) := TMR1H ; // put TMR1 16bit value in freq
    Lo(freq) := TMR1L;
    TMR1L := 0; // clear TMR1
    TMR1H := 0;
    T1CON := %00000011; // TMR1 back ON again
    // that's everything done for this second
    new_second:=true;
    int_sec_count := 125; // load ready to generate another second
  end;
  TMR2IF_bit := 0; // Clear TMR2IF before exit
 end;




//-----------------------------------------------------------------------------
Begin
  // setup PIC 16F887 registers
  ANSEL := 0; // Configure AN pins as digital
  ANSELH := 0;
  C1ON_bit := 0; // Disable comparators
  C2ON_bit := 0;

  TRISC := %00000001; // PORTC.F0 = input from freq signal

  TRISB := 0; //
  PORTB := 0xFF; //
  TRISB := 0xFF; //

  //-------------------------------------------------------
  // EasyPIC5 and 6 LCD setup

  // show startup message
  //Lcd_Config(0); // Initialize Lcd over SPI interface
  Lcd_Init();
  Lcd_Cmd(_LCD_CLEAR); // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
  txt := 'frekvens';
  Lcd_Out(1,2,txt); // display startup text to Lcd
  txt := ' & Omdrejtaller ';
  Lcd_Out(2,2, txt);
  Delay_1sec();
  Delay_1sec();

  // clear LCD again before main
  Lcd_Cmd(_LCD_CLEAR);

  //-------------------------------------------------------
  // setup the timers for frequency counting

  // setup TMR1
  T1CON := %00000011; // TMR1 ON, external clock pulse on PORTC.F0

  // setup TMR2 and enable TMR2 int
  T2CON := %00011111; // TMR2 ON, 8MHz xtal, 16:4:1 = 31250 Hz (Timer 2 prescaler settings)
  PR2 := 249; // TMR2 int is 31250 / 250 = 125 ints/sec
  PIE1.TMR2IE := 1; // TMR2 interrupt is on
  // load variables ready to run
  int_sec_count := 125;
  INTCON := %11000000; // GIE=ON, PIE=ON

  //-------------------------------------------------------
  // now do the main run loop
  while true do
   begin
    // everytime we reach a second, calculate and display freq
    if new_second then
     begin
      new_second := false;
      // safe limit freq at 65 kHz
      if freq > 65000 then
       freq := 65000;
       
      // display freq as "xxxxx Hz"
      WordToStr(freq,txt);
      Lcd_Out(1,8,txt);
      txt := 'Hz';
      Lcd_Out(1,14,txt);

      // calc RPM from freq
      rpm := (freq * 60);

      // format rpm to display as "xxxxxxx RPM"
      LongWordToStr(rpm,txt); // get the rpm as a string
      Lcd_Out(2,2,txt); // and display RPM!
      txt := 'RPM';
      Lcd_Out(2,14,txt);
      
      //************
      Dec(int_sec_count);
  if int_sec_count=0  then // if reached 1 second!
   begin
    // get the TMR1 count!
    T1CON := 0; // TMR1 OFF
    Hi(freq) := TMR1H ; // put TMR1 16bit value in freq
    Lo(freq) := TMR1L;
    TMR1L := 0; // clear TMR1
    TMR1H := 0;
    T1CON := %00000011; // TMR1 back ON again
    // that's everything done for this second
    new_second:=true;
    int_sec_count := 125; // load ready to generate another second
  end;
  TMR2IF_bit := 0; // Clear TMR2IF before exit
      //************
      
      
     end;
   end;
end.
Responder Con Cita
  #2  
Antiguo 16-01-2013
Mikro-77 Mikro-77 is offline
Registrado
NULL
 
Registrado: ene 2013
Posts: 6
Poder: 0
Mikro-77 Va por buen camino
Thumbs down

Vamos amigos ! se que hay verdaderos gurúes en este foro !!!
Responder Con Cita
  #3  
Antiguo 18-01-2013
Avatar de Ñuño Martínez
Ñuño Martínez Ñuño Martínez is offline
Moderador
 
Registrado: jul 2006
Ubicación: Ciudad Catedral, Españistán
Posts: 6.000
Poder: 25
Ñuño Martínez Tiene un aura espectacularÑuño Martínez Tiene un aura espectacular
Es que Mikropascal no es muy utilizado. Aun así, sé que algunos miembros lo usan, o al menos lo han usado.

En el IRC (IRC-hispano, salas #delphi y #pascal) entra gente que usa Mikropascal a menudo, así que quizá te pueden ayudar.
__________________
Proyectos actuales --> Allegro 5 Pascal ¡y Delphi!|MinGRo Game Engine
Responder Con Cita
  #4  
Antiguo 16-03-2013
Avatar de fenixariel
fenixariel fenixariel is offline
Miembro
 
Registrado: mar 2007
Posts: 77
Poder: 18
fenixariel Va por buen camino
No importa el lenguaje, se sigue de la misma manera, en C, Pascal, hasta en ASM,

Me parece que en la interrupcion no?


Saludos.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Duda con mikropascal y pic4520 Mindfield ASM y Microcontroladores 1 16-03-2013 23:54:21
Duda con mikropascal Mindfield ASM y Microcontroladores 1 09-10-2012 07:52:20
Delphi con Mikropascal barakuda Varios 1 16-09-2010 23:02:47
¿funciones Para Control De Temperatura Cpu, Revoluciones Ventiladores, Etc...? ermaska API de Windows 1 14-06-2010 11:35:57
Problemas con mikropascal chesare ASM y Microcontroladores 6 12-03-2010 18:23:29


La franja horaria es GMT +2. Ahora son las 06:20:24.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi