Parallax Propeller for a time
Greetings,
I have been using a Parallax Propeller for a time, however... I have encountered an issue with determining the state of a push button. I am pretty sure this is a software issue at this point, not a hardware issue. The push button is called INT.
How do I make sure that it only turns on pin 17 when the button is down?
EDIT: to specify, the issue is that the code believes that the button is always down.
Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:51:13 AM GMT
I have been using a Parallax Propeller for a time, however... I have encountered an issue with determining the state of a push button. I am pretty sure this is a software issue at this point, not a hardware issue. The push button is called INT.
' EMS
'
' Energy Management System
'**************************************************************************************
'Summary: This is a home energy management system.
'**************************************************************************************
'File: EMS.spin
'**************************************************************************************
'Correct Function: This system should control energy distribution
'**************************************************************************************
'
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
High = 1
Low = 0
Out = %1
In = %0
'
VAR
Byte INT 'Interrupt Pin
Byte Q1 'Quandrant 1 Pin
Byte Q2 'Quandrant 2 Pin
Byte Q3 'Quandrant 3 Pin
Byte Q4 'Quandrant 4 Pin
Byte A1 '(TEMP) Arg 1
Byte A2 '(TEMP) Arg 2
Byte A3 '(TEMP) Arg 3
'
PUB Start
INT := 1
Q1 := 2
Q2 := 3
Q3 := 4
Q4 := 5
A1 := 0
A2 := 0
A3 := 0
'DirA[noparse][[/noparse]INT] := In
DirA[noparse][[/noparse]Q1] := Out
DirA[noparse][[/noparse]Q2] := Out
DirA[noparse][[/noparse]Q3] := Out
DirA[noparse][[/noparse]Q4] := Out
Repeat 500
if (InA[noparse][[/noparse]INT] = 1)
DirA[noparse][[/noparse]17] := Out
OutA[noparse][[/noparse]17] := High
WaitCnt(5_000_000 + Cnt) 'ONE-HALF SECOND WAIT
End
'
PRI End
'
'INDENTION IS IMPORTANT IN SPIN: There are no ENDIFs, END REPEATs, END SUB, etc.
How do I make sure that it only turns on pin 17 when the button is down?
EDIT: to specify, the issue is that the code believes that the button is always down.
Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:51:13 AM GMT

Comments
Con On_Off_Switch = Pin 19 'what ever pin the switch is on Pub main dira[noparse][[/noparse]On_Off_Switch]~ ' Make it an Input CheckButton ' Check button pub Pub CheckButton | Button Button~ 'Clear button variable Button := Ina[noparse][[/noparse]On_Off_Switch] 'Store the state of the button as the variable "Button" IF (Button == 1) ' This will have to change if you haev a pull up or pull down {{do someting here}} {{Like}} RebootHope this helps.
Or why not just continually copy the input of INT out to Pin17 (or the logical inverse, depending on how the switch is wired)?
Cheers!
Paul Rowntree
' EMS ' ' Energy Management System '************************************************************************************** 'Summary: This is a home energy management system. '************************************************************************************** 'File: EMS.spin '************************************************************************************** 'Correct Function: This system should control energy distribution '************************************************************************************** ' CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 High = 1 Low = 0 Out = %1 In = %0 ' VAR Byte INT 'Interrupt Pin Byte Q1 'Quandrant 1 Pin Byte Q2 'Quandrant 2 Pin Byte Q3 'Quandrant 3 Pin Byte Q4 'Quandrant 4 Pin Byte A1 '(TEMP) Arg 1 Byte A2 '(TEMP) Arg 2 Byte A3 '(TEMP) Arg 3 ' PUB Start INT := 1 Q1 := 2 Q2 := 3 Q3 := 4 Q4 := 5 A1 := 0 A2 := 0 A3 := 0 DirA[noparse][[/noparse]INT]~ DirA[noparse][[/noparse]Q1] := Out DirA[noparse][[/noparse]Q2] := Out DirA[noparse][[/noparse]Q3] := Out DirA[noparse][[/noparse]Q4] := Out Repeat 500 if (InA[noparse][[/noparse]INT] == 1) DirA[noparse][[/noparse]17] := Out OutA[noparse][[/noparse]17] := High WaitCnt(40_000_000 + Cnt) 'ONE-HALF SECOND WAIT End ' PRI End ' 'INDENTION IS IMPORTANT IN SPIN: There are no ENDIFs, END REPEATs, END SUB, etc.Since this is an interrupt button, i want it to be high when pushed. I think that is how I have it set up. I have attached a relatively high resolution image of the current configuration.
Post Edited (HobbyCoder) : 1/10/2009 11:34:40 PM GMT
I would read the propeller education labs. These lessons wire up switches and read them.
John Abshier
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 High = 1 Low = 0 VAR Byte INT 'Interrupt Pin Byte Q1 'Quandrant 1 Pin Byte Q2 'Quandrant 2 Pin Byte Q3 'Quandrant 3 Pin Byte Q4 'Quandrant 4 Pin Byte A1 '(TEMP) Arg 1 Byte A2 '(TEMP) Arg 2 Byte A3 '(TEMP) Arg 3 ' PUB Start INT := 1 Q1 := 2 Q2 := 3 Q3 := 4 Q4 := 5 A1 := 0 A2 := 0 A3 := 0 DirA[noparse][[/noparse]INT]~ ' Make an Input DirA[noparse][[/noparse]17]~~ ' Make an output DirA[noparse][[/noparse]Q1]~~ ' Make an output DirA[noparse][[/noparse]Q2]~~ ' Make an output DirA[noparse][[/noparse]Q3]~~ ' Make an output DirA[noparse][[/noparse]Q4]~~ ' Make an output Repeat 500 IF(InA[noparse][[/noparse]INT] == 0) 'Since it is already high look for a low !OutA[noparse][[/noparse]17] WaitCnt(40_000_000 + Cnt) 'ONE-HALF SECOND WAITMake sure your switch is right looks strange.
PS. edit your first post and add a subject liine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
www.parallax.com/Portals/0/Downloads/docs/prod/prop/Web-PELabsFunBook-v1.0.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Aka: CosmicBob
as you seem to have to learn about electronics I recommend before connecting a circuit to the propeller
to check it with a digi-multimeter voltages AND current flowing through the circuit.
Especially flowing to that wire that is connected to the Propeller-IO-Pin.
You have to connect it to +3.3V and check it AND to connect it to ground=0V
If you define an input-pin accidently as an output pin the output could be switched to HIGH= 3.3V and Ground=0V
In both cases the current should stay below 30mA. Otherwise you are in danger to fry your propellerchip
best regards
Stefan