|
|
View previous topic :: View next topic |
Author |
Message |
koiranos
Joined: 23 Aug 2017 Posts: 1
|
LED Strip with PIC16f628A issue |
Posted: Wed Aug 23, 2017 2:41 am |
|
|
Hello everyone!
I want to drive a piece of a led strip (a group of 3) with PIC16F628A however, I stumbled uppon an issue that I can not overcome.
As you can see from the attached image, the circuit is an easy one, where the led stip is connected to an external 12V DC power supply to the collector of a 2n3904 general porpouse transistor.
The Base of the transistor is connected to the B5 PIN of the microcontroller. As you can understand the transistor is used as a switch in order to toggle on / off the led strip.
The program of the microcontroller is as simple as it gets where it toggles on and off the B5 pin.
Code: | #include <16f628A.h>
#fuses HS,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)
void main()
{
while(TRUE)
{
output_high(PIN_B5);
delay_ms(1000);
output_low(PIN_B5);
delay_ms(1000);
}
}
|
The problem is that the led strip is always on even if I set it to have a delay of 5 seconds.
Could you tell me where what is wrong?
Thank you in advance,
KostasP |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Aug 23, 2017 2:54 am |
|
|
You can't just connect the base of an open collector transistor straight into a logic output. The base of a transistor behaves like a diode when pulled up, and at about 0.7v will start conducting significant current, overloading the PIC output. You need a current limiting resistor (say 270R) between the PIC output and the base. You should also have a little bit of pulldown on the base to ensure the transistor is off when the PIC is not driving (perhaps 1KR).
Then you don't show Vss connected to the 12v rail -ve. It needs to be.
Then you have the external crystal oscillator selected, but no sign of a crystal on the circuit. You need this, or to select to use the internal oscillator.
Then MCLR needs to be turned off, or the MCLR pin needs to be pulled high. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|