PDA

View Full Version : Lower Cost Electronics Part 2


Aubrey
Wed 25 July 2007, 06:16
Hi everyone,
Now that the basic interface to the pc has been sorted out (see Lower Cost Electronics (http://www.mechmate.com/forums/showthread.php?t=391)), the next task is to take the step/dir signals and send them to the motors.
I've been lurking around the forums (both at Mechmate and elsewhere) to try and learn more but have only succeeded in becoming more confused. Terms such as PWM, Chopping and a whole bunch more are as clear as mud to me at this time.
The motors that I am using have 6 wires.
1a....1b....1c
|.....|......|
()()()()()()

()()()()()()
|.....|......|
2a....2b....2c
Assuming for the meantime that the "b" connections are permanently connected to earth.
a) Applying voltage to 1a will place the motor at a specific rotational point.
b) Disconnecting 1a and applying voltage to 1c will take it one step further. (call clockwise for arguement sake)
c) Disconnecting 1c and applying voltage to 1a will then take it back one step (counter clockwise).

Assuming that I use a PIC or other type of microprocessor to do the logical work (I feel that it would be far easier to re-program a chip than to change componentry on a board) then is the following correct?

If there are no mistakes in my understanding so far, then using an array of 4 bits will allow me to control the magnets in my stepper.
That way I can let the 1st bit control the voltage on 1a, the second bit controls 1c, and so on.
Lets call the array "posn()".
posn(1) = "1000" which energises 1a.
posn(2) = "0100" which energises 1c.
posn(3) = "0010" which energises 2a.
posn(4) = "0001" which energises 2c.

In addition, by adding more array elements, you could get a "finer" control of the motor.
ie
posn(1) = "1000" energises 1a - rotor centralised on 1a-1b coil.
posn(2) = "1100" energises 1a and 1c - rotor centralised on 1b connection.
posn(3) = "0100" energises 1c - rotor centralises on 1c coil.
posn(4) = "0110" energises 1c and 2c - rotor centralises between 1c and 2c.
And so on.

We have now effectively doubled the number of steps to be taken to do a sequence with greater control over the actual positioning of the rotor.

The physical connections to the PIC are as follows:
pin a: connected to "step" signal.
pin b: connected to "direction" signal.
pin c: connected to motor 1a via power control circuitry (FET or whatever)
pin d: connected to motor 1c via power control circuitry (FET or whatever)
pin e: connected to motor 2a via power control circuitry (FET or whatever)
pin f: connected to motor 2c via power control circuitry (FET or whatever)

What happens inside the PIC:
Need to declare an integer variable "cnt" and initialise to "1"
When the "step" is received,
If "dir" is +ve then add 1 to cnt else subreact 1 from cnt
if "cnt" = 5 then "cnt" = 1
if "cnt" = 0 then "cnt" = 4
Place value of posn(cnt) onto pins c,d,e and f.
end when.
wait for next "step"

Assuming that I have not made a mistake yet, this "should" move the motor in the required direction.

However, here is what is getting me confused:
Assume the instruction "step" = 5v, "dir" = 5v.
The motor will step 1 step clockwise.
The next instruction is ALSO "step" = 5v, "dir" = 5v.
The voltage on the "step" and "dir" pins HAS NOT CHANGED!
How does the program in the PIC know that it is supposed to step again???

Best Wishes to all
Aubrey

Richards
Wed 25 July 2007, 08:41
Aubrey,
You've done a lot of work and research to get an understanding of how stepper motors work. But, if your experience is like mine, you've made the first step on a thousand mile journey. Designing your own stepper motor driver is not for the timid. By the time that you're finished, you'll be able to compete with any electrical engineer anywhere in the world.

Mariss has an excellent white paper on stepper motors called 'Step Motor Basics' in the support area on the www.geckodrive.com website. You'll find some very valuable information there.

You'll need a thorough understanding of chopper circuits. That subject by itself may take several months to master or much longer depending on how solid your understanding of electronics is.

Computer control of the stepper driver is a field of science that you'll need to learn in addition to electrical engineering. Little fundamentals like SINKING or SOURCING and ACTIVE HIGH compared to ACTIVE LOW signals will be easy but they will need to be mastered before you'll be able to see the step signals marching across the oscilloscope. (Believe me, it was a relief when I finally got my first TTL circuit to work back in the 1970's.)

Somewhere along the way, you'll learn about timing sequences and interrupts so that you can send a step signal at a predetermined point of time. You'll also learn the formulae governing acceleration (ramping) so that you can get a stepper motor to speed without having it lose steps.

It is a fascinating journey, but not a short journey. I spent most of my free time for several years reading and experimenting before some of the concepts started to make sense - and that was with George Baulding as my personal tutor. (He had been a senior electrical engineer at Keiser, a company that designed some very complicated electronics for the military.)

For those of us who don't have the time or the patience to build it all from scratch, the Gecko G20x stepper drivers are excellent options and the PMDX or other breakout boards are easily connected to handle the 'glue' that connects the various electronics together. I know that being outside the United States can make 'standard' parts difficult to obtain, but sometimes the time and effort to do your own isn't worth the learning curve and expense.

Every once-in-awhile I have to step back from some of my 'projects' and ask myself what business am I really in. Am I a user of CNC equipment or am I a supplier of CNC equipment? Using Gerald's excellent plans makes building the mechanical parts of a CNC router possible - even for people like me. Using Gerald's recommendations for the electronic control greatly reduces the frustration of controlling the CNC router. Letting Gerold and others do the design work will relieve you from mastering every aspect of new and complex fields without adding substantially to the cost of owning the finished CNC router.

domino11
Fri 17 August 2007, 12:25
Hi
For anyone thinking of building their own drivers and interface boards, I highly suggest looking at www.pminmo.com. He has a variety of proven driver and interface board designs as well as a myriad of information you can use to design your own. He even sells printed circuit boards for his designs for a modest cost. Check it out.

Gerald, hope its alright to post links here. I have no affiliation iwth this site but have found it most usefull.

Aubrey
Thu 23 August 2007, 14:05
Hi Guys
Sorry for the disappearing act - work pressure and all that.
Been having a look around - found the "PicStep" board (see Alan the developers site (http://www.fromorbit.com/projects/picstep/)) and it looks promising - looks like a nice, simple design electronically as all the logic work is handled by the PIC.
Very basically, the program inside the PIC has an array of binary values and a counter. When the "step" is received, it has a look at the "direction" value and then moves up (or down) the array and sends the binary to the outputs which drives the stepper (via tha LMD). The array index is then stored in the counter variable and it waits for the next step pulse to arrive.
Only problem is the LMD18245T (a dual full-bridge power amplifier rated at 3amps 55 volts) which costs US$ 13.90 or ZAR 100.00 plus postage/import tax etc.
And we need 2 per axis.
As was the case in the Original Low Cost Thread (http://www.mechmate.com/forums/showthread.php?t=391), is there not a way that we can get away with using a minimum number of discrete components (ie power transistors/FETs or whatever) to replicate what the LMD18245T is doing?
I realise that the circuitry inside the LMD is complicated but my common sense tells me that we only need a part of whats there, the rest is just extra bagage and unnecessary.
As the stepper has 4 wires, each of which can be +ve or -ve, we need 1 discrete component for the +ve signal and 1 for the -ve per wire.
This is a total of 8 components to drive the high power side.
I was thinking of a common, cheap power transistor as used in a hi-fi power amplifier or something to that effect.
There will also probably have to be a switching transistor or something between the PIC output pin and the power transistor to slam the transistor "full on" as quickly as possible.
I heard somewhere that the majority of heat generated inside a semi-conductor happens in the area between full off and full on. In the full on stage the heat generated is low because the semi-conductor is at that stage operating like an open tap and is not trying to "control" the power being sent through it. Is anyone able to verify this?
So if what I heard is correct, the ideal would be to have the semi-conductor switched on or off as quickly as possible to reduce heat generation. This would also mean that the stepper would have maximum voltage for as long as possible which means that the torque would be at its peak and able to accellerate the gantry quickly or move the tool through the material being cut efficiently. I think that these are all desirable traits.
Basically we need "power switches" (on or off) as opposed to a "power amplifier" which is what the LMD is.

Any suggestions?
Best
Aubrey

Les Filip
Thu 23 August 2007, 23:36
In all seriousness, what possible advantage could there be to spending literally hundreds upon hundreds (if not thousands) of hours reinventing a Gecko? It is already the minimum number of components needed to get the job done with the most reliability and control. If it wasn't, then Mariss would simplify the circuit. The things are very cheap for what they accomplish, are well-understood, and are supported by a first-class company. If your goal is to try to create a "low cost" replacement for a Gecko, please think about what it will take in time and resources. Your development costs are going to far exceed any savings you might eventually realize over buying Geckos, assuming you come up with a design that works at all. Then you will need to have your design manufactured, which will take materials, tools, labor, and other overhead. You will then need to sell thousands of units before you break even.

If you still want to go forward with your project, I would suggest joining forums that are devoted to electronics and see what the experts have to say. Sorry if I sounded rude, I've had a long day.

Gerald D
Fri 24 August 2007, 03:12
Les, why bother to build your own CNC router if you can buy a ready-made one? No, don't answer that! :)

The famous Gecko support is meaningless out here in South Africa - to us it is just a little box that is very expensive to get here, and not worth the shipping costs to send back for repair.

Richards
Fri 24 August 2007, 06:41
Aubrey,

You're basically correct about heat buildup in transistors. Most designers use F.E.T.s (Field Effect Transistors) when designing stepper drivers. You can find some basic information about FETs on Wikipedia.

Aubrey
Fri 24 August 2007, 08:40
Made a few phone calls to price the LMD18245T locally......
With VAT about ZAR 310.00 EACH!
Need 6 ---- ZAR 1860.00 :eek: Totally out of the ballpark! :mad:
On the way home I stuck my head in at the local hi-fi repair shop - the "low heat generated at full throttle" theory was confirmed.
He also had a quick look at 55v 3a npn and pnp power transistors as used "everywhere" (according to him) as being freely available from almost any hi-fi repair shop at a cost of about ZAR 10.00 each. Says a 2N2222 transistor should be OK to drive the transistor from the PIC at less than ZAR 1.00 each.

Economics:
8 power transistors @ ZAR 10.00 = ZAR 80.00
8 2N2222 @ ZAR 1.00 = ZAR 8.00
8 fuses @ ZAR 1.00 = ZAR 8.00 (you dont think I'm not going to provide "oops" protection do you :rolleyes:)
Total Cost = ZAR 96.00 ( or just over 5% of the LMD18245T option)

I dare say that there is going to be a bit more involved than already stated but if the cost triples we are still going to be way below the LMD18245T cost.

Comments please - even if it is just that I am wasting your time.

Thanks
Aubrey

domino11
Fri 24 August 2007, 08:45
Gerald,
Have you ever thought of building some drivers for your Mechmate? If you were to get a printed circuit boards from pminmo, then assembling them is not all that hard. Could be quite a bit cheaper than a gecko! And you could easily repair them yourself as you would have the schematics and know what the replacement parts are.

Gerald D
Fri 24 August 2007, 09:35
Heath, everybody is not the same. I personally am happy around cutting steel, machining steel, welding, bearings, wiring, volts & amps. I am not comfortable around millivolts, milliamps, oscilloscopes and pc board soldering. I happily buy electric/electronic modules and wire them together, but I try to avoid building the modules themselves. Somebody else (like Aubrey) would want to build the modules themselves. There is room for everybody - that's what makes the world an interesting place. :)

Aubrey
Fri 24 August 2007, 09:48
Hi Les,
I see you are from the USA. You guys are LUCKY in that you earn US$, are able to source the good stuff LOCALLY, and the pricing is reasonable considering the average pay packet earned in the USA.
Its not that I dont want to use Gecko drives, I (like many people who dont live in the USA ) simply cant afford them!
As far as "re-inventing the wheel" goes, this thread was headed that way in the beginning before I had done MANY hours of Googling but then I found the PICStep design (via pminmo's site - thanks for the heads-up Heath) which, judging by the feedback, performs remarkably well.
The parts (9 resistors = ZAR9.00, 13 caps = ZAR30.00, PIC16F628A = ZAR20.00, and maybe ZAR10.00 of other stuff and of course the PCB at ZAR50.00 ) can be guestimated at approximately ZAR120.00 per motor driver board.
Add approx ZAR 100.00 for the power transistors etc makes it ZAR 220.00
Compare this to the Gecko at US$ 399.00, postage/packaging, VAT, import tax etc makes it about US$450.00 (may not be entirely accurate - has anyone in SA imported Gecko's? maybe you can give a more accurate figure.)
Now you take the exchange rate (ZAR 7.24 per US$ as at 5pm local 24th Aug 2007) and you get ZAR 3258.00 PER BOARD!
To put it in perspective, this is more than my monthly bond repayment and I for one simply cannot afford it!

Gerald:
naughty naughty!
I think that the problem is that the guys in the USA dont realize how fortunate they are to be able to buy equipment at a reasonable price locally and pay for it in local currency.
Maybe if they could build a driver board for 20% of the Gecko's price that gave 80% of the performance, they would see the advantages. After all, how many cutters could you get for US$300.00?

Mike:
Thanks for the confirmation:D
From your help in the first thread, I gather that you know your way around a transistor.
May I respectfully request that you keep an eye on this thread and if you see something that is going to be dangerous (like the charge pump issue) please give us a "heads up" so that we dont blow ourselves up. (BTW Is UT Utah?)

To all the "Lurkers" if there are any.
Please say hi - it would be nice to know if there are others who are not able to get thier mill project going due to the cost of the electronics.

All the best
Aubrey

Gerald D
Fri 24 August 2007, 10:10
Made a few phone calls to price the LMD18245T locally......
With VAT about ZAR 310.00 EACH!


National gives a budget price of $9.61 for that chip (http://www.national.com/mpf/LM/LMD18245.html) - the ZAR 310.00 that Aubrey was quoted locally is $40. And to put that $40 in perspective, that is about the daily wage of an engineer fresh out of college (less than half our population earns that much per day)

Richards
Fri 24 August 2007, 10:53
Aubrey,

I'm always happy to give advice - just ask my kids! UT is Utah, a great place to live and an even better place to raise a family.

Good luck with your project. Building a stepper driver was one of the most challenging things that I ever tried. After frying transistor after transitor, I finally decided to just buy pre-packaged steppers and stepper drivers from Oriental Motor. First, I used the Vexta series that cost about $900 each and then went to the CSK series that cost about $300 each - for the much smaller PK268 size motors. The Vexta motors and drivers gave me about 900 RPM - max. The CSK would only go half that fast, but it was fast enough for the project where it was used. Gerald wrote about the Gecko drivers several years ago. At first glance, I couldn't see why anyone would use something that micro-stepped and that only had four connections available to hook-up a motor. Well, Gerald knew what he was talking about and I soon realized that the Gecko stepper driver was thee best stepper driver available - bar none.

In theory, a chopper drive for a stepper motor uses two voltage levels - a high level that is 10 - 20 times the motor's rated voltage and a low/normal level that is the same as or a little less than the motor's rated voltage. Every time a step pulse is sent to the motor, the high voltage forces current through the motor. Because of inductance - or resistance to change - it takes a certain amount of time before the voltage actually starts to rise in the motor's coils. A sensor circuit monitor's the motor's coils. When the sensor detects that the voltage in the coil is almost at the motor's rated voltage, a circuit 'chops' off the high voltage and uses only the low voltage. In very simple terms, that's basically what needs to happen. But, like they say, the devil is in the details. Getting circuits to sense fast enough and getting switching transistors to switch fast enough and still getting sufficient performance out of the motor is very difficult. It will definitely an adventure for you. :)

domino11
Fri 24 August 2007, 11:10
Gerald,
Yes I understand the differences in peoples abilities/intersts but was just curious as to yours. You seem like a real hands on person and just thought you might have done some dabbling in the driver area. :) I have experience in electronics (hardware designer) so maybe I am a little biased. :) I also dabble in things that arent my forte, but thats where the cutting and welding is my sideline hobby. :)

Gerald D
Fri 24 August 2007, 11:37
Gerald wrote about the Gecko drivers several years ago. . . . . . . . . Gerald knew what he was talking about

*blush*

I am surprised that I am being credited with introducing Gecko's to Mike :o

It must have been about 2-3 years ago that I was hunting down alternatives to the IMS481H (http://www.imshome.com/im481h.html) (not the "Plus") that was briefly used by ShopBot at the end of 2000, beginning of 2001. We went through a batch of frying a couple and spares were priced ex-SB at $150 each (?). Visited many forums and discovered the talk around the Gecko and did lots of digging around it. Mike probably uncovered some of my diggings and took it from there. :)

(SB discontinued their problematic association with IMS, who couldn't deliver fast enough, and then built their own driver boards with Allegro chips. In the changeover they added 3.6:1 gearboxes because their Allegro driver was only half-stepping while the IMS481 was set up 1/8 stepping)

Aubrey
Fri 24 August 2007, 12:34
Hi all
To start, first we have to see how it all fits together.
What I've done is taken the schematic, copied the necessary pieces and "wired" them together using gaudy colors.
http://www.mechmate.com/forums/attachment.php?attachmentid=291&stc=1&d=1187978207
The original is on Alan the designers's sight (http://www.fromorbit.com/projects/picstep/pdf/picstep_v4_0_schema.pdf)
Now all that needs to be done is to figure out what is needed to replace the LMD while maintaining the functionality (or at least the most important parts of it!).
Speaking of Alan, I dropped him a mail telling him that someone (me :o) is busy hacking his good design. I did this so that there can not be any "you stole his concept" type accusations by his fans at a later date. Cant be too carefull.:)
One thing that is confusing me at the moment is the "Direction" pin (pin 11) on the LMD which is connected (the green lines) to pins 12/13 on the PIC. May have to really study the PIC source code to see what's happening here.

Mike:
At Last!!! A little light went on in the old brain when I read your "chopper drive" contribution. Starting to make sense - SLOOOWLY! I hope that the LMD hasnt got that sort of stuff going on. If it has, I think I have a problem!

Oh well, lets go download the spec sheet and print a few copys.
Have a good weekend all.
Aubrey

domino11
Fri 24 August 2007, 13:34
Aubry,
Actually, Im not sure what type of driver chip Mike was referencing, but I do know that the LMD18245 used in the pic step uses a constant current chopper drive. Essentially they use a higher than rated supply voltage so that when you switch on the winding in the motor, you can reach full rated current very quickly. The chopper action ensures that you dont over current the motor winding and fry your motor. Maybe Mike was thinking of a timeout holding power reduction. The picstep firmware has the option for this as well. However some people dont like this as the stepper might not have as much holding power in the reduced power mode. I am not sure how this works out in real life as I have not tried a timeout power reduction driver. I myself would use the non timeout version for the extra holding power when the motor is not moving. National has a good ap note called Increasing high speed torque for bipolar stepper motors AN828 if you are interested

Richards
Fri 24 August 2007, 15:01
You guys are way past me. I was describing the theory behind building a circuit from the ground up, without any "pre-packaged intelligent chip(s)" being part of the circuit. Using something like the LMD18245T chip and the PIC processor would eliminate about 90% of the design time. I don't have any experience with either product, so I'll have to study the data sheets. I do know that the various PIC processors are popular in a lot of projects, but, since I have the tools and programmers to work with the ATMEL 8051 type micro-controller, I've not taken the time to look at the PIC.

Aubrey
Fri 24 August 2007, 15:35
Aaaaaaaagh!!!
Never mind frying the board! I've just fried my mind:o
This LMD gizmo is WAY above where I am as far as electronics is concerned!:confused:

To everyone who read this thread and thought "This idiot does not know what he's getting into", you were right! But that is cool!:cool: All it means is that it is going to take a little longer to reach the destination.

OK. If your goal is out of reach, set yourself a goal that IS attainable and will get you nearer to the original goal. I often said this to people I was teaching PHP and MySQL. - Time to take my own advice!!!:rolleyes:

Original Goal: Replace the LMD with cheaper components and retain most of the functionality. The problem is that at this stage of my electronic experience, I dont understand what half the functionality is, never mind how to do it!

So.........

Attainable Goal: Forget about mega-voltages, chopper circuits and all the rest for the meantime, just use the voltage that is specified on the motor. In my case that is 10 volts, 5.0 VA or .5 amps. Forget about supersonic speeds and torques! Must crawl before walking before running may be a good motto in this case. At this point in time, I dont care if it moves slowly, it must just move! I get enough supersonic G00's at work - gives me heart attacks every time!

I still maintain that the PICStep is a great starting point up to the high power driver section so that is what we will use. Instead of taking the outputs of the PIC to the LMD chips, take them to 2 sets of 4 terminal blocks via opto-isolators. That way we can replace the power driver section without having to re-do the whole board. By taking the LMD chips out of the picture, it may be possible to make the board single sided without too many jumper wires - will have to fire up Eagle sometime and do some work on that aspect. Will have to get my PIC-Kit working again, Windows seems to have forgotten how to communicate with it but thats normal for Bills Revenge. :D

So to start:
Transistors can switch switch voltage on/off or ground on/off, not both.
Therefore we will need 1 transistor to switch the voltage and another to switch the ground. Both these transistors need to be connected to the same trigger pin so how do we do that?
http://www.mechmate.com/forums/attachment.php?attachmentid=293&stc=1&d=1187988786
Questions:
1) Will the attachment circuit work (in theory)?
2) If there is a possibility that the transistor that is NOT switched in do some "leaking" and cause a partial or total short and if so, how can it be prevented? Maybe use OR gates or some other logic to prevent shorting or if the circuit wont work in the first place, to get it to work.
3) Do I have the transistors in the correct places and are the diodes correctly orientated?
4) Do I need to add switching transistors to drive those in already the circuit or will the output from the PICStep be enough? I think the transistor in the opto should do the trick.

Thanks for reading this and if you could spare the time, answers and suggestions would be greatly apprecicated.

Best
Aubrey

Les Filip
Fri 24 August 2007, 18:23
To All,

Like I said before, I did not mean to be rude when questioning the need to re-invent a Gecko. But I still don't quite understand how it could be worth recreating one, even if exchange rates and shipping costs are as unfavorable as I'm seeing. Maybe I need to brush up on my math lessons.

Greg J
Fri 24 August 2007, 21:32
Aubrey,

I'm just a "lurker" and just wanted you to know your an inspiration. I tried the "PIC" programing route about 8 years ago when I needed some timing circuits for an irrigation gate I was working on (its a long story). I couldn't do it because it was over my head.

Anyways, thanks for the insight on building something in SA. The problem really sounds like an import/export issue. Just thinking out loud, I'll keep reading this thread and if I can help I'll add my two cents (USD).

Oh, when having a hard time with a problem, I step away from it for 24 hours (put it out of your mind) and then re-visit it. It's very en-lighting when you re-focus on the problem.

Greg

Aubrey
Sat 25 August 2007, 10:44
Hi Les:
Dont worry about being "rude", I'm of Irish extraction and can take it!:D
I've found that often the "top of the range" stuff is way better than what I need and more often than not, way out of my budget.
Its also a case that the USA is an affluent country with easy access to almost any resources. After all, Gecko is made right there, no export or import taxes, duties and all the rest. Remember that within 10 miles of where I live there are thousands of people who survive on less than a Dollar(US) a day. Its just the way it is.

Maybe we should call this the "80/20" controler - 80% of the functionality, 20% of the cost. I dont care if it is not as fast as another design of driver, it must fit in my budget and it must work - even slowly, I'm not too fussy. After ll, it is a hobby!

All I need at this stage is to get a mill to move under its own steam. I finished the X and Y axis on a very small mill (to cut PCB's) about 18 months ago but "the electronics!!!"

I made up my mind (with a "little" help from the wife:o ) that I am not going to start on my MechMate untill I am able to make the driver boards PCB Mill. She hasnt found out yet that I have already collected most of the raw materials for it.

Even if the 80/20 is not a world beating winner, if its affordable then who cares that it can only do half the speed as the top of the range unit. At least my mill will have life.

Time to get off the soap box!

All the best
Aubrey

Aubrey
Sat 25 August 2007, 13:23
To Greg:
Welcome! Sorry to tell you that I'm no "inspiration". I'm just an idiot who wont accept "cant" or "because I say so" for an answer. But thanks anyway:o

Re: Circuit.
Spent the day at an "Artist in the Park" exhibition (wifes oils and watercolours) so I had a lot of time to think. (NOT always a good thing!)
The circuit as it stands MAY work but if an opto isolator were placed between the PIC and the circuit as shown, when the PIC went high, the appropriate transistor would trigger. However, when the PIC went low, the opto would switch off. In effect that means that the part of the circuit that is supposed to connect the 0 volt line to the motor lead would never fire.

To get around this, we could put a "pull down" resistor just behind the base to get the voltage to 0 volts should there not be a 5 volts present.
Unfortunately, the time that it takes the line to get to 0 volts via the resistor may be important.

The next question is "Would the transistor connected to the 0 volt line fire if 0 volts were presented at the base?". Probably not I suspect.

So what do we do about it?
The most likely solution would probably be to put some sort of logic gate in there to supply a voltage to the base when 0 volts is required.
I see a visit to a number of logic tutorials in my immediate future;)

But hang about! What if we had 2 logic gates, both having a pin connected to the opto-isolator and the other "criteria" pins (I'll get the correct terminology and gate type when I check out the tutorial) connected to 5 volt and 0 volts respectively.
When the PIC pin (and therefore the opto-isolator outpt) is 5 volts (assuming an AND gate) then the gate with the 5 volt connection should go high and fire the transistor.
The other gate (being connected to the 0 volt line) should fire when the voltage on the PIC (and therefore the opto-isolator) is NOT 5 volts. (A NOT AND gate or maybe more correctly a NAND gate?)
This should put 5 volts on the other transistor which should fire it reliably.
But we should still have a "pull down" resistor in there somewhere which may (or may not) cause some delay in switching on the transistor supplying 0 volts.
Looks like whichever way we go, the 0 volt line is going to have some sort of delay! Question is "Is it something to worry about or is it so short that it can be disreguarded in this application?"

And that (with a bit of lateral thinking) raises the next point:
"Fancy" driver boards use 50 volts or more to accellerate the voltage rise from 0 volts as a 50 volt signal will rise to 10 volts faster than 10 volts will rise to the same 10 volts, simply because there is 5 times more "punch" in a 50 volt feed as compared to a 10 volt feed.
The "chopper" part then takes over and reduces the supply from 50 volts to 10 volts as soon as the effective voltage has reached the 10 volt mark and thus gets everything at its peak as quickly as possible and the motor is saved having to deal with an effective 5 times overvoltage situation.
The 0 volt transistor will always fire "later" than the 10 volt transistor connected to the other end of the motor winding due to the time it takes for the "pull down" resistor to get the line below the point where the effective voltage on the resistor leg away from the 0 volt rail is below the point where a logic device will register it as 0 volts.
If the 0 volt transistor fires before the 10 volt transistor has fully reached 10 volts, maybe we can increase the firing delay on the 0 volt transistors (ALL of them!) to allow the 10 volt transistors to get to 10 volts BEFORE the 0 volt transistor fires. This way, we wont need the 50 volt supply and the chopper circuit to control things and limit the actual voltage to 10 volts as we are already there due to the CONSTANT delay between the 10 volt transistor firing and the 0 volt transistor firing!

Or maybe I've been looking at the voltage rise in the wrong component!
If the "resistance to voltage rise" is not an issue in the transistor, but in the coil of the motor, the above rambling (highlighted in Red) is nonsense due to my not understanding the problem and functionality correctly.

HELP! Rip it apart if its wrong. Call me names! I dont care! As long as at the end of it, I UNDERSTAND the issues involved, I dont mind.

As I have another "Artist in the Park" day tomorrow, I'm now going to bed. It was a long, sunburned day.

To the guys who know what they are talking about, I think that somewhere I am not understanding something. PLEASE help me out.

All the best
Aubrey

Aubrey
Sat 25 August 2007, 13:42
Originally I wanted to ask whether this circuit would work or blow up. If it is going to "bang", is there a low cost way of "un-banging" it?
http://www.mechmate.com/forums/attachment.php?attachmentid=296&stc=1&d=1188070255
The idea is to switch on both transistors at the same time and then switch off the one carrying the 50 volts after X nanoseconds where X is the time that it takes for the voltage in the motor coil to build up to 10 volts.
My gut tells me that something will melt but I have to make sure.
If it is going to melt then we will have to switch on the 50 volt transistor and after X nanoseconds, switch it off and switch the 10 volt transistor on to get the chopper effect. If the timing isnt right, there will either be a bang (both transistors on at the same time) or the motor will loose power due to a "no voltage" condition being present after the 50 volt transistor is off and before the 10 volt transistor is on.
Why didnt I try tackling something easy - say time travel?
All the best
Aubrey

Richards
Sat 25 August 2007, 23:15
Aubrey,

It's time to dig out some information on "bi-level" DC circuits and Emitter Followers (a way of connecting NPN transistors) and Steering Diodes to control the way that DC electricity flows through a circuit.

In essense, you need to turn on two transistors to allow bi-level voltage to flow through a coil. After a period of time, or when a sensor detects that the coil voltage has risen to a certain set-point, the transistor carrying the higher level voltage is shut off. The steering diodes keep the high-level voltage from leaking into the low-level voltage. It's just basic electronics, but in order for that kind of circuit to work, you'll need to master a lot of the basics. Learning those basics takes time - lots of time. By the time that you really understand it all, you'll have probably built hundreds of circuits and spent thousands of dollars on parts. (Sorry, learning about electronics is not simple for most people. I was probably slower than most. The only thing that made it all bearable was that every experiment taught a valuable lesson - especially the ones that didn't work.) To be able to build a stepper driver that really works would take the ability and experience of an electrical engineer with an advanced degree. In my part of the world, that means at least five years to get the bachelors degree and another two or three years to get the masters degree. Formal training at a university is not required, but you'll surely find yourself studying the same material in much the same manner as the university students before it all becomes clear. Sometimes someone posts a schematic that shows how a circuit works, but until you understand what every component in that schematic does and why it is necessary, you most likely won't be able to design circuits of your own.

This isn't meant to discourage you. Electronics is (are) fun! Seeing mechanical things function with the help of electricity is fascinating. And for those of us who want to build our own machines, knowing how things work is a necessity - unless we're willing to call in an expert every time something stops working.

But, learning electronics is no harder than learning math or another language. In fact, because of a terrible experience I had with math in 9th grade, I really struggled with math clear through 12th grade. In college, I opted out of math and science by studying a foreign language. All that did was postpone learning math. For the last thirty+ years, I've had to use math every day as a computer programmer and as a designer of process control computers. However, I still stumble around the math. I have to check and re-check each equation because I've learned how to use formulas to solve each problem, but I still don't have a good understanding of math priciples.

So, if you have a friend or neighbor or relative who is really good at electronics, become his best friend. That's almost what I did. Years and years ago, I owned and operated a photo finishing business that only served professional photographers. My customers demanded top quality. Giving them top quality meant that I needed a Video Color Negative Analyser (a close circuit television that cost $40,000 back in 1977). I didn't have even $1,000, so I asked around to see if there was an alternative. It just happened that a great electrical engineer had been asking if there was a need for a low priced video color negative analyser. I looked him up that same day. Before long he was personally tutoring me about electronics and I was personally tutoring him about the photo industry. He drew hundreds of basic schematics for me until I finally understood how a resistor worked, how a capacitor worked, how a TTL gate worked. He taught me how to work systematically through a problem and most of all, he encouraged me to stick with it. It really took years and thousands of dollars for parts before I was able to design reliable process control circuits of my own. Thanks to George, it was an enjoyable journey.

Stick with it Aubrey and don't be too disappointed if there are a few problems along the way.

Edited:
Now that I've probably ruined your weekend, I should probably tell you two more important points. A stepper motor that only runs at its rated voltage will take 1 to 3 mS per step. So, a 1.8-degree stepper (most steppers used in CNC routers are 1.8-degree motors) will take 200 steps per revolution. That means that it will take between 200 and 600 milliseconds for the shaft to turn one time. That's not too bad, except for the fact that the per-step resolution on a 200 step motor is going to be really bad - ten times worse than a Gecko micro-stepping driver gives. If you were able to design a 10X micro-stepping circuit for your stepper driver, and if you had to live with the same 1 - 3 mS per step, each revolution would take 10X longer.

Sorry for the additional bad news.

Richards
Sun 26 August 2007, 14:06
Aubrey,

I've been mulling this over since you first posted. My suggestion would be to talk to your potential customers. Explain to them what you will be able to do once you have the machine built. Ask them to help front the costs to get the machine going.

Building your own driver controllers can certainly be done, but when you figure in the cost of missed business, its just too expensive to delay a project because of a few hundred dollars.

That's basically what I ended up doing in my photolab business. Even though George (in the post above) made a wonderful closed circuit television and even though he was a wonderful tutor and even though I traveled all over the United States installing his machine and teaching people how to use it (every week-end for a year in 1977), I ended up buying the VCNA from Kodak because the $40,000 machine did the job and George's machine didn't do the job as well. It just took a few minutes on a spreadsheet to see that even though the $40,000 machine from Kodak was almost 7X more expensive than George's machine, that within a year, the amount of waste generated by George's machine would end up costing me more than the Kodak VCNA. I met with several customers and asked them to commit to continue sending me their work so that I could qualify for direct financing through Kodak. They were happy to help and Kodak was willing to sell a machine to a guy working in a rented apartment in far off Utah. Within a year of getting that VCNA, Kodak was sending top people from their company to visit my lab to see how someone working from his basement could print 1,500 negatives an hour while their own labs, using the same equipment were printing 250 negatives an hour.

Everything is possible. Re-inventing the wheel is not always the best way to solve a small problem. Instead of thinking that the Gecko stepper drivers are too expensive, be creative and think of products that you can make once you have the machine built. Form some type of co-op, if necessary, where you guarantee to cut parts for members of the co-op at a reduced price if they're willing to help you get the machine and other tools needed to cut those parts. You'll all benefit - if you work together a little and help each other out.

domino11
Mon 27 August 2007, 07:48
Aubrey,
I am still wondering why you want to DESIGN your own controller. With the multitude of great driver chips available these days, and board layouts and schematics available at www.pminmo.com and www.fromorbit.com of circuits using the most popular chips out there. These are the same chips used in boards from places like hobbycnc and the like. The other thing is that these designs work. Check out post over at www.cnczone.com and you will hear of the people using these designs. A driver board with the allegro 3977 or the national lmd18245 will more than adequately drive the steppers used on the mechmate. You can use the 1 amp or 2 amp version of Geralds recommended motors. (Hint the 2 amp version has a much better torque curve). I am an electronics designer in my day job and I fully understand the interest in designing something yourself, but just ask Phil at pminmo.com or Alan at fromorbit.com how long they have worked to get their designs working as well as they do. Both guys are great and will drop you a line if you email them a question. Sometimes its better to use a proven design and just do the building of the boards yourself!

Doing your own design is possible but just very time consuming and expensive, as mistakes corst you time and parts.

If you need parts for a board give me a pm or email, I might be able to help you out.

Aubrey
Mon 27 August 2007, 14:56
Hi Mike
No you didnt ruin my weekend - sitting in the park freezing in the wind did a good job of that! :mad: But on the plus side I did a lot of figuring things out with regard microstepping - got a question ot two with regards this but will get to that in a later post.
I'll google "bi-level dc circuit" and see what comes up - thanks.
After reading your posts I think you have probably read me better than I read myself. Apart from making circuit boards and fancy frames for Nelly's art (Nellie is the better half!) I have come to the realization that this thing that I have about building a cheaper moustrap has its roots in the fact that in the late 60's and early 70's I started to get into electronics. Built a number of basic (by todays standards) lighting controlers, power amplifiers and effects boxes for guitars for a number of discos, bands and suchlike.
Unfortunately, life got in the way and I stopped playing with transistors.
At this stage of my life, the interest has re-surfaced so its time to re-learn what I knew (and have forgotten :o) and catch up on everythiing that has come along since then.
Fortunately, I have the ability to think things through (as opposed to simply taking what is said as fact) and usually pi$$ people off with so called "stupid questions" which normally arise because I dont understand what has been said. The "charge pump" issue in the "Lower Cost Electronics" was an example of me not understanding what the actual issue was. I didnt understand why one was needed. Once the light went on it became abundantly clear that in order to have a "safe" breakout board, the charge pump was critical.
One of the "gifts" that I have is that I pick things up quickly. I learned ASP programming from scratch in a week, had an inventory package up withing 2 weeks, became proficient in PHP in about 6 weeks (a rather complex insurance call center system was the immediate result) but I think this electronics thing may just take a little longer. :eek:
What will make the process a lot easier is the internet and the volume of information available, not to mention people like yourself who take the time to help stumbling idiots like me.
And I will stick to it! The first thing I did to make some order out of the chaos was to write a little browser based inventory program to keep track of the bits in my newly aquires parts drawers. If anyone wants a copy, PM me and I'll email you the code and setup instructions - it works well on WAMP (Windows Apache Mysql Php).

My only concern is tht Gerald will not like me taking up server space and time on a subject that may (or may not) be what he had in mind for this site.

Regarding the "additional bad news", the PCB mill has a 16mm x 2mm pitch lead screw, the motor is a 200 step/rev unit which gives me 2mm travel per rev or one onehundreth of a millimeter per step. That should be accurate enough for the job or have I got that one wrong too? At work we very seldom (only for medical devices so far) go to the micron level. As to the future MechMate, you will not be able to measure much better than a quarter millimeter anyway and a little bit of fine sandpapering would surely blend in any lumps and bumps.

As to the speed, 600 ms per rev = 300 ms per millimeter = 3.33 mm per second = 200mm (or about 8 inches) per minute which doesnt seem such a bad speed for cutting a PCB. At least the mill is alive and the job is getting done.I used to be into oval track racing and rallying and suchlike and I must admit that as I have gotten older, my need for speed has reduced.

As an aside: I often read with a smile, both here and on other cnc sites, guys wanting to get tollerances approaching the micron range with thier machines. In most cases they are cutting wood!!!! Even if they get the size correct to the 5 micron level, tomorrow when the humidity has changed, so has the size.:D I wonder why that level of accuracy on an unstable (at the micron level) medium is an issue. I'm not flaming anyone, go for it if you are able to, all I'm saying is that it simply does not compute in my grey matter. :confused:

The "Co-Op" idea is a good one. I may be able to set something up. Will have to do some thinking on that one.

Hi Heath,
I think the above explains my "somewhat futile" mission. However, for a number of us price is a dealbreaker.
I have been all over both Alan and Phils sites, I even emailed Alan to give him a heads-up about what I intend to do to his excelent PICStep creation just so that no-one can tell him that I am ripping off his good work for private gain.
I dont know whether either Alan or Phil are members of this forum as the member list has been disabled.
I agree with you that a proven design would be a better option but if I can get it done using bits from old hifi amps and such, my mill will be up and running sooner than eventually when I win the lotto.
I also admit that it wont be too long untill 8 inches/minute will start to agravate me but I can assure you that 0 ipm is agravating me a whole bunch more at this time.
By using "power" transistors that cost less than $0.50 each (need 8 per axis) to get the mill moving (however slowly) makes things a whole lot more affordable to some of us not lin the USA or Europe. If I manage to find (and more importantly, understand) the "bi-level" lead given by Mike and impliment this concept (probably as a version 2 option) then we have a chopper driver. At this stage I shudder to think of the troubleshooting that will probably have to be done but anyway....

As to the offer, you will definitely hear from me at some stage - thanks:)

Anyway, bed time. See you guys tomorrow.
Best
Aubrey

Gerald D
Tue 28 August 2007, 02:17
No problem with the server space. As I've said before, this MechMate project is all about people wanting the DIY route. When are you winding your own steppers? :)

domino11
Tue 28 August 2007, 07:39
Gerald,
I just noticed your post 4:17 am? I hope that doesnt take into account the time difference! Or do you stay up that late?

domino11
Tue 28 August 2007, 08:32
Aubrey,
Here are a few app notes from Allegro. Some reference specific brand steppers or specific Allegro chips but they have a lot of info on drivers and steppers and how to interface to them. Maybe of some interest to you.

Gerald D
Tue 28 August 2007, 09:22
Heath, that post shows 10:17 to me as my local time (during the morning tea-break) - you slow people are still in bed then, 6 hours behind us. :)

(This post shows me 17h22 - after the home commute)

Aubrey
Tue 28 August 2007, 11:14
When are you winding your own steppers? :)

Yea! Right!:rolleyes:

Thanks for the OK to carry on this project on Mechmate.
Aubrey

Aubrey
Tue 28 August 2007, 11:45
Aubrey,
Here are a few app notes from Allegro
Thanks - I see one of the pdf's have a seemingly complete driver circuit - will have to study this (untill I understand it:o)
Does anyone have a site that you can get a price on without having to send a RFC?

Aubrey

domino11
Tue 28 August 2007, 11:58
Aubrey,
Some of the better sites for electronics components (in the US anyways, Im in Canada and get stuff shipped to me all the time) are

www.digikey.com
www.mouser.com
www.newark.com

You can at least use these for price checks

domino11
Tue 28 August 2007, 12:01
Gerald,
Yeah I figured as much, I thought the forum corrected for your own time zone. Funny here in Canada everyone calls the morning and afternoon breaks "coffee breaks". Tea doesnt seem to be as popular here. Is coffee poplular in South Africa at all?

domino11
Tue 28 August 2007, 12:12
Aubrey,
here is a discrete design from Phils site. Take a look, easy to get parts

Gerald D
Tue 28 August 2007, 12:22
Coffee sure is popular, but 90% of it is "instant" (and vile). We didn't have a Boston tea party so we don't have an issue with the word "tea" :)

We are also the home of Rooibos (Red bush) tea which has become a popular export.

Tom Caudle
Thu 30 August 2007, 10:00
From an old power design engineer that has done motor drives (Up to 10HP) and switching power supplies (up to 2KW) I can tell you that even experienced Electrical Engineers avoid working with high current, big inductive loads and higher voltages. All the young engineers think EVERYTHING is digital and 5V or less (:-)

I have watched the threads on the DIY motor drives (CNCZone has one on a DIY Servo controller that has been going on for almost a year!) with a smile; it's not as simple as just finding a chip and putting the recommended components together. You need to have some pretty good test equipment (high speed Digital storage scope, active high speed current probe, good bench power supplies) and plenty of spare parts. Board layout is critical and you can't get too far with a hand built breadboard in the power sections. Even with a proven layout and cards being available the chances for success on the first try are low.

I have the experience and equipment to easily design my own stepper or servo controller. I do not have the hundreds of hours to devote to a project that really works. You can twist a stepper with some transistors and a few cheap chips BUT it will top out at about 60 to 100RPM and be really ragged (full step). It would be fine to spin a sign around or to move a toy but would be virtually useless for any CNC work. The easiest is a simple Unipolar driver (two power transistors per coil, 4 per motor) using LR (big resistor) current limiting. None of those work very well for larger applications or CNC.

This "hobby" of Home Shop CNC is interesting. For some it's enough to just build something (they are enjoying the journey). For others it's about what you can do with your own machine that motivates them (they are about the destination). There are varying levels of integration for a project. You can buy some parts ready made and others do yourself. You can buy the metal parts partially or fully cutout and fabricated or you can (as an extreme example) dig your own iron ore and smelt it and make your own steel. You can design and build your own electronics, wind your own transformer and build your own motors. Each one of those projects assumes you have the knowledge and skillset required to pull it off.

When I built my first table on a limited budget I scrounged everything I could find...still, I saved up and bought my motor drivers from Gecko because I KNOW what it takes to build one that actually works reliably and effectively.

If you want an educational project and to teach yourself some electronics then build your own motor controller. At the end you will learn a lot. If you want to build a CNC table and get it moving and cutting then buy some drives and realize there are MANY other challenges in the process.

This may come off as sounding mean spirited...it's not sent in the vein. It's from a grizzled old design engineer and comes from experience. I have been in the HSCNC space for over 6 years and have watched dozens of guys post on various lists about how they have been reading and thinking about the technology and THEY have a idea that will revolutionize the process and THEY are going to design and build the ultimate motordrive/interface/power control/[put your idea here], and it will be better than anything out there and cost pennies to make. Something bad must happen to them because so far I have never heard from any of them again!

Aubrey
Thu 30 August 2007, 14:28
Hi Tom
Dont worry about "mean spirited", your comments are appreciated whichever way they go.

I have been doing a fair amount of research and what I have read leads me to the same conclusion: "Stepper Driver hardware is not as simple and as easy as the uninitiated would first realise".

In my case it is really that I need to get the mill moving to see if the mix of designs that I used are working together. This need not necessarily be at the speed of light, quite the opposite in fact. At work we always run a new program (or modified ones) at 10% of the feed rates that are programmed just to see what it is doing. (Finger trouble is a b1tch!) On the Fanuc controler this is a rotary switch so it is easy.

Once the mill is alive, there are many aspects which I have to master before I would consider running at optimum feed rates especially on the software side as the apps we use at work are way out of my league financially. I'm definitely on a "freeware" budget at his stage.

I am also using the project to get my electronic skills kickstarted again after a 30 year absence. I do realize that education comes at a cost, normally fried components in this case - so be it.

So if the mill is painfully slow, at least I know that it is working and that knowledge will make the US$1200 investment in a trio of good commercial controlers easier to swallow.

Once I build my MechMate, I will be needing an accuracy of one tenth of a millimeter (cutting wood) so microstepping capability is actually not really required in this application. (The neighbours music will easily drown out the noisy steppers - they must just wait, my injection molder should be up some time in December, then we'll see who can make a bigger racket!)

I am also under no illusion that whatever is designed and built, it will fall short of the speed and dependability of the commercially available units. On the plus side, it should be a whole bunch cheaper and more accessable than imported commercial units.

So in the meantime, I must get some motion - ANY motion - EVEN INACCURATE motion. Only at that time can any realistic assesments be made as to what shortcomings are present, what the priorities are as far as reducing said shortcomings and what the financial considerations are.

As "modularization" is the key buzz-word here, I have yet to see a design that splits the driver board into a logic and a power module. To me, this makes perfect sense.

My modules will be as follows:
1) Computer (got Ubuntu up so it may well be EMC)
2) Breakout Board (see original Low Cost Electronics thread)
3) Logic Board (abreviated PICStep)
4) Power Board (from a unit using scrap power transistors out of old hi-fi sets to one using a 300 amp DC welding plant as a power source to take a rediculous example.)

From what I have read (and from what you have posted if I understood you correctly), the power circuit is where the entire system becomes efficient or blows up.

By using the 4 module approach, the guys that know about chopper circuit design can build very fancy power boards without having to worry about the preceeding logic and the guys on a limited budget can get thier machines moving while planning the purchase of components to build the more high performance power boards.

Who knows, maybe companies like Gecko and others will soon start offering logic boards and seperate power boards.

Anyway, 10:30pm local - I'm off to bed.
Best
Aubrey

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
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
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
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" (http://www.mechmate.com/forums/showthread.php?t=391) 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
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.

.... 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
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
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
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
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).


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
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
Hi All,
Drew this up after watching the Rugby World Cup opening ceremony.
Logic Board layout (http://www.mechmate.com/forums/attachment.php?attachmentid=326&stc=1&d=1189208878)
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
Made some changes and improvements to the Logic Board (http://www.mechmate.com/forums/attachment.php?attachmentid=327&d=1189246555).
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,
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.

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.

....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.

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/prod_documents/doc8017.pdf

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

Aubrey
Tue 11 September 2007, 15:21
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
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
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
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.

Aubrey
Sun 16 September 2007, 01:50
Aubrey,
You're making great progess!
Thanks Mike. I'll be surfing for info on Chuck Raskin later today.


I think that this would be a good time to saySTOP THE BUS





In post 78 I listed an array that is not necessarily correct!
Let me explain:
I have been fighting with the array since about post 62 where I first listed an the halfstep array of motor coil energizing commands.
Since then, I have been trying to figure out what the energizing sequences would be to get the motor to step one eighth of a step but have not been having too much success.
Eventually, I wrote a small VB app to take the byte that I want to send to the stepper and graphically represent it on screen so that I could "see" what happens as far as the coils magnetic fields are concerned when the various bit values are changed in the energising command byte that I want to send to the motor.
Had to do a bit of debugging and eventually got it to work OK for this exercise.
And here is the kick in the teeth!
Simply applying 10 volts to the motor (in appropriate polarity) works 100% for full stepping and half stepping.
I think that it is "ALMOST CORRECT" for quarter stepping as well.
But for eighth stepping and better, IT WONT WORK in its present form!

Everyone say in chorus: "But we told you so!" :o

Why wont it work?

Here is 2 of the graphical results from the app. The left image is the first full step and the right is the first quarter step. The yellow lines in each represent the central position of the magnetic fields.
Left Image (Full Step 1): As can be seen, there is only 1 line visible. The lines are in exactly the same orientation and therefore there is no "nudging" of the motor shaft due to the interaction of magnetic fields. The orrientation of the rotor/shaft is "north/south" or vertical.

Right Image (Quarter Step 1): Here 2 yellow lines are shown, one for the red half-circle, one for the blue quarter circle. The green line is the (approximate) average position that the rotor/shaft will find itself due to the interaction between where the red field wants to place the rotor/shaft and where the blue field wants to place the shaft.
Note: All green and yellow lines were added manually by me to the image to help me understand what was going on.

The white dot with the green background and yellow circle around it that is pointed to by the red arrow (yea! I know! Its a rainbow!) is where the rotor/shaft must be to sucessfully position at eighth step 1.

The only problem is that using the methodology as it stands, I cant get there! :mad::mad::mad::mad::mad:

http://www.mechmate.com/forums/attachment.php?attachmentid=361&stc=1&d=1189928027
<edit - for some reason the image wont display inline (for me). You will have to click the link.>
So, to get eighth stepping or better, we will have to make changes somewhere but what and where.

As we are using a PIC to get things done on the logic board, we probably wont have to change anything physical on the logic board. (Note to me: Maybe the opto-isolators cannot handle analog signals.) The programming inside the PIC is another case entirely!

Essentially what is going to have to happen is that we are going to have to change the output going to the power board from a simple 5 volts ON or OFF to a more complicated scenario where the voltage being placed on any pin (and therefore magnet coil) is variable between 0 volts and 5 volts. (Note to me: Can a pin on a PIC be set to output analog signals?)
By varying the strenghths of the fields produced by the various coils, we should be able to position the rotor/shaft at the exact position required.
Theoretically I think that we should be able to "step" the motor in such small increments that it would be rediculous.

Now the complexity of the arrays that Alan uses in the PICStep is starting to make sense. I'll have to study that code again in light of this discovery to see what else I can learn from it.

An equally important point to remember when it comes to the time to build the Power board is that the power transistors/FET's or whatever will now be required to do partial switching.
In effect this means that (assuming the motor voltage is 10 volts) if the Logic board outputs a 4 volt signal (logic board operates between 0 and 5 volts), the power board must be able to output an 8 volt (4/5 * 10v) to the coil.

:rolleyes: Mmmmm.... I wonder if the reason that no-one has produced seperated Power and Logic boards is to prevent people (idiots like myself) from using long lengths of wire between the two, thus affecting the voltage of the analog signal being received by the Power board and thus the field strength of the coils and thus the positioning. Long lengths of wire have been known to cause voltage drops and here it would change the positioning of the rotor/shaft. Something to bear in mind when writing the documentation for the final product.

Ok. The world suddenly got a whole bunch more complicated!:confused:
Not to worry though, the understanding of the processes involved also made a great improvement and now we are probably better equiped to get this project done with a better level of efficiency and success.

To those who have helped by posting comments and/or info links, thank you. Without your input, this thread would be dead in the water.

To those who are "lurking", hows about a post, subscription or a rating? I must admit that the discoveries that lead to this posting have somewhat sapped my energy but not my enthusiasm. This does not at all mean that its going to be abandoned but a little moral support would be good for the soul if you know what I mean.

Have a good Sunday all.
Best
Aubrey

Aubrey
Sun 16 September 2007, 02:17
Aubrey,
If you have time, Google articles and books written by Chuck Raskin, P.E.
He has also written articles for "Circuit Cellar", which is an excellent magazine dealing with computer control.

To quote one of his articles on circuitcellar.com

It's critical to understand both the operational and system-reaction differences among various types of steppers. For example, a chopper drive always causes stepper motors to vibrate when not commanded to move.
May explain complaints made about motor buzzing, vibrating etc.

The microstep translator is so-named because the stepper motor's current-generated magnetic field enables the armature to be positioned anywhere between its actual detent positions. The most popular microstep ranges available (at reasonable cost) are 2, 4, 8, 16, 32, 64, and 128 steps per full step.

Comments:
Maybe we should call the Logic" board a "Translator" board instead.
128 steps per full step gives a resolution of 50.625 Seconds. That would be high resolution in anyones books!:eek:

Aubrey

Aubrey
Sun 16 September 2007, 12:29
OK - time to stop feeling sorry for myself!
1) We dont have to use analog signals, we use PWM to get the result we want.
(Pulse Width Modulation - switching the pin on and off very quickly. By changing the length of the on and off parts, the average represents the voltage required. eg. 5v on pin, 50% duty cycle or 50% on, 50% off should give you 2.5v as the average voltage give or take)
I had a look around the Microchip.com site and found out that the PIC is often used to provide stepper driving. I specifically looked at Stepper Motor Control Using the PIC16F684 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en012150) which explained a number of points.

2) Opto-isolators generally are no good when using analog signals as they have a voltage below which they do not switch. Also, they dont "turn on partially", they are either on or off.
But as we are using PWM (which is digital) we wont need analog signalling.

All of this means that the Logic board design does not have to change which is a good thing. :D We can use the PIC to do PWM (a built in feature on certain units, if not all). All of this will have to happen in the program.

Speaking about the program, we are going to have to develop it mode by mode starting with the full step and working down, making sure that the mode currently under development does not screw up the operation of any of the preceeding modes.
As both full and half stepping wont need any PWM, when these are being developed, a 100% duty cycle can be used for the PWM setting. This way, when we get to the modes that need PWM, it is already implimented and can simply be used. The PWM cycle percentage info is stored in another array (THATS WHY ALAN HAS 2 ARRAYS - NOW IT STARTS TO MAKE SENSE!)

{Note to Gerald: Hows about a lightbulb smiley so that I can mark those "Eureka" moment?}

Where to now?
Tuesday I have to see a surgeon for a checkup. After that, I'll probably be going to Pretoria (or Tswanie if you are politically correct - wont go there on this forum :mad:) to get parts for a controler project at work and will get the bits for the Logic board at the same time. Another prototype board may be a good investment too.

Hopefully we can have a motor fullstepping on the bench by the weekend sometime as long as the work project does not give too much drama.

Sorry I was so negative in post 81 but panic set in when I realised that stepping below halfstep involved a whole re-think. At one point I really thought that this project had been blown out of the water and I would have to abandon it. I REALLY dont like giving up, its a bad habit to start.:(

Have a good week.
Best
Aubrey

Richards
Sun 16 September 2007, 12:47
Opto-isolators typically have minimum pulse-width requirements. Mariss uses good ones on the Gecko products that allow about 200,000 Hz, but many of the average (cheap) opto-isolators would have a hard time keeping up with a 10,000 Hz signal.

Aubrey
Mon 17 September 2007, 11:50
Opto-isolators typically have minimum pulse-width requirements. Mariss uses good ones on the Gecko products that allow about 200,000 Hz, but many of the average (cheap) opto-isolators would have a hard time keeping up with a 10,000 Hz signal.

Hi Mike,
Found the manufacturers data sheet (http://www.isocom.com/datasheets/db91081.pdf), they They quote figures as follows:
Turn-on time : 3.0 µs
Rise time : 2.0 µs
Turn-off time : 2.3 µs
Fall time : 2.0 µs
Cut-off frequency : 250kHz

The number I looked at was "250kHz". I assume (a dangerous word) that this means that the thing will start "mis-firing" above 250kHz.
So lets work at 80% which would give us 200 kHz. If we set the cycle of the signal being generated by the PIC to 200kHz (or less), it should be ok. We cant - its directly related to the crystal speed used on the PIC.

Extract from the basic manual:
PWM Pin,Duty,Cycle
Outputs a pulse width modulated pulse train on Pin. Each cycle of
PWM consists of 256 steps. The Duty cycle for each PWM cycle
ranges from 0 (0%) to 255 (100%). This PWM cycle is repeated Cycle
times. Pin may be a constant, 0 - 15, or a variable that contains a
number 0 - 15 (e.g. B0) or a pin name (e.g. PORTA.0).
The Cycle time of PWM is dependent upon the oscillator frequency. If a
4MHz oscillator is used, each Cycle would be about 5ms long. If a
20MHz oscillator is used, each Cycle would be about 1ms in length.
Defining an OSC value has no effect on PWM. The Cycle time always
changes with the actual oscillator speed.
Pin is made an output just prior to pulse generation and reverts to an
input after generation stops. The PWM output on a pin looks like so
much garbage, not a beautiful series of square waves. A filter of some
sort is necessary to turn the signal into something useful. An RC circuit
can be used as a simple D/A converter:

As we will be using a 20MHZ crystal, the cycle will be 1ms - that should deal with the strain comfortably.

The RF circuit they use as an example is a 10k resistor and a 1uF cap. Simple and cheap.

Your comments please.
Best
Aubrey

domino11
Mon 17 September 2007, 13:05
Aubrey,
At 200 Khz your period is only 5us. The 250 kHz is only the absolute maximum frequency the isolator will tollerate. With the other specs your setup, rise and fall times I dont think you will want to switch that fast. Maybe research a better isolator. As Mike said, gecko needed to use high quality isolators to get to 200Khz. I dont know of any good ones but a google search might be helpfull. :)

domino11
Tue 18 September 2007, 11:08
Aubrey,
I had a closer look at your datasheet and I noticed the following. The specifications for switching mode of operation for that opto has TYPICAL turnon time of 3 us and a min turn off time of 18us at an current of 20mA. Rise time and fall times are 2us and 11 us respectively. This looks to me like a max frequency (probably not usable at this freq due to tolerances the specs are typ not max) of about 29KHz. Maybe you could get a better isolator, a quick check turned up a 6n136, fairchild makes these and they are relatively easy to get here at most suppliers and they are a lot faster. Another option would be for logic level couplers used in data transmission, these can operate in the vicinity of 20 to 40 Mbaud. I dont have any part numbers off the top of my head but let me know if you are interested and I can dig some up. The 6n136 are probably easier and cheaper to get.

Tom Caudle
Tue 18 September 2007, 17:09
Those series of opto's are only usable to a few kilohertz. When your combination of rise and fall times become greater than the period of the shortest pulse you are pretty much through. Most processor chips need fairly snappy rise and fall times because you are only reading a pin for maybe 2 to 4 clock cycles. With trapezoid waveforms you will miss pulses.

The 6N136 series for faster risetimes and even then you have to be careful with deep saturation.

Then with microstepping your raw clock cycles start to come into play. In running CNC and spinning motors at 600 to 800 RPM you find you need lots of steps quickly. It's not unusual for 25.000 steps per second to be too slow. While that is no problem for a PIC remember that you are going to be burning multiple clock cycles and trying to do microstepping. Things add up pretty quickly. To spin a stepper at 10 Rev/sec (600 RPM) you need 200 * 10 or 2000 separate transitions. For 1/4 stepping you need 8000 per sec etc....
If your chip has to do anything else but generate the step sequences you quickly start facing max stepping issues.

I'll stop here. I don't want to spoil all your fun. (:)

Aubrey
Tue 18 September 2007, 20:00
Hi Heath, Tom,
Very good points that have been raised with regard the limitations of the CNY17-1X opto-isolator.
Could not find a local price for the 6N136 but based on the price of US$ 2.81 from RS Components (normally on the high end of the price spectrum) this will be about ZAR 21.00 each or 10 times more expensive and we need 8 per motor.

Been thinking about it a lot.
We have been doing a lot of problem solving for situations (microstepping variants) which we have not got to yet and are getting mired down, which is not a good thing.

I have to keep reminding myself that the idea behind this thread is to get the mill to move, not to make a driver that will dominate all the rest. (Net yet anyway! :D)

Once the bare bones design is built and tested, we can start developing it to get closer to the ideal running specifications.

Because we can in theory step at full and half step rates without PWM driving which will allow the use of the low cost opto-isolator, this is where we should start.
Once we start on phase 2, we must also ensure that we are backwards compatible so that the user can start with the low spec components and ride the upgrade path without having to get a new board.
And remember, we MUST get to phase 2 (microstepping) as soon as possible as I want to build my own MechMate over the December shutdown and with a 75mm per rev requirement, high power microstepping is mission critical.

Someone said to me today that if the opto was causing so much grief, we should simply leave it out.:eek: I wont even consider it as a "minimum specification" but I suppose we can put in jumpers that will carry the signal over the hole left by the opto. The guys can go that route if they want to but......

Someone else also explained to me that a silicon switching device generates very little heat when if is full on and full off. The heat gets generated while the state is changing and when it is operating between on and off (half on, quarter on etc). Therefore we must make sure that it spends as little time as possible between on and off (transision or partially conducting) to prevent destructing of the lower cost, lower specification components that will be used in the Power module.
Chopper circuits get the rise ramp happening steeper but at a cost of higher component count AND bigger power supply. A trade-off will have to be made somewhere so I think the base Driver board should also be as simple and inexpensive as possible and the full and half modes on the Logic board should have to be optimised for the base Driver board. To start with anyway.

Guys, I dont know where this project is going! It may go nowhere. It may also become the "Linux" of the CNC hobby field with a whole bunch of guys devloping Power board designs each with different pro's and con's and others doing the same to the Logic board. Users might be able to "mix and match" to get the ideal setup for thier machine. I simply dont know!

All I do know is that the longest journey starts with a single step and so to get that "single step", I need to build the prototype Logic and Power boards.
If it does not work, I'll see if I can get it to work. When it does work, then we look at improving it but all the time we have to stay true to the original concept of "a lower cost electronics" solution that the new guy can afford and build without robbing a bank to pay for it.

For the next 2 weeks or so I wont be as active on this forum but I will look in every other day or so. The reason involves about 350 resistors, many diodes transistors and caps, about 50 relays, 20 or so limit switches, 6 pieces of 12 inch by 4 inch Veroboard and 2 big 40 pin PICS which are all eventually going to to become an electro/pnumatic production machine controler. A lot of soldering, testing and fault finding lies ahead so wish me luck.

I've already bought a whole bag of bits, everything (I think) for the Logic board and most of the goodies for the Power board. Finished the 5v power supply today and on Saturday will be scrounging a transformer for the Power board main supply at the local HiFi repair shop but from tomorrow onwards, I will have to concentrate mainly on the boss's project.

But PLEASE dont let this thread die while I'm scarce, to quote the Terminator, "I'll be back!"

Suggestions, Wish Lists, Specs (volts/amps) of the motors that you may want to drive using this setup and anything else will be appreciated and answered, eventually.

All the best
Aubrey

Bill McGuire
Wed 19 September 2007, 19:58
Aubrey...
Good luck putting your board together...
Hope your Dr's visit went well...

Aubrey
Fri 05 October 2007, 21:25
Hi All
Just to let you all know that I have not fallen off the face of the earth.
Aubrey...
Good luck putting your board together...
Hope your Dr's visit went well...
Thanks Bill. Dr visit went ok. Almost got full mobility back, strength is still not so good but the pain is gone.

I have to get a couple of boards etched this week so I'll sneak in the logic board as well. The power board will be done on Veroboard for the meantime.

Busy battling with PICBasic Pro, cant get it working properly. If its not up and running properly by Monday, I'll be taking a crash course in mnemonics programming.
May be for the good. Fortunately, I pick up programming languages very quickly. EXCEPT C for some reason or other but I do PHP which is evidently much the same.
Maybe I suffer from "C" dyslexia or something. (No insult intended at all, some of those people who suffer from dyslexia really have it tough. But they survive and have my respect.)

About the opto-isolator thing, initially going with the unit proposed. There WILL be an upper speed limit but this is the first step of a development and there are probably going to be a number of other "problems" to overcome before it becomes a real issue to going forward.

Did some reading on reference material that I downloaded but had not yet got to. Evidently, if you full step using 2 coils (one North, one South) the resonance frequency is different to the one using only 1 coil (North only).

Basically what the author suggested is stepping using the method with the highest resonance frequency untill you are past the resonant frequency of the lower one and then switch to the method with the lower frequency. That way you never actually achive resonance.

For example, method 1 resonates at 2000 steps/sec, method 2 at 2500 steps/sec. So you use method 2 below 2250 steps/sec and method 1 above 2250 steps/sec. There is also a warning that every design of motor (and individual motors within the same model series) have different resonance frequencys. Maybe it would be a good idea to make the threshold frequency adjustable using a trimpot on the board. That way it is adjustable without playing around in the PIC's program.

He also warns that microstepping is not an exact science in that a 1/8th step's position probably wont be exactly in the center of the leading and trailing 1/4 step. Also, 2 identical motors can behave in different ways and/or positions using identical input signals. However the same is also true when full stepping he says. The difference is that a 0.1 degree error in positioning is far less of an issue when stepping 1.8 degrees (5.5%) than it is when stepping 0.225 degrees (44.4%)

Isnt it wonderfull having so many variables! Yea - Right!

But then again, the hobby machinist is not dealing in microns. My personal opinion is that a theoretical accuracy of 1/100th of a millimeter is way more than sufficient. Anyone who boasts of better than that (especially on wood or plastic) is probably kidding themselves. I'd like to know how to measure a micron on wood! My micrometers cant get that accuracy reliably on metal and metal is far more dimentionally stable than wood. Are we trying to machine parts for the shuttle or what?

All the best
Aubrey