View Single Post
  #20   Report Post  
Posted to rec.crafts.metalworking
Pete C. Pete C. is offline
external usenet poster
 
Posts: 6,746
Default List of milling machine features I am seeking


Ignoramus29207 wrote:

On 2010-08-09, Pete C. wrote:

Ignoramus2412 wrote:

On 2010-08-09, Pete C. wrote:

Ignoramus2412 wrote:

On 2010-08-08, Wes wrote:
Ignoramus2412 wrote:

As long as someone has already written the modules to control a
vari-drive, the rest is just more wiring so EMC2 can control the
up/down solenoid valves (and VFD if you haven't already done that).

Yes, I think that it should work, it is simpoly a configuration issue
for EMC.


Our older cnc lathes with gear boxes require a M41 or M42 command to switch gear ranges.
Perhaps you could implemnet something similar where the command emits an output you use to
shift the sheave. IRRC M41-44 are typical gear change M codes.

Wes, yes, I would like to find some good G code number and then
implement it. I got some suggestions on emc-users on how to do it,
with comparator elements of EMC. But speed change should only happen
during speed change, and not at any other moment, like reversal or
whatnot. If I get it to work, it will be much better than VFD, and
will let me tap with relatively larger taps.

i

You need to remember that there is a standard G-code, really S code to
set the speed of the spindle, and you implementation should properly
handle it. If the code says S1500, followed by M03, that should be all
that is required to start the spindle turning at 1,500 RPM. All the
code/script to start the spindle and adjust the vari-drive to the
correct speed needs to be hidden, so that there is nothing more than a
delay on the M03 while the spindle is brought to the correct speed,
before G-code execution continues.

The same can also apply to the high/low gear change, where the
background script can handle the high/low gear change transparently as
needed, i.e. set a threshold for the commanded RPM at which point the
high/low gear change occurs. There is no reason to have to add gear
changes to your G-code, when you already need special background
routines to handle the speed setting of the vari-drive.

PeteC, all I read about speed changes, makes it seem that it is
difficult to change speed by means of varidrive, within the regular
HAL logic.

However, I realized that it is a very easy way to do by means of
miscellaneous codes M100-199. Those codes are implemented in EMC by
means of scripts with ame names, living in a certain directory. Those
scripts. in turn, can get access to workings of EMC by means of
command "halcmd".

So, I wrote a speed change perl script. It is UNTESTED, because I am
away from home. But here it is.

It may be summarized as follows:

- if spindle is not running, start it and wait 1 second.
- calculate acceptable boundaries for actual speed.
- If speed is below acceptable boundary, turn on SPEED INCREASE
solenoid.
- If speed is above acceptable boundary, turn on SPEED DECREASE
solenoid.

- Assuming speed needed changing, wait up to 20 seconds until speed is
"in range".
- If after 20 seconds speed is in range, good, otherwise bad.

- if spindle was not running prior to this code, stop spindle and wait
until VFD stops is.

The advantage of this approach is that it is done in a totally self
evident script that can be debugged. The disadvantage is that S300
reads better than M141 P300. But I can live with it and leave S
command control VFD speed, which I do not really need to do with
varidrive that much, but just to look cleaner.

#!/usr/bin/perl

print STDERR "$0: " . join( ',', @ARGV ) . ".\n";

sub Kaput {
my ($msg) = @_;
die $msg;
}

sub get_hal {
my ($signal) = @_;
my $out = `halcmd getp $signal`;
chomp $out;
return $out;
}

sub set_hal {
my ($pin, $value) = @_;
system( "halcmd setp $pin $value" )
&& Kaput( "Could not halcmd $pin $value" );
}

my $P = $ARGV[0];
my $Q = $ARGV[1];

my $min_speed = 60;
my $max_speed = 4200;

my $min_delta = 5;
my $pct_delta = 0.05;
my $time_limit = 20; # seconds

my $commanded_speed = $P;

unless ( $min_speed = $commanded_speed && $commanded_speed = $max_speed ) {
die "Commanded speed $commanded_speed NOT between limits of $min_speed and $max_speed";
}

my $lower_limit = max( $min_speed, $commanded_speed * (1-$pct_delta) - $min_delta );
my $upper_limit = min( $max_speed, $commanded_speed * (1+$pct_delta) + $min_delta );
my $was_running = get_hal( 'motion.spindle-on' );

unless ( $was_running ) {
set_hal( "motion.spindle-forward", "TRUE" );
sleep 1;
}

my $start_time = time;
my $ok = undef;

my $speed = get_hal( 'motion.spindle-forward' );

my $increasing;
if ( $speed $lower_limit ) {
set_hal( 'halui.spindle.increase', 1 );
$increasing = 1;
} elsif ( $speed $upper_limit ) {
set_hal( 'halui.spindle.decrease', 1 );
$increasing = undef;
} else {
$ok = 1;
}

while( !$ok && time $start_time+$time_limit ) {
if ( $lower_limit = $speed && $speed = $upper_limit ) {
$ok = 1;
last;
}
sleep 0.01;
}

if ( $increasing ) {
set_hal( 'halui.spindle.increase', 0 );
} else {
set_hal( 'halui.spindle.decrease', 0 );
}

unless ( $ok ) {
# Stop spindle. We screwed up
set_hal( 'halui.spindle.is-on', 0 );
Kaput "Could not reach desired speed in $time_limit sec."
unless $ok;
}

unless ( $was_running ) {
# Spindle was not originally running, stop it
set_hal( 'halui.spindle.is-on', 0 );
}

exit 0;


I suspect your code will need some tweaking to account for lag time in
vari-drive response so it doesn't overshoot the target speed, i.e. only
turn on the up/down solenoid for 1 second, then turn it off and wait a
second for the drive to stabilize before checking the speed and
determining if it needs more adjustment.

There must be a way to hang this code off of the normal M03/M04 commands
so that the machine will operate more or less normally relative to other
CNC mills other than a bit slow spindle start when changing speeds. I
can't imagine that EMC2 has a limitation that would prevent this.


Pete, I am not speaking from any kind of knowledge. I think that I
found way to change spindle speed that I understand. There may be a
cuter aproach that I do not yet know. But I found something that I
personally find workable.

i


Jon seems to think someone else has already done this, I'd try to find
more information on that.