Problem with PIC16F87


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Now you can go back and play with the configs...

    Reading back though this thread the original problem was LEDs not blinking correctly and the a 555 showed up someplace...

    Please recap what you are trying to do and whit it is doing and current code.

    I am cornfused.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Im confused too

    I turned the watchdog timer off and the chip stopped resetting itself after a few seconds. I dont know why it suddenly started in the first place. Maybe its because the main loop hardly does anything and it thought it had crashed.

    Now back to the original problem. When the 555 is plugged in the PIC turns outputs on/off randomly. The strange thing is that it only seems to cause a problem when the PIC runs a pause command.

    The current code is as follows.
    Code:
    'Define the oscillator (20MHz)
    DEFINE OSC 20
    
    x var byte
    
    'Set the tris registers
    TRISA=%00000011
    TRISB=%00000100
    
    'ANSEL 	= 0
    'ADCON0	= 0
    'ADCON1 	= 0
    CMCON	= 7
    CVRCON	= 0
    CCP1CON	= 0
    
    'Define output pins
    pSocket1 VAR PORTA.2
    pSocket2 VAR PORTA.3
    pSocket3 VAR PORTA.4
    pSocket4 VAR PORTB.0
    pSocket5 VAR PORTB.1
    pSocket6 VAR PORTB.3
    
    pPower VAR PORTB.7
    pStatus VAR PORTB.4
    
    pData VAR PORTB.6	'Switches between Master and Slave
    
    'Define input pins
    iSensor1 VAR PORTA.0
    iSensor2 VAR PORTA.1
    
    low pstatus
    
    for x=0 to 10
        high ppower
        pause 100
        low ppower
        pause 100
    next
    
    'BEGIN: Main loop
    loop:
    
    ppower=isensor1
    pstatus=isensor2
    
    
    GOTO loop
    It should make the power light flash a few times then use the power and status LEDs to show the state of the 2 sensors. Whats weird is that the chip gets stuck on the for loop when the 555 is connected. The power LED flickers randomly. If i take the 555 out then it will run as normal and enter the main loop. Once in that loop i can put the 555 back in and it seems to be running as it should.

    On the circuit the 555 and ceramic resonator are right next to each other. Could that be why only the pause command seems to be affected?

    One other thing i think i should mention. The 555 part is to make IR transmitters flash at 38.5KHz. In a previous thread someone said i should also have pulses. I didnt have enough spare pins on the PIC to control those pulses and my breadboarded version worked fine without them. Could that cause this problem?

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Do you have a more complete schematic?
    Because something doesn't seem right ...



    The 555 part is to make IR transmitters flash at 38.5KHz.
    The way that 555 is set-up, it's NOT an astable multivibrator. (oscillator)

    Is it connected to the PIC?
    And if so, is that connection going to pin 7 of the 555?

    Pin 7 is the "Discharge" output from the 555. It should be tied to the 1nF capacitor via another resistor that's in series with the 15K resistor.

    If you have it connected to an OUTPUT from the PIC, it may cause the PIC to continually reset due to conflicting OUTPUTs drawing too much current.

    If you want to modulate a 38khz signal from the 555, it needs to be set-up as an "astable multivibrator" and the signal from the PIC should go to pin 4 (reset).
    DT

  4. #4
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    The 555 schematic i posted is complete. It is only connected to the PIC through the 2 power rails. The 555 part is actually working and appears to modulate correctly. The receivers detect the IR now where they wouldnt when the emitters were unmodulated.

    This 555 design is aparently an astable circuit but its not like any ive used before. I found the design for it on the internet and it was specificly designed for driving IR emitters.

    I did notice something strange. With only the 555 section of the circuit running (including 2 IR emitters) the 5V regulator is getting very hot (too hot to touch).

    Even though my picoscope clearly shows that the voltage doesnt vary by more than about 0.5V either side of 5V i think its possible that the 555 circuit is actually a monostable one but its designed to short something out which causes it to reset and act like an astable. This would account for the hot regulator and the PIC acting strange

    Edit: I did just notice. The only thing missing from the schematic are 2 resistors that go from the output to each of the 2 IR emitters.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    If the top of the 15K resistor is connected to pin 3 (output) it might work.
    But the schematic didn't reflect that.



    What size resistor goes to the LED's, and how big is the regulator?

    .
    DT

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh crap, now I see that the thing in the upper left corner of your schematic is actually a POT.
    It looked like the 15k was tied to power and a resistor was above that.
    That should work, sorry.

    But I'm still curious about the emitter loads and regulator.

    .
    DT

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Each emitter has a 33ohm resistor. The regulator is a standard DE7805 that i use for every project. These dont normally get this hot unless they are shorted out. I even had a DE7812 running 48 high power LEDs (in 15 sets) and it didnt get this hot.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem to compile my program
    By wagner in forum Off Topic
    Replies: 5
    Last Post: - 7th July 2008, 20:17
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. PORTA.PinNo = 1 ' problem
    By frank small in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 14:30

Members who have read this thread : 0

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