Connect with us

Just a quick check of my circuit

Discussion in 'Microcontrollers, Programming and IoT' started by j4cobgarby, Oct 15, 2018.

  1. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    upload_2018-10-15_17-28-22.png
    Here's a circuit I've came up with for my keyboard. Before I go any further, can anyone see any obvious mistakes? I'm most worried about the crystal, since most of the schematics I see have a three- or four-pin crystal, with ground pins, yet mine has none. Will that still work? Anyway, I'd be very grateful if anyone does find some potential problem with this.
     
  2. BobK

    BobK

    7,380
    1,559
    Jan 5, 2010
    You don't need all of those diodes.

    If you make the column drivers toggle between input and output driven low, and use the internal pull-up on each row input. You scan by making all the columns inputs, then you make one column an output at a time and read the row inputs for that column.

    Bob
     
    j4cobgarby likes this.
  3. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    That definitely seems like a logical idea... I wish I got rid of them before designing my PCB.
     
  4. BobK

    BobK

    7,380
    1,559
    Jan 5, 2010
    I guess that is why you should ask for a review first! :)

    Bob
     
    Arouse1973 and j4cobgarby like this.
  5. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    Do you have any idea why most of the keyboard schematics I've seen online use crystals with 3 or 4 pins?
     
  6. hevans1944

    hevans1944 Hop - AC8NS

    3,908
    1,867
    Jun 21, 2012
    Can you upload a keyboard schematic showing crystals with 3 or 4 pins?

    Sometimes a complete crystal-controlled oscillator module, with appropriate logic-level outputs and fast-transition edges, is used in lieu of a separate crystal with its required support circuitry. The oscillator module does not (usually) make the crystal terminals accessible, but it does require at least a power lead, a power return lead, and an oscillator output lead for a total of at least three pins.

    OTOH, some integrated circuits, such as many microprocessors, accept an external crystal or resonator which, of course, only needs (and has) two pins. There may be some confusion with regard to the schematic representation of a crystal and a crystal-controlled oscillator module, but the parts list should clearly make the distinction.
     
  7. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    Here - I found this guide after designing mine, and it made me think I may be doing something wrong.

    https://github.com/ruiqimao/keyboard-pcb-guide

    There's a PCB near the bottom of the page with the four-pin crystal, and also in the schematic nearer the top you can see there is a ground connection on the crystal.
     
  8. duke37

    duke37

    5,103
    687
    Jan 9, 2011
    There is no ground connection on the crystal proper. The ground(s) will go to the crystal can as shielding to give better stability.
     
  9. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    By better stability, do you mean that the frequency will be more constant?
     
  10. ratstar

    ratstar

    54
    0
    Aug 20, 2018
    Im not helping with your circuit, but just a comment about keyboards today - why do the keys always lock each other from turning on, seems like such a dodgy design, that everyone takes as the norm today. how crud are the keyboards we use!?!??
     
  11. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    They only do that on cheap designs. Note the diodes in my schematic, and then go and read about how to prevent N-key-rollover using them.
     
  12. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    EDIT: How to implement N-key-rollover
     
  13. BobK

    BobK

    7,380
    1,559
    Jan 5, 2010
    My keyboard does not do this if I understand you correctly. I can press and hold the a key, then press the b key and it will send a b.

    It is made by Logitech.

    Bob
     
  14. gorgon

    gorgon

    599
    22
    Jun 6, 2011
    The ground (GND) connection is for shielding, and the reason you have 2 GND pins is to make the package symmetrical for SMD mounting.
     
    j4cobgarby likes this.
  15. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    I've been thinking about this again, since I've just realised how much money I can save by getting rid of the diodes. Then I realised I may not understand quite what you mean. My understanding is: "For each scan, make two scans instead, one where the columns are outputs and the rows are inputs, and one where the rows are outputs and the columns are inputs". Correct?
     
  16. BobK

    BobK

    7,380
    1,559
    Jan 5, 2010
    No.

    First, put a pull-up on each row and each column to V+. If this can be done internally in the microcontroller, as it can on PICs, then use that, otherwise you will need to add a pullup resistor for each column.

    Now, to read a row, set that row as an output and output a 0. Read the column inputs. Any column input that has the key in the activated row pressed will read zero. All other column inputs will read a 1.

    Turn the row back to an input, and go on to the next row.

    Note that since the other rows are inputs, you do not get a short when two keys in a column are pressed like you would if the rows were all outputs, which is why the diodes were there.

    Bob
     
  17. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    Thank you very much, that was very helpful. So to implement this into the circuit, I would simply remove the diodes?
     
  18. BobK

    BobK

    7,380
    1,559
    Jan 5, 2010
    Yes, connecting the switch directly between the row and column. And don't forget to enable the pullups.

    Of course, I would try a prototype before designing a PCB.

    Bob
     
  19. j4cobgarby

    j4cobgarby

    38
    1
    Sep 18, 2018
    Thank you very much.
     
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.