Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

BASIC PICAXE Question

Status
Not open for further replies.

shaneshane1

New Member
back again :D now i have some questions about BASIC, i have been testing my skills on the simulator, still dont have the kit yet :mad: will have maybe next week.

I already know most of the commands of by heart, and how to implement them into the simulator :D

but i am confused with some things

eg:
Code:
main:
     if pin1 = 1 then
     goto traffic
     endif
     goto main
     
traffic:
        high 0
        pause 2000
        low 0
        high 1
        pause 4000
        low 1
        high 2
        pause 6000
        low 2
        if pin1 = 0 then
        goto main
        endif
        goto traffic

Now with the (if pin1 = 0 then goto main) code, i want that to function anywhere within the traffic section and not have to wait for all the stages befor it gets to that part of the code.

is this possible?

and yes futz i know this code could probably be alot cleaner,lol
 
The easiest (some would say dirtiest) way would be to write your own delay routine that exits if pin1 is zero. You could then make it slightly cleaner by putting a check after each delay.

Mike.
 
shaneshane1 said:
Iv had a look through the BASIC commands for the Delay, but i cant work out how or where to them in my code?

Isn't there a PICAxe forum, and loads of examples on the PICAxe website? - it's intended for school kids and teachers, so it has to be nice and simple.
 
Nigel Goodwin said:
Isn't there a PICAxe forum, and loads of examples on the PICAxe website? - it's intended for school kids and teachers, so it has to be nice and simple.

There is a PICAXE forum, but its crap, you post a thread and it takes days for people to reply :mad:

do you want me to go somewhere else and ask this questions???
 
shaneshane1 said:
Now with the (if pin1 = 0 then goto main) code, i want that to function anywhere within the traffic section and not have to wait for all the stages befor it gets to that part of the code.

is this possible?
Here is where interrupts get useful.

Page 60 in picaxe_manual1.pdf

If you can set an interrupt for that input pin, anytime it changes state normal program execution will be interrupted and an "interrupt service routine" piece of code will be called to handle whatever you want to happen.
 
shaneshane1 said:
There is a PICAXE forum, but its crap, you post a thread and it takes days for people to reply :mad:

do you want me to go somewhere else and ask this questions???

I was merely suggesting you try asking where people use them!, there's a thriving PICAxe market, but it's almost entirely schools. Because of that the documentation and examples are supposed to be pretty helpful and extensive, haven't you try checking the examples out?.
 
Nigel Goodwin said:
I was merely suggesting you try asking where people use them!, there's a thriving PICAxe market, but it's almost entirely schools. Because of that the documentation and examples are supposed to be pretty helpful and extensive, haven't you try checking the examples out?.


Well i have pretty much all the info i need within the PICAXE programming editor i downloaded, and its FULL of examples, but im having trouble with this particular code.
 
futz said:
Here is where interrupts get useful.

Page 60 in picaxe_manual1.pdf

If you can set an interrupt for that input pin, anytime it changes state normal program execution will be interrupted and an "interrupt service routine" piece of code will be called to handle whatever you want to happen.


Thanks!!!

i just tried the setint on my code, and it works exactly how i wanted it to :D
 
There is a PICAXE forum, but its crap, you post a thread and it takes days for people to reply :mad:

do you want me to go somewhere else and ask this questions???

I have always had good luck with the Picaxe forum. Someone has replied to every thread I have posted. Now they will NOT do your project or school assignment for you but will offer suggestions. Maybe it is a time zone thing with you.

As to the Picaxe being a toy, I find the different versions useful. I have used the BasicAtom, BX-24 and the Stamps and I think the 'axes hold their own against these. A serial port, two resistors and the free Program Editor and you're developing programs that can later be moved to a more capable micro if desired. I haven't had to do that yet. To each his own although I wish Picaxe would label their chips.

Al
 
alhoop you might be interested in Swordfish BASIC for the 18F, it's light years ahead of the Stamp & PICAxe
BRE
No doubt that Swordfish Basic when used with the !8F PICs is more powerful.
I guess I should have stated my application which is Model Railroad signalling. It is not like designing a logic analyzer where execution speed is very important, several hundreds of milliseconds execution time is more than adequate and the targeted audience will find the Picaxe code much easier to read and understand.

Regards
Al
 
Once you get a PIC programmer you don't need to buy PICAxe's, Atoms, Stamps or whatever. You can just buy any 18F PIC that suits your needs and they will always be cheaper per unit than preprogrammed PICs.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top