Can't get blink circuit to work :(


Closed Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Jul 2007
    Posts
    67

    Default Can't get blink circuit to work :(

    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
    Attached Images Attached Images   
    Last edited by Techbuilder; - 20th January 2008 at 03:48. Reason: Forgot to add something

  2. #2
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile Some things to check...

    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-
    Ohm it's not just a good idea... it's the LAW !

  3. #3
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile More stuff...

    Quote Originally Posted by Techbuilder View Post
    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-
    Ohm it's not just a good idea... it's the LAW !

  5. #5
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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?

  6. #6
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile don’t give up...

    Quote Originally Posted by Techbuilder View Post
    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-
    Ohm it's not just a good idea... it's the LAW !

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    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
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    Join Date
    Apr 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    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

  10. #10
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Andy Wood View Post
    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?

  11. #11
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Also,

    How did you connect your LED to PORTB.0 ?

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

    ___________________________________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  12. #12
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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?

  13. #13
    Join Date
    Jan 2008
    Location
    Vassar, Michigan USA
    Posts
    9


    Did you find this post helpful? Yes | No

    Smile Things to try

    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

  14. #14
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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


  15. #15
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default Yay!!!!!!!!!!!!

    I got it to work!!!

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



    Cool now I can start some projects

  16. #16
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    ...and females (if there are any)
    ...
    I know one so far.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  17. #17
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Hi, Sayzer

    Quote Originally Posted by sayzer View Post
    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  18. #18


    Did you find this post helpful? Yes | No

    Default What was the problem?

    fried LED?
    unfiltered regulator?

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


  19. #19
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    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?


    _____________________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  20. #20
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by sayzer View Post
    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  21. #21
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    It was a bad resonator and the current wasn't filtered enough

    that was all

    but works now

  22. #22
    Join Date
    Jan 2008
    Location
    Vassar, Michigan USA
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Unfiltered ps

    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.

Similar Threads

  1. Simple Blink program doesnt work.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st March 2009, 20:30
  2. Can't get POT work on P12f675 - Newbie
    By berslan in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th March 2008, 21:22
  3. Circuit reliability issues
    By hkpatrice in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd November 2007, 14:55
  4. Replies: 3
    Last Post: - 29th October 2006, 09:16
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts