PDA

View Full Version : Can't get blink circuit to work :(



Techbuilder
- 20th January 2008, 03:36
Hi
I was hoping someone can help me with this.

I want to start using pics but I can't even get my blink circuit to work.

I have PIC basic pro
and I use micro code studio.

My programmer is from ebay

I have knowledge in electronics but little knowledge in Micro controllers.

So I have done my board over and over again and nothing no led blinking

I have tried this

@ DEVICE pic16F84, XT_OSC

@ DEVICE pic16F84, WDT_OFF
' Watchdog Timer

@ DEVICE PIC16F84, PWRT_ON
' Power-On Timer

DEFINE OSC 4


TrisB = %00000000 ' Sets all bits portb as outputs

loop:
High PORTB.0 ' Turn on LED connected to PORTB.0
Pause 1500 ' Delay for 1.5 seconds

Low PORTB.0 ' Turn off LED connected to PORTB.0
Pause 1500 ' Delay for 1.5 seconds

Goto loop ' Go back to loop and blink LED forever
End


and this

' Example program to blink an LED connected to PORTB.0 about
' once a second

loop:
High 0 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Low 0 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Goto loop ' Go back to loop and blink LED forever
End


and nothing

I have re done my circuit over and over again and nothing

On my bread board I didn't use any filters on the 78L05
would that really matter and not make it blink?

Ps: the pictures of my programmer software and settings they are on are in the attachments

Pic_User
- 20th January 2008, 04:20
Hi Techbuilder,

1) Do you have a resistor pull-up on PIC MCLR to Vdd (+)?

2) Are you using a PIC16F84 (as written in the code) or a 16F84A (as listed in your programmer jpg)?
There is a big difference between the PIC16F84 and the PIC16F84A to the compiler, software, and programmer.

3) You should have a capacitor at the input to the regulator if the unregulated filter capacitor is over three inches away from it.

4) Do you have a 4 MHz crystal with capacitors to ground or a ceramic resonator with center tap to ground on the osc pins?

-Adam-

Techbuilder
- 20th January 2008, 04:29
Yep I have a resistor there

Yep I have a 16F84A

As for the 78L05 That doesn't have a cap
but can it stop the circuit from working?

I have a 4mhz resonator with the middle going to ground

Pic_User
- 20th January 2008, 04:52
Yep I have a resistor there

Yep I have a 16F84A

As for the 78L05 That doesn't have a cap
but can it stop the circuit from working?

I have a 4mhz resonator with the middle going to ground
The “DEVICE” in your code is listed as a “@ DEVICE pic16F84”

See this thread:
Novice 16F84A BLINK LED program help
http://www.picbasic.co.uk/forum/showthread.php?t=6763

The 78L05 or any three terminal linear regulator needs an “input capacitor”, if it is a distance from the rectifier filter capacitor.
If you don’t have a rectifier filter capacitor, THAT is a problem.

-Adam-

Techbuilder
- 20th January 2008, 05:03
Ohh opps even when I reprogrammed it still nothinghttp://www.picbasic.co.uk/forum/images/icons/icon9.gif
Unhappy

The link you gave me was different from mine.

His at least turned on

mine doesn't even do that :(

Shouldn't the sample program work from pbp?

Pic_User
- 20th January 2008, 05:51
Ohh opps even when I reprogrammed it still nothinghttp://www.picbasic.co.uk/forum/images/icons/icon9.gif
Unhappy

The link you gave me was different from mine.

His at least turned on

mine doesn't even do that :(

Shouldn't the sample program work from pbp?
Hi Techbuilder,

You are right, the other poster had a slightly different problem, with the PIC16F84A not blinking correctly, than you have.
But, if you could read some of the parts that MIGHT apply to your general problem, that would save the people trying to help, from repeating the same information.
It is a little easier to read than to type, and it is the reader needing the information not the person helping. This reduces the burden on the people helping, so that they do not get burned out and stop trying to help.
In fact it is considered good forum practice to search diligently, for any answered problem, that could contain a clue, before asking.

Some of the parts that MIGHT apply:

But, you may be trying too hard. Most of the defines are already supplied by the default *.INC file (16F84A.INC).


In Microcode Studio make sure you are using the button for Compile(ing) AND Program(ing), NOT the button for just Compile(ing).

See this microEngineering Labs web page:


Specifying configuration bit settings in PICBASIC PRO programs.
If you add a configuration directive to your program file, you are actually replacing the default configuration that the compiler would otherwise include. The easiest way to determine the correct syntax is to get examples from the compiler and assembler's built-in resource files. To that end, it's best to understand how the compiler determines the config defaults....

....The first thing the compiler looks for is a file in the PBP folder that matches the targeted PIC. If you tell it to compile for a 16F84A, it reads the file "16F84A.INC". The contents of this file are divided into 2 sections, one for each assembler. An internal variable, "PM_USED", tells the compiler which section of the file to use. In the following example, you will see that the top section ("ifdef" to "else") is meant for the PM assembler and the bottom section ("else" to "endif") is meant for the MPASM assembler.

http://www.melabs.com/support/config_defaults.htm
This might mean that if you refer to a different device in your code, compiler or programmer, you may run into trouble.


Let us know if you have tried any of our posted suggestions.

Did you add the capacitor to the 78L05?
Did you change the DEFINES in your code to @ DEVICE pic16F84A

The sample PBP program should work for your project, don’t give up.

-Adam-

Archangel
- 20th January 2008, 07:13
Hi
I was hoping someone can help me with this.

I want to start using pics but I can't even get my blink circuit to work.

I have PIC basic pro
and I use micro code studio.

My programmer is from ebay


Hi Techbuilder,
ebay programmer is not too descriptive, which one, which software are you using. I use the cheapest ebay programmer, a JDM clone with Ponyprog(free). It came bundled with winpc or winpic, I do not remember, only that I couldn't get it to work with that programmer, although it rang all the bells and blew all the whistles . . . my point is , maybe you really are not programming the PIC at all. After programming, read the program back and see if it is there, if not maybe you are not connected to the port your programmer thinks it is.
Now if you are programming, then next check your hardware, use a DVM, VOM or VTVM, an led or any other suitable method to check the pin connection of your PIC to the wires you have pushed into the proto board, I have been tripped up numerous times due to defective proto boards, after taking one apart I understood why, wear and corrosion made the connections bad.
JS

Techbuilder
- 20th January 2008, 20:31
I did read it I found some parts useful

I haven't got the chance to get the capacitors but I used my friends variable power supply and adjusted it to 5 volts and still nothing.

As for my programmer software

It's Micro Pro

I don't know if you had seen the picture attachments of the screen shots I did but that is how it looks.

It's K149-BC

I don't if that matters but that is what model it is

I can't compile and program because It doesn't download the new hex file I created
gary goddard had went through this problem that I had.

The solution is to compile then go into the programmer software and load the hex file.

I believe it's programming though because it's reading from the pic

Andy Wood
- 20th January 2008, 20:32
Hi Techbuilder,

1) Do you have a resistor pull-up on PIC MCLR to Vdd (+)?

2) Are you using a PIC16F84 (as written in the code) or a 16F84A (as listed in your programmer jpg)?
There is a big difference between the PIC16F84 and the PIC16F84A to the compiler, software, and programmer.

3) You should have a capacitor at the input to the regulator if the unregulated filter capacitor is over three inches away from it.

4) Do you have a 4 MHz crystal with capacitors to ground or a ceramic resonator with center tap to ground on the osc pins?

-Adam-


A capacitor between the output of the regulator and ground is *very* important to stop the device oscillating at high frequency. Try a value of 100nF.

Andy

Techbuilder
- 21st January 2008, 01:02
A capacitor between the output of the regulator and ground is *very* important to stop the device oscillating at high frequency. Try a value of 100nF.

Andy

Would that be necessary though if I used a power supply instead of a voltage regulator?

sayzer
- 21st January 2008, 08:04
Also,

How did you connect your LED to PORTB.0 ?

Usually, people make simple mistakes about it, and connect it WRONG.

___________________________________

Techbuilder
- 21st January 2008, 22:26
Well I connected it the positive side to PortB and connected the other side to ground.

If I didn't use a resistor would that stop the circuit from working just wondering?

Jasonce65
- 21st January 2008, 23:24
First, if you don't use a dropping (current limiting) resistor between the PORTB.0 pin and the LED, it could cause damage to either the PIC or the LED when it does come on. If you're not getting any light from the LED, try turning it around. They are polarity sensitive since they are a diode. A good value for the resistor is 470 ohms. You can buy them at radio shack or a parts warehouse like Jameco. I would place a capacitor at the power supply pins of the PIC as the long leads of the regulated power supply can introduce noise and cause problems. Any 1 uf to 100uf, 16 volt capacitor will do. Also be sure to make sure it is connected properly as they get hot and blow up if connected backwards. Ther is a minus stripe on one side.

Also, LED's are polarity sensitive, meaning they only work hooked up one way. A round LED usually has a flat side or shorter lead that is the negative lead. Connect this to the same place as VSS and connect the black lead from the regulated supply to both. VDD is positive 5 volts.

Also connect a 470 ohm resistor to the MCLR pin. This will make sure the chip always runs.

If you have more than one LED handy, it might be helpful to simply attach one to the same place that supplys power to your pic (be sure to also include a resistor on this LED as well or else you'll fry the LED). If you put an LED on PORTB bit 0 without a resistor, it will cause the transistors that make up the logic in the PIC overheat and will damage part or all of the PIC. The current output of most of the pins on a typical PIC should not exceed 20MA, which is what the LED draws with a proper resistor. With out the resistor, a typical 2.1V LED will draw over 500MA and zap... you may only see a brief blink and its all over. It's all about ohms law... You can also control other things like 5 or 12 volt relays, but not directly from the pins of a PIC. You should use a transistor to power the relay, then the relay can turn on or off things like motors.

there are several ways to write the code that turns on and off the LED, including this one:

trisb = 0

START:
portb.0 = 0 'turn led off
pause 1000
portb.0 = 1 'turn led on
goto START

Sometimes, if I can't get a new design on my breadboard to work, a simple program like this is the best thing to start with, just to make sure my crystal, capacitors on it (22pf) and power supply are all working as expected. Then I build on design from there. There are plenty of snafu's that make it hard to get a PIC to do what you want, so keep in mind that ports that also share functions could default to work as (say for example, an Analog port), so they won't put out any voltsge. Then you have to figure out what combinations of commands put the port into the mode you expect - this can be a little frustrating, but don't give up easily. This is an excellent support group and they can help you get started. I've built some amazing stuff with these chips.

Also, invest in a good volt meter. Harbor Freight Tools sells a good basic digital volt meter for $2.99. You need to check the voltage at the pins of the IC and check the voltage on Portb.0. If you suspect that pin to not work, also try other pins on that port. (be sure to change the code to turn on or off the new pin)

portb.1 = 0 'turn off port b pin 1
portb.1 = 1 'turn on port b pin 1

Hope this helps,
Jason

Techbuilder
- 22nd January 2008, 03:57
Thank you that was very helpful

I know about basic electronics likes diode and capacitors and how current only flows one way in order for it to work.

I have a multi meter

I have built circuits but I usually follow off of a schematic and no programing necessary.

So when it comes to pics I am a big noob

but you guys have helped me a lot

So I am going to try everything out

I think I will use my PIC16F627A since I already probably messed up the chip but I will run my multi meter and see if I am getting anything out from port0 on the 16F84A if not I will just use the 16F627A with all the corrections.

Well thanks a lot I am going to try this stuff out and post my findings after I get some more parts, I am running low and out of stock on some components.

Well thanks everyone for your help

:)

Techbuilder
- 26th January 2008, 07:30
I got it to work!!!

You guys are the best and females (if there are any)

:)

Cool now I can start some projects

sayzer
- 28th January 2008, 07:49
...and females (if there are any)
...

I know one so far.

Acetronics2
- 28th January 2008, 08:20
Hi, Sayzer


I know one so far.

We suspected it a bit ... AND, Of course it is yours !!!

But do not worry ... we all say "she" 's the one, even under torture !

She also always claim "he" 's the one ... buuuut, never tells who is "he" !!!

Have a nice day ... LOL.

Alain

nomad
- 28th January 2008, 09:53
fried LED?
unfiltered regulator?

curious minds would like to know..
(as well as the next person with the same/similar problem)

:)

sayzer
- 28th January 2008, 12:37
Hi, Sayzer



We suspected it a bit ... AND, Of course it is yours !!!

But do not worry ... we all say "she" 's the one, even under torture !

She also always claim "he" 's the one ... buuuut, never tells who is "he" !!!

Have a nice day ... LOL.

Alain


Alain,

Are you saying what I think you are saying about her?

"She" is actually an imaginary person then, isn't she?


_____________________

Acetronics2
- 28th January 2008, 13:08
Alain,

Are you saying what I think you are saying about her?

"She" is actually an imaginary person then, isn't she?


_____________________

YESSSS, of course ...

All the women we're in love with are imaginary persons .... Thanks to god !!!

re- LOL

Alain

Techbuilder
- 30th January 2008, 04:07
It was a bad resonator and the current wasn't filtered enough

that was all

but works now

Jasonce65
- 31st January 2008, 13:00
Yea, when I use one of these chips in an industrial setting, I like to include a 220uf to 470uf at the regulator IC, which can sometimes be across the circuit board from the PIC, and then at least a 22uf or 47uf at the Vss and Vdd pins, followed by a low ESR cap like a poly-film or tantilum 0.1uf right next to each other at the PIC's IC socket.

If the same power supply is going to be used for a analog chip, like a recording/playback IC, for example, even with this much filtering, you'll realize how much noise there really is on the lines, especially if you are driving devices on the I/O pins, serail or data at high speeds. Just making a LED blink on and off will make the audio click, click, click...

Then I add like 2200uf or so onto the circuit. Remember that if you do this, to put an high speed, medium current diode in the circuit, reversed to absorb the "jolt" from accidentally shorting power supply line on the board, just as a good design. Shorting a high energy capacitor on a PC board can cause circulating currents that when coupled with the inductance of the length of the traces themselves, can cause pico-second sized high voltage pulses (oscillations) that can mysteriously kill and C-MOS IC. A 1 watt 5.1 volt zener can work pretty good too, plus it gives you a little added protection if the regulator goes wild. Any diode that's designed for switch mode power supply applications will do. If you keep the total capacitance in the circuit under 100uf or so, you don't have to worry about this, but I've found that being skimpy on filtering is a recepie for disaster.