Hi, I am building a CNC driver with PIC 16f628a that goes connected to the parallel port. It will be a simple 3-axis CNC router.
I made a program for the pic that verifies the state of step and dir.
So it is something like this (THIS IS NOT THE REAL CODE, obviously):
:loop
if xstep = 1 then goto xmakestep
the same with the other axis
goto loop
:xmakestep
if xdir = 1 then goto xstepforward
else goto xstepbackwards
:xstepforward
if whatstepx = 0 then whatstep = 1
else if whatstepx = 1 then whatstep = 2
else if whatstepx = 2 then whatstep = 3
else if whatstepx = 3 then whatstep = 0
end if
(HERE'S WHERE THE QUESTIONS START)
if whatstep = 1 then port1 = 1
pause HOW MUCH TIME???
low port1
goto loop
else if whatstep = 2 then port2 = 1
BLAH BLAH THE SAME AS ABOVE
The backward step is the same as forward but backwards:D:D
I am using turboCNC, I did not build the CNC machine yet but I am starting with this.
The code I don't know if it is OK, I just felt It was the right way to do it.
THE REASON I AM USING A PIC TO CONTROL THE CNC:
I am using a pic instead of using up/down counters and decoders, but I will need to use one decoder because there is not enough ports in this PIC.
(Maybe then moving to other pic)
So the final question is: How much time I will need to make an output stay high? Is the code OK?
Regards,
Facundo, 15, from Argentina
Excuse me for my bad english.
I made a program for the pic that verifies the state of step and dir.
So it is something like this (THIS IS NOT THE REAL CODE, obviously):
:loop
if xstep = 1 then goto xmakestep
the same with the other axis
goto loop
:xmakestep
if xdir = 1 then goto xstepforward
else goto xstepbackwards
:xstepforward
if whatstepx = 0 then whatstep = 1
else if whatstepx = 1 then whatstep = 2
else if whatstepx = 2 then whatstep = 3
else if whatstepx = 3 then whatstep = 0
end if
(HERE'S WHERE THE QUESTIONS START)
if whatstep = 1 then port1 = 1
pause HOW MUCH TIME???
low port1
goto loop
else if whatstep = 2 then port2 = 1
BLAH BLAH THE SAME AS ABOVE
The backward step is the same as forward but backwards:D:D
I am using turboCNC, I did not build the CNC machine yet but I am starting with this.
The code I don't know if it is OK, I just felt It was the right way to do it.
THE REASON I AM USING A PIC TO CONTROL THE CNC:
I am using a pic instead of using up/down counters and decoders, but I will need to use one decoder because there is not enough ports in this PIC.
(Maybe then moving to other pic)
So the final question is: How much time I will need to make an output stay high? Is the code OK?
Regards,
Facundo, 15, from Argentina
Excuse me for my bad english.