16f877a USART display temp on PC
16f877a USART display temp on PC
Hi guys,
I am new to your forum ,and I hope that you help me ,please.
I want to display the temperature using the LM35DZ on the hyper terminal ,following is the code and does not have errors but I receive incorrect data >>
Any help please
Pic 16f877a hs 8MHz rs232
unsigned temp_value;
char *out="000000";
void main()
{
Usart_Init(9600);
ADCON1 = 0x80;
TRISA = 0xFF; // PORTA as input
while(1)
{
if (USART_Data_Ready()) {
Delay_ms(1000);
temp_value = Adc_Read(0)*5000/1024; // Read analog input
out[0]=temp_value/10;
out[1]= temp_value%10;
ByteToStr(temp_value,out);
Usart_Write("temp is");
Usart_Write(out);
}
}
}
any help ,please
I am new to your forum ,and I hope that you help me ,please.
I want to display the temperature using the LM35DZ on the hyper terminal ,following is the code and does not have errors but I receive incorrect data >>
Any help please
Pic 16f877a hs 8MHz rs232
unsigned temp_value;
char *out="000000";
void main()
{
Usart_Init(9600);
ADCON1 = 0x80;
TRISA = 0xFF; // PORTA as input
while(1)
{
if (USART_Data_Ready()) {
Delay_ms(1000);
temp_value = Adc_Read(0)*5000/1024; // Read analog input
out[0]=temp_value/10;
out[1]= temp_value%10;
ByteToStr(temp_value,out);
Usart_Write("temp is");
Usart_Write(out);
}
}
}
any help ,please
Re: 16f877a USART display temp on PC
I want to receive data as ASCCi
Re: 16f877a USART display temp on PC
Any help please
Re: 16f877a USART display temp on PC
why you do not help me
Re: 16f877a USART display temp on PC
Hi
I think that you are making several mistakes
1. If you want to just send data to the hyper terminal you don't need this method " USART_Data_Ready() ". Delete it and and just leave
everything that needs to be done over and again inside the while(1) loop
2. You are reading the data incorrectly. I know that when you read using the ADC ig gives you 10 bits. The PIC is a 8 bits microcontrellor.
Take a look at the ADC examples programs to see how you should read the analog port.
3. I don't understand the mathematics behind the reading of the value. I think that the sensor gives you 10mV per degree right? How much is
your reference voltage? Lets say you make the reference voltage equal to 1V. When the sensors output is 1V that means that the
temperature is 1/0.01=100 degrees. The ADC output will gives you 1023 counts. That means that the degree/LSB is equal to (in this case)
100/1023= When you read the ADC multiply the counts with (100/1023) and you will get the temperature in degrees. This is of course not
a good example to use but just so you just understand how to calculate the degree/LSB constant.
4. When outputting to USART try to do this. Create a char array like myarray[10]; The calculated temperature must be converted to string. Remember to use the correct form of convert to string.
Inside you put the information and what the information tells you:
myarray[0]='T'
myarray[1]='e'
myarray[2]='m'
myarray[3]='p'
myarray[4]='='
myarray[5]= here comes the first char of the temperature
myarray[6]=here comes the second char of the temperature
myarray[7]=here comes the third char of the temperature
myarray[8]=here comes the fourth char of the temperature
After everything is nicely inside a char you output the whole char via usart. Create e method and give the method this char like this
void Write_String(char *Awo)
{
for (t=0;t<=8;t++)
{
Usart_Write(awo[t]);
}
}
This code is not compleet and untested but at least you have a lot of information of how to do it
I think that you are making several mistakes
1. If you want to just send data to the hyper terminal you don't need this method " USART_Data_Ready() ". Delete it and and just leave
everything that needs to be done over and again inside the while(1) loop
2. You are reading the data incorrectly. I know that when you read using the ADC ig gives you 10 bits. The PIC is a 8 bits microcontrellor.
Take a look at the ADC examples programs to see how you should read the analog port.
3. I don't understand the mathematics behind the reading of the value. I think that the sensor gives you 10mV per degree right? How much is
your reference voltage? Lets say you make the reference voltage equal to 1V. When the sensors output is 1V that means that the
temperature is 1/0.01=100 degrees. The ADC output will gives you 1023 counts. That means that the degree/LSB is equal to (in this case)
100/1023= When you read the ADC multiply the counts with (100/1023) and you will get the temperature in degrees. This is of course not
a good example to use but just so you just understand how to calculate the degree/LSB constant.
4. When outputting to USART try to do this. Create a char array like myarray[10]; The calculated temperature must be converted to string. Remember to use the correct form of convert to string.
Inside you put the information and what the information tells you:
myarray[0]='T'
myarray[1]='e'
myarray[2]='m'
myarray[3]='p'
myarray[4]='='
myarray[5]= here comes the first char of the temperature
myarray[6]=here comes the second char of the temperature
myarray[7]=here comes the third char of the temperature
myarray[8]=here comes the fourth char of the temperature
After everything is nicely inside a char you output the whole char via usart. Create e method and give the method this char like this
void Write_String(char *Awo)
{
for (t=0;t<=8;t++)
{
Usart_Write(awo[t]);
}
}
This code is not compleet and untested but at least you have a lot of information of how to do it
Re: 16f877a USART display temp on PC
Thank you very very much
I will try it now
I will try it now
Re: 16f877a USART display temp on PC
I get tiered
Can any one please send me a tested code with its hardware connection to try it ,because I have tested what is written in the MikroC manual and in the examples that come with the compiler
and I really do not know the fault where ???
Any help please
The result of the last tries that it is only giving me indication that the com is connected,but with out any data....
please heeeeelp
Can any one please send me a tested code with its hardware connection to try it ,because I have tested what is written in the MikroC manual and in the examples that come with the compiler
and I really do not know the fault where ???
Any help please
The result of the last tries that it is only giving me indication that the com is connected,but with out any data....
please heeeeelp
Re: 16f877a USART display temp on PC
I wrote this code ,and I check it on the terminal ,but I can not receive any thing
unsigned int temp_value;
unsigned char out[9];
unsigned int i;
void main()
{
Usart_Init(9600);
ADCON1 = 0x80;
TRISA = 0xFF; // PORTA as input
while(1)
{
Delay_ms(1000);
temp_value = Adc_Read(0)>>2;
temp_value =temp_value *5000/256; // Read analog input
//out[0]=temp_value/10;
//out[1]= temp_value%10;
ByteToStr(temp_value,out);
Usart_Write('T');
Delay_ms(1000);
Usart_Write('E');
Delay_ms(1000);
Usart_Write('M');
Delay_ms(1000);
Usart_Write('P');
Delay_ms(1000);
Usart_Write('=');
Delay_ms(1000);
do
{
Usart_Write(out);
}while (i<9);
}
}
Any help
unsigned int temp_value;
unsigned char out[9];
unsigned int i;
void main()
{
Usart_Init(9600);
ADCON1 = 0x80;
TRISA = 0xFF; // PORTA as input
while(1)
{
Delay_ms(1000);
temp_value = Adc_Read(0)>>2;
temp_value =temp_value *5000/256; // Read analog input
//out[0]=temp_value/10;
//out[1]= temp_value%10;
ByteToStr(temp_value,out);
Usart_Write('T');
Delay_ms(1000);
Usart_Write('E');
Delay_ms(1000);
Usart_Write('M');
Delay_ms(1000);
Usart_Write('P');
Delay_ms(1000);
Usart_Write('=');
Delay_ms(1000);
do
{
Usart_Write(out);
}while (i<9);
}
}
Any help
Re: 16f877a USART display temp on PC
it is so bad when you see someone saying :heeeeeeeeeeeeeelp
and you ignore him
and you ignore him
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: 16f877a USART display temp on PC
Hello,
here is several links, which might help to you:
- mikroC PRO for PIC
- Examples for EasyPIC6 (mikroC PRO for PIC): http://www.mikroe.com/zip/easypic6/easy ... s_v101.zip
If you follow this link, you can find examples for DS1820 (One Wire) and RS-232 (UART)
Also, here is datasheet for LM35DZ:
http://pdf1.alldatasheet.com/datasheet- ... /LM35.html
I hope that you will find usable information's, and find solution.
For any further assistance, feel free to contact us.
Best regards,
Losic Tihomir
here is several links, which might help to you:
- mikroC PRO for PIC
- Examples for EasyPIC6 (mikroC PRO for PIC): http://www.mikroe.com/zip/easypic6/easy ... s_v101.zip
If you follow this link, you can find examples for DS1820 (One Wire) and RS-232 (UART)
Also, here is datasheet for LM35DZ:
http://pdf1.alldatasheet.com/datasheet- ... /LM35.html
I hope that you will find usable information's, and find solution.
For any further assistance, feel free to contact us.
Best regards,
Losic Tihomir
mikroElektronika [Support team]
Re: 16f877a USART display temp on PC
Thank you very much ....
But I have already gone through these links ....
And my problem is outputting the LM35 data on the PC ....
I can not receive any thing ....
even wrong data I do not receive >>
what can be the reason behind that ???
But I have already gone through these links ....
And my problem is outputting the LM35 data on the PC ....
I can not receive any thing ....
even wrong data I do not receive >>
what can be the reason behind that ???
Re: 16f877a USART display temp on PC
Beside that >>>
I have a code >>>
can any one tested using the proteus ....
just testing >>>please because what I have is demo version
any help please
I have a code >>>
can any one tested using the proteus ....
just testing >>>please because what I have is demo version
any help please
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: 16f877a USART display temp on PC
Hello,
This can be done by using generated COFF file for importing it in Proteus.
Here is a forum topic where users shared their experience of how this can be done:
http://www.mikroe.com/forum/viewtopic.php?t=21840
Proteus is really not supported mikroElektronika certified environment on which your test can be performed.
So, this is out of our support scope.
Thank you for your understanding.
Best regards,
Losic Tihomir
This can be done by using generated COFF file for importing it in Proteus.
Here is a forum topic where users shared their experience of how this can be done:
http://www.mikroe.com/forum/viewtopic.php?t=21840
Proteus is really not supported mikroElektronika certified environment on which your test can be performed.
So, this is out of our support scope.
Thank you for your understanding.
Best regards,
Losic Tihomir
mikroElektronika [Support team]
Re: 16f877a USART display temp on PC
ok
Thanks alot for your cooperation
Thanks alot for your cooperation