PDA

View Full Version : how to use the internal comparator in pic16f877a??



texas5
- 17th September 2008, 12:56
hi,how can i use the internal comparator in pic16f877a.can someone help me with the coding please.my Vin is 3.40 and my Vref is 4.00.please help me...

skimask
- 17th September 2008, 13:40
hi,how can i use the internal comparator in pic16f877a.can someone help me with the coding please.my Vin is 3.40 and my Vref is 4.00.please help me...

Write some code, I'm sure somebody here will help you figure out what's wrong with it...

paul borgmeier
- 17th September 2008, 13:49
See Melanie's excellent post here

http://list.picbasic.com/forum/messages/3064/3607.html?

it is for a different processor but converting to the 877a should be straight forward. Reply if you need more

Melanie
- 17th September 2008, 15:22
OMG... I wrote that SIX YEARS ago!!!

Acetronics2
- 17th September 2008, 15:44
Hi, Mel

I'm Aaaaabsolutely suuuuuure it's not you but your Elder sista ...

regards

Alain

texas5
- 17th September 2008, 17:57
thanx.i will work it out.if something goes wrong...i'll tell u guys...

texas5
- 17th September 2008, 18:02
' Device Programming Options
' --------------------------
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection

i can't compile if those code are exist.i use pic16f877a.

texas5
- 17th September 2008, 18:07
@ DEVICE pic16F877a, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F877a, WDT_ON
' Watchdog Timer
@ DEVICE pic16F877a, PWRT_ON
' Power-On Timer
@ DEVICE pic16F877a, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F877a, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F877a, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F877a, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F877a, PROTECT_OFF
' Program Code Protection

BatVal var CMCON.7

BatLoLED var PORTB.7

CMCON=%00100101


VRCON=%11101100

Pauseus 10

TRISA=%11111111
TRISB=%00000000

BatLoLoop:
BatLoLED=BatVal

Goto BatLoLoop

End

my vref=4v, vin=3.6 and my vout=9v.can someone help me which part of the coding need to be edit.please...

skimask
- 17th September 2008, 18:53
my vref=4v, vin=3.6 and my vout=9v.can someone help me which part of the coding need to be edit.please...

Vref = 4v - what is Vref connected to?
Vin = 3.6v - what is Vin connected to?
Vout = 9v - what is Vout connected to?

Read the datasheet for the 16F877A!
Can MCLR be turned off?
How many oscillator modes does the 16F877A have? What are they?

Archangel
- 17th September 2008, 22:05
OMG... I wrote that SIX YEARS ago!!!

I Love the way you think Melanie . . .


In a battery operated piece of equipment we need to detect when the
batteries are getting low, so in turn we can switch on a 'Battery Low' LED
to help flatten whats left of the battery even quicker... seems sensible to
me.... I wish more engineers thought as you do.

skimask
- 17th September 2008, 23:27
I Love the way you think Melanie . . .
I wish more engineers thought as you do.

Ranks right up there with....
I'm almost out of gas so I'll drive to the nearest gas station even faster so I can run out of gas quicker so I can start walking even sooner!

texas5
- 18th September 2008, 06:11
thanx everyone.it's work.but i have another problem that i can't solve.feel free to check my new thread...