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

Pull My Hair out, Optical Tachometer - PIC16F628A

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by DustinB, Mar 22, 2010.

  1. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    I'm using my own PCB I made for just the PIC, 7805, and LCD, with a 2K pot on the lcd contrast pin. I made the PCB layout based on your edit from this:

    [​IMG]

    Same connections as this, only there is no reset button, no sensor line, and no memory button. I have a 10 pin header with all the wires of the LCD lined up in order as well(1-6,11-14), then a 2 pin header for LCD backlight for 15&16.
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    This is getting a little crazy, but if you want to keep trying I'm up for it.:)

    I know its a pain, but since you have relaid out the PCB can we have a picture of both sides of the PCB.?

    I double checked the program and the wiring diagram, looks OK.

    EDIT:
    You can a free trial download of the Oshonsoft IDE, its about 28 trial days or 30 start ups.
     
    Last edited: Mar 30, 2010
  3. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    Sure, I'm getting the pictures sent to me now.

    Yes it is getting crazy. I made this board as suggested to get away from the project board as it may have had noise problems. Hopefully it will end up being something simple. I'll post the pictures in just a few minutes.

    Thanks for sticking with this and trying to help me keep my sanity.
     
    Last edited: Mar 30, 2010
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA

    Ok, here's the pictures. First picture is of the eagle pcb. The other 2 pictures are of the board. You will notice on the board I ended up doing jumpers over some things instead of going between pins like on the eagle layout. No overlapping wires are touching on the bottom. I put small wooden feet on the bottom of the board to prevent anything like that.


    EDIT: Looking at the pin assignments vs the datasheet it appears I have the following:
    LCD PIN -> PIC PIN/GND/+5v
    1 -> GND
    2 -> +5v
    3 -> 10K Pot
    4 -> Pin3/RA4 with +5v on 4.7k
    5 -> GND
    6 -> Pin9/RB3
    11 -> Pin17/RA0
    12 -> Pin18/RA1
    13 -> Pin1/RA2
    14 -> Pin2/RA3

    I noticed in the different codes I've used they all point to PORTB. Yet this pin layout and all the ones I've been using are on RA* pins. Is this the problem?
     

    Attached Files:

    Last edited: Mar 30, 2010
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Download your pics, will look them over.
     
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    The circuit looks correct.
    You should have a 100nF cap across the PIC power pins as close as possible to the PIC
    The 10 way connector looks OK.

    I cannot see the LCD pcb, do you have a pic.?

    brd1...jpg 1 002...jpg
     
    Last edited: Mar 30, 2010
  8. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    No I don't have a pic right off hand. It's this LCD from digikey: Digi-Key - 67-1758-ND (Manufacturer - LCM-S01602DSF/A)
    Here's the datasheet: http://www.electro-tech-online.com/custompdfs/2010/03/LCM-S01602DSF20A.pdf

    The pins are in order on the pcb layout. Pin 1 is on the right: 1,2,3,4,5,6,11,12,13,14
    The other 2 pins to the left are the anode/kathode.

    These are the connections:
    LCD PIN -> PIC PIN/GND/+5v
    1 -> GND
    2 -> +5v
    3 -> 10K Pot
    4 -> Pin3/RA4 with +5v on 4.7k
    5 -> GND
    6 -> Pin9/RB3
    11 -> Pin17/RA0
    12 -> Pin18/RA1
    13 -> Pin1/RA2
    14 -> Pin2/RA3

    I don't know if you saw my edit above, but I noticed the data pins are all connected to the RA* pins. Isn't the code calling for PORTB?
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi
    I have all the documentation for most LCD's, its an actual picture of the way you have connected it.

    Tomorrow I will build the 628A with an LCD configured the same way as yours and try that.
     
  10. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    I'll post an actual picture of the whole setup running and showing the display as well as the connections.

    Thanks for trying it, hopefully we can get the problem sorted out.
     
  11. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    dustin, as you see the LCD panel from the top ( able to see the screen).
    the counting 1 to 16 starts from left to right . a part diagram from datasheet attached
    but how do you count 1,2 etc from left?
    are you seeing from bottom ?
     

    Attached Files:

  12. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    On the actual lcd pcb I cam counting from the left side at 1. My board is marked on the back which pin is 1 and which is 16. I know they are in order.

    On the images I posted of my pic pcb board the header pins start from the right at 1.
     
  13. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    one simple doubt, Dustin B !!
    whether you have directly used the HEX from the link you provided, or did you use the pbp basic and compile for getting hex code.
    if you did later, i fear, at the time of programming you need to change the config settings to ensure that internal clock with port pis as Io is to be selected, before programing the derived hex into the chip
     
    Last edited: Mar 30, 2010
  14. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    I was using the last actual hex file Eric Posted, I was only looking at the basic file to see what the program was supposed to do.

    Using his hex file I hooked up an led/resistor with some alligator clips and connected it to PIN13/RB7, it blinks as it should so the chip is programmed right I'm guessing.

    I know what you're saying, if everything seems to be right and it's not working then something has to be wrong. Likely something I believed was right.

    I'll post a picture of the LCD hooked up shortly, I'll get the girlfriend to take another picture.
     
  15. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    Victory! :D

    I tried what you said Eric, about the 2.2K resistor instead of the 4.7K on pin 3 of the pic. Apparently the 4.7k resistor was dropping the voltage too much to get the signal through.

    I did it on the project board and it worked, then I desoldered and replaced the one on my pic pcb board and it worked there as well.

    I can't believe I have been trying to get this to work for 3 weeks, and you guys helping me for over 1, then it turns out to be something like this.

    I knew, at least most of the time, I had everything connected right and the programs worked. I can't believe the schematics all called for a 4.7k and it was actually too much.

    Now for the learning part if you guys don't mind. I know the resistor limits the voltage/current on the line. How was the 4.7K figured to be the right resistor for it? Why did it turn out to be too much? Would there be an easy way to have tested for this problem?

    I'm so relieved it works. Now I can finally build this circuit and get the tachometer going. Hopefully I can at least learn a lesson from this. I know I did further my knowledge of PIC's & LCD's as well.

    Thanks for the help guys, I really appreciate it. You went above and beyond what I was hoping for. I know it was getting frustrating at times.
     
    Last edited: Mar 30, 2010
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi dustin,
    I have found a wide variation in the response time of this type of LCD, especially the earlier production models.
    On some projects/products one LCD work and another would not, thats why I never use the LCD with R/W pin grounded. Any delays you have in the program have to be long enough to cope for the 'slowest' LCD that you may use.
    I read from the LCD, D7, the BUSY signal, to check when the LCD is ready for the next data/command byte.
    This can have the effect of 'speeding' up the program as whole as the program can minimise the delay wait period.

    The 4k7 resistor would pull up the RS pin slightly slower than a 2k2 which could cause a edge delay problem.

    Pleased to hear the good news, saves me a job today building your project.

    I would recommend that you 'beef' up the track widths on the 0V lines and the +Vsupply tracks. Add the 100nF to the PIC power pins.
     
    Last edited: Mar 31, 2010
  17. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    CONGRATULATIONS
    You have had hard times . but, a I had the same values and it worked for me. !! we need to thank Erricgibbs for his constant support and even he too was almost ready to make a duplicate rig to test why it fails.
     
    Last edited: Mar 31, 2010
  18. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    Thanks for the explanation Eric.

    By the way Sarma, I was going to ask. If you don't mind, could you post the eagle schematic and board files for the last layout you did?

    I wanted to edit some values on the components. I'm going to try and build the tachometer board over the next few days and see if I can finally get this optical tachometer finished.
     
  19. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    happy to share them and they were made for serving you. as theay are a set of files, perhaps it is better to send zipped. unfortunately zip format is not permitted here
    you may pm me your email address i shall send forthwith.
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Sarma,
    The Forum posts accept zipped file attachments.
     
  21. DustinB

    DustinB New Member

    Joined:
    Mar 22, 2010
    Messages:
    70
    Likes:
    0
    Location:
    Houston, TX USA
    Private message sent, thanks.
     

Share This Page