MechMate CNC Router Forum

MechMate CNC Router Forum (http://www.mechmate.com/forums/index.php)
-   80. Computer Hardware & Software (http://www.mechmate.com/forums/forumdisplay.php?f=7)
-   -   Lower Cost Electronics Part 2 (http://www.mechmate.com/forums/showthread.php?t=398)

Les Filip Thu 30 August 2007 18:20

Aubrey,

Since you keep stating that the speed doesn't matter to you, you may still be thinking that with a "lower cost" driver your CNC router will simply move slower but still have good cut quality. That is not at all the case. The real issue is the quality of the motion. Without a properly designed driver, it will be horrible and will result in ridiculously bad cuts, REGARDLESS of the speed of the router through the wood.

So, to clarify, do you understand that the issue is not speed?

Aubrey Fri 31 August 2007 08:09

Quote:
Originally Posted by Les Filip View Post
Without a properly designed driver, it will be horrible and will result in ridiculously bad cuts, REGARDLESS of the speed of the router through the wood.

So, to clarify, do you understand that the issue is not speed?
Hi Les
I am starting realise that there is an issue that I have not got a handle on yet.

Let me put the situation down as I understand it.
1) Stepper motors have 4 coils, each coil can be polarised seperately,
2) For the sake of illustration, lets call them A1-A2, B1-B2, C1-C2, D1-D2.
3) The most basic form of stepping would be to energise the coils individually.
ie placing 0v on the "1" and 10v on the "2" connections on A, then B then C, then D would step the motor 4 times - the whole process starts again at A.
4) After having done the cycle 50 times (200 steps per rev divide by 4 steps per cycle for my motor) then the motor shaft will have done 1 complete revolution and will be at exactly the same place as when I started.
5) This is the "low torque" method.
6) To double the torque (I think it is actually slightly less than double), you apply a voltage to the opposite coil in reverse polarity. ie A1=0v, A2=10v and C1=10v, C2=0v.
7) Either way, the motor is being driven in "full step" mode.

At some point, something called "resonance" takes over and the motor simply vibrates. Lets not consider this phenomina at this time as I'm sure it is a rather complex issue.

There are other sequences of applying current to combinations of coils to produce "finer" steps but for the sake of clarity, lets leave it here for the time being too.

Is my understanding correct (not taking resonance and partial stepping into account at this time) as it stands or is my education lacking?

All the best
Aubrey

Les Filip Sat 01 September 2007 13:53

Aubrey,

I have no doubt you understand the basics. But, as they say, the devil is in the details. Ignoring or putting off things that will very much matter later will not make them disappear. In fact, you should be planning for those issues now so that the work you are doing will not be wasted.

Let's use an analogy to shine some light on the resolution issue. JPEG images look fine for the most part, but are actually compressed versions of an original (whether a high resolution scan, or a RAW camera sensor image). There is not so much compression that most people care, but there is enough to produce a savings in storage requirements or transfer speed. In some cases, up to 90% of the original data is lost.

This is what you think you are building. In reality, the Gecko drive is what is described above. A non-perfect, non-microstep drive would be the equivalent of throwing away another 90% of the data that's left. Think about it - if you could go on compressing images forever and still have them be decent quality, then we could store millions of images on a single floppy disc.

Along each axis a microstepping drive will have ten times the resolution of a full step drive, which means a 2 axis microstepping system will have 100 times the resolution of a full step drive. On a 3 axis system the overall difference could be 1000x if all axis were being used at once.

Another thing to consider is that microstepping is done using specific formulas derived from testing of particular types of motors. It is by no means a directly proportional relationship to go from one full step to the next. It is non-linear to say the least. Dealing with this changes the circuit entirely from what you want to build to something else. To something like a Gecko.

If, as you say, you want to ignore these issues, you will be getting motion quality that is a magnitude worse than you are thinking.

Do you want to produce parts that are acceptable quality or just merely recognizable? Smoothness of motion is essential, at any speed, especially on a curved cut.

Take Care,
Les

Aubrey Sun 02 September 2007 11:00

Quote:
Originally Posted by Les Filip View Post
Aubrey,

I have no doubt you understand the basics.
Hi Les,
In reality I dont think that I have enough of a grip on the basics, that is why I'm always asking dumb questions. I'm not doing so to drive anyone insane at all.

The hardware I am using at the moment is as follows: stepper - 200 steps/rev, leadscrew - 16mm 2mm pitch.
This should give me a resolution of 1/100th of a mm per full step (just under 1/3 of a thousandth of an inch) which "should" be fine enough for the purpose that the machine is being built.

The backlash on the lead screw nut is probably a lot more than 1/100mm at present, but I can only test and measure it accurately (and maybe fix it) once I am able to drive the lead screw with the stepper.

As to my previous question, I am pretty sure that the motor shaft will be exactly where it started after 200 clean full steps.

This would be due to the fact that there can not be any "slip" between the poles on the shaft and the shaft or between the poles in the casing and the casing. There can only be "slip" when the motor is pulsed and for some reason, the step is skipped.
Any "inaccuracy" would be due to the fact that the 2 poles are not exactly lined up but they would still be "within the general area" of where they should be.
Step the motor again and it will then be "within the general area" of where they should be on that step.

I dont think that the resolution variance is accumulative but rather affects only that one step.

For Example:
Motor steps 1.8 degrees per step (full)
Lets take a variance of 25% as applicable to the step. (probably ridiculously high)
This equates to 0.45 degrees.
Each time you step the motor, it moves another 1.8 degrees on from where it should be (due to the physical positioning of the poles within the motor) with a variance or plus 0.45 to minus 0.45 degrees.
On a full revolution, that is 0.45 degrees (as it is only applicable to the step preceeding the measurement).
Doing the math: (2 / 360) x 0.45 = 0.0025mm either side of where it should be exactly after a full revolution or in this case, moving 2 millimeters.

I think that 2.5 microns is plenty accurate (considering the gearing, which is very fine to begin with) and we are not even dealing with microstepping yet. My micrometers cant even read that accurately LOL.

But I dare say that the proof of the pudding will be in the eating and maybe (I have been known to be soooo wrong on occation) I will be eating humble pie at some stage. Hope not though.

Thanks for your input and please keep it coming.
Best
Aubrey

Aubrey Sun 02 September 2007 11:54

Logic Board Feedback
 
Time for everyone to have a good laugh at my expense!!! :o:o:o

Wrote the PIC logic program (using single coil full stepping) and ran it on a friends emulator.

When I put 1 on the Direction pin and 0 on the step pin, thigs work as expected and nothing happens.

However, when I put a 1 on the step pin, I do not get a single step, the thing carries on stepping! On a mill, this would ram the axis into the end stop (or over travel sensor if one is fitted).

NOT good at all!!!

Basically the PIC is running a good deal faster than the parallel port baud rate and when it sees a 1 on the step pin, it steps. That is what it has been told to do!

What we now have to do is detect whether the 1 on the step pin has already been executed or if it is a new step instruction. This has to be driven by the app on the pc as the controler card ( or the breakout card for that matter) cannot "guess" when the next step is presented and to use a timer would be ineffective as the feed rate (and thus the time between steps) are probably altering constantly.

When I had a look at the original "Lower Cost Electronics" thread, I saw that the charge pump was connected to pin 14 (AutoFeed) on the parallel port.
That raised the question: Pin 1 is the "Strobe" pin and strobes are normally used to syncronize things. Why is the charge pump circuit not monitoring the strobe pin?
Next, How does Mach3 ( or any other similar app) let the controler circuit know that the data on pins 2 to 9 is another instruction (ie the data has "changed" even if it is the same)?

Maybe Mach3 can be set to use pin 14 as the strobe or maybe we should be using pin 1 to drive the charge pump.
Has anyone got the answer?

Another question: When Mach3 sends a new data byte to the port, does the strobe pin (pin 1, pin 14 or whatever) simply change state with each new instruction set or does it go low then high (or high then low) to signal the connected device that there is a new data set present on the port?
(edit) Or maybe Mach3 sends "00000000" to the port between each data set? Think I'll go check out some of the Mach3 support sites!(edit)

Anyway, whatever the answer is, we have to use that information to prevent the Logic Board from merrily stepping away when it has only been given a single step instruction.

Maybe this is the kind of trap that Les, Tom and others have been warning me about. There are probably many more that I will stumble into, who knows.

Anyway, its all in the interest of gaining knowledge.

All the best
Aubrey.

Richards Sun 02 September 2007 12:53

Aubrey,
If you were building a microcontroller circuit to feed pulses to a Gecko G203 stepper driver, you would be working with Active High signals. That means that a Step signal starts off at 0 (Low or Zero volts), then pulses 1 (High or 5V) for a minimum of 5nS, then it returns to the 0 level. The wait time between pulses is dependant on the pulse rate speed that you're sending, but the 5uS "High" state is fixed. Other stepper drivers might require Active Low signals and may also require longer On State delays.

When you're building your own stepper driver that uses a microcontroller to detect pulses from an outside pulse generator (Mach 3 driving a parallel port, for example), then you need the microcontroller to act everytime it detects a valid signal. Normally that active state is latched by outside logic (perhaps a 7474 chip) and the microcontroller's interrupt driven input pin is signaled. The microcontroller activates an output signal and then de-latches the 7474 after a time lapse longer than the step pulse width has expired.

There's really nothing simple about designing a simple stepper driver if you're using a microcontroller as part of the design. If you do that, then you also have to learn how to program, test, debug and implement the microcontroller into the design. It's not exotic, but it is another field of study with its own requirements.

Bill McGuire Sun 02 September 2007 12:57

Aubrey...
I for one am applaud you for your desire to produce a cheaper, better mousetrap... and hope you succeed. The side benefit is for folks like me who have a much less grasp on the basics of the design and engineering behind the electronics of these machines.

Just the fact that I am able to audit this thread has increased my own knowledge greatly...

Aubrey Mon 03 September 2007 14:35

Quote:
Originally Posted by Richards View Post
There's really nothing simple about designing a simple stepper driver....
Hi Mike,
C'mon... Say "I told you so!":D
Guess my education will now include the 7474 flip-flop as well.

If I understand your post correctly, the data pins on the parallel port (2 thru 9) are pulsed with the command byte for a period of at least 5 nanoseconds and then return to the "00000000" state until it is time for the next command byte to be sent (and therefor executed).

This being the case, it should be relatively simple to get the PIC to store the Step/Direction bits that it has just sent thru to the power boards in a variable (say "LastCmd") and on the next loop, test if the Step/Direction bits still are still the same as those stored in "LastCmd".
If it is the same, the PIC skips over the section which sends signals to the power board which will put it back at the start of the loop.
If the Step/Direction is "00" then the PIC is to place "00" in "LastCmd" and restart the loop.
I dont think it would be a good idea to send the "00" Step/Direction command to the power board as the motor will in all probability still be moving to where the last non "00" instruction told it to go.
In addition, if you turn all the coils of the motor off, the motor may be dragged off the position where it is supposed to be.
At this point, the PIC will not change the Step/Direction bits being sent to the power board and just loop untill a Step/Direction signal is received which is different to "00".
It may also be a good idea to have a timer running that is reset after every non "00" command is processed. Setting the timer to (say) 30 seconds will mean that the timer will fire 30 seconds after the last actual stepping command has been set. When the timer fires, all "Power" boards can be sent a "00000000" command byte which will then switch off any coils that are active, thus preventing the motor overheating and potentially burning out.

Quote:
Originally Posted by Richards View Post
.... then you also have to learn how to program, test, debug and implement the microcontroller into the design. It's not exotic, but it is another field of study with its own requirements.
I am very fortunate in that I am able to learn a new programming language in a relatively short period of time. ASP took me 6 weeks and at the end, I had an inventory control type app up for my then employer. PHP took me 4 weeks as it is able to do things without the need for buggy 3rd party dll's and the documentation is good too.
Unfortunately, for some reason, I have not got around to "C" or really into Mnemonics (as in PIC) yet but give me time....
This project is being done using PICBasic which is compiled by a buddy. He also has the "Emulator" which caught the "Runaway" bug reportd in my last post.
As far as PIC's go, I bought the PICKit(1) about 3 years ago. Currently I am playing with one of the 40 pin "16" series chips which will be controling a machine that I am building at work.
Had (past tense) a prototype board but somehow 380 VAC managed to get in and there was a fireworks display. Since then, I tend to go overboard on the opto-isolators because they are a relatively inexpensive form of insurance (being rated at 1000v). You will see what I mean when I post the Logic Board schematic and PCB details.
So far the PCB is single sided with no jumper wires. I find that resistors and capacitors are very usefull for laying tracks under. As to how wise it is to place tracks under capacitors, we will see. I am still busy checking IC pins and other component polarities at this time.

Last but not least, Welcome to Bill.:)
Thanks for your comments but I ask you to remember that the aim is not (at this time at least) to build a "Better Mousetrap" but to build a "More Affordable" one.
I think that taking the driver board and splitting it into a "Logic" board and a "Power" board may just get the guys that know about chopper circuits, high voltage/amperage switching and the like to do some development as they dont have to re-do the logic component.
Also, being fully isolated from the "Logic" board, if there is a meltdown in the "Power" section, you should not have to start the whole thing all over again which is more than likely with a combined logic/power design.

My first "Power" board will simply be 8 power transistors wired in 4 push-pull pair configuration supplying the voltage and amperage as stated on my motors.

My wife just switched off the study light (her way of hinting that its time to sleep:D) so its time to say goodnight.
All the best
Aubrey

Richards Mon 03 September 2007 16:05

Aubrey,
You're starting to get the whole picture. It's a big task, but, like all tasks, it can be managed if you take it one small part at a time.

One clarification, you talked of switching BYTES when you should be thinking of switching BITS. Each bit is independent of every other bit on the parallel port. You'll have to save the byte that was last transmitted and then mask the bit by using the OR and the AND operators to set/reset the intended bit. It takes a few minutes to get your mind around it all, but then the epiphany moment comes and everything is clear.

Greg J Mon 03 September 2007 21:43

Aubrey,

I agree with Bill, and I'll state it again, You'r an inspiration!!

When you have time, Google what Mark Twain had to say about "inspiration".

Keep up the good fight.

Greg

Les Filip Mon 03 September 2007 23:05

Aubrey,

I don't want to sound like a broken record, but full stepping is NOT very good quality for CNC work. Even some microstepping CNC machines do not produce very good results - because of the quality of the motion and because of torque issues.

That is why, and this is only my opinion, it is not worth it to go to this amount of effort for full steps. The minute you get your driver working it is going to feel like you are on top of the world. Soon thereafter you will want better quality. You will then want to build a "lower cost" microstepping drive. You will then realize what a few people have been trying to tell you about the time commitment involved with a project of this magnitude. There are probably less than 100 people in the world who can design what you really want to make. If you take into account what it will require in time, materials, and the goodwill of those willing to help you make a microstepping drive, you will then see you would be FAR better off buying a Gecko or pre-existing equivalent.

On the upside, if you succeed then you can sell them to many people. Of course, Gecko or any other big company could introduce a cheaper drive at any time and therefore negate your efforts completely. I applaud you for continuing the effort, and I will not butt in again since I have no advice that will realistically advance your agenda. I just wanted to let you know you are travelling up a steep hill and even though you have a lot of help right now, as the project advances that help will be much harder to come by.

The going price for a custom made stepper motor controller and microstepping driver combo starts at US$5,000 from a friend of a friend who does this type of design work day in and day out, and that is not for you to own the design itself. You would still have to buy the boards from him, at a price not much less than a Gecko.

That's it for now. Good luck with everything.

Take Care,
Les Filip

Gerald D Tue 04 September 2007 03:05

Les, I have been scanning every third line of this thread, or so.......

Aubrey has his motor on a leadscrew with a fairly fine resolution (I think about 2mm per motor rev). With my rack&pinion I think I am at about 75mm per rev - my 1/10th microstepping is still 3 times "worse" than his full stepping??

Richards Tue 04 September 2007 06:36

As Gerald pointed out, full-stepping stepper motors have their place. Somewhere on my 'wish list' of projects that I want to tackle 'someday' is a ball-screw driven Z-axis. The main problem is that, with a typical five-turns-per-inch ball screw, I would have to send 10,000 pulses per inch with a Gecko stepper driver. Sending that many pulses per inch of movement would not give me the speed that I need. However, if I used a full-step stepper driver and only had to send 1,000 pulses per inch, the project would work. I would still have 0.001-inch per step resolution and the speed would be acceptable.

Tom Caudle Tue 04 September 2007 12:43

Perhaps Aubrey will beat the odds. After having been around all of the lists for 6 + years I have seen dozens of well meaning guys decide that they can build an better/faster/cheaper [pick one] drive using everything from PICS to descreet transistors. So far it has never happened at a level that other users could benefit from. Honestly, if it were as simple as programming a chip and throwing a few power components on a card it would already be available. There are cheap DIY solutions for steppers up to about 3A max in the form of HobbyCNC and Xylotex. We sell a 4 axis complete Xylotex based unit with power supply, enclosure, motors and cableing for $640 bucks. It's undersized for a full sized table.

We do extensive embedded development with PICs and other chips, as well as my background in power electronics. I know the limitations of the approach of trying to re-invent the wheel. If you want to see a good application of a PIC look at our MPG101B hand controller. It scans 16 keys, an analog joystick, does proportional speed and direction for jogging on two axis, supports 4 axis control, has status LED's, supports a Mini-byte communication with MACH and has the ability to be reconfigured by the user with a GUI application. All using a single small 18 pin chip.

I of course do not consider my time to be 'free' (even my so called free time). So any costs to build, design, troubleshoot, redesign, troubleshoot, burned up parts, etc has a value to me.

Every day your machine lays in pieces is one less day you have to use it and enjoy the fruits of you labor.

I realize that a lot of the potential builders may have a problem with even the reasonable costs of available components. What I did with my first table was to scrounge as many mechanical components as I could over what was perhaps a year. I had to compromise parts of the design to match my components, but I did do a buy vs build analysis of all the pieces. I realized that I could not go through the design process (even if I counted my time as free) buy the parts, pay for PCB's and come anywhere close to the lower cost of a Gecko.

We all tend to see solutions to problems in our own context. A software person sees the solution as a software issue. A hardware person tends to want to fix everything with descreet components. The true solution is both when dealing with driving motors for complex movement.

Sorry to wax so judgemental. It's all been tried before. I guess we would still be walking if the Wright Brothers had taken my advice, but then again there was not a Piper factory down the street from them (:-)

Les Filip Tue 04 September 2007 16:40

Quote:
Originally Posted by Gerald D View Post
Les, I have been scanning every third line of this thread, or so.......

Aubrey has his motor on a leadscrew with a fairly fine resolution (I think about 2mm per motor rev). With my rack&pinion I think I am at about 75mm per rev - my 1/10th microstepping is still 3 times "worse" than his full stepping??
While the resolution is indeed better than I initially thought, I still think the quality of motion is going to be a huge factor in whether or not the full step "lower cost" driver will work acceptably well. In order to achieve good quality motion, the driver is going to be much more complicated than Aubrey currently thinks it will need to be.

Aubrey Wed 05 September 2007 15:19

Quote:
Originally Posted by Richards View Post
One clarification, you talked of switching BYTES when you should be thinking of switching BITS. Each bit is independent of every other bit on the parallel port. You'll have to save the byte that was last transmitted and then mask the bit by using the OR and the AND operators to set/reset the intended bit. It takes a few minutes to get your mind around it all, but then the epiphany moment comes and everything is clear.
Hi Mike,
Think I was talking with regard a single logic board. The logic board only gets 2 bits of info from the breakout board. ie. Step and Direction.
The output from the logic board is a pair of bits for each coil on the motor. On a 4 coil motor thats 8 bits or 1 byte.
You are correct when you say I should be switching bits but as there are 8 of them, instead of doing eight 1 bit switches, I simply do one 1 byte switch. (Effectively that means I'm lazy! :D)

For those who dont know what Mike and myself were talking about, let me try to put it in english.

Each coil can have both leads set to 0 volts "00" or not doing anything, lead A=10v + B=0v ( ie 10 )making it a North pole, lead A=0v + B=10v ( ie 01) making it a South pole.
(A 4th is A=10v + B=10v but this would have the same effect as the "all 0 volt case but wastes time doing funny "chopper" things in some cases)
Using a simple case:
10 00 01 00 = coil 1 north + coil 3 south (steparray[1])
00 10 00 01 = coil 2 north + coil 4 south (steparray[2])
01 00 10 00 = coil 3 north + coil 1 south (steparray[3])
00 01 00 10 = coil 4 north + coil 2 south (steparray[4])

The program also has integer variable called arraypointer (initialised to 1 at the start)
Using a full register (8 bits, on a 20 pin PIC, Register B is normally the one with all 8 bits, Register A often stops short of the full 8 for some reason but it all depends on the PIC you are talking about) on the PIC as the output pins, instead of programming "regb.1 (or Register B, Bit 1) = 1, regb.2 = 0" and so on, all you do is say "regb = steparray[arraypointer]" and all 8 bits in steparray[arraypointer] get placed on the appropriate bits (in reality, the output pins) which then go to the power board.
Note that arraypointer = 1 at this time.
The next time a Step/Dir is received, if Dir = 1 then increment arraypointer or if Dir=0 then decrement arraypointer.
Important: In the above example, there are only 4 elements in the array. Once you have done the increment/decrement, if arraypointer = 0 then make it 4, if arraypointer = 5 then make it 1 so that you dont move outside the array upper and lower boundaries which would be "unfortunate" to say the least.

At this point, you have the next arraypointer so you say "regb = steparray[arraypointer]" again and the pins get the appropriate values and the power board can do its thing.

When programming, I like to break things down into small chunks, usually in the form of subroutines or functions. This means that you are able to get the individual parts to work and when you string them all together into a program, if something is a problem it is easyer to pinpoint the function that is the problem and because the code in the function is smaller and does only one thing, its normally far easyer to debug.

The function for this would be something like:


Function DoStep(tDirection as integer){
//increment or decrement arraypointer as required
If (tDirection == 1){arraypointer = arraypointer + 1}
Else (arraypointer = arraypointer - 1}

//ensure arraypointer within boundaries of array
if (arraypointer == 0){arraypointer = 4}
if (arraypointer == 5){arraypointer = 1}

//send the info to the power board
regb = steparray[arraypointer];
}
End Function


Now you can call this function from anywhere in the program and the appropriate info (bits) will be sent to the power board.
Should there be a bug in sending info to the power board, this is where it will be, not in various places spread throughout the program.

Personally, I use many comments (the // indicates a comment) all over the place which makes the program far more readable (which is very handy in a years time when you need to modify it!), easyer to debug (some times computer processors get a mind of thier own) and it looks neat (which is a point of pride!).

The DoStep function above is what will be used to signal the power board when we get to the program. Maybe there will be minor syntax changes, but nothing else and if the C boys want to, they will be able to get it translated to C in about a minute flat.

All the best
Aubrey

Aubrey Wed 05 September 2007 15:23

Quote:
Originally Posted by Greg J View Post
Keep up the good fight.
Greg
Thanks Greg,
I'm Irish, fighting is what we do best:D
Regards
Aubrey

Aubrey Wed 05 September 2007 15:47

Hi Les,
Thanks for your comments and kind wishes, its really appreciated when it comes from someone who obviously is knowlegable on the subject.

Two posts back I gave an example using the "full step" sequence. By rewriting this array (adding four more elements) we "should" get half stepping, and so on. But that is after the logic board actually works. For me, programming is easyer than that "electronics" thing and the only difference between full stepping and micro-stepping as far as I can see is how many elements you have in the array if you disregard the power circuitry.

As to selling the boards, I dont think that will be right. This is after all an effort by a whole bunch of other people as well as myself. I dont hold "copyright" to it.

What I would like to do is mill boards for those that need them as a "keep busy" when I retire (not too far away) but that is for then, this is now.

Please feel free to "butt in" as you put it anytime, sometimes I will be needing a bit of "bringing down to earth" or an "I told you".

Once again, thanks for everything that you have brought to this thread.

All the best,
Aubrey

Aubrey Wed 05 September 2007 15:49

Quote:
Originally Posted by Gerald D View Post
Les, I have been scanning every third line of this thread, or so.......

Aubrey has his motor on a leadscrew with a fairly fine resolution (I think about 2mm per motor rev). With my rack&pinion I think I am at about 75mm per rev - my 1/10th microstepping is still 3 times "worse" than his full stepping??
Mmmm..... Good Point Gerald
Aubrey

Aubrey Wed 05 September 2007 16:18

Hi Tom.
A point to remember is that this is also me getting into electronics after a 30 plus absence. And maybe someone out there will also gain a better understanding on the way.

Although I hate "buzzwords", there are two that I would like to borrow, "Affordable" and "Scalable".

In my case, that means I can afford the "Model T" now, I can improve it (when I become a chopper drive expert) and should I need something more, I"ll get a Caddy (Gecko or whatever).

Quote:
Originally Posted by Tom Caudle View Post
We all tend to see solutions to problems in our own context. A software person sees the solution as a software issue. A hardware person tends to want to fix everything with descreet components. The true solution is both when dealing with driving motors for complex movement.
A very valid point!
I'm actually dreading the day that this thread starts on the power board. But then again, if it was easy it would be boring.

Also, with NASA and all the other governmental space organizations around, it took a private organization burning ground up tyres (from what I've heard) as a fuel, to get a private citizen into sub-orbital space.

Thanks for the input, Its needed to bring me back to earth every now and so often.

Best
Aubrey

domino11 Thu 06 September 2007 06:59

Aubrey,
What about starting with one of the discrete designs that are available and modifying it to meet your parts availability and cost perspective? That way you might at least eliminate some of the snags that you might run into with a brand new design. I think you will still learn a lot with the redesign , building and troubleshooting the board. Just a thought

Aubrey Fri 07 September 2007 17:35

Quote:
Originally Posted by domino11 View Post
Aubrey,
What about starting with one of the discrete designs that are available and modifying it to meet your parts availability and cost perspective? That way you might at least eliminate some of the snags that you might run into with a brand new design. I think you will still learn a lot with the redesign , building and troubleshooting the board. Just a thought
Hi Heath,
I think that that is more or less what is happening.
The original concept is the PICStep courtesy Alan.
Unfortunately, his "source" is mnemonics, a "language" which I am not anywhere near up to speed with as yet.
Therefore I will have to re-develop the code going into the PIC. For this I am using PIC Basic as Basic was the first language I learned and also because I know someone who has a compiler and is prepared to compile the code for me.
In doing this, I have learned (amongst others) that data is presented to the port in 5 uS pulses (thanks Mike) which is something I didnt know.
I am also sure that there will be a number of other pitfalls that I will stumble across and when this happens, we investigate and fix them.

The only "unique" feature on this project is that the logic and the power circuits are split off onto thier own boards. Once the logic board is developed, the user has the choice of using anything from a basic 8 power transistor push-pull type power circuit to one using the 2 of the most up to date power h-bridge chips or anything in between.
It all depends on what is affordable, available or required by the user.

In the final analysis, if the logic is not up to scratch, it doesnt matter what power circuit you use, it wont work properly.
Thus, using a microprocessor to sort out the logic, makes the most sense as it is relatively easy to modify the code, re-compile it and burn (maybe a bad word to use) it into the processor memory.
If we were to use discrete logic gates and the like to generate the logic, each time we "fix" an error or make an improvement, it would mean a new PC board which would cost plenty and therefore defeat one of the objects of this exercise.

The next question:
How many different types of stepping are there?
In post 56, I made an example of stepping using 4 "command bytes" which is for "Full Step - Full Torque" movement.
If we replace all the "01" parts with "00", this can be called "Full Step - Normal Torque" but I personally think that this mode is not required.

Half Stepping:
10 00 01 00 = coil 1 north + coil 3 south (halfsteparray[1])
10 10 01 01 = coil 1+2 north + coil 3+4 south (halfsteparray[2])
00 10 00 01 = coil 2 north + coil 4 south (halfsteparray[3])
01 10 10 01 = coil 2+3 north + coil 4+1 south (halfsteparray[4])
01 00 10 00 = coil 3 north + coil 1 south (halfsteparray[5])
01 01 10 10 = coil 3+4 north + coil 1+2 south (halfsteparray[6])
00 01 00 10 = coil 4 north + coil 2 south (halfsteparray[7])
10 01 01 10 = coil 4+1 north + coil 2+3 south (halfsteparray[8])

The Dark Red steps have been inserted in between the original steps of the Full Step sequence to get "HalfStep" logic but at this point I start getting a bit confused as to what to do next. Maybe I should have paid more attention at school:o

Can anyone help out?

We still need Quarter and Eighth stepping (I think eighth stepping also goes under the name of "micro-stepping" - Am I correct?)
Why am I interested in getting all the stepping arrays sorted out at this time? At this time, I still have 3 pins available on the PIC so I thought it may be nice to be able to select the stepping mode using jumpers connected to "some" of these pins.

Best and have a good weekend.
Aubrey

Aubrey Fri 07 September 2007 18:17

1 Attachment(s)
Hi All,
Drew this up after watching the Rugby World Cup opening ceremony.
Logic Board layout
Power is 5 volts
Step/Dir comes from the Breakout Board
8 signal wires plus supply voltage (to run the opto isolators) connects to the power board.
3 jumpers (ie 8 options) for selecting step mode (full, half etc)
Cost estimate:
PIC = R15.00
Crystal (from old computer motherboard, external modem or whatever) = free
Opto's @ R6.00 ea = R48.00
Caps, resistors, pins = R20.00
23 parts in total, not counting the header pins.
Cost (without PCB) about ZAR83.00 or about US$11.50
If you want to take the chance and leave out the opto's, its R35.00 or US$4.90

At a rough guess, I'd say that these sorts of prices are definitely "affordable".

Next thing to do is tie down the signal logic arrays for the rest of the stepping modes.

As soon as thats done, go thru to Pretoria, buy the bits and build the prototype and see what it does.

Please remember that this layout was designed by an electronically challenged fitter and turner and probably has a number of things wrong with it at this time. (testing is going to be fun :mad:)

Anyway, 2:20am local - hitting the sack
Goodnight

Aubrey Sat 08 September 2007 04:33

Logic Board 1.01
 
Made some changes and improvements to the Logic Board.
Added pull-down resistors to the mode selection jumpers in case I get up to my old trick of forgetting them.:o
Add another 3 resistors to the parts count.
Cost must be all of US$12.00:D
Also added another row of pins to the power board output so that I can use an old ribon cable (IDE drive type) to make the connections.
Condensed things and neatened them up.
Was going to add place for LED's but thought better of it. The pulses are so short and quick, you wont see a thing.
Have a good weekend guys.
Aubrey

domino11 Sun 09 September 2007 13:50

Aubrey,
Not that I am any expert on stepping algorithms, but I have written some assembly language programs to control some stepper boards for some projects we have done at work in the past. Are you sure that pic basic will execute fast enough for your stepper contoller? Will the processing overhead with the basic interpreter be too slow? All of the work I have done before has all been assembly for the speed aspects. Also there are probably hundreds of algorithms for stepping sequences out there. There are full step , half step then all the micro step functions. Then add all the different modifications that are out there for max torque, speed acceleration etc, sine wave etc. I would try checking allegro's site as well as national and sgs thompson for any stepper app notes to help you out. allegro has been doing this for many years and they have it down to a science. The app engineers there helped me out 10 years ago when I first started my stepper project then. There wasnt as many driver chips etc, so back then you HAD to incorporate the proper stepping algorithm you wanted to use, as well as acceleration modifications etc. You just cant go from a stop to full stepping , you have to have an acceleration ramp of some kind, timing and phasing all play a role. Hope this isnt swaying you off your project, just some background
so you can read up some more to do what you want.

later

Aubrey Mon 10 September 2007 14:22

Hi Heath,
Quote:
Originally Posted by domino11 View Post
Are you sure that pic basic will execute fast enough for your stepper contoller? Will the processing overhead with the basic interpreter be too slow?
As far as I know, PICBasic is compiled to native machine code before being burned to the chip, unlike systems like the "Basic Stamp" and others which is an interpreter running the "basic code" component.
If this is the case, there should not be too many speed issues.
However, if it should be an "interpreted" type setup, then we probably will have speed issues and the programming will have to be done in mnemonics and linked to create a hex file for burning.

Quote:
Originally Posted by domino11 View Post
Also there are probably hundreds of algorithms for stepping sequences out there. There are full step , half step then all the micro step functions. Then add all the different modifications that are out there for max torque, speed acceleration etc, sine wave etc.
Admittidly this is true. However my brain is telling me that seeing as there are only 4 coils, each capable of being "north", "south" or "none", there can only be a finite number of possibilities. I dont think that it would be possible (for arguements sake) to get the motor to step to 2 degrees 12 minutes 51 seconds. That sort of action is only possible using servo type motors with very fine encoding devices as far as I know.

The PICStep code has 2 arrays (one for each h-bridge chip as far as I can make out, at this point in time my ability to make heads or tails out of mnemonic code really sucks) containing 64 entries. I have seen a comment "; 1/16 Step" in there so I assume for the meantime that that means Alan is in fact doing 1/16th stepping.

Quote:
Originally Posted by domino11 View Post
....as well as acceleration modifications etc. You just cant go from a stop to full stepping , you have to have an acceleration ramp of some kind, timing and phasing all play a role.
I dont think that any of the currently available driver boards have the capability in themselves of being able to calculate the accelleration that will be required at any point.
Surely that is the function of the software that is sending signals to the driver circuitry?
In other words, the g-code interpreting app (Mach3 or whatever) is set up with parameters indicating the maximum accelleration/decelleration and maximum speed (for G00) applicable.
The g-code file will have the feed rate in it. It is the app's function to send the step/dir instructions to the driver at the appropriate intervals.
These intervals would get shorter as the motor has to accellerate, stay constant once the required speed has been reached and getting longer so that the motor is able to slow down in an elegant fashion when approaching the end of the cut.
Lastly, there is no controler board (Gecho or any other) that is able to "know" what the next instruction will be and when it will be getting it. (no disrespect to these boards intended!)

The only time that the stepper driver board would have to take care of the accelleration/decelleration function would be if it was taking the place of the g-code interpreter but this is not the case in our situation.

(Some time back I got the source of a DOS Basic g-code interpreter and just for fun, tried to convert the code to VB5. I found coding to calculate accelleration/deceleration ramps and all that sort of stuff there.)

It is very important to nail down what each section of the entire system has what responsibilities so here goes:

Lets assume that we already have the g-code file.

The G-Code Interpreter (Mach3 or whatever)
Loads the G-Code source file.
Converts the G-Code to appropriate step/direction instructions for each axis.
Passes the step/direction instructions via the parallel port to the rest of the system.
This is where information about where each axis finds itself (the co-ordinate positions)
Also does other stuff but we'll worry about that later.

The Breakout Board
Has a safety device (charge pump) that prevents any spurious signals from being sent on.
Once the charge pump is active, takes the information being received on the parallel port, splits each byte into four 2 bit pairs and forwards each 2 bit pair to the appropriate logic board as quickly as possible.

The Logic Board
Receives a pair of bytes (step/direction), figures out what coils to energise and to what polarity.
This is where the type of stepping (full, half, quarter etc) is to be set as it only receives 2 info bits (step/direction).
Note: the G-Code interpreter does not know what type of stepping (full, half etc) is being done. All it needs to know is that each step command will move the AXIS a distance of 0.005mm or whatever.
Note: The logic board does not know the co-ordinate position of the axis, all it does is work out the command byte to send to its motor to move it one step (full, half or whatever it has been set to) in the required direction.

The command byte contains 2 bits of info (+ve and -ve) for each coil and is passed to the Power Board as quickly as possible.

The Power Board
Receives the command byte from the Logic Board and immediately sends power to the appropriate coils as per the received command.
All sorts of fancy circuitry can be inserted here (choppers etc) but it can also be a very basic driver circuit. The choice is up to the user.

Quote:
Originally Posted by domino11 View Post
Hope this isnt swaying you off your project, just some background so you can read up some more to do what you want.
Not at all! Each post adds to the knowledge. Sometimes it leads to an improvement, sometimes it does not but it is ALL appreciated.

Anyway, wife switched the study light off again, time to go,
All the best,
Aubrey

domino11 Tue 11 September 2007 06:54

Aubrey,
Check out these links. One is an app note from the atmel corp which references an article in a trade journal. The second link is the authour of the articles web site with the original article intact. Might be interesting. This is the info I originally used in my first stepper motor driver.

http://www.atmel.com/dyn/resources/p...ts/doc8017.pdf

http://mysite.wanadoo-members.co.uk/stepper

Aubrey Tue 11 September 2007 15:21

Quote:
Originally Posted by domino11 View Post
This is the info I originally used in my first stepper motor driver.
Hi Heath
The stepper motor driver, was it a stand-alone or was it driven by another program on a computer?
Looking at the links you sent, I would say that the PIC was the originator of the timing, not an app on a computer although I may be wrong.

I understand that the motor cannot possibly accelerate from standstill to 50rpm (or whatever) instantaneously but for the life of me I cant see where the driver board is getting the information as to what the target speed is, whether it is accelerating, running at a constant speed or slowing down. All it gets is a step pulse and a direction flag.

And so, in true "fools rush in" fashion, I'm going to assume that the g-gode interpreter (Mach or whatever) takes care of the accelleration ramping and sends the command signals via the parallel port in real time.
This being the case, the hardware we are working on has the sole function of taking the signal, processing it and forwarding the result to the coils of the motor.

To get a working example up in the near future, we should also not panic ourselves to death about the "micro" aspect of the stepping sequences but should use "full", "half" and "quarter" stepping options during this stage of development to keep the complexities from becoming overwhealming.

Once we have something that works, we can get it to work better.

If anyone thinks that the logic board is complex, wait till we start on the power board. Hopefully tempers will not get too heated but I am sure that there are going to be a whole truck full of differing opinions as to how to go about that one.

Anyway, sack time so I'll see you all tomorrow.
Best
Aubrey

Gerald D Tue 11 September 2007 21:01

Quote:
Originally Posted by Aubrey View Post
And so, in true "fools rush in" fashion, I'm going to assume that the g-gode interpreter (Mach or whatever) takes care of the accelleration ramping and sends the command signals via the parallel port in real time.
That is correct, Mach/whatever does the ramping.

domino11 Wed 12 September 2007 07:23

Aubrey / Gerald,
Yes I agree that Mach does some speed ramping but that is not what I am referring to. There are still special algoirthms implemented in the driver boards (either in the driver chips themselves or in firmware) like the geckos. This stepping algorithm will greatly affect the torque of the steppers and the performance of the router. Alan over at www.fromorbit.com implemented a new torque algorithm in his picstep to improve the performance. The wave patterns he is talling about is the switching algorithm as I call it. Just want to make sure some of these details get missed and your performance is less than expected. That is why most diy boards use a driver chip that has the smarts built in. The chips are much more than just a dumb power driver.

a clip from Alans site on his new algorithm change:


I'm working with Henrik (mk2lehe @ CNCZone) in upgrading the PICStep firmware to utilise a "High Torque" stepping wave instead of the Sin/Cos wave I'm currently using.

This update should increase the torque of the steppers (I don't know yet how much, but it sounds like a worth while amount) and help reduce the resonace in motors even further.

I'm also toying with the idea of replacing the way the modes are selected and instead of switching to the different wave patterns for Full, 1/2, 1/4 and 1/8 I'll use burst pulses of the 1/8 pattern to make the Full, 1/2 and 1/4 modes work. This will make these modes silky smooth like the 1/8 mode, but offer the increased mechanical step size and potentially a lower drive pulse width.

Also I'll endeavour to fix the "switching modes while the drivers are running" bug too (not that anyone else has noticed it other than Henrik 8) ).

Richards Wed 12 September 2007 09:07

Heath,
I'm having a problem understanding the function of the PIC microprocessor when it is used with Mach 3 software. As I understand it, Mach 3 sends sets the direction signal and then sends out timed pulses to command the stepper driver to turn the motor's shaft. The stepper driver (PIC) does not modify the timing intervals between Mach 3's step pulses. So other than doing the very complicated functions of turning the motor's coils on/off in the proper sequence and running the chopper circuitry, I don't think that the PIC should have any ramping routines built in.

In a process control environment where the PIC totally controlled all aspects of running the motor, including running the motor a certain numbers of steps from start to finish, then I would agree that ramping would be part of the PIC's responsibilities. But in a CNC router application, where multiple axes could be moving at the same time, then something external to the PIC, Mach 3 for instance, has to control ramping so that all axes stay synchronized.

Aubrey Thu 13 September 2007 13:42

Hi All

Gerald: thanks for confirming that.

Heath: There are 2 places where "ramping" is going on.
1) the ramping of the speed at which the motor is being stepped.
2) in the chopper driver circuitry the voltage is ramped (at a level much higher than the motor specification) and then chopped once the coils resistance to change has been (quickly) overcome. In effect, high voltage is applied which allows the coil to change its state much more quickly and once the voltage effectively going thru the coil reaches the "legal" limit, the high voltage is chopped to produce the "legal" voltage.

Point 1 is under the control of the "g-code interpreter" which is on the computer.
Point 2 is under the control of the "power" module.

Remember that we have taken the traditional "driver" board and split it into a "logic" module and a "power" module.

Another point to remember is the name of this thread. We are not trying to make the best controler system, simply one that is affordable and in its basic form, does not require scarce (outside the USA/Europe), costly components.

As things stand, the breakout board comes in at maybe $5,00 (probably less)
The Logic board is about $12.00 at this stage. Need 3. Make that $36.00
With a "Bare Bones" power board that uses common power transistors to do the switching, need 4 pairs at (estimated) $2.00 per pair plus some other support circuitry, estimate (high) at $20.00 per board. Need 3 makes it $60.00

Grand Total = $101.00 (or ZAR 730.00)
This is a far cry from $1300.00 (ZAR9300.00) for the "professional" equipment, albeit the performance wont be there.

Once we have the mill moving (slowly), we can start on chopper drivers using any flavour of power h-bridge chip that we want, but that is "later". Lets crawl before we try sprinting.

Mike: You and I are seeing it from the same point of view. I think that Heath is seeing the PIC as the "process controler" instead of the PC/Mach3 being the "process controler".

If a future chopper circuit needs any "processor" power, we can put one on the power board specifically for that requirement.
The beauty of having split the logic module away from the power module is that we only have to upgrade the power module at a later point to upgrade the performance of the whole system.

As to the "High Torque stepping wave" and "Sin/Cos wave" that Alan wrote about, he is so far more advanced in his understanding of the whole process that it makes me nervous. But, once he was where I am so I will just have to learn.

Scary Thought: Where will he be when I am where he is now? :eek:

All the best,
Aubrey

domino11 Thu 13 September 2007 15:14

Aubrey,
Great, like I said before I am no expert, just trying to help you cover the bases as you round out home plate. :) Some of this stuff is from 15 years ago for me so please double check my ideas or facts!:rolleyes: I agreee with your synopsis and looks like you are looking into all the avenues. Have you decided on what fets/drivers you are going to use? There are a lot of good discrete fets available these days as well as driver chips like the lmd18245 from national that Alan uses.

Gerald,
How do we get you to come over to the Dark Side? :cool: Electronics can be as much fun as the mechanicals. Sometimes I feel more comfortable with a soldering iron than a welder.:)

domino11 Thu 13 September 2007 15:17

Mike,
I think Aubrey summed my thoughts up better than I did. I was referencing the chopper current ramping which will affect the available torque. This is what I think Alen is doing in his picstep design. He just implemented a new algorithm that improved the torque output in the stepper. You can probably get away without a chopper type drive but the performance will be lower I assume.:(

Gerald D Thu 13 September 2007 22:48

Heath, I might wonder over to your side when I can figure out why you guys block up your plastic pipes with copper :confused:

Aubrey Fri 14 September 2007 10:12

Quote:
Originally Posted by Gerald D View Post
Heath, I might wonder over to your side when I can figure out why you guys block up your plastic pipes with copper :confused:
Huh?:confused:

Gerald D Fri 14 September 2007 10:50

Us hydraulics people want our pipes to be clear and free-flowing. Those things that look like pipes on your circuits (I think you call them "wires"), wouldn't they flow more freely if you took the copper blockages out?

Aubrey Fri 14 September 2007 12:30

Hi All
This chap Alan is a very bright lad. :D
Like most people, I spend at least half of the time taken to get to and from work waiting at traffic lights. This is where I sit and ponder all sorts of things and today it was how Alan handles the array that contains the coil switching settings.
In his source, he uses 2 arrays (one for each power h-bridge I think) but the really cleaver bit is how he seems to step thru the array to get the necessary settings to the coils when they are needed.
I think I have stumbled on the secret!:cool:

Lets build our own array of commands first starting with the full steps.

10 00 01 00 (fullstep 1)
00 10 00 01 (fullstep 2)
01 00 10 00 (fullstep 3)
00 01 00 10 (fullstep 4)

Now we add the half steps between each existing step.
10 00 01 00 (fullstep 1)
10 10 01 01 (halfstep 1)
00 10 00 01 (fullstep 2)
01 10 10 01 (halfstep 2)
01 00 10 00 (fullstep 3)
01 01 10 10 (halfstep 3)
00 01 00 10 (fullstep 4)
10 01 01 10 (halfstep 4)

Next, the Quarter Steps also between each entry and then the Eighth Steps to complete the array.
1) 10 00 01 00 (fullstep 1)
2) ?? ?? ?? ?? (eighthstep 1)
3) 10 10 01 00 (quarterstep 1)
4) ?? ?? ?? ?? (eighthstep 2)
5) 10 10 01 01 (halfstep 1)
6) ?? ?? ?? ?? (eighthstep 3)
7) 10 10 00 01 (quarterstep 2)
8) ?? ?? ?? ?? (eighthstep 4)
9) 00 10 00 01 (fullstep 2)
10) ?? ?? ?? ?? (eighthstep 5)
11) 00 10 10 01 (quarterstep 3)
12) ?? ?? ?? ?? (eighthstep 6)
13) 01 10 10 01 (halfstep 2)
14) ?? ?? ?? ?? (eighthstep 7)
15) 01 10 10 00 (quarterstep 4)
16) ?? ?? ?? ?? (eighthstep 8)
17) 01 00 10 00 (fullstep 3)
18) ?? ?? ?? ?? (eighthstep 9)
19) 01 00 10 10 (quarterstep 5)
20) ?? ?? ?? ?? (eighthstep 10)
21) 01 01 10 10 (halfstep 3)
22) ?? ?? ?? ?? (eighthstep 11)
23) 1 01 00 10 (quarterstep 6)
24) ?? ?? ?? ?? (eighthstep 12)
25) 00 01 00 10 (fullstep 4)
26) ?? ?? ?? ?? (eighthstep 13)
27) 10 01 00 10 (quarterstep 7)
28) ?? ?? ?? ?? (eighthstep 14)
29) 10 01 01 10 (halfstep 4)
30) ?? ?? ?? ?? (eighthstep 15)
31) 10 01 01 00 (quarterstep 8)
32) ?? ?? ?? ?? (eighthstep 16)

(The reason why the eightstep entries are "?? ?? ?? ??" is I have not got round to figuring out what coil switching combination will take the stepper to the required position yet - give me time :o)

And here is where Alan gets very clever. It seems (to my non-expert eye) that if he is stepping in "Full Step" mode, he increments the array element counter by 8.
In other words, the 1st step is array element 1, the next is 9 which (co-incidently) is the next "full step" entry and so it carrys on.
When "halfstepping", the increment in the example would be 4.
When "quarterstepping", the increment is 2.
And when eighth stepping, the increment is 1.

Whats so good about that?
Well, firstly, there is only 1 array, not 4.
Secondly, duplicate information would not be stored. If there were 4 arrays, there would be 4 copys of the full step data, 3 of the half and 2 of the quarterstep data.

To allow us to manually switch between the 4 modes, we use 2 of the pins on the PIC and jumper them high or low. 2 pins would give you 4 valid options.
Will have to remove the 3rd jumper on the pcb as we dont need it.

Mmmm.... I wonder what we can use it for????:rolleyes:

In my case, with a leadscrew pitch of 2mm per rev, each eighthstep would move the axis 0.0003125mm. :eek: In my opinion, one third of a micron that is WAY to small a resolution.

I think I read someone say that the MechMate moves 75mm per rev of the stepper. That would give a resolution of 0.01171875mm per eighth step. Unless you have a very expensive digital vernier, you can only measure to that degree of accuracy with a micrometer and when last did you use a micrometer on a piece of wood?

Anyway, I hear a beer calling me and as it has been a rather hectic week, I'm going to listen to it.
Have a good weekend.
Best
Aubrey

Aubrey Fri 14 September 2007 12:31

Quote:
Originally Posted by Gerald D View Post
Us hydraulics people want our pipes to be clear and free-flowing. Those things that look like pipes on your circuits (I think you call them "wires"), wouldn't they flow more freely if you took the copper blockages out?
Ja Well No Fine:D
A

Richards Sat 15 September 2007 03:53

Aubrey,

You're making great progess! If you have time, Google articles and books written by Chuck Raskin, P.E.. His book, "Designing With Motion Hanbook II", published in 1992, was required reading before he would sell any stepper or servo electronics to first-time customers. I really didn't like being forced to buy a book before I could buy parts, but his book answered many of the questions that 'newbys' often have. I've referred to his book as often as I've referred to documentation from Oriental Motors. He has also written articles for "Circuit Cellar", which is an excellent magazine dealing with computer control.


All times are GMT -6. The time now is 11:40.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.