SK40C with PIC16F877A ADC

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

SK40C with PIC16F877A ADC

Postby pikachuX » Thu Jun 19, 2014 7:35 am

Hi,

i had connect the circuit as the picture, but i connect the RA0 with a infrared receiver ,and the RD7 for the Infrared transmitter and all the each PORTB has one led. I put the infrared very close to each other, it still nothing happen. My ADC programming got error? Please help. Thanks

Image


CODE: SELECT_ALL_CODE
#include<htc.h>
#include<pic.h>
#include "delay.h"
__CONFIG(0x3F3A);

void ADC_Init()
{
  ADCON0 = 0x41; //ADC Module Turned ON and Clock is selected
  ADCON1 = 0xC0; //All pins as Analog Input
                 //With reference voltages VDD and VSS
}

unsigned int ADC_Read(unsigned char channel)
{
  if(channel > 7) //If Invalid channel selected
    return 0;     //Return 0

  ADCON0 &= 0xC5; //Clearing the Channel Selection Bits
  ADCON0 |= channel<<3; //Setting the required Bits
  DelayUs(5); //Acquisition time to charge hold capacitor
 
  while(GODONE==1); //Wait for A/D Conversion to complete
  return ((ADRESH<<8)+ADRESL); //Returns Result
}

void main()
{
  unsigned int a;
  TRISB = 0x00; //PORTB as output
  TRISC = 0x00; //PORTC as output
  TRISA = 0xFF; //PORTA as input
  ADC_Init(); //Initializes ADC Module
  TRISD=0x00;
  PORTD=0xFF;
  do
  {
    a = ADC_Read(0); //Reading Analog Channel 0
    PORTB = a; //Lower 8 bits to PORTB
    PORTC = a>>8; //Higher 2 bits to PORTC
    DelayUs(5); //Delay
  }while(1); //Infinite Loop
}
pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm

Re: SK40C with PIC16F877A ADC

Postby yonghui » Thu Jun 19, 2014 11:11 am

Which pic u are using?

Sent from my Nexus 4 using Tapatalk
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: SK40C with PIC16F877A ADC

Postby ober » Fri Jun 20, 2014 5:38 pm

Do the circuit can function? The actual hardware, at least LED blinking.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: SK40C with PIC16F877A ADC

Postby pikachuX » Mon Jun 23, 2014 12:01 am

Hi guys, i using PIC16F877A to program it and i able to programming to blink all the PORTB LED.
Now i think i found the problem which the transmitter voltage just somehow around 2V only, therefore the receiver will receive 2V maximum.
How to make the SK40C output voltage 5V to the Port because i try to measure the previous programming LED ON maximum voltage also 2.4V++ only ?
pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm

Re: SK40C with PIC16F877A ADC

Postby ober » Mon Jun 23, 2014 8:59 am

What do you mean by transmitter voltage and receiver voltage? Not really understand. If you measure voltage at anode of LED of course it is lower because resistor taken up some of the power. You should measure directly from the output pin of PIC instead.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: SK40C with PIC16F877A ADC

Postby pikachuX » Mon Jun 23, 2014 2:20 pm

I think my problem because i using the PORTD supply the voltage for the transmitter, therefore it get only 1.2V++ only.
I shall supply the External voltage for it 5V connect from the PIC Vin to the transmitter, or i just use the variable resistor and external voltage from PIC to control the receiver output.
pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 5 guests