PDA

View Full Version : Voltage issue 16f627a



yasky1
- 12th June 2011, 05:47
I have a voltage issue with my project. When portA.0 is taken to +5v, PortB.5 and PortB.6 outputs +5v. When PortA.0 is taken to 0v,GND. PortB.5 and PortB.6outputs 2.7V. I need B.5 and B.6 to go low 0v when A.0 is taken low. I've tried using PortB.7 in place of PortA.0, same results. little help with the program please.

@ DEVICE pic16F627A, INTRC_OSC_NOCLKOUT


CMCON = 7
TRISB = %10000000
TRISA = %00000011

start:

if PORTA.0 = 0 then pivot1
if PORTA.0 = 1 then pivot2

pivot1: low 0
low 1
low 2
low 3
low 4
low 5
low 6

pivot2: low 0
low 1
low 2
low 3
low 4
high 5
high 6
goto start:

mackrackit
- 12th June 2011, 06:53
Not sure about Pic Basic, but with PBP it is a good idea to set the pin as a VAR
low0 VAR PORTB.6

mister_e
- 12th June 2011, 11:18
Nah, it won't change anything, HIGH/LOW work as expected. HOWEVER, when you write to consecutive pin, you may want to Write to the whole port, or use a Shadow register. This is to avoid the R-M-W issue.

PORTB=%11000000

or

ShadowRegister VAR BYTE
'
'
' some code here
'
ShadowRegister.7=1
ShadowRegister.6=1
'etc etc
PORTB=SHadowRegister

Also, make sure all your config fuses are properly set, LVP_OFF, MCLR_OFF (assuming your don't use MCLR pin), OSC (INT or XT, whatever)

Darrel Taylor
- 12th June 2011, 16:47
Your pivot1 routine "Falls Thru" to the pivot2 routine.
So the pins will have a 50% dutycycle signal and your voltmeter is averaging them to read 2.7V.

Just add a goto after pivot1.


@ DEVICE pic16F627A, INTRC_OSC_NOCLKOUT

start:

if PORTA.0 = 0 then pivot1
if PORTA.0 = 1 then pivot2

pivot1: low 0
low 1
low 2
low 3
low 4
low 5
low 6
goto start

pivot2: low 0
low 1
low 2
low 3
low 4
high 5
high 6
goto start:

mister_e
- 12th June 2011, 16:55
http://techpatio.com/wp-content/uploads/2010/04/homer-doh.jpg


"Mister E, You want to post less, think more"

http://eddiedeguzman.files.wordpress.com/2010/08/cartoon-bang-head-jpg.gif?w=200&h=200

Going back to my batcave...ashamed...