Friday, June 12, 2015

LinuxCNC controlled Grizzley G0704 mill with a Mesa 7i76e


CNC build: Grizzley G0704 LinuxCNC controlled with a Mesa 7i76





7i76e user manuel

http://www.mesanet.com/pdf/parallel/7i76eman.pdf


So to get linuxcnc working with the MESA 7i76e you are going to need an appropriate realtime kernel.  Here are the steps provided to me by PCW from Mesa Electronics, I may have made slight modifications based on notes or changes I needed to impliment based on my experience.

cd ~
mkdir rtlinux
cd rtlinux
wget ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.18.11.tar.xz
wget https://www.kernel.org/pub/linux/kernel/projects/rt/3.18/patch-3.18.11-rt7.patch.gz
tar -xpf linux-3.18.11.tar.xz
gunzip patch-3.18.11-rt7.patch.gz
// now copy the contents of rtconfig into .config inside linux-3.18.11
// this can be found at http://freeby.mesanet.com/rtconfig
cp patch-3.18.11-rt7.patch linux-3.18.11
cd linux-3.18.11
cat patch-3.18.11-rt7.patch | patch -p1
make xconfig
//ok at this point a window will open, make sure "fully premptable kernel" is enabled
//then close the kernel config, the configuration file should have enabled this.
make
// for my machine(asrock 1900-itx), make took a good chunck of the day..
// I am aware there are ways you can issue the make command that will utilise more of the processors // but I was unable to issue them without complicating the task beyond my means to figure out.
 
sudo make modules_install
sudo make install

// now when you reboot you should have a fully premptable kernel, which you should see at the top of grub apon booting
/****** instructions on how to get a copy of linuxcnc that you want for the 7i76e *****/
 //  you will need this or else the regular branch of linuxcnc won't have the stuff you need to talk to
// the 7i76e

cd ~
sudo apt-get install git-core gitk git-gui
sudo apt-get build-dep linuxcnc
sudo apt-get install linux-image-3.2.0-4-rt-686-pae
sudo apt-get install libudev-dev
sudo apt-get install iptables-persistent
// save rules yes
// save rules yes
git clone git://git.linuxcnc.org/git/linuxcnc.git linuxcnc-dev
cd linuxcnc-dev
git checkout master
git pull
cd src
./autogen.sh
./configure --with-realtime=uspace
make
sudo make setuid
cd ..
. scripts/rip-environment
//   you need to run this command each time you run linuxcnc


man hm2_eth
// follow the instructions in the man to get things further set up
address of 7i76 card:
192.168.1.121
Add these lines to the file /etc/network/interfaces to  configure  eth1
       with a static address:
       auto eth1
       iface eth1 inet static
           address 192.168.1.1
These instructions assume your dedicated network interface  is  "eth1",
       192.168.1/24
 The  board  must  have  its  hardware  loaded  on  the  board  by   the
       mesaflash(1) program.
 By  default, Linux may transmit IPv6 packets on all interfaces, even if
       they are not explicitly configured  with  global  IPv6  addresses.   In
       /etc/sysctl.conf, disable ipv6 on eth1 by adding this line:
       net.ipv6.conf.eth1.disable_ipv6=1
   Configure iptables for exclusive access
       Install  the  package  "iptables-persistent"  and  put this in the file
       /etc/iptables/rules.v4 (remove leading whitespace from every line):
       *filter
       :OUTPUT ACCEPT [0:0]
       :hm2-eth-rules-output - [0:0]
       -A OUTPUT -j hm2-eth-rules-output
       COMMIT
       If this configuration is present, then when hm2_eth loads it  will  add
       rules  restricting  use of the interface to only its own UDP socket; at
       (normal) exit, it will remove the rules.  You can  manually  clear  the
       rules with sudo iptables -F hm2-eth-rules-output.
       If  you  already  use  iptables,  create an empty chain named "hm2-eth-
       rules-output" (you must use this name; it is hardcoded in hm2_eth), and
       place  a  call to this rule early in the OUTPUT chain, before any rules
       that could potentially pass packets out eth1.
my particular machine only had one ethernet port
so I had to purchase a usb ethernet adapter and configure the network interfaces
set the w2, w3 jumpers
then I modified 7i76es1.ini  to connect to the address  
(09:25:19 PM) PCW: step_type 0 = step/dir
(09:25:21 PM) PCW: step_type 1 = up/down CW/CCW
(09:25:22 PM) PCW: step_type 2 and > = Table driven
(09:26:10 PM) Computer_barf: my x axis is stuck but I believe thats probably mechanical
(09:26:15 PM) PCW: man hostmot2 for the meaning of all the hardware parameters
(09:26:22 PM) andypugh: furrywolf: Yes, they are pressed in.
(09:26:34 PM) andypugh: But that’s a mad price
(09:26:57 PM) furrywolf: yeah, that's just a random forum link.  it's for a hitachi that's identical to my bosch.  figure that one out!
(09:27:22 PM) PCW:  also you must determine the max velocity and acceleration (so expect stalls until you get these set)
(09:27:30 PM) andypugh: furrywolf:  http://simplybearings.co.uk/shop/product_detail.php?products_id=152959&gclid=CJaji9DzocUCFUyWtAodpGMAwg
(09:27:39 PM) andypugh: Is that a less frightening price?
(09:27:43 PM) PCW: bbl dinner
(09:27:48 PM) Computer_barf: PCW: commentary logged to notes,  at this point im going to slow down and read over all the stuff ive saved, i wrote down before about the velocity and accelleration settings.
(09:27:59 PM) MrFluffy: budget bearing, does that mean it comes pre worn out?
(09:28:09 PM) PCW: Well that was easy :-)
(09:28:18 PM) PCW left the room (quit: Quit: ChatZilla 0.9.91.1 [Firefox 37.0.2/20150415140819]).
TB6
inputs
00 estop in
01 x home
02 y home
03 z home
04 probe in
05 x maximum limit
06 y maximum limit
07 z maximim limit
08
09
10
11
12
13
14
15
output's
00 ESTOP Out
01 Coolant Flood
02
03
04
05
06
0



flashing the 7i76

ive not done this but this is the command I believe needs to be run to do so: 

mesaflash --device 7i76e --addr 10.10.10.10 --readhmid


3d Printed Parts for G0704 CNC mill conversion



Electronics Enclosure


using my Mendelmax 3d Printer I printed up some standoffs for mounting the motherboard and 7i76e:

http://www.thingiverse.com/thing:335435/#files


Using this mount for the hard drive:


http://www.thingiverse.com/thing:418821


This is a good idea for the power supply but unfortunantly its in the wrong

orientation to serve my needs for overall case design

http://www.thingiverse.com/thing:292306


Estop, like the button but want to modify it to be able to trigger a simple switch:

http://www.thingiverse.com/thing:36144dd




General mill parts





Here is a cover that is for the hole that is left from removing the Z axis handwheel

http://www.thingiverse.com/thing:345032

spindel LED ring mount

http://www.thingiverse.com/thing:109915



Sunday, May 3, 2015

Stepper Motors & Drivers

CNC build: Grizzley G0704 LinuxCNC controlled with a Mesa 7i76e




Stepper motors & Drivers 



X & Y Axis steppers & Drivers:

NEMA23 570oz/in 5A 3/8” Dual Shaft Stepper Motor (KL23H2100-50-4B)

1.8° /200 Steps Per Rev.

https://www.automationtechnologiesinc.com/products-page/nema-23/nema-23-three_eighths-inch-dual-shaft-with-a-flat-570-oz-in

http://www.automationtechnologiesinc.com/wp-content/uploads/downloads/2012/02/KL23H2100-50-4BT.pdf
 

5.0 amps    50.6  volts

KL-5056D  Driver(s) 

Note:  I use a 48 volt supply, as cncshopmill on youtube had two of these go out on him with 50volts.  




Z Axis steppers:

NEMA34 Stepper Motor – 906 oz in 6.1A Single Shaft (KL34H295-43-8A)

1.8° /200 Steps Per Rev.

https://www.automationtechnologiesinc.com/products-page/nema-34/nema34-stepper-motor-%E2%80%93-906-oz-in-6-1-amp-single-shaft-kl34h295-43-8a

http://www.automationtechnologiesinc.com/wp-content/uploads/downloads/2012/01/KL34H295-43-8A.pdf

6.1 amps    58.1  volts


Driver KL-8070D

So now i need to configure the INI file for linuxcnc.  PCW of Mesa electronics helped me out greatly by providing some sample configuration files for the 7i76e controller board, to which I am modifying in attempts to match my G0704's hardwear as best as possible.  I searched around the internet for predefined settings for my drivers and steppers and didn't find much, but I'll add things here as i find things that influnced some choices, but ultimately ill arrive to my own values through testing:

this one isn't for certain based on my stepper driver, but at least its close to my mill so it gave me some numbers to start off from. 
https://www.youtube.com/watch?v=yWqFEjEg0dc


  I am most open to any information that might help refine these settings and as I work I will update the blog to reflect such files and settings.  

 I know that the drivers have dip switches that you select the number of steps per revolution.  Currently I have gotten my G0704 to operate in scale at 2000 steps per revolution configured on the steppers dip switches and having my INI file altered to work proportionally to that and how many rotations it takes to move one unit of measure (mm).   I have no idea if 2000 is optimal, but at least it is moving 10mm when i ask it to move 10mm, so I head over to linuxcnc on freenet to discuss and here is what transpired (I am computer_barf):


(09:57:27 AM) Computer_barf: are steppers bound by a certain number of steps per rev or is that more of a driver thing?
(09:58:39 AM) Computer_barf: currently I have my steps per rev set to 2000, with my driver's dip switches set to that
(10:01:59 AM) malcom2073: They have a certain number of steps per revolution, that's how they're built
(10:02:09 AM) malcom2073: the number dependson the stepper, but most motion control steppers are 200 steps per rev
(10:02:12 AM) skunkworks: normal steppers are 200 full steps per rev. So you have 10X microstepping.
(10:02:14 AM) Roguish: Computer_baf: it's both. http://homepage.cs.uiowa.edu/~jones/step/
(10:02:20 AM) pcw_home: 1.8 degree motors have 50 poles and 200 full steps (this is determined by the motor design)
(10:02:22 AM) pcw_home: you can have an arbitrarily high number of fractional steps per whole step
(10:02:53 AM) pcw_home: though > say 32 you get into diminishing returns
(10:05:52 AM) Computer_barf: Ok so what I get from that is that I probably shouldn't have my driver set to 2000 steps and I should instead switch the dip switches to have it configured for 200, then i would also need to alter
(10:06:25 AM) Computer_barf: my ini's scale to reflect that, in context to my c7 ballscrews mm/rev
(10:06:54 AM) pcw_home: no I would set it for say 6400 steps (32 u steps)
(10:07:04 AM) pcw_home: full stepping is nasty
(10:07:56 AM) pcw_home: lots of vibration and likelihood of resonance stalls
(10:08:31 AM) skunkworks: well - software stepping? That may limit your ustepping - may have to balance what you can do.
(10:09:33 AM) Computer_barf: ahh. ok , I will do that, PCW, so i guess there is a certain number of microsteps per step and thats why you end up with the bigger number?
(10:09:43 AM) pcw_home: this is hardware (though you need to check your drives minimum step length and space as this may also limit the maximum ustep ratio you can use)
(10:13:06 AM) pcw_home: yes think of a compass needle with a magnet pulling it around in a circle (the compass needle is the step motor rotor)
(10:13:07 AM) pcw_home: the ustep ratio is determines the angular step size of the magnet (full steps are 90 degrees)
(10:15:16 AM) pcw_home: note that the compass needle torque vs displacement does not change, just the angular step size of the external field

(10:18:01 AM) pcw_home: and just like the compass with a 90 degree step in the field, with a full step (1.8 degrees),
(10:18:03 AM) pcw_home: the step motor rotor will jump to the next position and then overshoot and oscillate
(10:18:14 AM) pcw_home: (ring)
(10:20:05 AM) pcw_home: so the main advantage of large ustep ratios is that they are smoother and dont tend to excite
(10:20:06 AM) pcw_home: vibrations and possible resonances that can lead to step loss or stalls



These guys are of course, geniuses, and I don't really always understand what they are saying when they first say it.  So here it is so that I may digest it over time.  For the moment, I'll go with PCW's advise of trying out
6400 steps (32 u steps), and calculating my C7 ballscrews rotations per unit of measure in accordance, and setting the scale in my INI respectively to that. 

So on my KL-5056D , I set my dip switches accordingly:
 (1)off(2)on(3)on(4)off(5)off(6)on(7)off(8)on

This is to set the steps to 6400 and the amperage to 4.9 amps

So now I must configure my linux CNC ini file to reflect such.  

I have discovered that if I do not place a MAX_LINEAR_VELOCITY setting in the [TRAJ] section things hardly move at all.  So I place that in that section at a setting equal to the highest MAX_VELOCITY amoung the axis settings, ie:

MAX_LINEAR_VELOCITY =   80 

So for each axis I modified the settings as so: 

MAX_VELOCITY =     80
MAX_LINEAR_VELOCITY =   80
MAX_ACCELERATION =   300
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL =    84
STEPGEN_MAX_ACC =    360


BACKLASH =           0.000
 

# drivers set to 6400 steps/rev 
# C7 ballscrews move 5mm per revolution
# therefore 1280 scale should make it move 1mm
SCALE =           1280


These settings seem to be working OK, with the mill moving at acceptable speeds for what I imagine my usage will be. I am jogging currently with a maximum 4800mm/min or 188.97 in/min.  When I set my MAX_VELOCITY settings faster I start getting errors.  In previous attempts Ive seen my mill move at faster speeds than it is operating at now, but as of current I am unlikely to need it to move that fast, so I only plan on exploring this if I really need to or maybe just for shit's and giggles when I have less important matters pending. Here is some interesting info that was discussed on freenet pertaining to this:


(11:20:55 AM) roycroft: just keep running it faster until it gets pulled over and issued a citation
(11:22:09 AM) pcw_home: you can also trade off accel for velocity
(11:23:07 AM) pcw_home: That is you can use more accel if you limit the velocity since step motors have much more torque available for accel at lower speeds

(11:30:09 AM) alex4nder: accel is going to be more useful while machining anyway
 

on headroom:

(11:09:51 AM) pcw_home: Computer_barf you need to set the stepgen maxvel so you have say 20% headroom
(11:31:28 AM) pcw_home: headroom can also be limited by steplength and stepspace settings