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

input and save input

Discussion in 'Microcontrollers' started by MrDEB, Nov 7, 2017.

  1. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    You don't got have wpu you can use a 50 k resistor and do the samething just more parts.
     
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,162
    Likes:
    340
    Location:
    Brisbane Australia
    On the above matrix diagram - swap the ports.

    Mike.
     
    • Like Like x 1
  3. tumbleweed

    tumbleweed Member

    Joined:
    Jan 25, 2007
    Messages:
    66
    Likes:
    19
    Good idea but it doesn't work. I assumed you'd enable the portB pullups.

    HINT: when the portC pin is low and the switch is pressed is the diode forward or reverse biased?
    Does it conduct? If it doesn't conduct what would the portB pin it's connected to see?

    How about just wiring things correctly? That'll work too. That way you won't have to swap port direction to turn on the led.

    But please, save us the anguish and just use a bigger chip. Please.
     
    Last edited: Nov 21, 2017
    • Like Like x 1
  4. dave

    Dave New Member

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


     
  5. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,162
    Likes:
    340
    Location:
    Brisbane Australia

    As I said in an earlier post, "never going to happen".

    It's all doable but not until 30 pages of posts and no conclusion. I'll be proved right in about 6 months.

    Have fun.

    Mike.
     
    • Like Like x 2
  6. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    Am getting some progress but very little.
    YES still have not eliminated the larger pic.
    What advantage to swapping ports? PortC.(x) = LOW, pressing switch PortB.(x) goes LOW
     
  7. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    If you use portb you can read the switches using the pullups to make it high the pullups are like 50 kohms and don't light the leds.

    But as said you got first make the layout of the leds and switches right first.

    You would be better using a adc pin to read 8 to 12 buttons on a ladder very simple and would work great with a game they been making games that way for years.
     
  8. tumbleweed

    tumbleweed Member

    Joined:
    Jan 25, 2007
    Messages:
    66
    Likes:
    19
    I assume you're still using the schematic shown in mexi-trainmatrix.jpg from post #71.
    Probably a bad assumption on my part but that's all I've got to work with.

    Assuming you have the portB(x) pin pulled high, when the switch is NOT pressed you'll read a high
    on the portB(x) pin from the pullup when the PortC(x) pin is either high or low. So far so good.

    Now, set portC(x) = 0. Press the switch. The diode now has 0V on the positive side and +5V from the pullup on the negative side.
    That's called reverse-biased... the diode doesn't conduct. So as far as the matrix is concerned you could just pull it
    out of the circuit. What's on the portB(x) pin? The 5V from the pullup, so the portB(x) pin again reads high.

    As shown the portB pins can NEVER read low (unless you decide to start writing to the input ports again).

    Once you get the matrix stright, you do realize that at the same time you're scanning the keys you'll have to scan the LED outputs as well,
    right? If you start adding the typical "delayms(500)" calls the LEDs are going to blink all over the place.


    That might be overly optimistic, Mike. I'm figuring 20-30 pages just to get the switches scanned. Then, lighting the leds will take...
     
  9. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    I totally neglected the reverse biased on the diodes. Need to reconsider.
    Yes realize the leds will be blinking. Taking one step at a time but this switch matrix idea is intriguing at best,
    I am leaning towards going with the bigger chip, take my time and learn how to solder the smaller footprint.
    news at 11
     
  10. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    As a fun exeecise and as part of your quest for knowledge, can you wxplain how to read a switch matrix?
     
  11. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    Weak pullup is around 50 k it can't light a led but I would go for a ladder and adc pin coding be a lot easier.
     
  12. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    You are typing far too fast Jon
     
    • Like Like x 1
  13. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    to deal with blinking leds and other issues IMO the easy solution is to go with the larger pic and possibly have two matrix's, one for Leds and one for the switches for a total of 14 port pins ( 2 - 2 x 5 matrix).
    designed a schematic with no matrix's and am seeing small issues arising already.
     
  14. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    I think I have a switch matrix code figured out? Just need to breadboard. Was looking at using pbyte(x).bits(y)??
     
  15. tumbleweed

    tumbleweed Member

    Joined:
    Jan 25, 2007
    Messages:
    66
    Likes:
    19
    I was joking about writing to the input pins. Please don't write to portB. Remove the diodes.
     
  16. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    "It's right there. Tumbleweed said it was ok to write to input pins!!!"

    MrDEB has a remarkable ability to only see what he wants to.
     
  17. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    "If portb.0 = 1" Guess he still don't no that's saying it's a 1
    == 1 is a test for 1 the = 1 your'll get a 1 even if it's a 0
     
  18. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,162
    Likes:
    340
    Location:
    Brisbane Australia
    Hi Burt,

    That's only in C. Swordfish just uses a single equals for comparison.

    mike.
     
  19. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    I put the portB.0 =1 to be sure it IS HIGH
    nothing wrong with guaranteeing it is the desired logic level that you want?
    Going with a 2 x 5 mayrix for the switches, a 2 x 5 matrix for the LEDs
    IMO it makes this projects code simplified.
    Now to get back to saving player positions.
    If players are at portC.0,2,4,5,7,9
    how do I INPUT and save the player positions to enable their LED when it's their turn to play?
     
  20. tumbleweed

    tumbleweed Member

    Joined:
    Jan 25, 2007
    Messages:
    66
    Likes:
    19
    It's a freaking input pin. You CAN'T write to it (well you CAN but it's not doing what you think it is).

    If you want to ensure it's high then arrange your hardware to assert it high.
     
    • Like Like x 1
  21. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    What ha says ^^^. If people who know what they are doing ALL tell you what you are doing is wrong, perhaps you need to get a fricking clue and figure it out.

    I explained a number of ways to know which players are active year ago when this first started. Use a VARIABLE in any of several ways. There is no reason to store it in EEPROM or do anything other than using a VARIABLE.

    Switches and LEDs in matrices using a 40 pin chip is plain old stupid, expecially since you don't understand how to do it.
     

Share This Page