Programming Help for a newbie
Tate
Posts: 6
in Propeller 1
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.
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
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.
If you get hung up post your code here using [c0de] [/c0de] tags, with o not 0s...
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
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.
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.
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?
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.
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.