leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« on: October 13, 2010, 08:08:17 08:08 » |
|
Hi, Anybody built PIC based H-Bridge driver (i.e. L6203) for Bipolar stepper control (for CNC). I have seen nice PicStep driver @ http://www.fromorbit.com/projects/picstep but they used the chip LMD18245, which is not available in my country. Besides I need 4A/5A driver with microstepping and L6203 is a good choice for power drive. I'm actually looking for following features: - PIC based controller - MicroStepping - Current control - H-Bridge Bipolar stepper driver Thank you in advance.
|
|
|
Logged
|
|
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #2 on: October 13, 2010, 09:05:04 09:05 » |
|
Thanx cncbasher. I need the controller basically for my DIY CNC build. Currently I'm using home built TB6560 and L297/L6203 based driver for my different built. I'm now going to build a strong CNC for aluminium routing and I'll be using 5-6A (bipolar) stepper. I'm on a budget so I have to build the controller for my own. L297 doesn't provide microstepping and I'm thinking to replace it by PIC. I used Atmel/Arduino and never used PIC before. Searching...if someone already built the same on PIC. The link you have provided is for (LiniStepper) Unipolar drive and can't be used for Bipolar stepper. But if someone helps to modify/rewrite the code for Bipolar... :-)
|
|
|
Logged
|
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #3 on: October 14, 2010, 07:43:53 19:43 » |
|
I have drawn following (attached) schematic based on PicStep. My idea is to use existing PIC setup but just replacing the driver part and using H-Bridge (L6203) instead. In this case I don't need to change or rewrite the code for PIC. Appreciate if somebody take a look and provide his expert opinion. PicStep detail including code can be found here: http://www.fromorbit.com/projects/picstepI have also attached here there schematic for edge. Thanks.
|
|
« Last Edit: October 14, 2010, 08:52:23 20:52 by leaveme »
|
Logged
|
|
|
|
sphinx
Hero Member
Offline
Posts: 915
Thank You
-Given: 607
-Receive: 265
|
|
« Reply #4 on: October 14, 2010, 08:52:14 20:52 » |
|
why dont you test it in proteus, thats how i tested linuxstepper in it to see it working before i made pcb. if you search for linstepper you might find proteus files that you can change the design to your liking. it was some time ago i looked at linstepper so i am not sure if it can be done.
best regards
|
|
|
Logged
|
laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
|
|
|
mmladenovic
Newbie
Offline
Posts: 18
Thank You
-Given: 3
-Receive: 3
|
|
« Reply #5 on: October 14, 2010, 09:39:22 21:39 » |
|
I think that input 1 and input 2 are digital inputs (TTL). Read this document ( http://www.st.com/stonline/books/pdf/docs/8700.pdf) page 11 Sorry, my English is not so good. best regards Milan
|
|
|
Logged
|
|
|
|
Ichan
Hero Member
Offline
Posts: 833
Thank You
-Given: 312
-Receive: 392
|
|
« Reply #6 on: October 14, 2010, 11:03:40 23:03 » |
|
Your circuit need a chopper controller (usually comparator + set reset latch) between dac and L6203. Above 3A discrete mosfet is your best choice. Microchip already have several application notes about microstepping driver, and a very good source to learn is Luminary Micro Stellaris Stepper Motor Control Reference Design Kit (RDK) - http://www.luminarymicro.com/products/rdk_stepper.html-ichan
|
|
|
Logged
|
There is Gray, not only Black or White.
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #7 on: October 21, 2010, 06:55:05 06:55 » |
|
Guy's,
I'm experimenting the following using PIC16F84A to drive L298. But stepper spin is not as expected and I can't control some of the PIN's of PIC, i.e. B2....B8. Appreciate some help.
I have attached the Proteus sim file and PIC code.
|
|
|
Logged
|
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #8 on: October 22, 2010, 07:58:16 07:58 » |
|
Ok, little correction in the code. Now stepping sequence is right. Stepper is spining 45degree...135...225...315...in full stepping mode. byte PA[4] = { 0b00101, //315 0b00110, //225 0b01010, //135 0b01001 //45 }; But I still need help from the PIC expert to handle RB0...RB7 data line. For instance, I want to use RB2 & RB3 pin's as output to enable L298 (pin -6, 11).
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #9 on: October 22, 2010, 08:49:31 08:49 » |
|
Hi leaveme,
Sorry for late.
I did look at your circuit but not your program. I have change the properties of the stepper motor a bit (see note on the circuit. It run but still not good. You set the property to 90 degree/step which is too large. I set it to 1.8 degree/step which is normal for 200 steps per revolution.
Try to work on the program to see you can speed up (your circuit run too slow) and the logic of the output pins to the L298.
Hope I will have time to look at your program this weekend.
Meanwhile, keep work on,
Tom
Attatch is the modified circuit of your.
|
|
« Last Edit: October 22, 2010, 08:53:37 08:53 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #10 on: October 22, 2010, 10:11:01 10:11 » |
|
Thank you Tom. Sure, I can step up by the help from you guys. I did a little mod in the code for the simulation to work. I'm getting the idea for stepping sequence. But need some help for controlling Enable-A & Enable-B for L298. Take a look on the enable (output) sequence at L297. Seems it's as follow: A B 01 11 10 11 Regards.
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #11 on: October 23, 2010, 07:55:58 07:55 » |
|
Leaveme,
Here is a modified program and Proteus DSN for you to try.
I have modified the interrupt routine for FULL step using table of pattern. Enable A and B is not use; you can use them on your real circuit.
Modify the int routine for half-step and ¼ and 1/8 if you like. The stepper motor is modified to 3.6 degree per step (change it the way you like). Please look at the waveform on the scope for CW and CCW to see if they are good.
I think you can start the project from here.
Best luck,
Tom
Attached are Proteus dsn file, C source code and HEX file
|
|
« Last Edit: October 23, 2010, 08:00:23 08:00 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #12 on: October 24, 2010, 04:25:34 04:25 » |
|
Thanks Tom once again. So I don't need the following functions and they turned out to be useless now. void step(char dir) void init_stepper() One more clarification... In halfstep mode, is the coil driving in same pattern? Appreciate if you can suggest the pattern. It will help me to understand the difference. // Two phase for high torque --- use this instead --- BYTE const State_Table2[4] = { 0b0011, // state 0 0b0110, // state 1 0b1100, // state 2 0b1001 // state 3 };
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #13 on: October 24, 2010, 07:08:06 07:08 » |
|
try this for half step: 0011 0001 0110 1000 1100 0100 1001 0001
Tom
|
|
|
Logged
|
Con Rong Chau Tien
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #14 on: October 25, 2010, 01:08:29 01:08 » |
|
It was my intention to have the above code not works well, but, no complains. He! He!
Here is the step sequence works correctly for half-step:
// Two phase Half-Step for high torque --- use this instead --- BYTE const State_Table3[8] =
{0b1100, // step0 cai nay tot hon 0b0100, 0b0110, 0b0010, 0b0011, 0b0001, 0b1001, 0b1000}; // step7 Con Rong Chau Tien
In the int routine modify the case so it can chk up to step7
That is done for this,
Tom
|
|
« Last Edit: October 25, 2010, 01:27:20 01:27 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #15 on: October 25, 2010, 07:22:48 07:22 » |
|
Thanks buddy. I was busy yesterday for official work and couldn't test your half stepping.
Anyway, I'll be actually using it for full, half, 1/4 and 1/8th stepping mode. Will use RB6 & RB7 (pin's) as stepping selector. Though I'm not sure whether PIC16F84A can accommodate my whole program. Any replacement idea...?
By the way, Tom, seems you're from Vietnam, right?
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #16 on: October 25, 2010, 08:33:31 08:33 » |
|
leaveme,
Think about how many stepper motor you will use for your system then decide how many pin you need. More motor more code, more code more features. Few extra pins unused could not hurt any thing.
Tom
|
|
« Last Edit: October 25, 2010, 08:35:38 08:35 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #17 on: October 25, 2010, 08:51:00 08:51 » |
|
Well, I'll be using one PIC for each stepper. I choose 16F84A because it is readily available in my local electronics shop. For others, I have to order at online and that takes lot of time. Besides it has very little memory and CCS frequently complaining (during compilation) about memory.
|
|
|
Logged
|
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #18 on: November 01, 2010, 06:20:47 06:20 » |
|
Thanx guy's, I'm near to finish the simulation part. I'll now build the PCB to see about how it performs. Though, I still couldn't find the way to implement microstepping.
My actual implementation will be like this: Logic_Controller>Current_Controller>Motor_Driver PIC16FXX>L6506>2xL6203
Following is the output from Oscilloscope for different stepping mode. I need help from you for 1/4th microstepping. Full step index (sequence) - 2phase high torque: 0b0011, // state 0 0b0110, // state 1 0b1100, // state 2 0b1001 // state 3
Half step index (sequence) - 2phase high torque: 0b1000, // step 0 0b1001, // step 1 0b0001, // step 2 0b0011, // step 3 0b0010, // step 4 0b0110, // step 5 0b0100, // step 6 0b1100 // step 7
1/4th step index (sequence) - NOT WORKING: 0b1000, // step 0 0b1101, // step 1 0b1001, // step 2 0b1000, // step 3 0b0001, // step 4 0b0011, // step 5 0b0011, // step 6 0b0001, // step 7 0b0010, // step 8 0b0110, // step 9 0b0110, // step 10 0b0010, // step 11 0b0100, // step 12 0b1100, // step 13 0b1100, // step 14 0b0100 // step 15
|
|
« Last Edit: November 01, 2010, 09:01:57 09:01 by leaveme »
|
Logged
|
|
|
|
Ichan
Hero Member
Offline
Posts: 833
Thank You
-Given: 312
-Receive: 392
|
|
« Reply #19 on: November 01, 2010, 08:56:26 20:56 » |
|
Better then half step then current modulation is needed, that is the DAC thing playing its role.
I just look closer to the Picstep schematic, I think the LMD18245 can be replaced by L6506 + L6203 or even simpler by an L6207, a logic inverter will be needed to combine 2 inputs of the driver into one.
-ichan
|
|
|
Logged
|
There is Gray, not only Black or White.
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #20 on: November 02, 2010, 09:16:09 09:16 » |
|
L6207 is a DIP package and it's very difficult to heatsink it. L6506+L6203 combo is a better choice in this case.
I'm actually not familier with ASM, can't understand the coding for PicStep....
|
|
|
Logged
|
|
|
|
leaveme
Junior Member
Offline
Posts: 93
Thank You
-Given: 38
-Receive: 15
|
|
« Reply #21 on: November 09, 2010, 09:57:09 09:57 » |
|
I redesigned the circuit to introduce microstepping. So what I did is, I used a PIC16F84A to generate step sequence (which I have to provide in logic input at L6506) and another PIC16F628A for current modulation.
I have a question to TOM or other PIC experts: can I use one PIC for both the purpose?
Thank you in advance.
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #22 on: November 09, 2010, 04:30:52 16:30 » |
|
Leaveme,
The answer to your question is YES and NO (with my limit knowledge about stepper motor). NO: If you connected L6506 and L298 together. The L6506 has only 4 pins for phase input; the output is connected to the L298 so you don’t need to use TWO PIC. If you don’t connected them together then the sense current can connect to ADC to control the current. But, how you are going to control the L6506 and L298.
YES: If you connected L6506 and L298 together. It is possible to drive the stepper motor in microstep but the phase input to the L6506 is very complex. Since you have only FOUR phase input; you need to arrange what phase is on, what phase is off and the timing of ON/OFF to get the current pattern for microstepping. You could use PWM (two or four) to generate the phase sequence for microstep. Now is the time to move on to the higher end PIC that provide 5 or 8 PWM.
Quote by data sheet: “The L6506 may also be used to implement microstepping of either bipolar or unipolar motors”.
Please research so you can implement the L298 with microstep. Post here what you find for discussion.
Regards,
Tom
|
|
« Last Edit: November 09, 2010, 04:33:31 16:33 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
Ichan
Hero Member
Offline
Posts: 833
Thank You
-Given: 312
-Receive: 392
|
|
« Reply #23 on: November 09, 2010, 06:19:00 18:19 » |
|
Yes, and mostly use only one uC.
Have you read microchip application notes on stepper motor?
There is another old app note on allegro micro web site that use PIC, find it on the A3955 page.
-ichan
|
|
|
Logged
|
There is Gray, not only Black or White.
|
|
|
PaulHolland
Guest
|
|
« Reply #24 on: November 09, 2010, 07:24:13 19:24 » |
|
Hi All.
Here a very low cost and simple H-Bridge design using only low cost mosfets !!!.. For fast switching make 3K3 smaller if needed..
Operation:
Control A Control B 0 0 Motor without VCC 1 0 Motor turns left 0 1 Motor turns right 1 1 Motor Brakes
BSS138 are used to prevent shoot-through of H-Bridge.
|
|
« Last Edit: November 09, 2010, 07:39:26 19:39 by PaulHolland »
|
Logged
|
|
|
|
|