Whilst this was written some time ago, the subject crops up every now and again, so may be useful to some folks. Written for a 4-wire Stepper Motor...
Melanie
Whilst this was written some time ago, the subject crops up every now and again, so may be useful to some folks. Written for a 4-wire Stepper Motor...
Melanie
Fantastic Mel.. I shall give this a go. You wouldn't happen to have a schematic of the circuit at all?
I did this about a year ago on request from another piclist member. In the code you will see where the each individual windings are connected. The actual arrangement will depend on your stepper... naturally you will have to use a driver circuit suitable for your stepper's demand. If you want a test and a light-show, connect LED's (with series Resistors) to represent each winding.
Mel,
I see in your program you go to half step.
How difficult would it be to increase it 1/256th step?
I am trying to configure o stepper drive system
that would allow this. I am not sure about the coding tho.
DougB
oooohhhh.... let's think about this...
Do you really mean 1/256th of a single step... or do you mean there are 256 steps in a revolution and you mean 1/256th of a Revolution?
Most (though not all) stepper motors have four coils. We'll call them A, B, C and D. A step is when we rotate the shaft from one set of coils to the next... Let's also say that coil A is our starting sequence (it doesn't have to be, but for our example it is)...
A to B = A is energised, then de-energise A and energise B = 1st step
B to C = B is energised, then de-energise B and energise C = 2nd step
C to D = C is energised, then de-energise C and energise D = 3rd step
D to A = D is energised, then de-energise D and energise A = 4th step
the cycle now repeats from the top.
This is the conventional way a Stepper Motor rotates. Now the number of steps you have per revolution depends on your actual stepper motor. There's dozens and dozens of variants. Steppers are usually specified in a step angle (eg 1.8 Degrees per Step, or 7.5 Degrees per step), usually a figure divisible evenly into 360 (one rotation). So the 1.8 Degree stepper needs 200 steps for a revolution.
You can drive most Steppers in half-steps... like so...
A only is energised = 1st step
A to AB = B is additionally energised (A+B energised) = 1.5 step
B only is energised = 2nd step
B to BC = C is additionally energised (B+C energised) = 2.5th step
C only is energised = 3rd step
C to CD = D is additionally energised (C+D energised) = 3.5th step
D only is energised = 4th step
D to DA = A is additionally energised (D+A energised) = 4.5th step
the cycle repeats from the top
With this 'half-step' arrangement you now double the steps of your stepper making it twice as accurate. So if you had a Stepper that needed 200 steps per revolution (our 1.8 Degree Stepper above), you now can give it 400 half-steps to achieve the same result (which means we've an achieved an accuracy of 0.9 Degrees with our 1.8 Degree Stepper)
Naturally you can reverse the sequence from any point to drive backwards.
Now, can we take that 1.8 Degree step and achieve an accuracy of 1/256th of our 1.8 Degrees? - in other words 0.007 Degree micro-steps?... the answer is No. I've not seen a Stepper with such a complex coil phasing arrangement that it allows 256 micro-steps per individual step. But point me to a Datasheet if you know of one. Trust me, if it exists, we can drive it.
0.007degrees per microstep
http://www.indoor.flyer.co.uk/stepperdriver.htm
http://www.allmotion.com/EZHR17ENDescription.htm
Luciano
Very clever... using a standard four coil stepper too... must find out more how they've achieved this.
I am using a microstepper from allmotion that microsteps at 1/256th step per step input
I plan to use a 16F676 to provide step & direction signals to the motor controller
I have a -5v to +5v input siggnal to the pic a/d
How do I configure the pic to apply the hightest resolution on the input
and calculate the steps & direction for the output.
I am stumped right now.
0v means the motor doesn't move.
the input signal is derived from an electrolytic tilt sensor condtioning board
Well first of all you need to get that - 5V off the PIC before you burn it up. I'm surprised you haven't seen smoke yet. The voltage references need to stay between the range of 0 to Vcc. You are going to have to get yourself an op-amp and offset that -5V up to a zero volt potential and then divide your signal down. The resolution is what it is. You will get 10 bit resolution as the signal at the input pin varies between vref- and vref+ potential. If you want higher resolution or the ability to use your -5V to +5V signal directly then you will need a separate ADC. Funny... I don't see PIC16F676 as a device offered by Microchip.
Thanks for the help.
I decided to get an L297 and L298 from ST. It'll drive a bipolar with a pulse from the PIC. However, there is WAY too much wiring to interface and use the L298. It works but it takes too much time.
Is there a single chip solution for a bi-polar motor?
I think DougB meant PIC16F876.
Funny...Originally Posted by hansknec
http://www.microchip.com/stellent/id...cName=en010213
and worldwide available from Digikey and others
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bipolar Stepper Motor Driver with Translator
* * *
L6228 (1.4 Arms)
http://www.st.com/stonline/books/pdf/docs/9454.pdf
* * *
L6208 (2.8 Arms)
http://www.st.com/stonline/books/pdf/docs/7514.pdf
* * *
APPLICATION NOTE AN1451
L6208 FULLY INTEGRATED TWO PHASE STEPPER MOTOR DRIVER
http://www.st.com/stonline/books/pdf/docs/8607.pdf
Modern motion control applications need more flexibility that can be addressed only with specialized IC products. The L6208 is a fully integrated stepper motor driver IC specifically developed to drive a wide range of two phase (bipolar) stepper motors. This IC is a one-chip cost effective solution that includes several unique circuit design features. These features, including a decoding logic that can generate three different stepping sequences, allow the device to be used in many applications including microstepping. The principal aim of this development project was to produce an easy to use, fully protected power IC. In addition several key functions such as protection circuit and PWM current control drastically reduce external components count to meet requirements for many different applications.
* * *
APPLICATION NOTE AN1495
MICROSTEPPING STEPPER MOTOR DRIVE USING PEAK DETECTING CURRENT CONTROL
http://www.st.com/stonline/books/pdf/docs/8700.pdf
* * *
One project with L6208
http://www.otocoup.com/CarteL6208_e.htm#Specif
* * *
Regards,
Luciano
Last edited by Luciano; - 22nd July 2005 at 10:24.
Originally Posted by mister_e
There is a 16F676 PIC, I have one on my desk.
ww1.microchip.com/downloads/en/DeviceDoc/40039c.pdf
Melanie,
Are you interesed in developing PICBasic PRO source code on a consulting basis for new product development project?
Thanks
Tom
Ohhh... a proposition! I just knew the ad in the back of the dodgy personals would pay off eventually! If you really want to wreck your Bank Managers day Tom, message me off list.
Hi all,
I am still working on the stepper tilt project,
I am looking to do the following:
1) recieve an ascii string (similar to nmea) on a port pin serially from
a signal conditioning board, the string loks loke this in hyperterminal:
$ 0.00,16112.95,21.96,N6374
2) I need to parse this string and keep only the 16112.95 value or whatever value it happens to be.
3) I need to take this value and compare it to a stored value and if it is less
it sends the appropriate count to a port pin as pulses to a stepper driver
4) I also need it to determine the sign of the number and output a high for + and a low for -.
Currently I am using a 16F627A, There are a few more things needed but this is the main parts.
Help!!!!
Hi Doug
Am in the middle of this myself but have NOT gone down to the level of energising each coil as per example.
I opted for a dedicated controller board to run the motors so the controller box could be ran using popular software for CNC such as Kcam and Mach2 etc via the parallel port, but also so people could use the processor board for controlling the motor circuit direct.
By using this method, all your Pic has to do, is supply 2 pins to control each motor.
One for direction High/Low and the other for Pulses using PWM from the Pic or simple toggle high and low with a pauseus in between each step.
On the CNC machine I have built, the motors along with the thread on the shaft work out at 533 pulses per 1 MM in eight step mode and decrease as you step up.
If interested, please check out http://www.cncdudez.com and under the development link you will see the protocol I have gone with to control the motors via USB or Serial using a 18F4550 chip.
The commands shown at the moment are for Jog mode, but am working on taking raw G-code and feeding it straight into the Pic, which is going well.
The huge difference between using a Pic to control the pulses and using a PC Parallel port is incredible. There is too much going on in windows that disturbs the pulses and the motors run so noisey.
Using a Pic lets you hit incredible speeds and hardly any noise of the motors.
Regards
Sean.
I must first correct myself from an earlier comment. One can digitally microstep using a pic using fast comparator inputs triggering interrupts and such. There is an application note about this at the microchip website, but the code is assembly and rather complex.
Now that I know better, I would also steer away from the simple code driving 4 FET's, because the resulting torque you get from your motor is poor. (unless you don't care about torque).
There is a new DMOS Microstepping driver with translator chip available from Alegro MicroSystems that can perform up to 1/16th microstepping precision and drive up to 2.5Amps/phase right from the chip.
The chip is the A3979.
http://www.allegromicro.com/datafile/3979.pdf
The chips are only about $5 ea in single quantity.
Now you can write your pic code to simply count steps and give a direction bit. With the code space you save, you have more room available for cool things like trapazoidal acceleration/deceleration curves and speed control.
Enjoy
I live in Japan.
I do not understand English.
I write sentences with a translation machine.
I arranged the circuit and the operation theory of Maicrostepping.
It comparatively puts out the angle ratio by using a power element, detection resistance, and an analog comparator referring to the table.
It ..program.. doesn't actually have the storage power though I hope for the assembly language because of operation speed.
http://2.suk2.tok2.com/user/nonnno-p...08-02-16-0.JPG
ttp://2.suk2.tok2.com/user/nonnno-protok2/img/2008-02-11-0.JPG
ttp://2.suk2.tok2.com/user/nonnno-protok2/img/2008-02-03-1.JPG
About the MICRO STEPPING STEPPER drive circuit.
The image and the circuit chart that I displayed here are ,so to speak, informal signboards and an accurate appearance is not drawn.
I can continuously write Sa and details of the circuit.
I can show the table of the voltage ratio of two aspects and the table of the decrease rate of both aspects.
No one showed the interest when this matter was shown in Japan, and it was not possible to develop into Maicrostepping.
You can able to make an effort to someone's serious approach of this method, and the completion of the program and promise to open it to the public in the place of the lever?
If it is so, it wants to announce everything I learnt, to catch everyone's opinion, to put, and to make a better device.
I believe that this function can be composed of comparatively cheap PIC and AVR, etc.
Even if I do not use special IC such as "Sunken" "ST" "NS", I can enjoy this function.
In addition, I :. 「Pawa?Switch」Separates and it is possible to correspond also to the motor drive of "Super-Big".
It believes if it is possible to change to the one, a damage repair, and a bigger power element easily.
Kyoji
There are a lot of "I" because "Translation machine" demands "Subject".
There are "Switching type" and "Pawardoropp type" in the fixed current drive of "stepper", and "Switching type" doesn't generate extra heat, and be able to use the electric power effectively.
To characterize, to detect the current, and to convert it into the voltage, the main current route is finished by a low voltage.
"Unipolar" Maicrostepping is written in the starts most.
Is this an easy circuit and Pawa of 70% of "Bipolar"?Can be demonstrated and it makes it to "Bipolar?" in an easy change.
The feature of "Unipolar" is a current in the energizing period in which momentary increases by sink "Inductance of the rolling line" at the drive as for the current in a positive direction.
This current is put for the interception period and changing momentary ..current sucked up.. decreases from ground in the opposite direction.
I think about the constant current of 3A as an example and am seeing.
It should be a voltage of "1.0V from 0.5" because it suppresses the electric power loss though the current of these positive and negative is converted into the voltage of the positive and negative by the detection resistance.
In addition, it is rectified, it converts into the signal in a positive direction, and it transmits to the following circuits by the current of 10 considerable mA.
A positive direction obtains the absolute value current comparatively easily by "Level shift" and the direction of negative using "Level shift" and "Break out" in this circuit.
An integrated current can be controlled by easily adding the mean value of these both aspects to a smooth comparator.
In addition, driving power smooth at all circumference angle can be generated by tempering with the decrease rate according to driving angle.
Last edited by apollo21; - 17th May 2008 at 02:00.
I might be doing an impolite way to come.
Please forgive me if it is so.
Does this code have the ability to output the frequency pulse of
which place?
Do its deflecting have the ability to enable Maicrostepping?
I am looking for the PWM code of PIC16F648A to enable Maicrostepping.
Please show if there is something that becomes some references.
hi.
The following image is a connection of two aspect Yuniporrasteppingmortarmaicrostepping to
LED.
It tries to build the fixed current circuit into following.
It was named Raundorimittoscear.
[QUOTE=apollo21;68104]hi.
Greetings
Since I posted the previous post, that many more experienced.
Allegro One solution would be achieved at IC.
Another, however, set a vector of phase 2 D / A converter in the conduct,
Sorted by comparing the current signal value and the output switching element is a way to drive.
The current regulation requires the ability to fit the criteria.
Vector miracle two-phase partitioning error occurs from an angle and draw a circle, the intermediate value of 0.7 instead of 0.57 has been announced to be correct.
D / A converters to simplify the PWM can be used.
1bit PDM is called conversion ways, by number, because repetition is undefined, and is not suitable for such use.
MPU is a 2ch analog 2ch and needs of the PWM output.
If you seek to maintain the accuracy of the angular speed 8bit pulse repetition frequency should not be limited to around 6bit.
Thus repetition frequency 6bit seeking 8bit accuracy,
If you use a decentralized approach four times, without sacrificing the angle, fast response can be obtained.
(Many more bit of resolution can be given)
I did a mathematical analysis of Open Office Calc functions.
http://den-nekonoko.blog.so-net.ne.j...o/WS000539.JPG
Can stay if you need more, "6bit_pwm.ods" We attached.
Yours sincerely
Hello all, after lots of posts with some other members here, and lots of digging on my own, I came to the conclusion for anything over 500mA drive capacity, it really is less expensive to go with a dedicated chip solution. This is when you figure in board space, manufacturing cost, ...
Just my 2 cents FWIW
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
please help me..we have a project using stepper motor..we are making simple linear robot..when the circuit is on it will automatically open the gripper then after a seconds it will close the grip then after a seconds the slider stepper will turn forward then after a seconds again the gripper will open again then close and back to its original position..
please give me sample code or correct my code because when i tried it the gripper will only vibrate:
Code:clear ti var byte c var byte z var byte ti=100 trisb=0 gripper open(cw the gripper stepper): for z=1 to 2 portb=128 pause ti portb=64 pause ti portb=32 pause ti portb=16 pause ti next z goto delay gripper open1(cw the gripper stepper): for z=1 to 2 portb=128 pause ti portb=64 pause ti portb=32 pause ti portb=16 pause ti next z goto delay3 close(reverse gripper stepper): for z=1 to 2 portb=16 pause ti portb=32 pause ti portb=64 pause ti portb=128 pause ti next z goto delay1 close1(reverse gripper stepper): for z=1 to 3 portb=16 pause ti portb=32 pause ti portb=64 pause ti portb=128 pause ti next z goto delay4 delay: portb=0 pause 2000 goto close delay1: portb=0 pause 2000 goto loop delay2: portb=0 pause 2000 goto open1 delay3: portb=0 pause 2000 goto close1 delay4: portb=0 pause 2000 goto loop1 delay5: portb=0 pause 2000 goto open loop(cw the slider): for c=0 to 11 portb=8 pause ti portb=4 pause ti portb=2 pause ti portb=1 pause ti next c pause 2000 goto delay2 loop1(ccw the slider): for c=0 to 11 portb=1 pause ti portb=2 pause ti portb=4 pause ti portb=8 pause ti next c goto delay5 end
Last edited by ScaleRobotics; - 4th March 2011 at 12:33. Reason: added code tags
If a stepper motor vibrate this is happen because the power supply is too low or the rotation speed (given by the code) is too high.
i came accros this thread by accident but looks like it maybe what i need.
i have a bipolar stepper motor, plus a driver chip. will this code work on a pic16f84a ?? also i need an imput pin for step pulses and a direction pin, trying to see in the code if this exists
I tried to figure a schematic for Melanie code.
Both motors seem to work in the same way.
The second motor has a ULN2003 driver (ULN 2803). My question is if I choose the right schematic for driver configuration.
Thank you
The answer is no!My question is if I choose the right schematic for driver configuration.
First of all never connect directly to the pic port any motor ( max current you can supply is 25 milliAmps) but use a current driver as the ULN2803.
ULN2803 is an array of 8 NPN darlington transitors, that you can connect directly to the port pin without any other passive components (no resistors needed) so with one ULN2803 you can drive two unipolar stepper motor with 350 milliAmps per coil.
From the schematic the motor appears to be bipolar, and if they have only 4 wires there is no way to connect them as unipolar.
Google for unipolar stepper motor to understand the difference.
Al.
Last edited by aratti; - 25th March 2010 at 11:08.
All progress began with an idea
Hello Mel, Everyone,
I`d like to know how to get the code into the chip, (might sound silly), but it doesn`t seem to want to compile in any of the software.
I`ll more than likely be using a 6 wire stepper motor, but shouldn`t matter, as there`s still only 4 to drive the coils, the other two are power wires.
Have tried a few things, like using PortC outputs on pin 5,6,7,8 instead, that`s just by changing the portB to portC, no go either.
Other items would be,
9&10 for LED output, 11 for step, 12 for Direction, 13 for Enable, pins 1&2 to pull hi / low, via jumpers or 2 switch DIL component. (1on/2on, 1off/2on, 2on/1off, 1off/2off)
Any assistance at all would be appreciated immensley.
Thank you.
What version of PicBasic Pro do you have? Melanie's example from post#1 seems to compile fine over here. I tried the 16F877.
You might also be interested in this microstepping example http://www.picbasic.co.uk/forum/cont...per-controller
and these: http://www.picbasic.co.uk/forum/content.php?r=39
http://www.scalerobotics.com
Hi Scalerobotics,
Thanks for the other couple of links, I`ll have a look.
One of the latest versions, but see the attachment one screen capture of BasicPro & one from Picaxe compiler and their respective messages.
Note, I don`t have any headers etc. just copy pasted the code as is, oh, and with different port#`s, which hasn`t made any difference to the error messages.
In any case, the 16F877 isn`t any good to me, my requirements/specs are for a 14 pin Pic.
I`d have to reconfigure the code to suit again, so there`s Picaxe14M/2, 16F684, 16C505, 16F505, 16F676,etc, or if I`m not fussy, I can get really universal and put one of those AVR chips in if they`re easier to configure, that way both camps can enjoy (a balance in the force, perhaps ha,ha).
Thanks again
If you are not using Pic Basic Pro the examples from this forum will not work. Nor will they work for an AVR chip or picaxe.
Dave
Always wear safety glasses while programming.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hello Alain,
Not quite sure of your response, so as I understand it, I`ll respond...
The Allegro won`t fit either,( but having a look at it, you`ve given me another idea, on which I must think on).
Just for the following unit I have constructed, 3 separate ICs, not "networked".
looking at a few alternatives.
Thank you
Bookmarks