Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2016, 08:42:32 20:42


Login with username, password and session length


Pages: [1]
Print
Author Topic: Pic16F877A A/D Converter  (Read 2510 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, 07:22:46 07: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, 09:07:58 09:07 »

Does it not compile or does it not work ?

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

Posts: 84

Thank You
-Given: 185
-Receive: 22


« Reply #2 on: August 23, 2007, 09:56:45 09: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
*
 Muted
Offline Offline

Posts: 10

Thank You
-Given: 10
-Receive: 13


« Reply #3 on: August 23, 2007, 10:06:42 10: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, 06:08:36 06: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, 06:46:06 18:46 »

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

Posts: 23

Thank You
-Given: 1
-Receive: 16


« Reply #6 on: September 07, 2008, 08:24:37 08: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