TODOPIC
Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: zoder45 en 28 de Abril de 2021, 14:41:58
-
Que tal buena tarde a todos.
tengo un proyecto con una pantalla stone de 7 pulgas para visualizar temperatura y humedad y set point.
la programación con MicroC ya la tengo hecha y puedo visualizar los valores vía serial
El problema que tengo es lo siguiente, no e podido hacer la comunicación entre el pic y la pantalla
ya leei la hoja de datos pero no le entiendo mucho como realizar dicha programación en MicroC
les dejo el código que tengo
a qui se encontrara la información de la pantalla
https://www.stoneitech.com/support/download/user-manual
si me podrían ayudar se los agradeceré mucho saludos
Estoy ocupando MicroC y Pic 16F877A
#include "floattostr_.h"
sbit CALEFACTOR at RB0_bit;
int tem1;
char Text[10]; //Cadena de caracteres para impresión de datos.
char fracc;
char hume;
char texto[30];
unsigned int HUM1;
unsigned char Check, T_byte1, T_byte2, RH_byte1, RH_byte2, Ch ;
unsigned Temp, RH, Sum ;
unsigned be, me,ne, Sum2,h1,h2 ;
//////////////////////////////
void Uart1_write_text_const(const char *info)
{
while(*info) UART1_Write(*info++);
}
//////////////////////////////
void StartSignal(){
TRISA.F0 = 0; //Configure RD0 as output
PORTA.F0 = 0; //RD0 sends 0 to the sensor
delay_ms(18);
PORTA.F0 = 1; //RD0 sends 1 to the sensor
delay_us(30);
TRISA.F0 = 1; //Configure RD0 as input
}
//////////////////////////////
void CheckResponse(){
Check = 0;
delay_us(40);
if (PORTA.F0 == 0){
delay_us(80);
if (PORTA.F0 == 1) Check = 1; delay_us(40);}
}
//////////////////////////////
char ReadData(){
char i, j;
for(j = 0; j < 8; j++){
while(!PORTA.F0); //Wait until PORTD.F0 goes HIGH
delay_us(30);
if(PORTA.F0 == 0)
i&= ~(1<<(7 - j)); //Clear bit (7-b)
else {i|= (1 << (7 - j)); //Set bit (7-b)
while(PORTA.F0);} //Wait until PORTD.F0 goes LOW
}
return i;
}
//////////////////////////////
void main() {
UART1_Init(9600);
Uart1_write_text_const("INICIANDO\r\n");
TEM1=350;
ADCON1 = 0x07; //Configura puerto A como digitales
while(1){
StartSignal();
CheckResponse();
if(Check == 1){
RH_byte1 = ReadData();
RH_byte2 = ReadData();
T_byte1 = ReadData();
T_byte2 = ReadData();
Sum = ReadData();
if(Sum == ((RH_byte1+RH_byte2+T_byte1+T_byte2) & 0XFF)){
Temp = T_byte1;
Temp = (Temp << 8) | T_byte2;
RH = RH_byte1;
RH = (RH << 8) | RH_byte2;
delay_ms(500);
sprinti(texto,"HUMEDAD=%u \r\n",rh);
UART1_Write_Text(texto);
sprinti(texto,"Temperatura=%u \r\n",TEMP);
UART1_Write_Text(texto);
delay_ms(500);
} else {
CALEFACTOR=0;
}
}
}
-
Por lo que veo esa pantalla primero la tenes que programar o diseñar la UI con un soft... Mas claro que al comienzo de la hoja de datos no hay:
https://www.stoneitech.com/media/upload/LargeFile/TOOL2019-User-Development-Guide-200327.pdf
Development Flow
It only needs 3 steps in developing by Intelligent TFT LCD Module to complete complex human- machine interface design.
① Prepare the project materials; Arrange the artwork to design the needed background image and icon for
the products, and prepare fonts, audio and video files according to the design needs.
② Interface design; Firstly the Intelligent TFT LCD Module 4. 3 development tool is used to perform
Interface layout, screen parameter configuration and control configuration with designed picture, and
then perform compile, then preview the effect, finally the generated configuration file is downloaded into
the Intelligent TFT LCD Module.
③ User MCU sends UART command to debug interface display. Once the configuration file is downloaded
into the screen, and once one button on the screen is pressed, the user MCU will receive the address
information of button variables which uploaded from the Intelligent TFT LCD Module. By resolving the
variable address, the user can obtain the function attribute of the current button, so that the related
peripheral device or interface update display can be controlled.
Luego de alli tenes un formato para enviar los datos. Especificado en la pagina 19 del PDF (14 del documento)
Donde tenes que enviar todo esto:
command frame header, command length, command and start address. [Data length], [data content], [CRC checking code]
El Command Frame Header que lo programas en el paso de diseño, esto te permite varias pantallas (son 2 bytes).
El Command Length, que es un byte, que indica la cantidad de bytes que posee command, start address, data length, data content y el CRC.
Luego tenes el command, que este es donde vas a definir si leer/escribir,ejecutar alguna accion, etc.
La direccion de inicio, y finalmente todo el dato que vas a enviar..
Un ejemplo que da para la lectura de algun registro que posee el modulo (los registros estan listados pag 27 PDF) es el siguiente:
0xA5 0x5A 0x04 0x80 0x03 0x00 0x01
El Command Fram Header es 0xA5A5
El Command Length (largo) es de 4 bytes
El Comando es 0x80, que es escritura de registro
Direccion de inicio : 0x03
Poner los datos 0x00 y 0x01
Es decir en el registro 0x03 vas a tener el valor 0x00, y en el registro 0x04 vas a tener el valor 0x01.
Observaras que falta el CRC, si lo activas, tenes que enviar además de eso, 2 bytes mas con el CRC del tipo X16 + X15 + X2 + 1. Y el Command Length pasa a ser de 6 bytes.
Y muchisimas cosas mas que realmente merece la pena que lo observes. El panel permite reproduccion de videos, animacion, sonidos. Entrar datos y que al presionar "ok" se envíen al micro (con el mismo formato que haces para enviarle). Dibujar, etc. Eso queda en vos investigarlo como hacerlo.
-
Muchas gracias
se que me toca investigar mas cosas jejej
lo que no se como programarlo en microc o como empezar a mandar los datos via serial
si me podrían ayudar con lo principal para empezar a enviar los datos o cuales serian los comandos para enviar
gracias y saludos
-
Pero es buscar Mikro C UART y te aparece la documentacion de la misma
https://download.mikroe.com/documents/compilers/mikroc/pic/help/uart_library.htm#uartx_write_gen
Con la funcion Write, escribis cualquier cantidad, vas a enviar byte a byte.