
Stepper Motor help
Stepper Motor help
I need help. Objective: To use the PC parallel port to drive a stepper motor to left and right. The pin RB0 is for Step. The pin RB1 for direction. The signal at pin direction is high and low (0 or 1) and the signal on pin RB0 is a 1KHz clock. The PIC is a 16F628A used. How to proceed?


- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Stepper Motor help
Hi,
How are you planning to use parallel port to control the stepper motor as in your description you just mentioned about pic not anything about interfacing between parallel port to pic. By the way which os you are using. You need buffer ic between pic and pc to protect your mother board. No level conversion ic is needed as parallel port uses TTL logic. You need to know which parallel port you are using. I mean is that standard parallel port or extended parallel port. In standard you can't use hand shaking mode but in extended one you can use hand shaNong. In xp and later os you have to unmusk the parallel port as that is musked by os.
How are you planning to use parallel port to control the stepper motor as in your description you just mentioned about pic not anything about interfacing between parallel port to pic. By the way which os you are using. You need buffer ic between pic and pc to protect your mother board. No level conversion ic is needed as parallel port uses TTL logic. You need to know which parallel port you are using. I mean is that standard parallel port or extended parallel port. In standard you can't use hand shaking mode but in extended one you can use hand shaNong. In xp and later os you have to unmusk the parallel port as that is musked by os.
Re: Stepper Motor help
Hi... Thanks for the reply. I do not speak English and use Google translator for our conversation, sorry if you do not understand everything clearly. You're right, I use XP. Pin 2 and 3 of the DB25 port (SPP mode) makes the step and direction. The software is Mach3.
Do you think I should use optocouplers?
Do you think I should use optocouplers?
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Stepper Motor help
Hi,
If you have access in language support forum you can post there..I can reply by Google translation. Mach3, I guess is a CNC control program; Is it so? SO you might be trying to make some kind of CNC. Opto-coupler is obvious thing to use as I have mentioned. There are some buffer ICs available you can use those or can use opto-coupler for each bit.
If you have access in language support forum you can post there..I can reply by Google translation. Mach3, I guess is a CNC control program; Is it so? SO you might be trying to make some kind of CNC. Opto-coupler is obvious thing to use as I have mentioned. There are some buffer ICs available you can use those or can use opto-coupler for each bit.
Re: Stepper Motor help
Yes, you are correct again.
Mach3 is for cnc machine control. I build machines in my home workshop. (http://www.cncgladiador.com).
WHAT I need is to implement a Driver to control stepper motors of these machines.
Using the TMR0 the pic 16f628 with Flowcode?
Mach3 is for cnc machine control. I build machines in my home workshop. (http://www.cncgladiador.com).
WHAT I need is to implement a Driver to control stepper motors of these machines.
Using the TMR0 the pic 16f628 with Flowcode?
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Stepper Motor help
Hi,
That looks great
I am really interested in CNC machine. In fact I was thinking to make one for PCB making. I have seen one in my friend's workshop couple of years back in my early days of PIC. I can help you in writing the code in FC. Can you please help me in making one CNC? I will be really grateful to you.
That looks great
Re: Stepper Motor help
Yes, I can help you in building your Cnc-pci. We can do her project together, and need to exchange many emails. - ojsvargas@gmail.com 
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Stepper Motor help
Hi,
Thanks for the email address. I will make something for you which can control stepper motor depending on the parallel bits you mentioned.
Thanks for the email address. I will make something for you which can control stepper motor depending on the parallel bits you mentioned.
Re: Stepper Motor help
When you have something you can send me by email.
Would like to know how you intend to build your CNC-pci, you have knowledge of MIG welding, electronics and a bit of Metallurgy or intend to do just MOUNT party?
Has knowledge of CAD / CAM?
In that part of the job you need help?
Would like to know how you intend to build your CNC-pci, you have knowledge of MIG welding, electronics and a bit of Metallurgy or intend to do just MOUNT party?
Has knowledge of CAD / CAM?
In that part of the job you need help?
-
bercioiu
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: Stepper Motor help
Good evening Mr. Enamul.
Any progress of this project ?
I`m interested on that project to. I saw that the other one (of the S.K.S. is on the dead line). I have an controller (an analog one with 4013 and FET) for my CNC but I want to make my own design based on the PIC and L298. I don`t know what is the best solution: to make one controller for all 3 axis controlled by one PIC let`s say 16F877A or to make 3 separate drivers with 3 PIC 16F88. What is your opinion?
Thank you in advance!
Any progress of this project ?
I`m interested on that project to. I saw that the other one (of the S.K.S. is on the dead line). I have an controller (an analog one with 4013 and FET) for my CNC but I want to make my own design based on the PIC and L298. I don`t know what is the best solution: to make one controller for all 3 axis controlled by one PIC let`s say 16F877A or to make 3 separate drivers with 3 PIC 16F88. What is your opinion?
Thank you in advance!
Re: Stepper Motor help
I have started a project using PIC 16f628 but as I have no time, the project has stalled. In my opinion make a plate for the three engines is better because it only works with cnc 3 axis. (http://www.cncgladiador.com/eletronica/stepper/).Use the google translator because I can not speak English, sorry. 
-
bercioiu
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: Stepper Motor help
Do you have a schematic for that driver?
I can`t find there. How do you power the motor and how do you limit the current for the motor. Thank you!
I can`t find there. How do you power the motor and how do you limit the current for the motor. Thank you!
-
Steve001
- Valued Contributor

- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: Stepper Motor help
hello attached is a pin out for the lpt printer or parallell port for cnc control which they say is compatable with mach3 or emc2
they recommend that you dont use opto isolators due to to current draw on the port.
If you wish to isolate the port they recommend that you use rf digital signal isolators.
steve
they recommend that you dont use opto isolators due to to current draw on the port.
If you wish to isolate the port they recommend that you use rf digital signal isolators.
steve
Success always occurs in private and failure in full view.
-
bercioiu
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: Stepper Motor help
Thank you STEVE for the breakout scheme.
As I said before, I want to design my own controller and driver for my CNC. I have some knowledge in the Flowcode and I read more about that issue. If there is someone who can guide me I`ll appreciate.
Next is a long "don`t know how to" list :
1. What is the best way to approach that? One single PIC for entire controller or three PICs for all three axes?
2. STEP and DIR signals from LPT have to be treated in the interrupt of the PIC? If yes, what is the recommended frequency of the interrupt (and of course of the PIC) knowing that the maxim recommended frequency in Mach3 is 25KHz ?
3. In Flowcode what is the best solution: the motor is enabled in the beginning of the program or after the STEP command has received ?
4. After the increment/decrement the motor has done, the very next step is to put some delay ? If yes, what is the amount of that delay?
5. It is a god practice that if a period of time the controller don`t received any signals from LPT to disable the motor? If yes, what is the amount of that time?
6. For limiting the current that flow thru the motors, can I read the current that flow thru the R sense on the L298 (pin 1 and 15) with the ADC? If yes, what shall I do with the measured tension? I have to compare with an reference tension ? Or I have to put in the program a variable for the limit current and compare with it?
I have a lot more but for the moment this are the "strictly necessary" to start the project. Thank you for your time spent reading this.
As I said before, I want to design my own controller and driver for my CNC. I have some knowledge in the Flowcode and I read more about that issue. If there is someone who can guide me I`ll appreciate.
Next is a long "don`t know how to" list :
1. What is the best way to approach that? One single PIC for entire controller or three PICs for all three axes?
2. STEP and DIR signals from LPT have to be treated in the interrupt of the PIC? If yes, what is the recommended frequency of the interrupt (and of course of the PIC) knowing that the maxim recommended frequency in Mach3 is 25KHz ?
3. In Flowcode what is the best solution: the motor is enabled in the beginning of the program or after the STEP command has received ?
4. After the increment/decrement the motor has done, the very next step is to put some delay ? If yes, what is the amount of that delay?
5. It is a god practice that if a period of time the controller don`t received any signals from LPT to disable the motor? If yes, what is the amount of that time?
6. For limiting the current that flow thru the motors, can I read the current that flow thru the R sense on the L298 (pin 1 and 15) with the ADC? If yes, what shall I do with the measured tension? I have to compare with an reference tension ? Or I have to put in the program a variable for the limit current and compare with it?
I have a lot more but for the moment this are the "strictly necessary" to start the project. Thank you for your time spent reading this.
-
Steve001
- Valued Contributor

- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: Stepper Motor help
for current messuring i would look at this post and set a alarm led at one level and at a higher level enable the em stop input
http://www.matrixmultimedia.com/mmforum ... it=asc+712
as to using one pic or severel to control the motor's i am not too sure maybe somebody on here could advise you better
if your looking at using a L298 have a look at it's mate the L297
http://www.st.com/internet/com/TECHNICA ... 000063.pdf
digital isolator guide here
http://www.ti.com/lit/an/slla284/slla284.pdf
there are quite a few web site about home brew cnc machines
http://www.cncroutersource.com/
http://buildyourcnc.com
https://probotix.com/ - this is quite a good one as it has calcs for motor loading
steve
http://www.matrixmultimedia.com/mmforum ... it=asc+712
as to using one pic or severel to control the motor's i am not too sure maybe somebody on here could advise you better
if your looking at using a L298 have a look at it's mate the L297
http://www.st.com/internet/com/TECHNICA ... 000063.pdf
digital isolator guide here
http://www.ti.com/lit/an/slla284/slla284.pdf
there are quite a few web site about home brew cnc machines
http://www.cncroutersource.com/
http://buildyourcnc.com
https://probotix.com/ - this is quite a good one as it has calcs for motor loading
steve
Success always occurs in private and failure in full view.
-
bercioiu
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: Stepper Motor help
Thank you Steve001 for the links! I appreciate this!
I have read all sorts of opinions and finally I decided to make a driver for each axis and a breakout board. I made a sketch with a 16f88.
This are the 10 commander of the driver:
1. STEP signal from the breakout board will be treated on RB0 INT.
2. DIR (CW/CCW) from the breakout board to RA4
3. ENABLE from pic (RB3) to L298 for chopper
4. FULL STEP / HALF STEP AND WAVE will be set from two dip switch (or jumpers) on RA2 and RA3
5. Reference tension for chopper will be on AN0 (RA0)
6. SENS is the tension measured on the sense resistor of the L298.
7. IN1 to IN4 are the outputs from pic (RB4-RB7) to L298 for stepper motor.
8. Quartz 19,660800 MHz
9. External reset.
10. There are two spear pins that I will probably use to communicate with the breakout board for an LCD or some jog switch etc, will see.
For chopper I will read the tension on the sense resistor of the L298 and compare that tension with a preset tension.When the tension on the R sens is bigger than preset tension, the pic will cut the enable of the L298. Any opinion ? Its a good idea ?
I`m not sure too about the increment/decrement stepper on Flowcode... I don`t know what is the correct way to enable, increment/decrement, disable stepper...
In this link is the flowcode file. The file is bigger then 256 Kb because I made a custom panel and in the rar file attached are the simulation in ISIS, the hex file and a PDF with schematic of the driver.
I`ll appreciate any help from you.
I have read all sorts of opinions and finally I decided to make a driver for each axis and a breakout board. I made a sketch with a 16f88.
This are the 10 commander of the driver:
1. STEP signal from the breakout board will be treated on RB0 INT.
2. DIR (CW/CCW) from the breakout board to RA4
3. ENABLE from pic (RB3) to L298 for chopper
4. FULL STEP / HALF STEP AND WAVE will be set from two dip switch (or jumpers) on RA2 and RA3
5. Reference tension for chopper will be on AN0 (RA0)
6. SENS is the tension measured on the sense resistor of the L298.
7. IN1 to IN4 are the outputs from pic (RB4-RB7) to L298 for stepper motor.
8. Quartz 19,660800 MHz
9. External reset.
10. There are two spear pins that I will probably use to communicate with the breakout board for an LCD or some jog switch etc, will see.
For chopper I will read the tension on the sense resistor of the L298 and compare that tension with a preset tension.When the tension on the R sens is bigger than preset tension, the pic will cut the enable of the L298. Any opinion ? Its a good idea ?
I`m not sure too about the increment/decrement stepper on Flowcode... I don`t know what is the correct way to enable, increment/decrement, disable stepper...
In this link is the flowcode file. The file is bigger then 256 Kb because I made a custom panel and in the rar file attached are the simulation in ISIS, the hex file and a PDF with schematic of the driver.
I`ll appreciate any help from you.
- Attachments
-
- 16F88_L298.rar
- (37.3 KiB) Downloaded 385 times
-
- driver_16f88_l298.jpg
- (151.15 KiB) Downloaded 1457 times