1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

[SOLVED] Why programming micro sometimes works and sometimes doesnt?

Discussion in '8051/8951' started by mik3ca, Feb 14, 2018.

  1. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    I made this programmer found at: http://www.dinceraydin.com/8051/index.html

    [​IMG]

    When I try programming the AT89C4051-12PC, the software works correctly in detecting the busy signal and all that, but when I actually try the chip in my circuit, it sometimes works perfectly and it sometimes functions as if its the most useless item.

    I use 250ms delay between each step in the erase procedure (to make sure the damn thing is erased) then I use a 5ms delay between each step in writing a byte to the chip. These delays are well over the minimum required by the chip so I don't understand why things aren't working out.

    In all tests, I plug the circuit into the parallel port then I apply the power. I'm sending the exact same code to the chip at the exact same speed from the PC. then I disconnect the power then the circuit from the parallel port.

    I use a mini IC extractor tool to remove the IC from the socket.

    So what could be going on?

    Only thing I could think of is to make a bracelet out of unshielded wire, wear it and connect it to ground while working with the chip, but is there another better solution before I go that route?
     
  2. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    7,545
    Likes:
    161
    add decoupling caps for the mcu
     
  3. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    My whole programming board is 50 x 60 mm in size and I forgot to mention that I did connect a 47nF ceramic between 5V and ground. So I guess you're saying I should add a capacitor between the micro's VCC pin (and no further) and nearest ground point?

    Could I also get away with replacing that 47nF with another capacitor of the same kind of dimensions but of larger value and the thing still work or must the capacitor be right at the micro?
     
  4. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  5. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    7,545
    Likes:
    161
    What's the clock on the MCU during programming anyways? The cap technically should be as close to the Vcc and GND pins as possible but the slower the clock is the farther you can get away with it. Do things improve if you change it to a 100nF cap? A 1uF cap?

    And do MCUs that don't program never program even when removed and re-inserted indicating they were damaged? What about if the plug is re-inserted? It could just be a bad connection somewhere on the board. How is the board constructed?
     
    Last edited: Feb 14, 2018
  6. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    Right now, I deliberately made it super slow. 5ms for each operation (meaning 5ms pause then write starts then 5ms then write stops then 5ms delay then raise xtal pin to increment program address then wait 5ms then lower xtal pin then wait 5ms then repeat for remaining bytes) Generally, the norm is 1.2ms max?

    This is something I am looking into trying. I made a programmer in the past like this with a 22uF electrolytic capacitor but not right next to the VCC pin and it worked more often.

    I dealt with some that were indicating during programming that they were damaged (I checked the P3.1 busy pin.) but the new ones I tried didn't want to have this problem which suggests to me that timing is an issue.

    I have everything on a single-sided PCB soldered in place.
     
  7. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    Pardon my old camera, but I took pictures of my programmer. Yes I wasted 1cm board space on either side since I didn't want to cut it. oh well. This is the top:
    IMG408.jpg
    This is the PCB side. Sometimes I add extra solder on the ground plane to strengthen it (make it less resistive). Quality isn't great, but all connections are solid:
    IMG409.jpg

    This is the PCB in Eagle:

    circuitp.png
    This is the schematic: circuit.png

    I added a 74HC245 IC to prevent the parallel port data pins from breaking the micro if the micro isn't in reset mode. The resistor above the 74HC245 is a 0-ohm resistor and I had to use it, otherwise I'd have to hire someone to make a 2-sided board which I don't have time for. All transistors used ate 2N3904 and all other parts have their values listed in the schematic. Pull-up resistors are 10K.

    VDD is 5V, and VSS is ground. That on the top-left of the schematic is the plug to the power that I made from a 3-pin jumper.

    Would I get luckier if I replaced 74HC245 with 74HCT245 or other 74xx245? hmm...
     
  8. dave miyares

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    2
    Likes:
    -10


     
  9. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    7,545
    Likes:
    161
    Hm, yeah I dunno man. Intermittent stuff can be super difficult to track down. I guess I would take some MCUs that I have been able to program them and repeatedly redo the whole procedure over and over again to see if it ever fails. Try and figure out if the problem follows certain chips around or if every chip is fair game.

    Maybe something in your circuit just outside the the tolerances of the microcontrollers so some chips respond while others don't. Maybe the timing components or logic input level of something.
     
  10. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,629
    Likes:
    145
    Location:
    Seattle, WA
    PIC programmers based on using parallel ports rarely work. I would be very suspicious of the parallel port unless your computer is very legacy (i.e., very old).
     
  11. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    I'm not using a PIC. I'm using an AT89C4051 (8051 IC).

    Ok, so I just reduced the pull-up resistor (that's connected to P3.5,P3.4, and P3.7) to 1K. I'm beginning to think that the IC functions like a 74LS IC. I'm so used to working with 74HC IC's that these low value resistors scare me.

    I also read that parallel ports that support EPP/ECP have 4.7K resistors as pull-ups for their control ports.

    Should I just lower every resistor to only 1K?
     
  12. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,629
    Likes:
    145
    Location:
    Seattle, WA
    You kind of missed the point entirely. The parallel ports that "old" programmers were designed to use no longer exist. The PIC programmers were an example showing that "modern" parallel ports aren't up to the task.
     
  13. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    When I was testing my programmer, I specifically configured the bios to use SPP (on my laptop, bios, I selected "Normal at-compatible mode").

    So if I were to redo this circuit to make things compatible with every parallel port in existance , will I have to be stuck with only using a pin from the data line to send data out through a shift register and other data lines to control the writing operation and just not use the control ports at all?
     
  14. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,629
    Likes:
    145
    Location:
    Seattle, WA
    Pardon me for mentioning that modern parallel ports can be a problem. Not my circus. Not my monkeys. Obviously you know what you are doing
    ...er..or maybe not since you are the one asking for help.
     
  15. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    I'm just trying to understand why the port can be a problem. Because if it can be instantly fixed from altering a few resistors in my circuit then I'd do that. I hate having to constantly throw circuit boards in the garbage
     
  16. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,710
    Likes:
    421
    Location:
    Brisbane Australia
    ONLINE
    Older printer ports were pretty robust and could take a lot of abuse. Newer ones are the same except if you try to draw too much current they just refuse, unlike the old ones.

    If I were you I'd give up on any circuit that uses a parallel port.

    Mike.
     
    • Like Like x 1
  17. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    The reason I want to use a parallel port is because my computers have them and I even ordered some parallel port adapters online. Plus its easier with compatibility than serial or USB.

    I'm trying to understand the AT89C4051 datasheet but I'm not sure if my resistor values are low enough for it to understand the dfferent logic levels. I mean I'm used to using 74HC devices, and I just read 74LS devices require different voltage/current levels to recognize a logic high.
     
  18. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
  19. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    428
    Likes:
    1
    Ok, I just found out a few things that fixed the circuit.

    1. After extensive testing with a multimeter, it turned out one bit was disconnected which meant incorrect data was always programmed. so I used extra solder on that PCB trace.

    2. I changed all 10K pull-ups to 3.3K pull-ups, and the pull-up attached to the transistor and the port pin is now 1K.

    3. I added a 4.7K resistor bus across pins 1 through 9 of the 74HC245 to make it function as 74HCT245 because that's the only way an LS output can communicate with an HC input (was to connect the output and input with a pull-up resistor)

    and 4, compared to the original circuit, I added a 22uF capacitor close to the power source (between 5V and ground).
     
  20. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,615
    Likes:
    697
    Location:
    Derbyshire, UK
    Adaptors rarely work for such purposes, as they aren't a 'real' parallel port so you usually can't 'bit-bang' their hardware.

    As others have said, parallel port programmers are last century, there's no real use for them now - and nothing remotely modern even has a parallel port.

    For that matter, they don't have serial ports either, but you can easily get USB/Serial adaptors which work well, and serial ports are easier to use than parallel ones.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice