project script problem

chucky315

New Member
hi my name is chuck im a student doing a picaxe project for my year 12 assignment and i need so assistance with my script.
im building a project the goes backwards and forwards on a cable.
i want the project to go one way then hit a switch and go the other way and hit the other switch and then go back the other way and just keep repeating that.

this is the script i have done so far but i just can't get it to work correctly

chuck:
if input0 = 0 then Straight
if input0 = 1 then goto chook

goto chook

chook:
if input2 = 0 then backwards
if input3 = 1 then goto chuck

goto chuck



backwards:
low 0
high 1
low 2
high 4
goto chuck

Straight:
high 0
low 1
high 2
low 4
goto chuck



if someone could please help it would be much appreciated

kindly chuck
 

grim_reaper

Senior Member
Obviously, being a student, I don't know how much you've learned about writing this sort of code (my son's not as old as you, so he hasn't got to the good stuff yet!). But my first bit of advice is to logically following the script through in your head.

First clue: your check of input3 is irrelevant. Whether this is by accident or a by-product of you trying to get it to work, you'll have to tell us.
 

Buzby

Senior Member
Hi Chuck,

It's been a long time since I was a student, but I'm still learning.

One thing I learned with PICAXE is to use the simulator, it's the programmer's best friend !.

Put your code in the simulator, then you will see exactly what it is, or isn't, doing.

Cheers,

Buzby
 

oracacle

Senior Member
it would be very helpful to a schematic, however, you are going to a proceedure and the going back, however you have not tekn into account that once the item has moved to deactiveate both switches all arcuments could be null (this is why a schematic is needed).

depedning on how thing are wired, there maybe a very simple way of calling the loop for movement
 

marks

Senior Member
Welcome to the forum chucky315,
assuming you only what two switches perhaps try something like this

ForwardsChucky:
low 1,4
high 0,2
if input0 = 1 then BackwardsChucky
goto ForwardsChucky

BackwardsChucky:
low 0,2
high 1,4
if input3 = 1 then ForwardsChucky
goto BackwardsChucky
 

westaust55

Moderator
It would also be worthwhile posting your entire code and advising which PICAXE chip you are using.

What are the Symbol assignments for input1 and input2 or input3 ?
eg SYMBOL input1 = 1 for older PICAXE parts or SYMBOL input1 = B.1 for newer parts
There will be a significant different between a newer M2 or X2 chip and an older M or X1 PICAXE chip.

What type of motor are you using and is there one or two motors for moving back and forth?
A simple DC motor via an L293D will work as proposed but if it is a steppper motor then more changes in the outputs are required to keep the motor turning.
 

oracacle

Senior Member
It would also be worthwhile posting your entire code and advising which PICAXE chip you are using.

What are the Symbol assignments for input1 and input2 or input3 ?
eg SYMBOL input1 = 1 for older PICAXE parts or SYMBOL input1 = B.1 for newer parts
There will be a significant different between a newer M2 or X2 chip and an older M or X1 PICAXE chip.

What type of motor are you using and is there one or two motors for moving back and forth?
A simple DC motor via an L293D will work as proposed but if it is a steppper motor then more changes in the outputs are required to keep the motor turning.
this is why i asked for a schematic, it should give us all the info required, including how each of the switches are wire, although it wont give any info on weather a switch activation will drive the pin low or high which maybe a significant factor in how the programme has to be writen
 

chucky315

New Member
Marks thank you so much that's exactly what i was after i can't tell you how much you assistance means to me

thanks again
chucky315
 
Top