Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] programming in pic19f2431 using ADC giving problems in defining ports

Status
Not open for further replies.

aishwarya_gaur

Newbie level 1
Joined
Oct 2, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
10
In this pic18f2431 microcontroller i am not able to operate two LDR together. both the readings of LDR are shown by tha AN0 pin of the microcontroller ! how to get these two diffrent values on different ports? Help asap!
 

Connect the LDRs to different pins, for example AN0 and AN1 then decide which is to be measured by the ADC by programming the appropriate registers.

That particular PIC has quite a complicated ADC signal routing method because it can automatically sequence through analog input pins. You will have to work out the values to be sent to the registers using the data sheet.

Brian.
 

If you want to display LDR1 data on PORTB and LDR2 data on PORTC then you have to configure the ADC Registers and then read the adc value and right shift the adc values 2 times and assign them to LATB and LATC.

Here is the project I made using mikrC PRO PIC Compiler.

Mention your Compiler and Crystal frequency and I will write a code for you.

See attached image. It shows the simulation result.

Voltage at adc inputs are 4.81V.

5V = 1023 raw adc value
4.81V = 984 (integer value)

984 right shifted 2 times = 246

246 = 1111 0110

The LEDs are showing the right values.
 

Attachments

  • Proteus Simulation Result.png
    Proteus Simulation Result.png
    29.1 KB · Views: 94
  • Reading LDR - Monochrome.PDF
    37.3 KB · Views: 74
  • Reading LDR.rar
    32.5 KB · Views: 77
  • mikroC PRO PIC.rar
    11.6 KB · Views: 78

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top