Is my Pic Running?

Discussion in 'Embedded Systems and Microcontrollers' started by halfshaft, Oct 4, 2009.

  1. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    A small amount of background. My friend wants to be a ghostbuster for a halloween party later this month. He asked me to do the wiring/lighting for the proton pack. I did research and decided that a PIC seemed to be the ideal solution for controlling all the lights/motions/activations. I have written code in ASM for a 16F57 and compiled it in MPLAB. It compiles fine, and runs in the MP Sim. I can even export the code and run it in 2 seperate third party simulators and the code works great. Wired the chip up and plugged it in...... Nothing. I've checked and double checked my work for weeks... Even bought a different chip (16F873) and a new programmer (PicKit2) and rewrote the code for it with no luck. Is there a way to test the PIC to make sure it is 'healthy' or in working condition. I've exhausted every online resource that I can find save for the advice of real people. I should be able to just hook up the PIC to power and let it run right? Even trying to replicate the simple blinking LED program I find everywhere on the net leads me nowhere? What am I doing wrong? Any help would be appreciated.
    Thanks,
     
  2. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Crystal Ball broken, you're going to need to post your code and schematic.
     
  3. walid el masry

    Active Member

    Mar 31, 2009
    132
    0
    if it was a crystal problem check the info below

    [​IMG]

    but if it was ok check that the port or pins you used isn't conflict with other modules in the chip like PORTA is conflict with Analog to digital converter module so you must 1st tell the controller that you want PORTA to work as a Digital i/o not ADC and that step is before the TRIS

    and like blueroomelectronics said you need to post your code and schematic so that we can understand the problem if it was a hardware or a software problem
     
  4. russ_hensel

    Well-Known Member

    Jan 11, 2009
    818
    47
    If you have an oScope, put it on x10 and check the ossc. pins to see if there is a signal. ( assuming it is configured to give a signal, normally it is )
     
  5. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    Hi,
    1. Check if you have made all analog pins digital and check to see if you have disabled the comparator module(only available in 16F873A not in 16F873) which is multiplexed to PORTA.
    2. Check your configuration bit settings. I'm guessing this could be the problem.
    3. Check if you have MCLR pin (pin1 on 16f873a) pulled up. Maybe you didn't do this in hardware.
    Good luck!
    Tahmid.
     
  6. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    Didn't post any code because I've literally written dozens of iterations of the same thing trying to rule out any type of software anomaly. I've done the same with the hardware portion and have wired it many ways to check if any combination gives more desirable results. Lastly, I was using two different PIC's and as such didn't know which code to post.

    I do not own an Oscilloscope, I would love to, but do not. I am using the internal oscillator because it is not a precision timed process. I have in fact pulled the MCLR pin high on both chips at one point or another, both with a simple jumper, and with resistors. I'm using a 6v Lantern battery run through a 7805 Voltage Regulator. This connects to the VDD (+) pin and the VSS (-) pin(s) on my PIC. The 16F57 gets +5v on pin 2 and 0v on pin 4. The 16F873 get +5v on pin 20 and 0v on pins 21 and 8. An led is brought off of any of the pins because I'm flashing all of them, run through a 330 ohm resistor to 0v. (polarity of led is correct, have checked.) Right now all I'm worried about is getting the led to flash and I'll work on something else from there.
     
  7. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    A 7805 needs at least 7v to work properly.
     
  8. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    I've also used an variable voltage regulator, a LM317. Both are giving out a perfect 5v by my multimeter.
     
  9. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Post your code.
     
  10. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    Code ( (Unknown Language)):
    1.  
    2.         LIST P=16F57
    3.         radix HEX
    4.     org 0x00
    5. PORTB equ 0x05
    6.     movlw 0x00
    7.     tris PORTB
    8. start
    9.     movlw 0x01
    10.     movwf PORTB
    11.     movlw 0x00
    12.     movwf PORTB
    13.     goto start
    14.     end
    15.  
    or
    Code ( (Unknown Language)):
    1.  
    2.         LIST P=16F873
    3.         include P16F873.inc
    4.         radix hex
    5.     org 0x00
    6.     movlw 0x0E
    7.     CLRF PORTB
    8.     BSF STATUS,5
    9.     movlw 0x00
    10.     movwf TRISB
    11.     BCF STATUS,5
    12.     goto start
    13. start
    14.     movlw 0x01
    15.     movwf PORTB
    16.     movlw 0x00
    17.     movwf PORTB
    18.     goto start
    19. end
    20.  
     
  11. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Where's your config statement?

    It's running far faster than you can see it flash, you need delay code. What oscillator are you using? do you have decoupling caps on VDD & VSS? Do you have a pullup resistor on MCLR?
     
  12. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    There is no internal osc on either of those PICs. The OP is using PORTB so the comparator setting doesn't apply.
     
  13. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    True but the OPs code is far from functional.
     
  14. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    As far as the config setting goes, I'm using MPLAB as my native programming environment. Using it as the text editor and the compiler, as well as using the internal MPSim to check the code is viable. The settings for config are all set in a drop-down menu inside MPLAB and compiled into the code as necessary. As far as the oscillator goes, I'm running both chips in RC (resistor/capacitor) mode. Which, if I'm not mistaken from the datasheet I'm reading, is in fact an internal oscillator of marginal accuracy. I understand that the flashing of the led would be far faster than my eye could detect, but one would think it would give the illusion of being on all the time in this condition. On a whim I tried rewriting both sets of code to turn the led on, and not turn it off. (I removed the section of code rewriting PORTB to 0x00) This was my way of trying to see if it was the speed of the flash causing me some type of optical illusion. The ADCON1 was actually being written 0x07 in a newer version of this file. (sorry, should have posted that one...) If my code is far from functional why does it run in three separate simulation environments without issue? Just curious. I might try seeing about using a different form of oscillator though. I'll have to buy a crystal/oscillator...
     
  15. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Like I said before neither the 16F873 or ancient 16F57 have internal RC oscillators. you can use a simple RC clock on them. A PIC can run millions of instructions per second. You need a delay.
     
  16. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    Okay, so I don't have an external oscillator/crystal handy... I do have a 555timer, can this be made to output a suitable signal to feed either PIC? I understand the need for a delay, and am not arguing that fact. My final program for the ghostbuster pack used a delay subroutine to provide decent timing in the simulation environment. The delay in that program was definitely necessary.
     
  17. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
  18. halfshaft

    Thread Starter New Member

    Oct 4, 2009
    7
    0
    I was wondering if this was the case. I have to provide some external hardware for the RC oscillator to function. This does in fact make sense, and if I have the appropriately sized capacitors and resistors in my possession I'm going to give it a try. Have you seen a schematic for using the 555 to run the osc on a PIC? I've been looking with less than stellar results.
     
Loading...