CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with compiling lcd.c and kbd.c
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 19, 2010 4:20 pm     Reply with quote

Create a routine that waits for a keypress and then call it.
Example:
Code:

#include <16F877.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include "flex_lcd.c"
#include "flex_kbd.c"

// Wait for a key on the keypad to be pressed.  Then return it.
char wait_kbd_getc(void)
{
char retval;

while(1)
  {
   retval = kbd_getc();

   if(retval)
      return(retval);

   delay_ms(10);
  }
}

//======================
void main()
{
char k;

lcd_init();
kbd_init();

while(1)
  {
   k = wait_kbd_getc();    // Wait for a key press

   printf(lcd_putc, "\fKey = %c", k);  // Display it on LCD
  }

}
Athar Rasul



Joined: 19 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 4:12 am     Reply with quote

I know this shouldn't be happening but now I have to press the keys for quite some time, otherwise they aren't detected. And what about sending control commands to lcd. How can I do that?
Athar Rasul



Joined: 19 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 5:20 am     Reply with quote

Also please tell me can I call "wait_kbd_getc(void)" routine from some other routine? (other than main())?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 11:05 am     Reply with quote

Quote:

Now I have to press the keys for quite some time, otherwise they aren't detected.

Get creative. Try reducing the debounce period. Reduce it from 10ms to 5ms. Experiment.

Quote:

Can I call "wait_kbd_getc(void)" routine from some other routine?

Don't ask my permission. Just try it.
Athar Rasul



Joined: 19 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 1:31 pm     Reply with quote

 
Code:
#include <16F877A.h>
#device ADC = 8 // 8-bit conversion
#use delay(clock = 16000000)
#use rs232(UART1) // Select hardware UART

#include <lcd.c>
#include <kbd.c>

char wait_kbd_getc(void);
int input();

int selection;

void main(){
   int tin,degc[3],degf[3],key,temp_t,level_t,in; // Input variable
   long tf;
   set_tris_d(0); //Made Port D Output port (to use with in main function)
   set_tris_e(0); //Made Port C output port (to use with outer function)
   setup_uart(9600); // Set baud rate
   setup_adc(ADC_CLOCK_INTERNAL); // ADC clock
   setup_adc_ports(AN0_AN1_AN3); // Input combination
   set_adc_channel(0); // Select RA0
   delay_ms(100);

   lcd_init();
   kbd_init();

   while(1){
      delay_ms(500);

      if(!input(PIN_B0)){
         in=input();
         if(in!=0 & selection==1){
            temp_t=in; printf("New Temp Thresh is %c",temp_t);delay_ms(1000);
         }
         if(in!=0 & selection==2){
            level_t=in; printf("New Level Thresh is %c",level_t);delay_ms(1000);
         }
      }
      tin=read_adc();
      tin=tin/1.7; //digital to temperature value
      tf=(tin*1.8)+32;

      degc[2]= tin%10+'0';
      degc[1]= (tin/10)%10+'0';
      degc[0]= (tin/100)%10+'0';
      degf[2]= tf%10+'0';
      degf[1]= (tf/10)%10+'0';
      degf[0]= (tf/100)%10+'0';

      lcd_putc("\fTEMP:");
      printf("Temperature is ");
      if(degc[0]!='0'){
         putc(degc[0]);
         lcd_putc(degc[0]); goto skip;
      }
      if(degc[1]!='0'){
         skip: putc(degc[1]);
         lcd_putc(degc[1]);
      }
      putc(degc[2]);putc(0xDF);
      printf(lcd_putc, "%c%cC/",degc[2],0xDF);  // Display it on LCD
      printf("C or ");
      if(degf[0]!='0'){
         putc(degf[0]);
         lcd_putc(degf[0]);
      }
      putc(degf[1]);
      lcd_putc(degf[1]);
      putc(degf[2]);putc(0xDF);
      printf(lcd_putc, "%c%cF",degf[2],0xDF);  // Display it on LCD
      printf("F.");
         putc(13);
   }
}

// Wait for a key on the keypad to be pressed.  Then return it.
char wait_kbd_getc(void){
   char retval;
   while(1){
      retval = kbd_getc();
      if(retval)
      return(retval);
      delay_ms(1);
   }
}

input(){
   int key,input;
   start_input: lcd_putc("\f1:Temp Thresh.\n2:Level Thresh.");
   key=wait_kbd_getc();
   switch(key){
      case 1: selection=1; lcd_putc("\fSet Temp(0-150)\n"); goto start_temp;
      case 2: selection=2; lcd_putc("\rSet Level(0-100)\n"); goto start_level;
      case '#': input=0; goto end_input;
      default: goto start_input;
   }
   start_temp: key=wait_kbd_getc();
   switch(key){
      case '*': if(input>150){lcd_putc("\fOut of range...");
               delay_ms(1000);input=0; lcd_putc("\fSet Temp(0-150)\n");
               goto start_temp;}
               else return(input);goto end_input;
      case '#': input=0; goto start_input;
      default: input=(input*10)+key; lcd_putc(key); goto start_temp;
   }
   start_level: key=wait_kbd_getc();
   switch(key){
      case '*': if(input>100){lcd_putc("\fOut of range...");
               delay_ms(1000);input=0; lcd_putc("\fSet Level(0-100)\n");
               goto start_level;}
               else return(input);goto end_input;
      case '#': input=0; goto start_input;
      default: input=(input*10)+key; lcd_putc(key); goto start_level;
   }
   input=0;
   return(input);
   end_input:
}
[/code]

Last edited by Athar Rasul on Sat Mar 20, 2010 2:43 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 2:10 pm     Reply with quote

I have no idea where lines 32 and 117 are in your code. I am not a
mind reader. I suggest that you read the CCS manual and look at
the correct syntax for whatever lines are causing the problem. Also
look at the code for a few lines above the error line. Sometimes the
compiler generates an error in later lines, if you are missing a brace
or some other syntax error.

In other words, don't depend on me to solve your problems.
Learn how to trouble-shoot the problem by using your own mind.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 2:25 pm     Reply with quote

You cannot re-declare the function input().

How do expect the compiler to know what you mean here?

Code:
         input=input();


_________________
Google and Forum Search are some of your best tools!!!!
Athar Rasul



Joined: 19 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 2:41 pm     Reply with quote

I want to call the function input() and assign the value it returns to input variable. Is that ok?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 2:47 pm     Reply with quote

You are not allowed to assign anything to the function input().

You cannot name a variable with a reserved word such as the name of a
function. Change the name...
_________________
Google and Forum Search are some of your best tools!!!!
Athar Rasul



Joined: 19 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 3:15 pm     Reply with quote

Ok. I changed the name of function and variable. But it still gives error "expecting a numeric expression here" at the last line i.e. line containing '}'
Code:
abc(){
   int key,in;
   start_input: lcd_putc("\f1:Temp Thresh.\n2:Level Thresh.");
   key=wait_kbd_getc();
   switch(key){
      case 1: selection=1; lcd_putc("\fSet Temp(0-150)\n"); goto start_temp;
      case 2: selection=2; lcd_putc("\rSet Level(0-100)\n"); goto start_level;
      case '#': in=0; goto end_input;
      default: goto start_input;
   }
   start_temp: key=wait_kbd_getc();
   switch(key){
      case '*': if(in>150){lcd_putc("\fOut of range...");
               delay_ms(1000);in=0; lcd_putc("\fSet Temp(0-150)\n");
               goto start_temp;}
               else return(in);goto end_input;
      case '#': in=0; goto start_input;
      default: in=(in*10)+key; lcd_putc(key); goto start_temp;
   }
   start_level: key=wait_kbd_getc();
   switch(key){
      case '*': if(in>100){lcd_putc("\fOut of range...");
               delay_ms(1000);in=0; lcd_putc("\fSet Level(0-100)\n");
               goto start_level;}
               else return(in);goto end_input;
      case '#': in=0; goto start_input;
      default: in=(in*10)+key; lcd_putc(key); goto start_level;
   }
   in=0;
   return(in);
   end_input:
}
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Mar 20, 2010 4:34 pm     Reply with quote

As PCM told you earlier, you are going to have to do some of the work yourself.

Comment out sections of the code until it compiles then put them back one at at time until you find the culprit.
_________________
Google and Forum Search are some of your best tools!!!!
ferborghese



Joined: 24 Mar 2010
Posts: 1
Location: argentina

View user's profile Send private message AIM Address ICQ Number

problemas kbd.c puerto b pic16f887
PostPosted: Wed Mar 24, 2010 2:26 pm     Reply with quote

Search:
I am minded to a port where d pic16f887 have a 4x3 keypad and Nogra make it work, this project originally worked well with a PIC16F877A but we have a bad connection Reliz burn, and going to buy indicaroon us that this is the replacement and half cost.
I have to send two draft pic 16F877A with each other with the pic16f887 in each folder is a diagram of proteus 7.2 and ccs compiler used is used inside the MPLAB environment.


//**************************************************************************************************
// PROYECTO FINAL DE CARRERA: "CONTROLADOR UNILAZO"
//
// ALUMNOS: RUBEN DAVID ALONSO, LEGAJO:
// BORGHESE FERNANDO ARIEL, LEGAJO: 4735.
// DIRECTOR DE PROYECTO:
// DESCRIPCION:
// CONTROLADOR PID, PI, PD, P, ANTI WIND-UP CON ENTRADA ANALOGICA 0 A 5 V, SALIDA PWM, DOS SALIDAS DIGITALES ALARMAS,
// i2c comuninacion conmemoria 24lc256 ,COMUNICACION RS232, ETHERNET.
// *************************************************************************************************
//
#include <16F887.h>
#device adc=10
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#include <lcd.c>
#include <kbd.c>
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK)
#include <stdlib.h>
#include "input.c"
#include "24256.c"
#include <math.h>
//*************************************** FUNCIONES UTILIZADAS *************************************
void SELECCION_TIPO_CONTROL(void);
void CONFIGURACION_CONTROL(void);
void FUNCIONAMIENTO_CONTROL(void);
void INICIALIZO_VDU(void);
void LEOENTRADA_ANALOGICA(void);
void CALCULO_ACTUACION_PID(void);
void CALCULO_ACTUACION_PD(void);
void CALCULO_ACTUACION_PI(void);
void CALCULO_ACTUACION_P(void);
void leo_r232_PID(void);
void leo_r232_PI(void);
void leo_r232_PD(void);
void leo_r232_P(void);
void salida_pwm(void);
void carga_SP(void);
void carga_KP(void);
void carga_KI(void);
void carga_A_AL(void);
void carga_A_BA(void);
void carg_kd(void);
// *************************************************************************************************
// ***************** DECLARACION DE VARIABLES ******************************************************
char TIPO_CONTROL=' ',cambio_control=' ',sel=' ';
float sp=0,kp=0,kd=0,kii=0,error=0;
INT16 val232,tc=0;
float analogico=0,A_AL=0,A_BA=0,sum_error=0,error_ant=0,error_ant2=0,actuacion;
int tiemp=0;
long SALIDA=0;
// *************************************************************************************************
// **************************************************************************************************
// ************************************ FUNCIONAMIENTO DE CONTROL ***********************************
#int_rda // interrupcion para lectura por puerto serie
void interr_rs232(void)
{
if (kbhit()) // se pone en true si recibe algo por el puerto serie
tc=0; //tc=0 valor recibido por puerto serie
sel=getc(); // grabo el valor recido por el puerto serie en la variable sel
}
#int_TIMER0 //interrupcion del timer 0 en base al cual funciona el TM de control, y el TM de almacenamiento
void FUNCIONAMIENTO_control(void)
{
tiemp=tiemp+1;
LEOENTRADA_ANALOGICA(); //funcion de lectura de la entrada

switch (TIPO_CONTROL)
{
case '1': //si se sellecciono control PID
CALCULO_ACTUACION_PID();
SALIDA_PWM();
break;
case '2': //si se sellecciono control PD
CALCULO_ACTUACION_PD();
SALIDA_PWM();
case '3': //si se sellecciono control PI
CALCULO_ACTUACION_PI();
SALIDA_PWM();
break;
case '4': //si se sellecciono control P
CALCULO_ACTUACION_P();
SALIDA_PWM();
break;
}
}
// *************************************************************************************************
// ************************* MAIN ******************************************************************
void main()
{
setup_port_a(sAn0);
setup_adc(adc_clock_internal);
set_adc_channel(0);
setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM
setup_timer_2(T2_DIV_BY_1,255, 1);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);// configura el timer0
// tiempo de muestreo = (32(rtc_div_x)/(4000000Mhz/4)(tiempo de un periodo))*256(resolucion del timer0 = 8 bits)= 8,192 ms
set_timer0(0);
lcd_init();
kbd_init();
port_b_pullups(true);
SALIDA_PWM();
// *************************************************************************************************
while (true)
{
SELECCION_TIPO_CONTROL();
CONFIGURACION_CONTROL();
while (cambio_control == ' ')
{
lcd_gotoxy(2,3);
printf(lcd_putc,"E:%lf",analogico);
printf(lcd_putc," S:%lu ",salida);
printf("\b\r %f",analogico);
if(analogico >= A_AL)
output_high(pin_C0); // ALARMA ALTA
else
output_low(pin_C0); // ALARMA ALTA

if(analogico <= A_BA)
output_high(pin_C5); // ALARMA BAJA
else
output_low(pin_C5); // ALARMA BAJA

if ((sel == 'S') || (sel == 'P') || (sel == 'I') || (sel == 'D') || (sel == 'V'))
{
disable_interrupts (INT_TIMER0);
disable_interrupts (INT_rda);
switch (sel)
{
case 'S':
sp=0;
carga_SP();
sel=' ';
tc=0;
break;
case 'P':
kp=0;
carga_KP();
sel=' ';
tc=0;
break;
case 'I':
kii=0;
carga_KI();
sel=' ';
tc=0;
break;
case 'D':
kd=0;
carg_KD();
sel=' ';
tc=0;
break;
case 'V':
TIPO_CONTROL=' ';
cambio_control=2;
sel=' ';
sp=0;
kp=0;
kii=0;
kd=0;
break;
}
if (cambio_control!=2)INICIALIZO_VDU();

tc=0;
} //if principal

} //primer do
cambio_control=' ';
} //segundo do
} //cierre del main
//**************************************************************************************************
// **************************************SELECCION TIPO DE CONTROL ***********************************
void SELECCION_TIPO_CONTROL(void)
{
int stc=0;
// INICIALIZO LCD
lcd_init();
lcd_putc("SEL.CONTROLADOR\n");
lcd_putc("1PID 2PD 3PI 5ID");
delay_ms(100);
// INICIALIZO PANTALLA
printf("\r\n SELECCIONAR CONTROLADOR \r\n");
printf(" 1 - PID.\r\n");
printf(" 2 - PD.\r\n");
printf(" 3 - PI.\r\n");
printf(" 4 - P.\r\n");
while (stc == 0)
{
// LECTURA DE VDU
if (kbhit())
{
TIPO_CONTROL=getch();
if ((TIPO_CONTROL == '1') || (TIPO_CONTROL == '2') || (TIPO_CONTROL == '3') || (TIPO_CONTROL == '4') || (TIPO_CONTROL == '5'))
stc=1;
}
// LECTURA DE TECLADO
else
{
TIPO_CONTROL=kbd_getc();
if ((TIPO_CONTROL == '1') || (TIPO_CONTROL == '2') ||(TIPO_CONTROL == '3') || (TIPO_CONTROL == '4') || (TIPO_CONTROL == '5'))
{ tc=1;
stc=1;
}
}
}
// cambio_control=' ';
}
// **************************************************************************************************
//************************************ CONFIGURACION DE CONTROL********************************
void CONFIGURACION_CONTROL(void)
{
switch (TIPO_CONTROL)
{
case '1':
carga_SP();
carga_KP();
carga_KI();
carg_KD();
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," PID Sp:%f",sp);
break;
case '2':
carga_SP();
carga_KP();
carg_Kd();
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," PD Sp:%f",sp);
break;
case '3':
carga_SP();
carga_KP();
carga_KI();
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," PI Sp:%f",sp);
break;
case '4':
carga_SP();
carga_KP();
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," P Sp:%f",sp);
break;
}
carga_A_BA();
carga_A_AL();
if ((TIPO_CONTROL == '1') || (TIPO_CONTROL == '2') || (TIPO_CONTROL == '3') || (TIPO_CONTROL == '4') || (TIPO_CONTROL == '5'))
{
clear_interrupt(INT_TIMER0);
clear_interrupt(int_rda);
clear_interrupt(int_EXT);
enable_interrupts(INT_TIMER0);
enable_interrupts(int_rda); //habilita interrupcion
enable_interrupts(int_EXT); //habilita interrupcion
enable_interrupts(GLOBAL);
}
}
// *************************************************************************************************
//**************************** FUNCION DE LECTURA DE ENTRADA ANALOGICA *****************************
void LEOENTRADA_ANALOGICA(void)
{
analogico=read_adc();
}
// *************************************************************************************************
// *************************** calculo de control **************************************************
void CALCULO_ACTUACION_PID(void)
{
error=(sp-analogico);
sum_error=((kp+((kp*kd)/8))*error)+ (((kp*8)/kii)-kp-(2*kp*(kd/8)))*error_ant;
actuacion=sum_error+(kp*(kd/8))*error_ant2+actuacion;
error_ant2=error_ant;
error_ant=error;
if (actuacion >= 1023)
{
SALIDA =(long)1023;

if (actuacion >= 3096)
ACTUACION=1023;
}
else if (actuacion <= -1)
{
SALIDA =(long)0;

if (actuacion <= -3096)
ACTUACION=0;
}
else
{
SALIDA=(long)actuacion;
}
}
void CALCULO_ACTUACION_PD(void)
{
error=(sp-analogico);
actuacion=kp*(error+(kd/1)*(error-error_ant))+actuacion;
error_ant=error;
if (actuacion >= 1023)
{
SALIDA =(long)1023;

if (actuacion >= 3096)
ACTUACION=1023;
}
else if (actuacion <= -1)
{
SALIDA =(long)0;

if (actuacion <= -3096)
ACTUACION=0;
}
else
{
SALIDA=(long)actuacion;
}
}
void CALCULO_ACTUACION_PI(void)
{
error=(sp-analogico);
actuacion=kp*error+(((8/kii)-KP)*error_ant)+actuacion;
error_ant=error;
if (actuacion >= 1023)
{
SALIDA =(long)1023;

if (actuacion >= 3096)
ACTUACION=1023;
}
else if (actuacion <= -1)
{
SALIDA =(long)0;

if (actuacion <= -3096)
ACTUACION=0;
}
else
{
SALIDA=(long)actuacion;
}
//
}
void CALCULO_ACTUACION_P(void)
{
error=(sp-analogico);
actuacion=(kp*error);
if (actuacion >= 1023)
{
SALIDA =(long)1023;

if (actuacion >= 3096)
ACTUACION=1023;
}
else if (actuacion <= -1)
{
SALIDA =(long)0;

if (actuacion <= -3096)
ACTUACION=0;
}
else
{
SALIDA=(long)actuacion;
}
//
}
// *************************************************************************************************
//*********************************** funcion salida analica pwm **********************************
void SALIDA_PWM(void)
{
set_pwm1_duty(salida);
}
// *************************************************************************************************
//************************************ INICIALIZO VDU *********************************************
void INICIALIZO_VDU(void)
{
switch (TIPO_CONTROL)
{
case '1': //si se sellecciono control PID
printf("\r\nCONTROL PID\r\n");
printf(" S - SETEAR SET POINT:%f\r\n",sp);
printf(" P - MODIFICAR KP:%f\r\n", Kp);
printf(" I - MODIFICAR KI:%f\r\n", Kii);
printf(" D - MODIFICAR KD:%f\r\n", Kd);
printf(" V - DETENER Y SELECCIONAR TIPO DE CONTROL \r\r\n");

break;
case '2': //si se sellecciono control PD
printf("\r\nCONTROL PD\r\n");
printf(" S - SETEAR SET POINT:%f\r\n",sp);
printf(" P - MODIFICAR KP:%f\r\n", Kp);
printf(" D - MODIFICAR KD:%f\r\n", Kd);
printf(" V - DETENER Y SELECCIONAR TIPO DE CONTROL \r\r\n");
break;
case '3': //si se sellecciono control PI
printf("\r\nCONTROL PI\r\n");
printf(" S - SETEAR SET POINT:%f\r\n",sp);
printf(" P - MODIFICAR KP:%f\r\n", Kp);
printf(" I - MODIFICAR KI:%f\r\n", Kii);
printf(" V - DETENER Y SELECCIONAR TIPO DE CONTROL \r\r\n");

break;
case '4': //si se sellecciono control P
printf("\r\nCONTROL P\r\n");
printf(" S - SETEAR SET POINT:%f\r\n",sp);
printf(" P - MODIFICAR KP:%f\r\n", Kp);
printf(" V - DETENER Y SELECCIONAR TIPO DE CONTROL \r\r\n");
break;
}
}
// *************************************************************************************************
// ********************************* FUNCION DE LECTURA RS232 *************************************
void leo_r232_PID(void)
{
char seleccion;
val232=' ';
seleccion=getch();
switch (seleccion)
{
case 'S':
carga_SP();
break;
case 'P':
carga_KP();
break;
case 'I':
carga_KI();
break;
case 'D':
carg_KD();
break;
case 'V': disable_interrupts (INT_TIMER0);
TIPO_CONTROL=' ';
cambio_control=2;
break;
}
if ((seleccion == 'S') || (seleccion == 'P') || (seleccion == 'I') || (seleccion == 'D'))
{
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_gotoxy(0,1);
printf(lcd_putc," PID Sp:%f\n\r",sp);
lcd_gotoxy(0,0);
}
}
void leo_r232_PI(void)
{
char seleccion;
val232=' ';
seleccion=getch();
switch (seleccion)
{
case 'S':
carga_SP();
break;
case 'P':
carga_KP();
break;
case 'I':
carga_KI();
break;
case 'V': disable_interrupts (INT_TIMER0);
TIPO_CONTROL=' ';
cambio_control=2;
break;
}
if ((seleccion == 'S') || (seleccion == 'P') || (seleccion == 'I'))
{
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_gotoxy(0,1);
printf(lcd_putc," PI Sp:%f\n\r",sp);
lcd_gotoxy(0,0);
}
}
void leo_r232_P(void)
{
char seleccion;
val232=' ';
seleccion=getch();
switch (seleccion)
{
case 'S':
carga_SP();
break;
case 'P':
carga_KP();
break;
case 'V': disable_interrupts (INT_TIMER0);
TIPO_CONTROL=' ';
cambio_control=2;
break;
}
if ((seleccion == 'S') || (seleccion == 'P'))
{
// MUESTRA EN PANTALLA VDU
INICIALIZO_VDU();
// MUESTRA EN PANTALLA LCD
lcd_gotoxy(0,1);
printf(lcd_putc," P Sp:%f\n\r",sp);
lcd_gotoxy(0,0);
}
}
void carga_SP(void)
{
printf("\r\n Seleccion set point:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," CARGA SP: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
sp=get_float();
if (tc == 1)
sp=get_float_kbd();
} while(sp==0);
}
void carga_KP(void)
{
printf("\r\n Seleccion Constante Proporcional:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," CARGA KP: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
kp=get_float();
if (tc == 1)
kp=get_float_kbd();
} while(kp==0);
}
void carg_KD(void)
{
printf("\r\n Seleccion Constante Derivativa:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," CARGA KD: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
kd=get_float();
if (tc == 1)
kd=get_float_kbd();
} while(kd==0);
}
void carga_KI(void)
{
printf("\r\n Seleccion Constante Integral:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," CARGA KI: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
kii=get_float();
if (tc == 1)
kii=get_float_kbd();
} while(kii==0); while(sp==0);
}
void carga_KD(void)
{
printf("\r\n Seleccion Constante Derivativa:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," CARGA KD: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
kd=get_float();
if (tc == 1)
kd=get_float_kbd();
} while(kd==0);
}
void carga_A_BA(void)
{
printf("\r\n CARGA A_BA:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," C A_BA: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
A_BA=get_float();
if (tc == 1)
A_BA=get_float_kbd();
} while(A_BA==0);
}
void carga_A_AL(void)
{
printf("\r\n CARGA A_AL:");
lcd_init();
lcd_gotoxy(0,1);
printf(lcd_putc," C.A_AL: ");
do{
if (kbhit()) // si recibi un caracter por el puerto 232= true
A_AL=get_float();
if (tc == 1)
A_AL=get_float_kbd();
} while(A_AL==0);
}
// *************************************************************************************************


From already thank you very much.
Greetings
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group