1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics Easy(?) PIC Question

Discussion in 'Modding' started by mikecx, 13 Jul 2004.

  1. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    I have a pic setup (16F877A) and i'm using some test code that is supposed to flash a LED on and off.

    The code for it is here: http://www.sparkfun.com/tutorial/Bloader/code/Blink.c

    Now to test it I don't have a led and a resistor available but I do have tons of spare fans. I was wondering how to set it up (connection wise) before I randomly go soldering stuff and breaking things. I was also wondering if it would even work :).

    Seems like it would be a simple question for someone who understands PIC's better than I do.

    BTW: It is flashed and the program is on there. The pragma origin 4 is to start the code after the bootloader. Everything else should be self explanitory. I can also link to the ASM and Hex for it if that helps.
     
  2. kobaj

    kobaj Banned

    Joined:
    4 Jul 2004
    Posts:
    837
    Likes Received:
    0
    one you have fans but no led. (doesnt madder realy just had to say that) just youse your multymeter turn the nob to 2volts stick the positive to the correct pin and the negative to ground.
     
  3. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    I'm a cheap person and I don't have a multimeter :sigh: . I know I should get one but I can't, atleast for another few days. I was hoping somone would have an easy answer :( .
     
  4. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    You dont want to try to power fans directly from the PICs pins. They only output upto 20mAmps, where fan amperage is usually higher.

    I personally suggest getting the LED to verify the circuit.
     
  5. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    I managed to steal the LED out of an old ISA nic card I had lying around and also picked up a multimeter (as my credit card debt rises). The led lit up between pins 2-11. 11 is the Vss(ground) and 2 is supposed to be RA0/AN0 input/output. I forgot to check and see if it was ouputting in digital or analog :wallbash: but the led just seemed to stay lit. I was thinking with a name like Blink that the LED should do a bit more... blinking. I'm not sure pin 2 and pin 11 are the correct pins. It seemed to only be putting out a steady 1.7V, not the ideal voltage for a blink.

    Since you don't suggest powering a fan directly from the PIC how would I go about doing this. Eventually it's going to be a software controlled PWN fanbus if that plays into the implementation any.
     
  6. Smilodon

    Smilodon The Antagonist

    Joined:
    25 Mar 2003
    Posts:
    6,244
    Likes Received:
    102
    are you sure you have the right frequency on yout oscillaotr? and do you have any delay on your output? the LED might flash... just to fast for you to see it
     
  7. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Post up the assembly file.

    Also, is this the first program you've flashed onto your PIC? Or do you know for sure you have all 4 power supply pins, MCLR and oscillator pins connected up properly.
     
  8. cpemma

    cpemma Ecky thump

    Joined:
    27 Nov 2001
    Posts:
    12,328
    Likes Received:
    55
    Did you also steal a series resistor? Or the 1.7V could be the average voltage if it's flashing too fast to see, as Smilodon says.
    Use the pic signal to switch a transistor that can handle the current.
     
  9. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    Alright, things I know for sure. First, the pic is running at 20MHz, second, I know the code was properly put on there and that the board is setup right (I bought it, it's an olimex version of the JDM).

    Linkie to the ASM file: http://www.sparkfun.com/tutorial/Bloader/code/Blink.asm

    Didn't steal a resistor off of there. You may be right about the too fast thing, first time I tested it with the multimeter i thought I saw it alternating, but then the second time I tested it it looked like it was staying steady. What value resistor would you suggest ( I have no idea what the info on the led is).

    cpemma, the transistor will not have any effect on me using PWM? I can't see any reason for it to, but i might as well ask to make sure.
     
  10. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    What are you testing it on? A breadboard? Is MCLR tied high, because it sounds like it might be floating.

    The code looks ok, but I've just remembered why I hate using C to program PICs :blah:
     
  11. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    Right now it's just on the olimex prototype-programming board. I'm going to move it to the plain old breadboard as soon as I figure out what all I need to do that.

    What do you mean by is MCLR tied high? I know MCLR is pin 1 but is there anything to check for to see if it's "tied high"? Sorry, i'm still new at a lot of this.

    The ASM code is also posted :)
     
  12. specialk

    specialk What's a Dremel?

    Joined:
    5 Feb 2002
    Posts:
    68
    Likes Received:
    1
    A. The sparkfun.com Olimex JDM programmer is poo. I had one for about a week and it did nothing but give me trouble. Constantly made bad flashes and would not read back data correctly (I would argue probably because of a low-voltage serial port, but that is a poor excuse for a production board). I've used a Kit 128 for the past 6 months and it has worked perfectly every time. I would suggest it.

    B. How do you know the PIC is running at 20MHz? From the sound of your post it seems like you don't have any of the necessary components to work with a PIC. Do you have a 20MHz osc? If so, what kind, crystal or resonator? How is it hooked up?

    C. Hmm... MCLR, why would you tie it high (which means using an APPROPRIATE resistor to connect it to +V)? Have you even thought of *maybe* looking at the datasheet? I would also suggest you try out this: http://www.voti.nl/blink/index_1.html#16F871

    -special [k]
     
  13. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    A.) Seems to be working fine, reading in and out consistantly. I will keep that in mind.

    B.) I bought it from sparkfun, it says it has a 20MHz osc. Looking at the board I can see it, it's a MEC 20.000Mhz 1 AD metal looking thing. It's connected to pins 13 and 14 with 13 having a capacitor and a resistor and just straight to 14. What else do you suggest I buy or find to make this easier (aka what are the neccesarry components, which ones am I missing?)

    C.) Looked at the datasheet from Microchip.com. Only part I understood was the pin listing and some small parts. This is my first attempt at a PIC project and i'm taking it one step at a time. C\C++ experience, basic electronic knowledge (I can tell a capacitor from a resistor and identify most *usual componenets), and finally some money to spend. That's what i'm working with :worried:
     
  14. mikecx

    mikecx What's a Dremel?

    Joined:
    24 Nov 2001
    Posts:
    66
    Likes Received:
    0
    Any suggestion on what I should get to transfer this whole thing to a proper protoboard?
     

Share This Page