PDA

View Full Version : 16F628A using PORTA.4, and it works, but...



zx81
- 16th August 2005, 19:01
First, excuse my english, it's not too good...

I've a PCB with a 16F628A and a L293B (motor driver) and I want (need) to power the driver through a transistor, but I only have the RA4 free, so I'm using a BC516 (PNP) transistor connected to it.

This sequence turns the motor to the right until switch ZZ is activated:

low L293B 'this lows PORTA.4 and activate the BC516
low MOTOR_1
high MOTOR_2
LOOP:
if ZZ=0 then goto LOOP

and this to the left:

low L293B 'this lows PORTA.4 and activate the BC516
high MOTOR_1
low MOTOR_2
LOOP:
if ZZ=0 then goto LOOP

All this works ok, but here start the problems. While the motor is running it activate some switches (ZZ in the sample), I use this to know its position and when to stop it. When I activate the driver through the BC516, the pic apparently doesn't reads the switches, but if I connect the driver directly to VCC, all works ok.

I've tried with a pull-up in RA4, without, same problem.

Any idea?

Regards

zx81
- 17th August 2005, 08:45
Well, It seems a speed problem. I'm using internal clock, and if I use RC4 as described, the program loose the ZZ switch, but if i lock the switch, it works ok.

It's possible that the use of PORTA.4 speed down the PIC?

The switch that fails is connected to PORTA.5 (MCLR pin), don't know if this is important.

Regards