Yet another iteration of nothing
Random header image... Refresh for more!

Category — CNC

CNC Probing

CNC utilizes contact probes for various purposes:

  • Edge Finding
  • Zero Setting
  • Digitizing (point cloud)
  • Mapping

Several major companies exist (example Renishaw) to service major industry; less so for home or prosumer markets.

Of late, two have captured my attention.

Kurokesu AKA Saulius Lukse  from Lithuania (http://lukse.lt/uzrasai/) (two production runs have been produced so far, and a wireless variant in development):

Announcing TPA2 touch probe

 

 

and TouchExpress ( Cliff Hall from New Zealand):

 

October 31, 2016   Comments Off on CNC Probing

Driving a Ballscrew – Servo vs. Steppers

Excellent example of Servo vs. Stepper vs. Feed Speeds. This is by John Dammeyer, developer of the Electronic Lead Screw Project: Electronic Lead Screw Main Page

…now I did some experiments as a result of this posting subject. I found if I turned the handle for moving the carriage at what was a pretty normal speed it went 10” in about 4 seconds. That means 10 inches in 4 seconds is 2.5 ips or 150 ipm.

If your goal is to replace the lead screw with a ball screw and still be able to traverse as quickly as the rack and pinion while maintaining knowledge of the position to the nearest 0.0005” you need to consider how you drive this lead screw and the pitch of the screw.

Let’s look at a stepper based solution first.
1. Max RPM with a stepper and still decent torque is about 700 RPM.
a. Use 600 RPM to be conservative (10 RPS).
b. 10 uSteps per step results in 2000 steps per rev x 10 RPS is 20,000 steps per second. (Gecko Driver)
c. Resolution is 2000 steps per rev but accuracy is still only to the nearest ½ step so 400 steps per rev.
2. With 400 steps per rev and a target of 0.0005” accuracy a pitch of 0.2” or 5 TPI is required.
3. With 10 RPS we’re moving 0.2”/Rev x 10 Revs/Sec = 2”/second (2 IPS). However, your target is 2.5 IPS or better.
4. This system won’t move the carriage quite as fast as you normally would with the handle.

Now a Servo.
1. Max RPM is usually 3000 RPM and torque is good all the way to the top.
2. Aiming for 750 RPM means a 4:1 belt reduction.
a. 4:1 on the belt though results in 4x the encoder resolution.
b. With a 100 line encoder in quadrature you get 400 lines per rev x 4:1 or 16,000 steps per rev.
c. Accuracy is still 16,000 steps per rev.
3. Stay with a 4 TPI ball screw and 0.2” pitch we resolve (and position) down to 0.0000125” per step.
a. But at 20,000 steps per second from the ELS you can really only turn the lead screw 1.25 turns per second
b. That’s 0.2”/rev x 1.25 revs/sec = 0.25”/second (0.25 IPS). A factor of 10 too slow.
4. I think Gecko has a step multiplier that turns the servo 10 lines for every step in.
a. Now we’re at 2.5 IPS which was the goal.
So: A DC servo Motor with 100 line encoder on a 4 TPI ball screw results in a position resolution and accuracy of 0.000125” with a top speed of 2.5 IPS and a step rate input of 20,000 steps per second.

Please correct my math if I’ve made a mistake.

From: E-LeadScrew@yahoogroups.com [mailto:E-LeadScrew@yahoogroups.com]
Sent: March-19-16 8:29 AM
To: E-LeadScrew@yahoogroups.com
Subject: [E-LeadScrew] Re: Ball screw question

Though I am not an engineer it looks to me that the stock design of the
leadscrew on this particular lathe looks to be at fault. The leadscrew has a
slot that runs down the entire length of the screw itself that is used to
power the cross feed. The screw was turned and then the slot was milled.
This left many “teeth” that in a relatively short amount of time “cut” away
the half nut. The half nut itself just pushes forward on a lever. There is
no “backing ” at all to support the half nut and in order for it to track a
considerable about of force is applied to keep the half nut engaged.

I doubt it is the design’s fault. Thousands of lathes use this exact
system to drive the carriage and cross slide without and wear issues. The
half nuts stay engage without any extra pressure also. I am wondering if
someone ground the bed and didn’t take the extra time to align the lead
screw with the carriage? I can assure you something else is going on with
your lathe other than the keyway down the center of the lead screw.
Rick in WA State

[Non-text portions of this message have been removed]

__._,_.___

Posted by: “John Dammeyer” <johnd@autoartisans.com>


Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (12)
EXACTLY !

I use a 10.000 count encoder on the servo, and 1:2 belt drive, and 5 mm 
pitch screw.
=> 20.000 counts/rev at screw.
=> 4000 steps/mm.
= 0.25 microns.

This is pretty much the ideal setup.

However,
3000 rpm = 50 revs/sec.
50 revs x 10.000 counts = 500.000 kHz.

So, I must have a hardware timing engine able to pulse at 500 kHz 
(Cslabs CSMIO-IP-S).

End result.
The servo will spin upto 3000 rpm in approx 0.03 secs (20 ms no-load, 
and 20-30 ms with the 100 kg carriage).
This is far too fast, huge wear on belts and screw and ways, and very 
much more than needed.
So, I limit it in sw to something same.

Speed.
At 1500 rpm at screw, or 25 revs/sec
=> 25 x 5 = 125 mm (==5") per sec.
Movement on z axis is approx 400 mm max.
So, end to end is 3.2 secs.
This is far too fast, so I software limit it to something sane.

Generally, the tools are only about 100 mm from the workpiece, and in 
less than a second the lathe has the potential to crash.
Thats why I normally keep the speeds way down.

The 0.25 micron step size results in real-worl, actual, resolution of 
approx 1 micron, or a bit better.
Hope is to get 0.5 microns, and may (or may not) need ground ballscrews.

Engineering theory and lots of real world examples says 0.5 microns is 
routine, given a sufficiently rigid system.
Thats why I use a very think, 32 mm, ballscrew, because it has very high 
rigidity of 54 kgf/um.

(High precision optronics screws with 0.25 mm rise can position to 0.5 
micron accuracy and several manufacturers quote similar accuracies.
Available from thorlabs, about 70€ each.
Its the kind of thing I will be making).

Accuracy is not, at the moment, 0.5 microns, but in theory and practice 
I will probably get there.
Plan is to add glass scales, and secondary feedback to the CSMIO controller.

At the moment, its possible to do incremental movements to 1 micron.

This means I can make gages, with steps, of 1 micron.
By then measuring the gage, one of the steps will be 49.999 mm.

This will then be what I make bore for, to mount high precision bearings.
(7210AC-DUP-P2. Yes P2 or ABEC 9).

The z axis started working last tuesday, after 300 work hours (this time 
round), and 12 years of development and tries.
Alignment was really hard.

Last TS bracket (not really needed) will hopefully be finished today.

Very Big Grin.
Gonna go make bracket.



On 19/03/2016 17:18, 'John Dammeyer' johnd@autoartisans.com 
[E-LeadScrew] wrote:
Now a Servo.
1. Max RPM is usually 3000 RPM and torque is good all the way to the
top.
2. Aiming for 750 RPM means a 4:1 belt reduction.
a. 4:1 on the belt though results in 4x the encoder resolution.
b. With a 100 line encoder in quadrature you get 400 lines per rev x
4:1 or 16,000 steps per rev.
c. Accuracy is still 16,000 steps per rev.
3. Stay with a 4 TPI ball screw and 0.2” pitch we resolve (and
position) down to 0.0000125” per step.
a. But at 20,000 steps per second from the ELS you can really only
turn the lead screw 1.25 turns per second
b. That’s 0.2”/rev x 1.25 revs/sec = 0.25”/second (0.25 IPS). A
factor of 10 too slow.
4. I think Gecko has a step multiplier that turns the servo 10 lines
for every step in.
a. Now we’re at 2.5 IPS which was the goal.

So: A DC servo Motor with 100 line encoder on a 4 TPI ball screw 
results in
a position resolution and accuracy of 0.000125” with a top speed of 
2.5 IPS
and a step rate input of 20,000 steps per second.

Please correct my math if I’ve made a mistake.

John Dammeyer
— -hanermo (cnc designs) ———————————— ———————————— ————————————

I think its a fact that microstepping, where you are actually stopping at the microsteps (i.e. using them for resolution) definitely is less torque, simply because the motor cannot hold that position accurately against load. In a dynamic situation however, lots of factors come into play. For example, if the axis is in constant motion the only torque required is to overcome friction and cutting loads, there is little torque required to provide acceleration. Unless the motor is being operated close to its torque limit (at that speed/volt/current combo) then microstepping should have little impact. The general rule I have used is in the spreadsheet is that the motor should provide 3x required dynamic torque at the maximum speed.

Large motors have high inductance so the torque drops off very fast with speed – the corner speed of those motors is 240rpm. I don’t know how big your axis are, but I’m guessing its going to be around 1 – 1.2m? With your 10mm pitch screws 2.5m/min = 250rpm, so that is close to optimal (and 1/8 stepping = 6664steps/sec) and it looks OK at cutting speeds, but its very marginal at 10m/min rapids and that is where you may have lost steps (=27000steps/sec). You need to reduce rapids to 7m/min but it should be OK at 1/4 or 1/8 stepping.

March 19, 2016   Comments Off on Driving a Ballscrew – Servo vs. Steppers

KmotionCNC Conditional Logic

The GCode Interpreter included with KmotionCNC is more bare-bones than the extended on in LinuxCNC, and some people were discussing how to work-around this perceived lack. I found a link on CNCZone that outlined a method (albeit on Mach3) of performing conditionals (as Mach3 also does not support the higher-functions in LinuxCNC). At one point, Tom Kerekes also weighed in:

Comment#1:

The same approach should work with KMotionCNC as with Mach3.  Both support variable numeric subroutine labels. With Mach3 the Interpreter should work the same regardless of what motion plugin is performing the motion. KMotionCNC also supports a Variable loop count (L word) which includes zero calls.  To me that is a simpler form of conditional. See the example: SubroutineWithConditionals.ngc I’m not sure why Eon feels that the Loop Count must be less than 100.  Any value up to ~2 billion should be allowed

The reason for the bold statement is apparently Mach3 (which Dynomotion has a plug-in to interface to) claims a limit of 99 iterations Limit on Loops. Others state there is no such limit to Kmotion, and using the Gcode window in Kmotion, I have easily proven this. Instantly I can have huge loops amounts (tested to 20 Million). Another claims to use M47, which in MACH3 repeats program from first line. This Mcode does not exist by default in Kmotion.

 

Comment#2:

KMotionCNC doesn’t support if/while statements.  You can conditionally call subroutines and repeat subroutines.

Comment#3:

Regarding KMotionCNC Subroutines: unfortunately calls to other files are not supported. The subroutine must be within the same file.

Comment #4:

If you don’t like using a subroutine with an infinite loop count you should be able to add an action to M30 to automatically re-cycle start.
Configure the M30 (stop rewind) with an additional action to execute:

#include “KMotionDef.h”
#define TMP 10
#include “KflopToKMotionCNCFunctions.c”

main()
{
while (JOB_ACTIVE) ;  // wait until GCode Finishes
DoPC(PC_COMM_EXECUTE);  // Cycle Start again
}

The source code for the Interpreter is there if you wish to add a new command.

This last statement is something I spent some time looking for: where exactly is the defined commands.  More on that later.

I have copied below the example Tom cited: SubroutineWithConditionals (Github link)

 

G20
#100 = 5

(examples of logical operations)
(result is 1 if condition is true)
(result is 0 if condition is false)

#101 = [#100 >  5]
#102 = [#100 >= 5]
#103 = [#100 <  5]
#104 = [#100 <= 5]
#105 = [#100 =  5]
#106 = [#100 <> 5]

(subroutine call can be looped a number of times)
(the L or Q word may be used to specify the count)
(if neither L or Q is specified a count of 1 is used)
(if the count is 0 the subroutine will not be called at all)

M98 P1 L3  (example using L to specify the loop count)
M98 P1 Q3  (example using Q to specify the loop count)

M98 P1 L#100  (example using a variable loop count)

M98 P1 L[5 > 4]  (example using a conditional as a loop count)
M2

O1
#200 = [#200+1]
M99

Although this was new to me (using a third party CAM package, I rarely do more than tweak the resulting G-code; I know, but too many other priorities), but apparently the question was not new. May 2014 Post CNCZone:

Is there a G code supported that will allow a line jump? An M99 P12 will jump to line 12 for example on a Fanuc and some others . I have also seen GOTO used in the G code.

Response:

KMotionCNC supports Jumps to Subroutines which is similar to a Jump if you simply never return. M98 Pxxx can be used to Jump to the GCode Line with the Label: Oxxx The Jump can be conditional as well by specifying a Subroutine Loop Count of either 0 or 1. See the included example SubroutineWithConditionals.ngc

A further example refining the code was given

Still a bit clumsy but here is a way to eliminate your list of repeated conditional subroutine calls by using a looped surbroutine:

 

#100=1
#101=1
M98 P2 L100 (Do up to 100 tools)
G10L2P9X0Y0Z0
#100=0
#101=0
(MSG,Tool Setting Complete)
M2

O2 (Sub to conditionally call another sub)
M98 P1 L[#101=1]
M99

O1
(Change Tool)
M6 T#100
(Set Fixture Offset)
G59.3
(Set Height Offset & Save XY Offset to G59.3)
M101
(Go Home)
G00 G53 G90 Z0.
G00 G53 G90 X0. Y0.
(Send Message and pause)
(MSG,Change to next Tool!)
(Pause)
M00 (Uncheck "Block Delete" To End)
/#101=0
/M99
G00 G59.3 G90 X0. Y0.
#100=[#100 + 1]
M00 (Move Z to desired Offset Height)
M99

And more: Aug 2015 – Yahoo GroupsKflopWebNC Sub Programs

 


Now, on to finding the place to modify the interpreter

I found where the G-Code words are referenced to internal numbered functions (Definitions are in rs274ngc.h), but not where the internal functions are defined. As an example: #define G_93   930. Great. Now where is 930… According to Windows Search, that term only occurs in the aforementioned file (searched the entire directory). RS274ngc.cpp DOES have an occurrance of 300 in it as well, so looking through it.

They are not in either of the above header or program file. I have found DMRS274 Interpreter file in the KMotion Dot Net directories (all C#).

At this point, I surfaced and did a Google search for adding a custom G-code into the linuxCNC compiler. Since that, Mach3 and Kmotion all are derived from the same source, I could find some hints that way.

Stand Alone Interpreter for LinuxCNC

The interpreter is really just a library of related functions that work together to read RS274 files and output canonical commands, it does not
have a main() function(...) nor does it have a "user interface". 

Well. That was helpful. Off to RS274NGC_3.pdf – 2000.

1.3.1 How it Runs

When the Interpreter starts up, before accepting any input, it sets up a world model that includes data about itself, parameter data, and data about the machining center being controlled (including data about the tools in the tool carousel of the machine).

Once initialized, the Interpreter runs using a two-step process: 1. Get a line of RS274/NGC code and read it into memory, building an internal representation of the meaning of the entire line. We will call this stage “reading.” 2. Change internal state and/or call one or more canonical machining functions (see Section 4) in order to do what the line says to do. We will call this “executing” the line.

So, as far as I can see, I might have been right to look in the canonical section, despite not seeing anything before (it is to be included in RS274ngc.h). Well, that was somewhat useful; most of the items in there state references to external code… Let us search keyword: DWELL. It appears in several places, and corresponds to a GCode.

Well.

That showed me enough to convince me that I was correct; there is no one file with definitions for each Gcode; it is spread all over the place.

Aha.

Appendix D. Interpreter Software

D.1 Interpreter Interfaces

The Interpreter has four interfaces, as shown in Figure 9. These are all function call interfaces. The direction of function calling is indicated by arrows. The flow of information in the reverse direction from the arrows differs in the different interfaces. The Interpreter-do-it functions tell the Interpreter to do something, such as read a line of NC code or execute the line last read. These functions all return an integer status code as described in Appendix A.1. The functions themselves are described in Appendix D.4. They are declared in rs274ngc.hh and defined in rs274ngc_pre.cc. The names of these functions all begin with “rs274ngc_”.

So, off to look at _pre. Annnd there is no file in Kmotion labeled that. Reading through NGC…

The file may be pre-preprocessed

into "pre.cc" by "prepre" (a lex-based pre-processor). All

fifteen executables may be compiled from the pre.cc file.

Fair enough; was not pre-processed. Well, back to Google:

Also, after asking a few questions on the developer”s list, I found out that the EMC2 version of the interpreter is encapsulated in a C++ class. Not too long ago, all the functions in the rs274ngc intepreter were named rs274ngc_functionxxx(), but Paul Corner was kind enough to drop the “rs274ngc_” prefix from all the sources, which was a great first step towards generalizing the interpreter function call interface. Here”s how to find out what interpreter functions are being called: 1. The rs274ngc interpreter in EMC2 (and presumably any future
interpreter) encapsulates its functions into a C++ class named Interp.

Well…

January 5, 2016   Comments Off on KmotionCNC Conditional Logic

Brief History of G-Code, Numerical Control, and G-Code Complilers

G-Code (more precisely G and M Code, more formally, RS-274D or other names) is a programming code that dates back circa 1950, and was originally developed to control mechanical machining operations using paper tape.

It shows.

The last ratified standard was in 1980, and the last open source variant in 2000 (RS274NGC_3.pdf – 2000). Most manufacturers extend it in their own directions, making incompatible changes to others doing the same thing. The standardized code has no ability to do any of the commonly done flow control (loops)or logic operations (if, then, else, and, nor). Outrageous, says someone coming from a computing background.

When one examines in detail the actual history, intended operations and uses of these machines, a different picture emerges.

Simple Machines have existed for thousands of years, with compound or complex machines for hundreds, and each generally performed simple, repeated tasks. For example: windmills were used to grind grains to flour continuously, the Archimedes screw was used to lift water. More complex machines, such as the lathe, exist to rotate items, removing material from their diameters. In most cases, the machining progression is a straightforward, beginning-to-end process. 

To illustrate, here is a sample process to produce a wooden candlestick from a raw work-piece on a lathe. It can be broken down into single, discrete steps:

  • load the work-piece into the lathe
  • start the lathe (bow, pedal, water, steam, electricity or other motive power)
  • turn the work-piece cylindrical with a tool
  • carve away material to form the general intended shape
  • carve decorative features if desired
  • drill a hole for the candle
  • stop the lathe
  • unload the machined work-piece

In the above example, there is very little need for any advanced flow control or logic. The workflow is a straightforward progression of isolated steps performed in a procedural manner.

Historically, someone would perform all those steps by hand, and doing so quickly with minimal mistakes became a production bottleneck when industries switched from cottage level craftsmanship to mass production. After all, a Master woodworker can only turn out so many finished pieces in a day. Adding more people and more lathes would speed up production, but costs also rise, since more Master level woodworkers are needed, as is more machines. It is an oversimplification, but it can be said the focus changed to more production at less cost. 

As technology progressed, what used to take a Master level worker with a handheld gouge and pedal powered rotary motion to produce could now be manufactured in a single cycle by an unskilled person placing a work-piece blank into a lathe equipped with multiple cutting knives on a bar and triggering the entire series of operations with a single motion, drastically decreasing machining time. Factories in the 20th century had rows of such machines, each doing a single set of operations on the work-piece, and once completing its process, transferred the work-piece to the next machine to do the following operations. In the generally more complex metalworking world, ways were found of reproducing the actions of the master worker via mechanical means (cams, levers and gears shaped to replicate the same actions). Now that same Master level worker could oversee gangs of lesser skilled personnel overseeing the mechanically automated machines.

Manufacturing continued to move from skilled worker to assembly line worker to automation.

This was acceptable for industry for a time, but setting up each machine mechanically to do only one job and then changing the job performed required expensive and time consuming changes to the mechanisms. A logical extension of the technique was to make a single machine capable of performing the actions of several other machines. Enter the world of Numerical Control (NC); the precursor to Computer Numerical Control.

Machines were constructed that could have their work patterns altered by a punched paper tape, which was fed into a reader, which in turn controlled the machine operation. As technology progressed, the paper tape was replaced with magnetic media, but the basic operations required to produced the same candlestick really did not change; the same operations had to occur, in the same order; only the timeframe for the production of the product had shifted from hours to seconds. The production of G-Code reflected that process; the produced code had little need of more than the ability to loop operations and utilize subroutines. Typical operations were:

  • re-iterate a cutting/drilling/boring/milling procedure until final depth was reached
  • utilize a preexisting movements (subroutine) when a particular point in the main program was reached (move the machine to a specific spot, trigger the drilling subroutine, move to another spot, trigger the drilling routine again)

Very procedural programming.

Enter the 21st century, with vertical machining centers capable of self-feeding in work stock, performing lathe and mill operations simultaneously while interfacing to external automation systems, and now operational complexity has outstripped the original purposes.

Machine control manufactures extended the standard G-Code to include storage variables, more so-called canned cycles, goto, if-then-else flow control, AND,OR,NOR logic, and even so-called conversational programming (select operation, select size, select depth, select direction, speeds and feeds, push go; the machine generates the G-Code), all to the goal of increasing production, decreasing cycle time, improving cost-effectiveness.

But what if you have none of those features built in to the controller? Enter G-Code Compilers.

General purpose computer programming languages have long since needed flow control and conditional operations, and it is entirely possible to interface the two. An example from my own research is using C language to handle the flow and conditionals, and have it produce executable G-Code for each case. Here is an example from the web; someone made a compiler that converts logical arguments in C to LinuxCNC compatible G-Code:

CGCC Gcode CompilerFeatures and Examples

// Constants
const float X_Holes = 10;
const float Y_Holes = 10;
// Loop
for (float y = 0; y < Y_Holes; y++) {
for (float x = 0; x < X_Holes; x++) {
if (x != y) {
G00 Z1
G00 X[x] Y[y]
G01 Z0 F1
G00 Z1
}
}}
The above code is as follows:
– Want to drill a grid of 100 holes in a 10 x 10 inch grid
– the code is repeated 100 times with different X and Y coordinates.
– The code has to skip a line of holes down the diagonal where X equals Y

The person states that LinuxCNC CAN produce this workflow through the added-on O-codes (extension of the original RS-274D standard) but it is hard to produce good programs quickly. The result is a program that takes C language syntax incorporating G-Code and produces LinuxCNC compatible Gcode.

Others have similar needs:

GCME – G-Code Meta Compiler

January 5, 2016   Comments Off on Brief History of G-Code, Numerical Control, and G-Code Complilers

Dynomotion KFLOP and KSTEP running from Raspberry Pi using patched version for Linux of KMotionCNC

Who might be interested in this.

Anyone that would like to operate their KFlop controlled machine from their phone, tablets or anything with a web browser.

Github Repository of the patched system

GitHub Parhansson

YouTube Link of Operational System

January 5, 2016   Comments Off on Dynomotion KFLOP and KSTEP running from Raspberry Pi using patched version for Linux of KMotionCNC

Motion Controllers (Software and Hardware)

CNC toolchain:

CAD -> CAM -> G-Code PostProcessor -> Motion Controller -> Drives

A Motion Controller is, well, just that. A structure to control the coordinated motion of at least a singular CNC axis. Motion controllers can be software or hardware based. On the hardware side, the continuum runs from as simple as relay logic through small embedded controllers to complex machine controllers such as the Dynomotion KFLOP.

Software

Software controllers have a distinct disadvantage running under Windows, as it is not a real-time operating system (Mach3, Mach 4). Software interrupts (caused by running other programs or a slow machine), or other normal operations run close to the performance envelope can cause buffer failures, wrecking parts. LinuxCNC runs under a real-time kernel, and as such should not experience such issues.

Hardware

Relay or ladder logic controllers only react to a dedicated set of inputs. For example, controlling the end points of travel. When reached via sensors, simply reverse travel at set speed/rates.

More advanced hardware controllers are dedicated and do all of the trajectory planning onboard with higher speed, optimized hardware. The host PC only passes the G-Code file and operational parameters to the hardware controller to execute. As an example, the KFLOP:

“uses a DSP-based microcontroller with 1.2 GFLOPs of processing power, a 100k Gate FPGA, 16 Mb SDRAM, 8 axes of control, lots of I/O and the ability to program in C and do path planning with G-Code”

 

Finalists (Hardware)

Ethernet Eding 4 Axis

Advanced

Dynomotion KFLOP

December 5, 2015   Comments Off on Motion Controllers (Software and Hardware)

KFLOP C Programming Dissection – My Init.c Pendant Code

#include “KMotionDef.h”

// Example Init program that includes “smooth” MPG motion example
// which makes use of the exponential motion command.

// Which Pins were somewhat arbitrary; 11 I/O were needed, so JP4 and JP6 were used. The remainder were wired to level shifting boards and remain unused.
#define SELECTX 24 // KFLOP JP4, Pin 15 (I/O 24):
#define SELECTY 17 // KFLOP JP4, Pin 06 (I/O 17):
#define SELECTZ 19 // KFLOP JP4, Pin 10 (I/O 19):
#define SELECT4 21 // KFLOP JP4, Pin 12 (I/O 21):

#define FACTOR1 23 // KFLOP JP4, Pin 14 (I/O 23):
#define FACTOR10 25 // KFLOP JP4, Pin 16 (I/O 25):
#define FACTOR100 26 // KFLOP JP6, Pin 05 (I/O 26):

#define TAU 0.02 // smoothness factor (Low Pass Time constant seconds)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change

#define QA 16 // KFLOP JP4, Pin 5 (I/O 16): define to which IO bits the AB signals are connected; I’ve assumed A+ and B+
#define QB 18 // KFLOP JP4, Pin 7 (I/O 18):
//Note: Dynomotion seems to just use single ended, the pendant is dual/differental; as such, two inputs are not needed, could reduce total to nine from eleven.
//Note: Current assignment of QA and QB results in backwards operation. Swapped lower down in code. Need to verify hardwire assignment correct.

int main()
{
double T0, LastX=0, LastY=0, LastZ=0, Tau;
int result;
int BitA,Change1=0,Change2=0, DiffX2;
int PosNoWrap, NewPos, Pos=0, wraps;
int InMotion=FALSE,Axis,LastAxis=-1;
double LastChangeTime=0,Target,Factor=0;

// Add a small amount of Coordinated Motion Path smoothing if desired
// Tau = 0.001; // seconds for Low Pass Filter Time Constant
// KLP = exp(-TIMEBASE/Tau);
KLP=0; // force to 0 to disable
// printf(“Tau=%f KLP=%f\n”,Tau,KLP);

// Main program starts here; includes MPGSmooth subroutines
for (;;) //Main program, cycle forever
{
// Pendant reading code
// convert quadrature to 2 bit binary
//BitA = ReadBit(QA);
//PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA<<1);
BitA = ReadBit(QB);
PosNoWrap = (ReadBit(QA) ^ BitA) | (BitA<<1);

// Diff between expected position based on average of two prev deltas
// and position with no wraps. (Keep as X2 to avoid division by 2)
DiffX2 = 2*(Pos-PosNoWrap) + (Change2+Change1);

// Calc quadrature wraparounds to bring Diff nearest zero
// offset by 128 wraps to avoid requiring floor()
wraps = ((DiffX2+1028)>>3)-128;

// factor in the quadrature wraparounds
NewPos = PosNoWrap + (wraps<<2);

Change2 = Change1;
Change1 = NewPos – Pos;
Pos = NewPos;

// Determine which Axis is selected; Logic tree. If none are selected, disable pendant MPG control, as the unit is in the OFF position
// Pendant purchased did not have a ENABLE switch, no free conductors to install one; this will work fine to function as an erstaz one.

if (ReadBit(SELECTX)) // is x selected?
Axis=0; //X axis in my setup
else if (ReadBit(SELECTY)) // is y selected?
Axis=1; //Y Axis in my setup
else if (ReadBit(SELECTZ)) // is z selected?
Axis=2; //Z axis in my setup
else if (ReadBit(SELECT4)) // is 4th axis selected?
Axis=3; //A axis in my setup
else
Change1 = 0; // Disable Pendant, since OFF is selected (none of the above resolve to TRUE)
Factor = 0; // Force the change factor off (13 Nov 2015)

// Determine which multiplier is selected; unlike above, must be one of the three positions by hardware design
// Factor numbers by design, how much to move per MPG pulse

if (ReadBit(FACTOR1)) // is X1 selected?
// Factor = 1.5748031496062992125984251968504;
Factor = 1;
else if (ReadBit(FACTOR10)) // is X10 selected?
Factor = 10;
//Factor = 15.748031496062992125984251968504;
else if (ReadBit(FACTOR100)) // is X100 selected?
Factor =15;
//Factor =157.48031496062992125984251968504 ;
}

return 0;
}

// Debounce a bit
// return 1 one time when first debounced high
// return 0 one time when first debounced low
// return -1 otherwise
#define DBTIME 300
int Debounce(int n, int *cnt, int *last, int *lastsolid)
{
int v = -1;

if (n == *last) // same as last time?
{
if (*cnt == DBTIME-1)
{
if (n != *lastsolid)
{
v = *lastsolid = n; // return debounced value
}
}
if (*cnt < DBTIME) (*cnt)++;
}
else
{
*cnt = 0; // reset count
}
*last = n;
return v;
}

November 17, 2015   Comments Off on KFLOP C Programming Dissection – My Init.c Pendant Code

KFLOP C Programming Dissection – My Init.c E-Stop Code

#include “KMotionDef.h”

int elast=0,elastsolid=-1,ecount=0; // for debouncing estop pushbutton
int Debounce(int n, int *cnt, int *last, int *lastsolid);
int DoPC(int cmd);

#define ESTOP 168 // set to the external estop input bit
#define TMP 10 // which spare persist to use to transfer data
#include “C:\KMotion433\C Programs\KflopToKMotionCNCFunctions.c”

int main()
{
double T0, LastX=0, LastY=0, LastZ=0, Tau;
int result;
int BitA,Change1=0,Change2=0, DiffX2;
int PosNoWrap, NewPos, Pos=0, wraps;
int InMotion=FALSE,Axis,LastAxis=-1;
double LastChangeTime=0,Target,Factor=0;

// Main program starts here; includes ESTOP, MPGSmooth subroutines
for (;;) //Main program, cycle forever
{
WaitNextTimeSlice();

// Handle ESTOP interrupts
result = Debounce(ReadBit(ESTOP),&ecount,&elast,&elastsolid);
if (result == 0)
{
DoPC(PC_COMM_ESTOP);
printf(“Local ESTOP Active!\n”);
MsgBox(“Local ESTOP ACTIVE!”,MB_OK|MB_ICONEXCLAMATION);
}
}

// Debounce a bit
// return 1 one time when first debounced high
// return 0 one time when first debounced low
// return -1 otherwise
#define DBTIME 300
int Debounce(int n, int *cnt, int *last, int *lastsolid)
{
int v = -1;

if (n == *last) // same as last time?
{
if (*cnt == DBTIME-1)
{
if (n != *lastsolid)
{
v = *lastsolid = n; // return debounced value
}
}
if (*cnt < DBTIME) (*cnt)++;
}
else
{
*cnt = 0; // reset count
}
*last = n;
return v;
}

November 17, 2015   Comments Off on KFLOP C Programming Dissection – My Init.c E-Stop Code

Using USB Microscopes for Optical Comparators, Edge Finding, Centreing

with the rise of inexpensive optical cameras, people have been adapting them for machine tool use.

Technitoys – Machine Camera

 

Hobby Machinist – Cheap Optical Comparator

http://BangGood (China) USB Microscope

 

Microscope Camera for Mill

November 10, 2015   Comments Off on Using USB Microscopes for Optical Comparators, Edge Finding, Centreing

One of the better threads summarizing a new CNC purchase

CNC Zone – Help Choosing CNC

The big question you need to ask yourself is what do you intend to do with it? I’ll be honest…owning a cnc is sort of like owning a boat. As soon as you buy it you immediately need a bigger one. So by trying to define what it is you wish to do with it, you can shop for a machine that will a least suit your initial requirements. Next you have to figure out what your budget is and see if it will cover the cost of the machine you need. If it doesn’t, then I will be honest; save your pennies till you have enough and resist the urge to purchase a lesser machine. Always allow at least 20% more for shipping/odds and ends/tax etc.

Next but not least by any means is the controller and the software. For the controller there are really two types of configurations: DSP and Windows based. DSP is a hand held unit hard wired to the controller. Windows based means you have controlling software such as Mach 3 or WinCNC running on a dedicated computer. Both have pros and cons. But the controller software does cost dollars. As for the design software it ranges from free to 2k US for a package like Vetric’s Aspire. You get what you pay for.

As Awerby said CNC machines vary tremendously. It can be particularly troublesome in Canada as the choices for the serious hobbyist are some limited compared to the American market given the state of the dollar. While we do have some choice there are a lot of holes in the selection. On one hand you have the Intellicarve which is available at Busy Bee and the Shark by Rockler distributors on the entry level end. These are really a carving machines that vary in price from approximately $2499.00 to $5499.00. On the other end of the scale you have The Professor HDX available at Canadian Woodworking made by CWI weighing in at around $8500.00 for the serious hobbyist/light production, but by the time you add the stand/tooling/software you are north of $11,000.00. It also depends if you want a Windows based or DSP based controller. Some of the nice machines available in the US are Shopbot and CamMaster but due to the weakness of the Canadian dollar you probably be on the other side of $15k by time you got through with the exchange/import/gst for an entry level machine. If you could give us an idea as to what you are looking to do with it and what your budget is then we could offer much more salient advice.

 

November 10, 2015   Comments Off on One of the better threads summarizing a new CNC purchase