[LINAxepad] None of my syntax works after line 1....ever. Help!

Cillakin

Member
I have tried programming a very simple program several times. The program is as follows...

Code:
Main:
pinC.2  High
Pause 500
pinC.2  Low
Pause 500
pinC.2  High
Pause 1000
pinC.2  Low
Pause 1000
pinC.2  High
Pause 1500
pinC.2  Low
Pause 1500
GoTo Main
End
No matter what I put in after
Code:
Main:
the syntax check says there is an error. Simply says pinC.2 = High/Low or whatever registers an error. No idea why this is. I first noticed it while trying to create a if/then statement and ever since LINAxepad says every code is a syntax error. Why? Even this doesn't work...

Screenshot from 2013-08-21 21:42:58.png

Either LINAxepad is broken, I'm retarded, or something else is going on. Any suggestions/help is greatly appreciated.

**Note** I've even changed
Code:
pinC.2
to just C.2 (which worked for the Hello World blinky program) but now nothing works. :confused:
**Note** It is also worth mentioning that the specifics of the program are not of great concern, the concern is that absolutely no code will work.

EDIT:
I tried fiddling around with it and used the PWM Wizard to try to get something to work. And it has, however, anything other then the Wizard generated code will not register successfully.
 

tony_g

Senior Member
im using the windows environment for P.E and will get a syntax error for pinc.2 high

change your code to high c.2 and see how that works
 

Cillakin

Member
im using the windows environment for P.E and will get a syntax error for pinc.2 high

change your code to high c.2 and see how that works
This works! Not entirely sure why it needs to be flipped like this in order to work as I recall the manual using pinX.x = High/Low yet it needs to be written as High/Low pinX.x
Either way thanks for the simple and quick fix. Now it's off to see why my if/then statements are not working. This is what I am trying to use...

Code:
dirs = %01010
Main:
if pin1 high then trig
else
Goto Main
trig:
high pin2
Goto trig
end
The error it registers is in the if statement. Examples online indicate this should not be an issue. Using an "=" in the statement also has no effect.
 
Last edited:

PaulRB

Senior Member
Hi, yes I can see more errors there! Read the manual pages for each command carefully, especially the examples. You can't just write "pseudo code", the syntax has to be exact, same for any computer language.

Paul
 

tony_g

Senior Member
for your trigger pin the statement will need to be : if pinc.1 =1 then trig and it should compile ok for that part
and for the trig label if you change high pin2 to high c.2 or whichever pin you are using.

when you want to observe when a pin goes high or low to trigger a response in another part of your code you will always write the expression as "if pinc.2=1 then..." depending on what you are looking for whether its a high (1) or a low (0)

however if you want to switch a pin between on or off you will refer to it codewise as "high c.2" or "low c.2" depending on what you want it to perform

hope this clears it up a bit more for you

tony
 

Cillakin

Member
for your trigger pin the statement will need to be : if pinc.1 =1 then trig and it should compile ok for that part
and for the trig label if you change high pin2 to high c.2 or whichever pin you are using.

when you want to observe when a pin goes high or low to trigger a response in another part of your code you will always write the expression as "if pinc.2=1 then..." depending on what you are looking for whether its a high (1) or a low (0)

however if you want to switch a pin between on or off you will refer to it codewise as "high c.2" or "low c.2" depending on what you want it to perform

hope this clears it up a bit more for you

tony
Yes thank you! Helps a bunch.

After browsing the net a little bit I picked up some additional example code to tinker with but although the program syntax was correct and compiled/downloaded successfully it was not performing as expected. I think the issue I had was hardware related. The intent of the program was to use pin3 (which by default is input IAW Manual 1 for 08M parts) to detect if it was high/low. The default setup was to blink an LED on/off once every second, and if pin3 went high via a tact switch it was to increase the speed it blinked at; in this case it was twice as fast. However what happened was it was always blinking at the higher speed. Using a 100 Ohm resistor to pull the tact switch high, so when it was closed would pull pin3 high and cause it to blink faster. Perhaps a higher resistor should be used?

In any case my understanding of the if/then statements is much improved so thank you very much. =]

EDIT:
All is well! The code I used was this...

Code:
input 3
Main:
if pinC.3 = 1 then turbo
if pinC.3 = 0 then reg
reg:
	high 2
	pause 1000
	low 2
	pause 1000
	goto Main
turbo:
	high 2
	pause 250
	low 2
	pause 250
	goto Main
I also had to do some tinkering with the tact switch. Pulling pin3 low in tandem with jumping it to the tact switch which was pulled high gave a satisfactory outcome. Now when the switch is pressed it blinks faster and when not, it goes at its normal pace.
Thanks a bunch guys for all the help, greatly appreciated!
 
Last edited:

tony_g

Senior Member
if you are using a mechanical switch be sure have a look at manual 3 which will give you various information for some of the common types of devices used with the picaxe just to help you get under way.

if you go to page 26 and have a look at that you will see they have added a couple of resistors along with the switch, the 10k is acting as a pulldown to ground and the 1k is i believe to reduce the volts and or current going into the pin to make sure it doesnt somehow get damaged.

if you are looking for a low to high on your input then copy the setup in the manual with a couple of resistors shown, this ensures that when you are not pressing the switch that the input pin is being pulled to ground, it would be the opposite setup if you were to have the input looking for a high to low transition to do something in your code.

also it might be worth having a quick search in the forum just to find out about button debounce and how to account for this in your code to help smooth things along as input switches can be noisy things electrically speaking lol

tony
 

Cillakin

Member
if you are using a mechanical switch be sure have a look at manual 3 which will give you various information for some of the common types of devices used with the picaxe just to help you get under way.

if you go to page 26 and have a look at that you will see they have added a couple of resistors along with the switch, the 10k is acting as a pulldown to ground and the 1k is i believe to reduce the volts and or current going into the pin to make sure it doesnt somehow get damaged.

if you are looking for a low to high on your input then copy the setup in the manual with a couple of resistors shown, this ensures that when you are not pressing the switch that the input pin is being pulled to ground, it would be the opposite setup if you were to have the input looking for a high to low transition to do something in your code.

also it might be worth having a quick search in the forum just to find out about button debounce and how to account for this in your code to help smooth things along as input switches can be noisy things electrically speaking lol

tony
Thanks Tony! I did have a look at Manual 3 and that's where I got the idea for using a tact switch. After some digging I came across this schematic/code from PICAxe itself although they did not seem to mention a value for R1, just that it should be used. I ended up going with a 1k for safety's sake. Thanks again though, the learning process has been a very nice curve! Started out struggling but have since gained a lot of traction and its been fun. =]
 

eclectic

Moderator
. After some digging I came across this schematic/code from PICAxe itself although they did not seem to mention a value for R1, just that it should be used. I ended up going with a 1k for safety's sake. Thanks again though, the learning process has been a very nice curve! Started out struggling but have since gained a lot of traction and its been fun. =]

Go to the Bill of materials section.

10k

e
 

tony_g

Senior Member
the learning curve can deffinately be a challenge at the start, i had fun trying to understand things properly at first as i had never done any sort of code writing at all before discovering picaxe but as long as you try and keep at it through all the hurdles and read the commands descriptions enough from manual 2 you eventually get a good enough grasp to start going away and progressing at a good rate.

just remember to have fun and if needed get help from probably one of the best forums around, there are alot of smart people on here who have done some great things with these little chips and have alot of knowledge and insight to help if you get stuck or need something explained in a different manner to get you moving forward.

tony
 
Top