[code]
#chip PIC16F84A, 20 MHz
#define Xinputstep PORTA.1
#define Xinputdirection PORTA.2
#define Xmotoroutput1 PORTB.0
#define Xmotoroutput2 PORTB.1
#define Xmotoroutput3 PORTB.2
#define Xmotoroutput4 PORTB.3
ADOff
DIR Xinputdirection IN
DIR Xinputdirection IN
DIR Xmotoroutput1 OUT
DIR Xmotoroutput2 OUT
DIR Xmotoroutput3 OUT
DIR Xmotoroutput4 OUT
If xinputstep = ON THEN
If Xinputdirection = ON THEN
Will pulse out work or should I use set? set on and then set off for a specific time?
The ouput of the parrallel port for the cnc program is a high (low voltage actually) for a step and the direction is either a high(for one direction or low for the opposite). I have defined 1 direction but I need a bit of help figuring out the other.
Can you use [ELSE]?
Could I rewrite the first bit
(
If xinputstep = ON THEN
If Xinputdirection = OFF THEN
+ the opposite motor sequence?
)
Is their a easier way!!??
First program ever so it might be really crappy!!!
Also could you take a quick look for any mistakes - im so excited to learn about the motor control in general -my dog needs to go out every morning at 5am - im thinking automatic sliding door!!
Thanks in advance, Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
**Code amended**
How do you use the internal clock aswell, or should i buy a 4mhz crystal? still have to do Y axis.
#chip PIC16F84A, 4 MHz
#define Xinputstep PORTA.1
#define Xinputdirection PORTA.2
#define Xmotoroutput1 PORTB.0
#define Xmotoroutput2 PORTB.1
#define Xmotoroutput3 PORTB.2
#define Xmotoroutput4 PORTB.3
ADOff
DIR Xinputdirection IN
DIR Xinputdirection IN
DIR Xmotoroutput1 OUT
DIR Xmotoroutput2 OUT
DIR Xmotoroutput3 OUT
DIR Xmotoroutput4 OUT
start:
If xinputstep ON THEN
If Xinputdirection ON THEN
[code]
#chip PIC16F84A, 20 MHz
#define Xinputstep PORTA.1
#define Xinputdirection PORTA.2
#define Xmotoroutput1 PORTB.0
#define Xmotoroutput2 PORTB.1
#define Xmotoroutput3 PORTB.2
#define Xmotoroutput4 PORTB.3
ADOff
DIR Xinputdirection IN
DIR Xinputdirection IN
DIR Xmotoroutput1 OUT
DIR Xmotoroutput2 OUT
DIR Xmotoroutput3 OUT
DIR Xmotoroutput4 OUT
If xinputstep = ON THEN
If Xinputdirection = ON THEN
PULSEOUT xmotoroutput1, 10us
WAIT 10us
PULSEOUT xmotoroutput1, 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput4, 10us
PULSEOUT xmotoroutput1, 10us
END IF
END IF
Will pulse out work or should I use set? set on and then set off for a specific time?
The ouput of the parrallel port for the cnc program is a high (low voltage actually) for a step and the direction is either a high(for one direction or low for the opposite). I have defined 1 direction but I need a bit of help figuring out the other.
Can you use [ELSE]?
Could I rewrite the first bit
(
If xinputstep = ON THEN
If Xinputdirection = OFF THEN
+ the opposite motor sequence?
)
Is their a easier way!!??
First program ever so it might be really crappy!!!
Also could you take a quick look for any mistakes - im so excited to learn about the motor control in general -my dog needs to go out every morning at 5am - im thinking automatic sliding door!!
Thanks in advance, Chris
**Code amended**
How do you use the internal clock aswell, or should i buy a 4mhz crystal? still have to do Y axis.
#chip PIC16F84A, 4 MHz
#define Xinputstep PORTA.1
#define Xinputdirection PORTA.2
#define Xmotoroutput1 PORTB.0
#define Xmotoroutput2 PORTB.1
#define Xmotoroutput3 PORTB.2
#define Xmotoroutput4 PORTB.3
ADOff
DIR Xinputdirection IN
DIR Xinputdirection IN
DIR Xmotoroutput1 OUT
DIR Xmotoroutput2 OUT
DIR Xmotoroutput3 OUT
DIR Xmotoroutput4 OUT
start:
If xinputstep ON THEN
If Xinputdirection ON THEN
PULSEOUT xmotoroutput1, 10us
WAIT 10us
PULSEOUT xmotoroutput1, 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput4, 10us
PULSEOUT xmotoroutput1, 10us
END IF
If Xinputdirection OFF THEN
PULSEOUT xmotoroutput4, 10us
PULSEOUT xmotoroutput1, 10us
WAIT 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
PULSEOUT xmotoroutput4, 10us
WAIT 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
PULSEOUT xmotoroutput3, 10us
WAIT 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput1, 10us
PULSEOUT xmotoroutput2, 10us
WAIT 10us
PULSEOUT xmotoroutput1, 10us
END IF
END IF
goto start
RETURN
hey I was compiling to HEX and got this ""Register in operand not in bank 0. Ensure that bank bits are correct."" should I be worried?
>hey I was compiling to HEX and got this ""Register in operand not in bank 0. Ensure that >bank bits are correct."" should I be worried?
No... don't worry that's just an informative message from assembler, GCBasic takes care about bank issues...
thanx for the reply Im building the circuit now i'll see if this code approah goes alright compared to an array