pmacduffie
Member
Hello, I am new to the Picaxe but not new to basic programming languages. I have about 20 years of structured text programming in my professional past, but I have a project that I think the picaxe can do. I first learned about it many years ago in school where I used to teach the parallax bs2 to kids in a robotics program at my local community college. Regardless I have found a few things differnt that I expected and these questions I think are rather basic, but maybe the answers might help others that are searching as I did.
1) In an IF statement is it expected to not reference a "Symbol" that is also an IO pin? It would seem I can't name the I/O and use it for example. Am I just dumb and the "symbol" command is only related to variables?
The below is what I think I could do which the compiler says no to.
This I know works, and I understand it, but am I just using the syntax wrong? Does it have something to do with defining the i/o wrong? Or the direction wrong? Or am I correct there is no way to label these pins as an alias?
2) I understand multitasking is a contentious discussion on the forum here. I considered its use to run one start making a 1.5 second toggling oscillator that is writing to bit0. Then I would use this in other starts. I would employ the pause command to do the wait as my understanding is it will branch during pause and scan my inputs. Everything is slow here so I don't need any sort of interrupt capability.
The 18M2 internal counter seems to only output 1hz and the overflow size isn't adjustable like the X2. So, I assume this is the only way to do it internally without an RTC. I don't want to add one and do not require that level of precision it offers. I bet the internal resonator is good enough for what I'm trying to do.
So, the real question. If the multitask is emulated parallelism by branching during commands like pause. How much of each line actually executes? I can't find in the manual a real description of how much time it would spend in start1 vs start0 ? Is pause the only command that it will branch during, as I assume serial commands will not as they cannot stop. So, it would run one line in Start0 then one in start1 ?
Thank You in advance for your time. I look forward to learning this microcontroller better but it's a huge refresh for me to go back to something so simple after all this time. I think some of my "cleverness" has been lost working with much more capable systems. But, I understand the pride in writing less to do more and make more efficient code. I think this back to basics might be good for me.
Phil
1) In an IF statement is it expected to not reference a "Symbol" that is also an IO pin? It would seem I can't name the I/O and use it for example. Am I just dumb and the "symbol" command is only related to variables?
The below is what I think I could do which the compiler says no to.
Code:
let dirsC = %11001011
let dirsB = %11110000
Symbol Myinput = pinB.0
Symbol OutputThing = C.1
Symbol flipflop = w0
do
if Myinput = 1 then
OutputThing = flipflop
Else
Low OutputThing
endif
This I know works, and I understand it, but am I just using the syntax wrong? Does it have something to do with defining the i/o wrong? Or the direction wrong? Or am I correct there is no way to label these pins as an alias?
Code:
do
if pinb.0 = 1 then
pinc.1 = flipflop
Else
Low c.1
endif
2) I understand multitasking is a contentious discussion on the forum here. I considered its use to run one start making a 1.5 second toggling oscillator that is writing to bit0. Then I would use this in other starts. I would employ the pause command to do the wait as my understanding is it will branch during pause and scan my inputs. Everything is slow here so I don't need any sort of interrupt capability.
The 18M2 internal counter seems to only output 1hz and the overflow size isn't adjustable like the X2. So, I assume this is the only way to do it internally without an RTC. I don't want to add one and do not require that level of precision it offers. I bet the internal resonator is good enough for what I'm trying to do.
So, the real question. If the multitask is emulated parallelism by branching during commands like pause. How much of each line actually executes? I can't find in the manual a real description of how much time it would spend in start1 vs start0 ? Is pause the only command that it will branch during, as I assume serial commands will not as they cannot stop. So, it would run one line in Start0 then one in start1 ?
Thank You in advance for your time. I look forward to learning this microcontroller better but it's a huge refresh for me to go back to something so simple after all this time. I think some of my "cleverness" has been lost working with much more capable systems. But, I understand the pride in writing less to do more and make more efficient code. I think this back to basics might be good for me.
Phil
Last edited: