Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2024, 10:47:59 10:47


Login with username, password and session length


Pages: [1]
Print
Author Topic: Pic16F877A A/D Converter  (Read 5090 times)
0 Members and 1 Guest are viewing this topic.
smoogy
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 9
-Receive: 0


« on: August 23, 2007, 06:22:46 06:22 »

Hi. I just tried to make a program to read an input voltage from an infrared sensor to convert it then to a digital output but it won't get compiled. Here's my code:

define osc 20
DEFINE ADC_BITS 8       ' Set number of bits in result
DEFINE ADC_CLOCK 3     ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds

B0 var byte
trisa = 255 ' Set PORTA to all input
trisb = 0
ADCON1 = 2  ' PORTA is analog

main:

ADCIN 0, B0

if B0<125 then
portb.0=0
else
portb.0=1
endif
goto main

Can anyone help me?
Logged
GreenGiant
Junior Member
**
Offline Offline

Posts: 38

Thank You
-Given: 2
-Receive: 1


« Reply #1 on: August 23, 2007, 08:07:58 08:07 »

Does it not compile or does it not work ?

If not compile, also post what error it puts out.
Logged
mcr
Junior Member
**
 Muted
Offline Offline

Posts: 90

Thank You
-Given: 217
-Receive: 23


« Reply #2 on: August 23, 2007, 08:56:45 08:56 »

Does it not compile or does it not work ?

If not compile, also post what error it puts out.

Do that please.
Logged
RCO
Newbie
*
Offline Offline

Posts: 10

Thank You
-Given: 10
-Receive: 13


« Reply #3 on: August 23, 2007, 09:06:42 09:06 »

smoogy

The code compiles fine here, using Picbasic Pro 247 and MPASM  Wink
Logged
smoogy
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 9
-Receive: 0


« Reply #4 on: August 30, 2007, 05:08:36 05:08 »

Thanks everyone. Code was fine. My pbp installation needed to be repaired due to missing files.  Embarrassed
Logged
revoltage
Guest
« Reply #5 on: September 05, 2008, 05:46:06 17:46 »

What infrared sensor did you used? Sharp IR?
Logged
ero
Junior Member
**
Offline Offline

Posts: 43

Thank You
-Given: 12
-Receive: 27


« Reply #6 on: September 07, 2008, 07:24:37 07:24 »

Pic 16F877A having also a default comparator (Pic16F877 not). You have to cancel it first by putting following command;
CMCON=7
otherwise some pins of PORTA will not work properly. Try it.

Ero
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC