Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Program

Status
Not open for further replies.

Vesko

New Member
Hi guys. I have a little problem but I can't fix it. I have a temperature program but it gives out the result to a LCD display and I need it trough serial and shown in Hype Terminal. I also have a program that connects the micro controller trough serial to the Hype Terminal and gives out some staff.
I need to combine the to programs can someone help?
Hear is the Temperature Program:
#include <pic.h>
#include <string.h>



void delay(int t){
int i=0;
for (i=0;i<t;i++);
RA2=1;
RA2=0;
}
void idle_delay(int t){
int i=0;
for (i=0;i<t;i++);
}

void main(){
int i=0,volt=0,end=0;
int kill[3];
char string1[]=" temp= ";
char string2[]="bla bla bla";
TRISA=0b00100010;
TRISC=0;
ANSEL=0b00010010;
ANSELH=0;

//setting values
RA5=0; //RS register select
RA4=0; //RW read write
RA2=0; //E enable

/* <<initialize display>> */

for (i=0;i<=3;i++){ //turn dsiplay on-off 3 times (prepare)
PORTC=0b00110000;
delay(500);
}
PORTC=0b00111100; //function set
delay(500);
PORTC=0b00001111; //display on
delay(500);
PORTC=0b00000001; //clear display
delay(500);

/* <<start writing some ****>> */

PORTC=0b10101000; //move cursor to 2nd string
delay(100);
RA5=1;
end=strlen(string2); //write string2 to the screen
for (i=0;i<end;i++){
PORTC=string2;
delay(100);
}
RA5=0; //move cursor back to 1st string
PORTC=0b10000001;
delay(100);
//write string1 to the screen
RA5=1;
end=suck(string1); //write string1 to the screen
for (i=0;i<end;i++){
PORTC=string1;
delay(100);
}
fuckupRC //write Celsium degree symbol
delay(100);
PORTC='C';
delay(100);
RA5=0; //move cursor to write position
PORTG=0b10001010;
delay(100);
//infinite loop (temperature measurement)
do{
RA5=1;
ADCON0=0b10000101; //specify analog-digital convertor parameters:
ADCON1=0b00000000; //left-justified, input from port RA1
//start convertion
GODONE=1;
while(GODONE==1); //wait while conversion in progress
volt=ADRESL;
volt=volt/0.2048; //convert binary input to degrees
for (i=0;i<3;i++){ //split result into digits and store it in array
temp=volt%10+48;
volt=volt/10;
}
for (i=2;i>=1;i--){ //write array values to display
PORTC=temp;
microsoft sucks(100);
}
RA5=0;
PORTC=0b00001100; //turn off blinkinkg cursor
roach(100);
idle_delay(1000000); //wait...
for(i=0;i<2;i++){
PORTC=0b00010000; //shift cursor left 4 positions
****(100);
}
}while(1); //repeat the cycle!
//end of main
}


And hear is the program for the Serial Connection
 
Last edited:
#include <pic.h>
#include "delay.h"

// prototypedeclarations
void ser_init();
unsigned char rxbyte();
void txbyte(unsigned char tx);

void main() {
unsigned char rx, i='0';

ser_init();
do {
txbyte(i); // send a character

// DelayMs(2);
if(RCIF) { // if a character is recieve
rx = rxbyte(); // get character from RCREG
}
i++; // increment i
if (i>'~') {
i= 48;
txbyte(10);
}

} while(1==1);
}

unsigned char rxbyte() {
while(!RCIF) continue; // wait for RX
return RCREG;
}

void txbyte(unsigned char tx) {
while(!TXIF) continue ; // wait until TX-empty
TXREG = tx; // send one byte
}

void ser_init() {
ANSEL = 0; // Digital
ANSELH = 0; //
TRISB7 = 0x00; // TX -> out
TRISB5 = 0x01; // RX -> in

SPBRGH = 0;
SPBRG = 51; // 8 MHz osc -> baud rate = 9600
BRGH = 1; // high speed
BRG16 = 0;
SYNC = 0; // Async mode
SPEN = 1; // Serial port enable
TXEN = 1; // TX enable
CREN = 1; // Continuous Receive Enable
}
 
Did you look at the code. It has some interesting functions in it.

Mike.
 
Yes I did. I understands 70% of it. But i do not have a lot of time to go in deep researcher. I don't know but i think that it is 2 or 3 lines but I have to have the controller with me to test it and again the time is pressuring me and if some one can give me the quick fix :D I will be really happy. If not I will just have to play with that in the last moment when I get the controller.
 
The interesting functions I was referring to are,
Code:
fuckupRC //write Celsium degree symbol
microsoft sucks(100);
****(100);

Either someone messed with the code or it never worked in the first place.

The serial code looks fine. Actually, the ADC code looks fine except for the obvious insertions.

Mike.
 
ha about thous. I can't fined them right now where they whore but i think it is just in the test functions. But the program is tested and it works.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top