Losing steps in Mach3: Kernel Speed, Pulse Width and "Sherline 1/2 Pulse mode"

by Ivan Hamilton 7/7/2010 8:50:00 AM

Introduction

The standard signalling for hobby CNC axes is know as STEP/DIR. Two lines, one indicating direction (High/Low=Fwd/Rev), and the second is pulsed (Low to High to Low) to indicate a single step. A problem with this scheme is the possibility of this STEP pulse going by unnoticed.

While hardware based schemes for capturing this pulse may have no trouble dealing with fairly short pulses (1µS or less), in a solution where the signal is "captured" by software (even one initially triggered by a hardware interrupt) may not respond quickly enough to catch these fleeting pulses.

I've seen numerous discussions about getting reliable pulsing from Mach3 to the external device (stepper or servo driver). There's usually claims of accuaracy or reliability from certain setting changes... usually without providing any basis for such claims.

Kernel Speed

Manual: "The Mach3 driver can run at frequencies from 25,000 Hz (pulses per second) up to 100,000 Hz, depending on the speed of your processor and other loads placed on it when running Mach3. The frequency you need depends on the maximum pulse rate you need to drive any axis at its top speed."

That sounds fair enough. The kernel can produce at most 1 pulse per cycle - the maximum pulse rate is the kernel rate.

Pulse Width

Manual: "Pulse width is another consideration. Most drives will work well with a 1 microsecond minimum pulse width. If you have problems with the test moves (e.g. motor seems too noisy), first check that your step pulses are not inverted (by Low active being set incorrectly for Step on the Ports and Pins>Motor Outputs tab), then you might try increasing the pulse width to, say, 5 microseconds. The Step and Direction interface is very simple but, because it can still 'sort of work' when configured badly, it can be difficult to fault-find without being very systematic and/or looking at the pulses with an oscilloscope."

On my copy of Mach3, I can alter the step pulse width (Config->Motor Tuning->"Step Pulse 1-5 us") between 1 and 15 (values greater than 15, are reverted back to 15). This is three times greater than the UI or manual might lead you to believe. How do these changes present in the real world?

Watched on an ol' silly-o-scope, my machine produced step pulse widths matching this setting, but with a minimum width of 3µS (entering 1, 2 or 3, all produced a 3µS pulse).

"Sherline 1/2 Pulse mode"

1/2 a pulse? If you can't even catch the short duration pulse currently produced, why would you want a shorter pulse?

The name is misleading because what it performs is actually half of the pulse change on each kernel cycle (ignoring the pulse width setting). The pulse rises at the start of one kernel cycle and falls on the next, so that the pulse duration is a full kernel cycle duration. With a kernel set to 25kHz, that's a full 40µS of pulse width - much greater than the UI would let you set.


Timing of various pulsing sizes & methods

What's the catch? The downside is that a full pulse cycle (rise & fall) will now take 2 full kernel cycles - effectively halving your maximum pulse output rate. That said... you could always up the kernel speed if your hardware has the grunt to support it. Even at 65kHz, the pulse width will still be slightly longer (15.4µS) than the maximum configurable width with standard pulsing (15µS).

Kernel Speed (kHz)

 25

35

45

60

65

75

100

Standard

Pulses/S

25000

35000

45000

60000

65000

75000

100000

Pulse Width µS

As per config

Sherline 1/2 Pulse mode

Pulses/Second

12500

17500

22500

30000

32500

37500

50000

Pulse Width µS

40

28.6

22.2

16.7

15.4

13.3

10

Kernel speed & pulse widths

"Enhanced Pulsing"

What's this do? Well... it doesn't affect the pulse duration. So it's not about "recognising" steps.

Manual: "Enhanced Pulsing, if checked, will ensure the greatest accuracy of timing pulses (and hence smoothness of stepper drives) at the expense of additional central processor time. You should generally select this option."

Accurate timing pulses? Accuracy of what? Pulse duration, cycle length, spacing?

It turns out, that Mach3 calculates movement in sets of 5 kernel cycles - "In the next 5 cycles, I need 2 steps", "In the next 5 cycles, I need 4 steps", etc, etc. "Enhanced Pulsing" distributes these steps more evenly within the sets of 5 (e.g. wait-STEP-wait-STEP-wait instead of STEP-STEP-wait-wait-wait). It takes more processing, but a "smoother" stream of steps it the result.

Art wrote: "Shifter is a bit special, it tells the engine how to space the maximum of five steps the move represents to keep them as well anti-aliased as possible in time. Smoothness is the result. This 'Shifter' variable is what you are turning off or on when you select 'Enhanced Pulsing' in the App configurations."

So, "Enhanced Pulsing" helps with smoothness, and this may be more important for stepper based systems (where each step results in a physical actions), than servo based systems (where a step just updates the desired position).

For my controller (and probably everyone else's) it probably makes sense to push the pulse width as close as possible to half the cycle duration. For 25 or 35kHz, that's the maximum 15µS available in standard (non-Sherline) mode, and 11, 8, 8, 7 & 5µS for 45, 60, 65, 75 & 100kHz respectively.

This makes sense to me... but of course, there could be some reason internal Mach3 that would make this a "bad thing".

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CNC

Replacing Notepad with Notepad2 in Windows 7 & Vista

by Ivan Hamilton 1/13/2010 6:48:00 PM

Standard Notepad Just Isn't Enough

For a technical user like me, Windows build in Notepad.exe sucks. It's better than nothing, but it's missing a stack of features:

  • line numbers ("status bar")
  • line numbers (it's worth mentioning twice)
  • line ending LF (Unix), CR/LF (Windows) & CR (Mac) handling
  • whitespace display
  • line ending display
  • regular expressions in search & replace
  • adjustable tab width

Don't use it then? I don't. I use Notepad2. Unfortunately, the standard Notepad.exe in Windows is embedded in a million different places - "Open With...",  open ".txt" files, edit ".bat" files, edit SQL scripts, view HTML source, and many more. Sure, you could try a search and replace excercise in the registry, but you'll probably install a new product that will try and utilise the original Notepad. Simply copy Notepad2.exe over Notepad.exe? The file protection mechanisms in Windows will automatically switch back to the original. Replace the protected version? It's possible if, a little tricky, but a future service pack or hotfix may simply overwrite it. What we need is EXE redirection.

Image File Execution Options 

Windows offers a neat way to automatically start a process within a debugger. Before execution, the Windows CreateProcess function checks for a registry key at "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\filename.exe". If that key has a string value named "debugger", then that value is executed instead with the existing command line added to the end (this could be [notepad] or ["C:\Windows\system32\notepad.exe"]). This means instead of "notepad hosts.txt", it will execute "debugger.exe notepad hosts.txt". So, you could run a substitute executable as long as you can get the new executable to ignore the first parameter. Notepad2 4.0.24 has introduced the "/z" switch, which means "ignore the next parameter" (this also exists in Programmer's Notepad) just for this purpose.

Configuring for Notepad Replacement

Start a command prompt (cmd.exe) as Administrator, and execute the following (replacing "C:\Program Files (x86)\Notepad2\Notepad2.exe" with the full path to your Notepad2 executable):

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"C:\Program Files (x86)\Notepad2\Notepad2.exe\" /n /f \"^%LOCALAPPDATA^%\Notepad2.ini\" /z" /f 

Command line text Explaination 
reg the registry editing tool
add add the value
"HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"  the key we're setting a value on
/v "Debugger" name of the value
/t REG_SZ type of the value (string)
/d the data to assign follows
" start of quotes around the data
\"C:\Program Files (x86)\Notepad2\Notepad2.exe\" The "debugger" executable to run (quotes are escaped with backslashes).
Change this to the full path to your Notepad2 executable (I'm on a x64 system).
/f \"^%LOCALAPPDATA^%\Notepad2.ini\" Notepad2 will use config file in user's profile directory (percent signs are escaped with carets)
/n Always open a new Notepad2 window
/z Notepad2 will ignore the next parameter (will always be the original Notepad.exe name)
" end of quotes around the data
/f forces reg.exe to overwrite any existing value

The first time you run it, the user specific config file won't exist (and won't automatically save on exit). If you want to keep your config settings, you'll need to explicitly save settings (F7) once, and from then on your settings will be saved.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

BlogEngine Comment Spam

by Ivan Hamilton 12/23/2009 9:58:00 AM

So BlogEngine must be popular... I'm getting targetted quite heavily for comment spam.

I'm going to moderate comments until I can get around to upgrading the software and tightening up the anti-spam features.

Damn spammers!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

BlogEngine.NET

Relay Driver - Finished

by Ivan Hamilton 5/5/2009 12:45:00 PM

As briefly mentioned before, I need a way to take the CNC4PC C10 breakout board's output signal (5V@24μA) and switch higher currents and voltages. After the 4 pairs of step & direction signals, the C10 board still has another 4 outputs (spindle, coolant, etc). CNC4PC do sell the C15 (a nice opto-isolated dual relay board). I should just buy two of these (they're quite reasonably priced), but this is about the journey, not the destination.  

In pursuing modularisation I think that opto-isolation belongs on separate modules, so my quad relay board won't have it. All that's required is a few transistors to step up the current, some relays capable of 240V@10A, LEDs for diagnostics and supporting passives (current limiting resistors and fly-back diodes).

With the new X axis coupling, the board drilled and milled without losing position. The only issue was the double-sided tape holding the board down gave up during the final board shape routing (hence the lack of squareness). The isolation ran at 60mm/min and took about 30 minutes to run (I really need to find a way to get 30,000rpm instead of 1200rpm).

To make it easier to place the components, I printed the overlay on paper and stuck it on top of the PCB (using a needle to pierce the lead holes). The Ø1.2mm pads on the diodes & resistors were a challenge to solder (it was very easy to bridge across the milled 0.2mm isolation channels). In the future, for manually soldered boards, I should make both the pads and the channels larger (the board design didn't need such small pads -  Ø1.5mm should be fine).

If you're interested in the tool-chain: Altium Designer for Schematic & PCB layout, CopperCAM for Gerber to GCode, Mach3 for Milling.

 
PCB design


Milled & Soldered PCB


The top overlay and components

 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CNC | Electronics

Z Axis Demo - X Axis Coupling

by Ivan Hamilton 5/4/2009 2:20:00 PM

I got a little carried away with one of the couplers I'd made for the X axis, and it broke. I managed to jury rig it, but a few jobs I've tried recently have lost X registration. I initially thought it was a backlash issue, or lost steps due to electronic interferance, but the simplest answer is often correct. The broken coupler was most probably slipping...

I needed to make a Z axis coupler, so I thought I'd do a new X at the same time. Here's a quick look at it in action, and also a demo of the new panel.

 

Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CNC

Mill Panel - Rewiring

by Ivan Hamilton 4/30/2009 10:48:00 PM

In my quest to add E-Stop control to the PC & Servos, and PC spindle switching I had already created a new mill panel front and relay holding PCB. All that remains it to rewire the panel.

The only wiring that will be kept is the 240V motor supply & switching (to respective relays), all other wiring will be removed and replaced. I've already removed the control wiring (most of it relating to the dubious "tapping" feature) and need to plan the final wiring (hopefully I can reuse some of the spade terminated wires).

 

 It's fairly straight forward (I'm not showing the 12V supply, or 240V neutral line). You can see the 5 spots that the PCB will need to link into the 240V wiring (well 6, 1 more for neutral). This will give me a very good idea of the wiring links required, and should allow for a well planned and neat job.

After some concentrated effort, here is the result:


Rewired Panel

You can see the the new relay circuit board hanging from the bottom (it will be mounted within the box). I must have had too much time as I even colour coded the wires (and heat shrink!). I had several pieces of the original harness left over, but what remains is much more functional. The next step is a relay driver board to take the signal from the CNC4PC C10 breakout board (5V at 24μA) and deliver 12V to a 320Ω relay coil (38μA). A little transistor is in order here. I think I might mill up a PCB...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CNC | Electronics

A couple of my favourite electronics books

by Ivan Hamilton 4/30/2009 12:08:00 PM

I thought I drop a quick note on the lumps of tree I've found useful in my electronic escapades.  

Electrical Engineering 101 - Darren Ashby

This is a great book for all those little practical ideas around electronics that you missed when you first learned it. Great for the basics. Read it cover to cover.

The circuit designer's companion - Tim Williams

So now you're actually going to design and build something? What about all those little gotchas in the real world?

This book is filled with how to deal with the real world. It covers the theoretical "ideal" situations, and then shows how to handle the realistic "practical situations".

Wiring, grounding, distortion, interference, heat sinking, etc.

Read it by the chapter when you're thinking about those things. Not for the beginner, more for the novice designer.

The Art of Electronics - Paul Horowitz, Winfield Hill

If there was a book that was seen as the bible, this is it. 1125 pages of detailed information.

Personally, I find it too detailed to just read through, and will read a subsection on the particular item of interest.

An invaluable reference, but fairly full on for novices.

 

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Electronics

Mill Panel PCB - PCB Milling

by Ivan Hamilton 4/28/2009 11:47:00 AM

My new mill panel needs both rewiring and new components to allow the PC to switch the spindle on & off. This includes 3 new relays (1 x 240V for "on" latching, and 2 x 12V relays for FWD+REV). Whilst I could just wire them up, it would result in an unstructured mess. I really wanted a nice PCB to mount them.

I had previously fallen in love with the idea of milling PCBs. With etching PCBs, after all the messy chemicals and issues with brokens tracks, etc... you still had to (manually) drill them anyway. I wanted to CNC drill the boards, and being able to isolation route them as well would make PCB creation a single "tool" process.

For about $20 AUD on eBay I bought 5 x 60˚ V-Shaped Carbide Engraving Bits. At a depth of 0.25mm these 60˚ V bits create a Ø0.29mm path at the surface. All you need is some software to create the milling G-code from the PCB's Gerber definition.

I tried a demo of CopperCAM (others have mentioned CircuitCAM, and also exporting as DXF to vector tools for manual manipulation).

After exporting the Gerber & drill files from my PCB software, I imported them into CopperCAM. CopperCAM produces the final G-code, with tool-change commands for swapping thru different engraving, milling and drilling bits. This G-code was then run in Mach3 (blank PCB was held down with double sided tape).


Milled PCB

Unfortunately my mill is designed for heavy work and 1250 RPM is the spindle's top speed. So I used a very slow feed speed of 60mm/min (~0.05mm/rev). I may be able to go faster (maybe 120mm/min) but not much more. I do plan to find a way to mount a high speed rotary tool to my mill to allow for such needs. The slots are a bit sloppy, but I did those under manual control with the V bit as I don't have a small enough endmill - yet.

I'll solder it up today, and look to mount it in the mill's control box. Once again... I'm very happy with the result of my latest mill experiment.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

CNC | Electronics

BlogEngine.NET 1.5.1.1 r27024 on Mono Patch

by Ivan Hamilton 4/23/2009 4:25:00 PM

I've been seeing an increasing amount of comment spam lately. BlogEngine.NET isn't a large target, but the spammers are starting to find it and I'm getting sick of manually culling the comments.

Before investing more time into my current install, I figured it was worth looking at an upgrade. This isn't something I'll do lightly. In the past, the BlogEngine.NET project hasn't been very responsive to my bug reports & fixes. It has taken about 6 weeks from a bug report (with an attached fix) to being committed to the repository. 6 weeks is a little beyond my attention span.

There's been a fair bit of updating since the 1.3.1.30 release that I'm currently running and the idea of switching to 1.5.1.1 is a little scary. My past experiences with Mono and BE haven't been smooth, and hunting down bugs in both Mono & BE again just to get a minor upgrade, is far too much effort. But since my previous logged issues had been fixed, I felt it was time to give BE another upgrade shot.

With my notes still lying around from last time, I decided to grab the latest BE source (r27024) and see how it went. To my surprise it not just compiled (previous versions would not even compile)... but it also ran.

I headed off to download Justin Etheredge's Akismet Extension for BlogEngine.NET. I wasn't too familiar with Akismet, but it requires you to have a WordPress API key. I headed off to WordPress to create an account and get an API key (just a blog, just an account with an API key).

I wasn't too familar with BlogEngine.NET Extensions, so after setting the Akismet Extension options, I clicked the "View" link for that extension... "Source for [/opt/blog/BlogEngine/BlogEngine.NET/App_Code\Extensions\AkismetExtension.cs] not found" Doh! Clash of the Slash!

It appears that BlogEngine.NET still doesn't have enough of a *nix following to have ironed all the bugs out. But I've reported what I've found, and just put my latest patch for BlogEngine on Mono up. You'll find it on the BlogEngine.NET Mono Patches page.

From your BlogEngine directory:

host:/opt/blog/blogengine-27024.dev# patch -i /tmp/blogengine-27024.patch -p1
patching file 'BlogEngine.NET/admin/Extension Manager/Editor.ascx.cs'
patching file DotNetSlave.BusinessLogic/API/MetaWeblog/XMLRPCRequest.cs
host:/opt/blog/blogengine-27024.dev#

P.S. I haven't actually switched my live blog to the new 1.5.1.1 code... yet. I want to test it in a development environment a little more first.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET | BlogEngine.NET

New Mill Panel

by Ivan Hamilton 4/21/2009 5:43:00 PM

In rewiring the mill's controls, I will need a new front panel for the mill.

I started by Drawing my desired panel in CorelDraw. I've used CorelDraw since the dark ages, and the current X4 product feels like it's lost some of its shine. Still, it's the simplest Vector drawing package I know how to use, so that's where I started.

It wasn't long before I hit my first hurdle. CorelDraw's DXF export leaves a lot to be desired. Instead of exporting curves, circles and arcs are exported as a series of lines (yuck!). There is a "work around", and that's a product called "DXFTool for CorelDraw V2". It's an add-on to CorelDraw that exports curves as curves. Unfortunately, it's commercial, and my evaluation version will shortly expire. I will need to find a better vector tool.


Initial CorelDraw drawing 

Once the design was in CorelDraw, I exported the indicator and switch holes to a DXF file, and imported them to CamBam. It was just a series of hole, so I did an internal profile with an end mill. The extra yellow arrow you see are the lead-in movements. This is to help give a uniform appearance to the hole (no drilling evidence).


Hole Pattern Exported to CamBam 

Firstly the steel cover had these holes milled into it, and then a piece of 0.5mm thick aluminium (the face) had the same machining performed.

The label portions (text & markings) of the panel were printed (mirrored) to a sheet of laser printer transparency. The aluminium panel was cleaned and then covered in spray adhesive, and the transparency laid on top. This puts the toner between the transparency and aluminum face, protecting it from being worn off. The transparency material covering the holes was cut out with an exacto knife (and a quick edge grind with a rotary tool).


Final Assembled Panel

Ok... I have to admit it. I'm pretty happy with the result. I'll even go as far to say that I think it now looks better than the original factory panel.

Every time I use the mill, I'm learning something about "machining". But what I seem to be learning most of all, is about work holding. How do you mill into sheet? How do you keep it flat? How do you not drill into your mill table? How do you align the part to the mill? I think there's an awful lot to learn before a tool even meets the part.

I've got all the parts I'll need for the new wiring scheme, and with the new panel in place I can begin the rewiring. Now it gets interesting!

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.3.1.30
Original theme by Mads Kristensen

About the author

Name of author Ivan Hamilton
"My inner nerd can beat up your inner nerd."

E-mail me Send mail

Adsense

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent posts

Recent comments

Tags

None

    Entropy

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in