Error PicaxeProgrammer 5.1.5 related to pin0

sedeap

Senior Member
*************
Picaxe Programming Editor
version 5.1.5 (Syntax DLL 131072)

Picaxe 08/08M

If you put

<code><pre><font size=2 face='Courier'>symbol outrelay = pin0 </font></pre></code>

Or even =&gt; <code><pre><font size=2 face='Courier'>High pin0 </font></pre></code>
or =&gt; <code><pre><font size=2 face='Courier'>Low pin0 </font></pre></code>

you obtain one error of unknown symbol...
you can see here =&gt;<A href='http://www.elpato.homeip.net/ventas/picaxeweb/errorpin0.jpg' Target=_Blank>External Web Link</a>


So if you use <code><pre><font size=2 face='Courier'>High 0 </font></pre></code> works ok

but how can I reference to pin0 to check it status?
like <code><pre><font size=2 face='Courier'>if pin0 = 1 then startmotor </font></pre></code>


Picaxe_manual2.pdf on page 72 say:
<i>&quot;Examples:
Checking an input within a loop.
main:
if pin0 = 1 then flsh &#8216; jump to flsh if pin0 is high
goto main &#8216; else loop back to start
flsh:
high 1 &#8216; switch on output 1
pause 5000 &#8216; wait 5 seconds
low 1 &#8216; switch off output 1
goto main &#8216; loop back to start
....&quot; </i>

:eek:)
 

hippy

Technical Support
Staff member
Pin0 is an output only pin so it doesn't really make any sense to use &quot;If pin0&quot;.

&quot;High pin0&quot; is probably not what you want either, and it causes an appropriate error message these days if an attempt is made to use such a command even with a pin which the compiler knows about ( try &quot;High pin3&quot; ).

What &quot;High pin0&quot; would do if allowed to is read pin0 as an input, returning 0 or 1, and then go on to set output pin0 or output pin1 high. This confused a lot of people and caused 'unexpected behaviour' which is why that usage has been rejected and an error message is given.

That the compiler says pin0 is an unknown symbol is an artefact of it only knowing those pins which can be inputs pins. On the 18X you will find it claims pin3 to pin5 are unknown symbols in High and Low commands. To get round that, outpin0 to outpin7 are available for the pins which do exist as outputs.

So, for the 08/08M - <code><pre><font size=2 face='Courier'> If pin0 = 1 Then ' Meaningless, pin0 is not an input
High pin0 ' Not allowed, probably not what was intended
High 0 ' What was probably intended above
pin0 = 1 ' Not allowed, &quot;Unknown symbol&quot;
outpin0 = 1 ' Allowed, and works </font></pre></code> Hope that makes it a bit clearer !

Edited by - hippy on 01/09/2007 04:47:34
 

sedeap

Senior Member
***************

Thanks hippy

but tell me why &quot;High pin0&quot; not allowed if pin0 IS OUTPUT pin

You says
<i>&quot;...What &quot;High pin0&quot; would do if allowed to is read pin0 as an input, returning 0 or 1, and then go on to set output pin0 or output pin1 high. This confused a lot of people and caused 'unexpected behaviour' which is why that usage has been rejected and an error message is given.&quot; </i>

IMHO tell High to pin means &quot;put that pin high&quot; ( = 1 )
NOT &quot;read it as input&quot;

And what I intend to do is:
<code><pre><font size=2 face='Courier'>
main:
'(do some routine here)
If pin2 = 0 then warn
goto main

warn:
high 0 'this Output pin conected to buzzer
for b13 = 1 to 60
pause 1000
gosub lookat
next b13
goto main

lookat:
if pin2 = 0 and pin0 = 1 then alarmNow
return

alarmNow:
for b10 = 1 to 6000
high 4 ' This output pin conected to siren
pause 1000
low 4
next b10
goto alarmNow

goto main ' just in case...
</font></pre></code>
:eek:)

Edited by - sedeap on 01/09/2007 07:41:34
 

hippy

Technical Support
Staff member
<i>but tell me why &quot;High pin0&quot; not allowed if pin0 IS OUTPUT pin
IMHO tell High to pin means &quot;put that pin high&quot; ( = 1 )
NOT &quot;read it as input&quot; </i>

There are two forms of the High command, &quot;High &lt;pin number&gt;&quot; and &quot;High &lt;variable&gt;&quot;.

It's not the High itself which tries to use anything as an input, but the fact pin0 ( or any other pin ) is used.

Except when pin0 is on the left of an assignment ( Let, and few other cases ) pin0 is used as an input variable, not a constant, and High uses the value that variable contains to determine the physical pin number to set.

&quot;High pin0&quot; is shorthand, not for &quot;High 0&quot;, but for -<code><pre><font size=2 face='Courier'> If pin0 = 0 Then
High 0
Else
High 1
End If </font></pre></code> A lot of people have had trouble getting their heads round this, so its use has simply been banned.

Edited by - hippy on 01/09/2007 13:36:39
 
Top