Programming Help for a newbie

Hello Everybody. This is my first post. I am new to the propeller line of products. Hopefully I'm posting in the correct forum.

I have purchased a Propeller Project Board USB. I have (2) banks of buttons, 10 buttons in each bank. Each button in bank 2 corresponds to a button in bank 1. I want to read the buttons in bank 1. When a button is pressed, I need to energize a SSR. The SSR will remain energized until the corresponding button in bank 2 is pressed. I have never programmed a propeller chip. I am assuming the program would read the bank 1 buttons, when a button is pressed it will fall into a subroutine looking for a press of the corresponding button in bank 2, and then reset to start reading the bank 1 buttons again. I hope this makes sense. Thanks for your help. Have a good day.

Comments

  • 13 Comments sorted by Date Added Votes
  • Welcome aboard. I would suggest starting with reading about the Propeller chip, and understand what voltage the pins are, how much current you can source and sink, etc. Then move on to reading the state of one button, debouncing it, and then controlling an LED with that button. With 20 different inputs you might also want to check out shift registers - https://www.parallax.com/product/602-00009

    The Project Board has examples to get you started. A lot will depend on what language you want to use. Were you going to use SPIN or PropC programming language?

    If you're new to programming either will do. IMO SPIN is easier than C.
  • Thanks for the reply. I am going to use SPIN. I decided to use the propeller, because of the number of inputs. Shift Registers scare me only because of my lack of experience. I thought using each button to a pin on the board maybe easier for me starting out.
  • Great, inside of the Propeller Tool go to "Help" and then click "Propeller Education Kit PDF". I would (for now) focus on SPIN, and the simple stuff like "Hello World". Once you do some of the initial tutorials you'll be able to accomplish what you want, or at least get a good start around page 50.

    If you get hung up post your code here using [c0de] [/c0de] tags, with o not 0s...

  • I don't think this will be a difficult programming exercise, but a little more information would be helpful. Do you have a common line for each bank? Are the associated Bank 1 and Bank 2 buttons tied together, forming a 2x10 matrix? If this is the case, you should have 12 total connections for the buttons. Is this correct?
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • frank freedmanfrank freedman Posts: 1,269
    edited July 10 Vote Up0Vote Down
    If you have not found it yet, I believe the full manual for the propeller education kit is up as a PDF. Easy read, great way to get up to working speed with the prop chip.

    https://www.parallax.com/downloads/propeller-education-kit-labs-fundamentals-text

    And you can just download it. Also, just got my hands on this, and it looks pretty good.

    https://leanpub.com/propellerassemblerpasmintroduction
    Ordnung ist das halbe Leben....
    Ich lebe in der anderen Hälfte
  • Hey Jon. If im looking at the schematic right. Each bank of buttons would have a 3.3V common wire. I wasn't planning on doing a
    matrix, i was planning on each button going to its own pin. So, the first bank of buttons being pins 0-9, and the second bank of buttons being pins 10-19. Will this be O.K. I really appreciate your time. I hope my answers are making sense. I know you guys are taking your time to help me out. Thanks.
  • That'd be fine, and would be simplest to program. You'll need a pull down (or pull up) resistor on each of your buttons. (Google "pull up resistor" or "pull down resistor" - either type will work, but you'll have to pick one)

    Probably the easiest way to code it would be to have an internal state value for each of the 10 SSR's, and then simply scan each "pair" of buttons repeatedly, setting the SSR state accordingly if either of the buttons is pressed.

    Wire the buttons so there's a consistent offset between the two banks. For example, pins 0 to 9 for bank 1, and pins 10 to 19 for bank 2, or use even numbered pins for bank 1 and odd numbered pins for bank 2. Either approach will work, but having a set order for everything will make the code simpler because you'll be able to loop over the buttons easily.
  • Tate wrote: »
    Hey Jon. If im looking at the schematic right. Each bank of buttons would have a 3.3V common wire. I wasn't planning on doing a
    matrix, i was planning on each button going to its own pin. So, the first bank of buttons being pins 0-9, and the second bank of buttons being pins 10-19. Will this be O.K. I really appreciate your time. I hope my answers are making sense. I know you guys are taking your time to help me out. Thanks.

    This is fine, so long -- as Jason pointed out -- you have a pull-up or pull-down [my preference] on each button input. Go with 10K. The other side of the buttons will connect to 3.3V which will cause a pin to read as "1" when the button is pressed.

    This leaves you with eight user outputs (I never touch P28..P31) for anything else. How many relays do you have?

    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Hey Jon. Just one relay. I just ordered some 10K resistors. Still confused on the programming. I hope i am not being a bother.
  • JasonDorieJasonDorie Posts: 1,925
    edited July 10 Vote Up0Vote Down
    Everyone starts somewhere - as long as you're trying to work on your own you'll find people here happy to help you along the way. You might also find the "Propeller Board of Education" tutorials worth a look. They're somewhat tailored to the hardware of that board, but general enough to be useful for your needs. Particularly this one: http://learn.parallax.com/tutorials/language/spin/get-started-propeller-board-education/4-pushbutton-monitoring

    Also, check to see if the relay you have will work with a 3.3v input, or if it needs a different (higher) voltage. If it triggers with 3.3v you'll be fine, otherwise you'll need additional circuitry (like some transistors) to make it go.
  • You guys are awesome. I appreciate all the information.
  • There are many ways to skin this cat; here's one that -- as they say here in Hollywood -- is for your consideration.

    Again, this is just one way to do it, and it's not tested at that (I don't have enough buttons or the time to hook things up). Still, the code is based on my actual projects, and I believe it should work without problems. After you've studied it, make changes to make it your own.

    Per Jason's comment: if your relay isn't a solid state type that will work with 3.3v, use a buffer transistor or FET circuit (easy-peasy). Do not connect a relay coil directly to a Propeller pin.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Thanks Guys.
Sign In or Register to comment.