- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I'm starting to program in PSOC and I have problem with the ADCINC, I made a program for read a LM35, but when i conected it, to psoc it only read cero, if a remplace with a pot i can see the variation, i have been searching a explain but i cant found it. I hope that you can help me. I anex the code. excuse me for me redaction y and the coments in spanish.
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "stdlib.h" //incluimos la libreria para conversiones
#include "delay.h" //incluimos la libreria para retardos
#include "string.h" //incluimos libreria para punto flotante
#define _FTOA_TOO_LARGE -2
#define _FTOA_TOO_SMALL -1
/*El programa realizará una conversion analogica a digital para detectar temperatura mediante un sensor LM35
y visualizarlo posteriormente mediante un LCD con barra grafica.
ADCINC: PGA:
DataFormat: UnSigned. Gain: 1.00
Resolucion: 10bits. Input: AnalogComun_InputMUX_0
Data Clock: VC1(2MHz). Reference: VSS
ClockPhase: Normal. AnalogBug: Disable
PosInput: ACB00
NegInput: --
NegInputGain: Disconected.
REFERENCIAS:
http://www.cypress.com/?rID=58118
http://www.cypress.com/?id=4&rID=47960
http://psocenespanol.blogspot.mx/
http://www.cypress.com/?id=4&rID=60580
Hoja de datas del ADCINC
Hoja de datos del PGA
Hoja de datos lenguaje C
*/
//----------------------------------------------------------------------
// CONDICIONES GLOBALES
//----------------------------------------------------------------------
char*flotante; //puntero para el punto flotante
int valor; //entero para almacenar valores
float temperatura; //flotante para generar voltaje
int estado; //estado de comparacion para el flotante
//----------------------------------------------------------------------
// Codigo de Programacion
//----------------------------------------------------------------------
void main(void)
{
M8C_EnableGInt ; //Abilitamos interrupciones globales.
LCD_Start(); //inicializamos la LCD
PGA_Start(3); //iniciamos el PGA e indicamos que opera con potencia alta (3=PGA_HIGHPOWER)
ADCINC_Start(3); //iniciamos el ADCINC e indicamos que opera con potencia alta (3=ADCINC_HIGHPOWER)
ADCINC_GetSamples(0); //indicamos que el ADC registra muestras continuas.
LCD_InitBG(LCD_SOLID_BG); //inicializamos la barra grafica con lineas
while(1){ //iniciamos el bucle infinito
LCD_Position(0,0); //posicionamos el lcd para escritura
LCD_PrCString("Temperatura:"); //escribimos la etiqueta voltaje
while(ADCINC_fIsDataAvailable()!=0){ //mientras la lectura sea valida
valor=ADCINC_wGetData(); //valor adquirirá el valor de lectura
ADCINC_fClearFlag(); //reseteamos la bandera del ADC incremental
temperatura= (float)valor*100/1023; //convertimos los bits a flotantes
LCD_Position(0,9); //posicionamos el LCD
flotante=ftoa(temperatura,&estado); //conversion para impresion en LCD
LCD_PrString(flotante); //imprimimos el voltaje
LCD_DrawBG(1,0,25,temperatura*.8);
}
Delay10msTimes(20); //creamos un retardo
LCD_Control(1); //resetamos la lcd
}
}
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content