don't work on circuit, please help


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2012
    Posts
    14

    Default don't work on circuit, please help

    Hi you all:
    I am from mexico, and I do apologize for my English, so I am new to programming, as a matter of fact this is my first intent, I have learned reading from posts on this forum and consulting the pbp and proteus manuals, the thing is that I wrote this code on pbp 2.6 and simulated it on proteus and works fine so i programmed the micro controller with masterprog (wich is a programmer that I got from Mercado libre, same than ebay over there) and when I put the micro on the protoboard nothing happened, and when I pressed the reset button and tree leds light up (00101010) and stay on and nothing else, I have tried reprogramming and checked al connections over and over again but noting seems to work, I have read many threads on this forum but I don’t find anything that can help, so I really will appreciate if any one look at the code and comment what I am doing wrong thanks very much in advance.
    This is the code

    'Note: This program it will light eight leds on nine different routines selectables by a button
    @ DEVICE PIC16F877A, HS_OSC
    @ DEVICE PIC16F877A, WDT_OFF
    @ DEVICE PIC16F877A, PWRT_OFF
    @ DEVICE PIC16F877A, BOD_OFF
    @ DEVICE PIC16F877A, LVP_OFF
    @ DEVICE PIC16F877A, CPD_OFF
    @ DEVICE PIC16F877A, WRT_HALF
    @ DEVICE PIC16F877A, DEBUG_ON
    @ DEVICE PIC16F877A, PROTECT_OFF

    tempo var byte ' set variables
    cuenta var byte
    x var byte
    bot var byte

    tempo= 50 ' set variables values
    bot= 0

    trisa= 0 ' set port's tris
    trisb= 0
    trisc= %00100000
    trisd= 0
    trise= 0

    inicio: ' begining of routines
    portb= %10101010 ' this loop makes odd and pair
    pause tempo ' leds to turn on and off alternately
    portb= %01010101
    pause tempo
    button portc.2,0,100,0,bot,1,una
    goto inicio

    una:
    portb=%11111111 ' this loop makes all leds to turn
    pause tempo ' on and off alternately
    portb= %00000000
    pause tempo
    button portc.2,0,100,0,bot,1,dos
    goto una

    dos: ' this loop makes the leds to scroll
    portb=%00011000 ' from the center outwards
    pause tempo
    portb= %00100100
    pause tempo
    portb= %01000010
    pause tempo
    portb= %10000001
    pause tempo
    button portc.2,0,100,0,bot,1,tres
    goto dos

    tres: ' this loop makes the leds scroll from the
    portb=%10000001 ' sides inwards
    pause tempo
    portb= %01000010
    pause tempo
    portb= %00100100
    pause tempo
    portb= %00011000
    pause tempo
    button portc.2,0,100,0,bot,1,cuatro
    goto tres

    cuatro:
    portb=%00001111 ' this loop makes leds to turn on and off four
    pause tempo ' at the time
    portb= %11110000
    pause tempo
    button portc.2,0,100,0,bot,1,cinco
    goto cuatro

    cinco:
    cuenta=1 ' this loop makes leds to scrool from right
    ciclo: ' to left
    portb=cuenta
    pause tempo
    if cuenta= 128 then cinco
    cuenta= cuenta*2
    button portc.2,0,100,0,bot,1,seis
    goto ciclo

    seis:
    cuenta=128 ' this loop makes leds to scroll from left
    ultimo: ' to right
    portb=cuenta
    pause tempo
    if cuenta= 0 then seis
    cuenta= cuenta/2
    button portc.2,0,100,0,bot,1,siete
    goto ultimo

    siete:
    portb= %11000000 ' this loop makes leds to scroll on pairs from
    pause tempo ' left to right
    portb= %00110000
    pause tempo
    portb= %00001100
    pause tempo
    portb= %00000011
    pause tempo
    button portc.2,0,100,0,bot,1,ocho
    goto siete

    ocho:
    portb= %00000011 ' this loop makes leds to scroll on pairs from
    pause tempo ' right to left
    portb= %00001100
    pause tempo
    portb= %00110000
    pause tempo
    portb= %11000000
    pause tempo
    button portc.2,0,100,0,bot,1,inicio
    goto ocho

    end

    and this is the schematic from proteus

    Name:  proteus circuit.jpg
Views: 3540
Size:  120.1 KB
    Last edited by DonLuis; - 24th July 2012 at 13:53.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Hi, and welcome to the forum DonLuis.

    Proteus lets a lot of things work in the virtual world, that will not work in the real world. For the real world 16F877 you need an oscillator to be connected, or a resonator. Resonators already have the capacitors needed, but aren't quite as accurate as real crystals. If you get a 8 to 16 mhz crystal, you will need two 10 to 20 pf capacitors. See page 145 of the datasheet (147 in adobe).
    http://www.scalerobotics.com

  3. #3
    Join Date
    May 2009
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Trisc should be = %00000100

  4. #4
    Join Date
    Apr 2012
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Thank you grahamg and scalerobotics for answering.

    I already corrected the trisc issue and I do have installed the xtal, I have tried with a 4 and 18 Mhz before and the problem remains still, I wonder if the fuses are correct or I am missing something , I also thing that something is wrong with the programmer but I’ll like to make sure before I contact the seller, or the pic is to big for the program what do you tink.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Increase the PAUSE in TEMPO, 500 would be a good start.

    Robert

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    4 mhz would require the config to be XT_OSC. I would try changing to the XT config using the 4 mhz chip. Oh, that and turn debugger off. Otherwise you can't use RB6 and RB7.
    Last edited by ScaleRobotics; - 25th July 2012 at 04:37.
    http://www.scalerobotics.com

  7. #7
    Join Date
    Apr 2012
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Ok. Guys:
    I do have good and bad news, I teared the hole thing apart and stared from the beginning (the circuit I mean) and changed the XT and turned the debug off and ˇooorale! It works, that is the good one, the bad one is that I don’t really know what happened, any way thank you all very, very much. ahh and changed tempo to 500 also
    Last edited by DonLuis; - 26th July 2012 at 02:34.

  8. #8
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Well, you say you're new to programming so why not take a step back and write a few routines to make sure you're LEDs are working properly and connected well?

    Your schematic isn't very clear on my screen but it looks like your LEDs are hooked to PORTB. Something like:
    (I usually work with 12F683 so this code may not be totally correct.)

    STARTHERE:
    TRISB = 0
    PORTB = 0
    PORTB = %00000001
    PAUSE 100
    PORTB = %00000010
    PAUSE 100
    PORTB = %00000100
    PAUSE 100
    BLAH BLAH BLAH


    GOTO STARTHERE

    This way you know the LEDs will work once you get the right code.

    Also, I see it worked in Proteus but if the real world LEDs need more voltage/current, looks like a 330ohm current limiting resistor, than 6mA the LEDs may never come on no matter what your programming looks like.

    Could you post an updated schematic if none of this helps? Sometimes a second set of eyes helps find problems hidden by the forest.

    Best wishes

  9. #9
    aliciaDJones's Avatar
    aliciaDJones Guest


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Pleas tell me this form is except link after how long or how many posts.

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: don't work on circuit, please help

    Please stop spamming this forum.

    See also your private messages.

    Ioannis

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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