Code for driver motor not working

lamxe

Senior Member
Dear All
I wrote this code for the driver motor of the solenoid coil machine but it doesn't work. Please help me correct it for working many thank you.
Best regards
lam
#Picaxe 08M

Symbol PIN_IN = pin3
Symbol counter = b0

main:
if b1<30 then forw
if b1>30 then bak


goto main

forw:
Gosub WaitForPulse
inc b0
inc b1
if b0=2 then high 1 low 2
endif
if pin4=1 then low 1 low 2
endif
b0=0
goto main
bak:

Gosub WaitForPulse
inc b1
inc b0
if b0=2 then high 2 low 1
endif
if pin4=1 then low 2 low 1
endif
b0=0
goto main
Gosub WaitForPulse
goto main
rese:
b1=0; loop for new cycle
goto main

WaitForPulse:
Do : Loop While PIN_IN =1
Do : Loop Until PIN_IN = 1
Return

#Picaxe 08M

Symbol PIN_IN = pin3
Symbol counter = b0

main:
if b1<5 then forw
if b1>5 then bak
if b1=10 then rese
goto main

forw:
Gosub WaitForPulse
inc b0
inc b1
if b0=2 then high 1 low 2
endif
if pin4=1 then low 1 low 2
endif
b0=0
goto main
bak:

Gosub WaitForPulse
inc b1
inc b0
if b0=2 then high 2 low 1
endif
if pin4=1 then low 2 low 1
endif
b0=0
goto main
Gosub WaitForPulse
goto main
rese:
b1=0; loop for new cycle
goto main

WaitForPulse:
Do : Loop While PIN_IN =1
Do : Loop Until PIN_IN = 1
Return
 
Last edited:

Jack Burns

New Member
Dear All
I wrote this code for the driver motor of the solenoid coil machine but it doesn't work. Please help me correct it for working many thank you.
Best regards
lam
In what way does it not work?
If you could provide further information so we know what the code is supposed to do, then someone should be able to help.

In the meantime, the following code doesn't allow for when b1 = 5, so your code will always get stuck within that loop once b1 reaches a value of 5. This also means the value of b1 will never change as the code will never branch to forw or bak.
Code:
main:
if b1<5 then forw
if b1>5 then bak
if b1=10 then rese
goto main
 

Jack Burns

New Member
I’m struggling to see your photos as they are far too small to see any detail. Would you be able to post some larger ones?

At the moment I have more questions than answers:
  1. Can you post your circuit diagram?
  2. How do you ensure the guide starts from a known position?
  3. How are you detecting the end of each wire layer?
  4. What controls the speed of the guide moving side to side (gearing?)
 

oracacle

Senior Member
As far as i can tell:
Motor "w" turns 3 times. During this period motor "g" turns 1 time - I assume this is done machanically and not controlled by the picaxe
At each trun, each motor generates a pulse (via switch?)
So there should be 3 pulses read from motor "w", at which point motor "g" changes direction.

So if we assume we start from a fixed poistion:
1) Set both motors going
2) Monitor pulses from motor "w"
3) when motor "w" pulses = 3 reverse motor "g"
4) incrment layer count and check for time to stop machine
5) Repeat steps 2-4 until desired layer count is reached
6) End programme

Things that may need to be addressed:
are the motor speed controlled by the picaxe
would it be better to look for a single pulse from motor "g" instead of 3 fro motor "w"
we need a circuit digram so we can identify any issues that may arrise there
 

hippy

Technical Support
Staff member
Motor "w" turns 3 times. During this period motor "g" turns 1 time - I assume this is done machanically and not controlled by the picaxe

So there should be 3 pulses read from motor "w", at which point motor "g" changes direction.
I am guessing this relates to https://picaxeforum.co.uk/threads/not-go-to-subsection-in-programing.32531/#post-339373

What I couldn't tell from the description is what the mechanics are; whether we have a guide motor which traverse left to right and right to left actively guiding the wire, or whether there is a guide channel which is placed left or right and thrown between those two positions by the guide motor.

Whether the PICAXE is directly controlling the guide motor, or controlling something which dictates what the guide motor will be doing.
 

oracacle

Senior Member
There were some very small pictures, from I could tell the motor was turning some sort of lead screw with the guide or winding head on it
 
Top