Sample code of PR11 does not work on PIC16F877a

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: Sample code of PR11 does not work on PIC16F877a

Postby TeoYX » Sat Oct 01, 2011 5:24 pm

I need the confirm to this pin connection. From the sample source code, it is as output. Does it correct?
TeoYX
Apprentice
 
Posts: 47
Joined: Fri Aug 12, 2011 10:47 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby altron11 » Thu Oct 06, 2011 12:56 am

Hi Guys,

Now i would like to use PORT E as output to a LED.

DO i need any special codings? As i already set TRISE=0b00000000;
But the PORT E0 does not have any output.
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby robosang » Thu Oct 06, 2011 8:18 pm

TeoYX WROTE:I need the confirm to this pin connection. From the sample source code, it is as output. Does it correct?


Curious to know, which part of the code showing that RA3 as output? I thought that is Vref pin? Though I din study this DIY project from Cytron much, but did went through the schematic before. I don think it is output.

altron11 WROTE:Now i would like to use PORT E as output to a LED.

DO i need any special codings? As i already set TRISE=0b00000000;
But the PORT E0 does not have any output.

Who say PORTE does not have output? Every PORT can be input and output, and how come PORTE is not?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby TeoYX » Thu Oct 06, 2011 11:45 pm

From the source code:

void main(void)
{
ADRESH=0; //clear A/D result
ADRESL=0; //clear A/D result

//setting ADCON1 Register
ADCON1=0b11000101; // A/D result right justified,
// configure RA2 and RA5 as digital I/O

TRISA=0b11011011; //configure PORTA I/O direction
TRISB=0b00000000; //configure PORTB as output
TRISC=0b00000000; //configure PORTC as output

PORTA=0;
PORTB=0;

Above are parts of the program... Do u know why?
TeoYX
Apprentice
 
Posts: 47
Joined: Fri Aug 12, 2011 10:47 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby altron11 » Mon Oct 10, 2011 4:19 pm

Hi Guys,

I have a circuit simliar to the PR11. The sensor(LM35) connection is the same with a capacitor series to gnd. On my project board, it is working. But after i soldered up every component, the readings from the sensor shoot as high as 60deg upon power up. Is there anything wrong?
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby zhenning » Mon Oct 10, 2011 9:48 pm

altron11 WROTE:Hi Guys,

I have a circuit simliar to the PR11. The sensor(LM35) connection is the same with a capacitor series to gnd. On my project board, it is working. But after i soldered up every component, the readings from the sensor shoot as high as 60deg upon power up. Is there anything wrong?


Most likely something is wrongly connected on your hardware :0
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: Sample code of PR11 does not work on PIC16F877a

Postby altron11 » Tue Oct 11, 2011 12:46 am

I guess not as it is very similar to the PR11. Difference is my PIC is on the SK40-C and i soldered the LCD onto the SK40-C. I connect RA0 to the Vout pin of the LM35. V+ to the VCC (5V) and a 0.1uF Cap in series from Vout to GND. now the temperature fix at 31deg. it will not increase or decrease. I do have a question, do i still need to connect a variable resistor of 4.7k ohm to the Vref+? thats the only thing i missed out.
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby robosang » Tue Oct 11, 2011 7:21 am

TeoYX WROTE:void main(void)
{
ADRESH=0; //clear A/D result
ADRESL=0; //clear A/D result

//setting ADCON1 Register
ADCON1=0b11000101; // A/D result right justified,
// configure RA2 and RA5 as digital I/O

TRISA=0b11011011; //configure PORTA I/O direction
TRISB=0b00000000; //configure PORTB as output
TRISC=0b00000000; //configure PORTC as output

PORTA=0;
PORTB=0;

Woh.... you cannot paste a source code and ask why, I am sure no one will entertain you. 8-) Furthermore there is already comments at back of most line. You need to highlight which part you don understand, if you don understand all, please go back to the datasheet, I am sure will be able to find what is ADCON1, PORTA, TRISA, ADRESL...etc

Btw, I din see any code saying PORTE is output, that is my earlier question. Curious to know where you get conclusion that PORTE is output. I think this sample code that you refer is using smaller PIC, maybe 28-pin and now you are using 40-pin. Of course in 28-pin the program cannot configure pins that do not exist. :mrgreen: Yet, you are using 40-pin now, but do you use it? If you don use it, ignore it.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby robosang » Tue Oct 11, 2011 7:29 am

altron11 WROTE:I guess not as it is very similar to the PR11. Difference is my PIC is on the SK40-C and i soldered the LCD onto the SK40-C. I connect RA0 to the Vout pin of the LM35. V+ to the VCC (5V) and a 0.1uF Cap in series from Vout to GND. now the temperature fix at 31deg. it will not increase or decrease. I do have a question, do i still need to connect a variable resistor of 4.7k ohm to the Vref+? thats the only thing i missed out.


I think I answered this some thread before. If the code is using Vref+ and hardware is not connected with proper Vref+, you will have problem. I din go to check the PR11 code nor the schematic, yet seeing your explain, you will need to provide Vref+. Again, curious to know why don just put that circuit in?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Sample code of PR11 does not work on PIC16F877a

Postby altron11 » Wed Oct 12, 2011 12:22 am

robosang WROTE:
altron11 WROTE:I guess not as it is very similar to the PR11. Difference is my PIC is on the SK40-C and i soldered the LCD onto the SK40-C. I connect RA0 to the Vout pin of the LM35. V+ to the VCC (5V) and a 0.1uF Cap in series from Vout to GND. now the temperature fix at 31deg. it will not increase or decrease. I do have a question, do i still need to connect a variable resistor of 4.7k ohm to the Vref+? thats the only thing i missed out.


I think I answered this some thread before. If the code is using Vref+ and hardware is not connected with proper Vref+, you will have problem. I din go to check the PR11 code nor the schematic, yet seeing your explain, you will need to provide Vref+. Again, curious to know why don just put that circuit in?


Hi robosang,

Thanks for the advise. I found out that I had a open connection thats why it is not measuring.
I overlook on this while i tested on a project board and it works thus i did not soldered up to the Vref+. I had done it.
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Previous

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests

cron