PropBASIC code issue and general questions
bill-phx
Posts: 11
I have just started programming in PropBASIC, and am having a few issues.
I have a simple piece of code (I think) that is an on/off timer. The main code is the display portion (4-bit LCD connection), it then launches a cog for actually turning a relay on/off, and a cog that looks for button inputs to change the timer values.
Currently, my "off time" keeps decrementing by 1, in what looks like less than a second. If I comment out line 384 (WRLONG to put decremented value back in hub memory), the decrementing stops. All the other up/dn buttons work fine.
I have tried changing the input PIN, removed the input PIN entirely, grounded the input PIN. I don't think it is a wiring issue. btw- buttons are wired like on page 133 of the propeller education kit labs book.
3.3v
|
button
|
+
100ohm
PINx
|
10k ohm
|
GND
I'm at a bit of a loss here. I am guessing that it is something simple that I either overlooked with tired eyes, or a fundamental issue with how I am trying to do it.
Also-- can someone explain:
1) Cog variables -- what happens when you have a SUB call a SUB? I assume that they both cannot use the same temporary variable names, or strange things happen? (Variables are local to a cog, not a SUB, right?)
2) What exactly are the __tempx variables? Are they unique in a SUB? Is it a long? Can it be used as a temporary string?
3) Any other __xxxxx variables I should be aware of?
If anyone wants to look at the code, that would be great. I am also open to suggestions on how to code more efficiently, so suggest at will! (Guessing that this being one of my first programs, I am probably doing at least one thing "the hard way" if not "the wrong way." )
*** NOTE: Code moved down a few entries, cleaned it up a little, still having issues. ***
Thanks!
bill
I have a simple piece of code (I think) that is an on/off timer. The main code is the display portion (4-bit LCD connection), it then launches a cog for actually turning a relay on/off, and a cog that looks for button inputs to change the timer values.
Currently, my "off time" keeps decrementing by 1, in what looks like less than a second. If I comment out line 384 (WRLONG to put decremented value back in hub memory), the decrementing stops. All the other up/dn buttons work fine.
I have tried changing the input PIN, removed the input PIN entirely, grounded the input PIN. I don't think it is a wiring issue. btw- buttons are wired like on page 133 of the propeller education kit labs book.
3.3v
|
button
|
+
100ohm
PINx
|
10k ohm
|
GND
I'm at a bit of a loss here. I am guessing that it is something simple that I either overlooked with tired eyes, or a fundamental issue with how I am trying to do it.
Also-- can someone explain:
1) Cog variables -- what happens when you have a SUB call a SUB? I assume that they both cannot use the same temporary variable names, or strange things happen? (Variables are local to a cog, not a SUB, right?)
2) What exactly are the __tempx variables? Are they unique in a SUB? Is it a long? Can it be used as a temporary string?
3) Any other __xxxxx variables I should be aware of?
If anyone wants to look at the code, that would be great. I am also open to suggestions on how to code more efficiently, so suggest at will! (Guessing that this being one of my first programs, I am probably doing at least one thing "the hard way" if not "the wrong way." )
*** NOTE: Code moved down a few entries, cleaned it up a little, still having issues. ***
Thanks!
bill
Comments
2) The __tempx variables are used by PropBasic commands. They are also global to the cog.
3) __paramx variables are used to pass parameters to subroutines. You can use them as a temporary variable if you don't call a subroutine when using them.
Bean
As in they are reserved, or I may use them in a SUB (as long as I do not use the same one in another SUB I call from a SUB)?
So basically, the __tempx and __paramx variables are really the same thing (undefined variables that you can use), except the __paramx has the added feature of auto-filling when you give arguments to a SUB call?
Any chance you want to give my code a quick once-over? I am also looking to make sure that I am doing things cleanly, as well as fix the variable decrementing issue...
thank you
bill
Some memory or variable allocation issue that I missed?
a) I knew it would be something simple.
b) That was left over from debigging why it was happening.
thank you!!
bill
The __tempx variables will be used by PropBASIC commands, __paramx variables are ONLY used by subroutine calls.
Bean