Hello Guest it is January 26, 2021, 06:50:54 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - DamonJones

Pages: 1
1
General Mach Discussion / High Speed Servo as Spindle - My Solution
« on: November 22, 2011, 03:13:08 AM »
I thought I'd share my solution to some of the issues I've brought up here recently in other threads. This all started with my plan to add a 4th axis to my mill with the intent to be able to run it as a spindle for turning processes as well as index mode. Well if any of you have looked very deep into this Mach3 has a few gotchas and although there has been some success in this area I wasn't really happy with any of the solutions. Now before I get to far into this so far this has been bench tested only so if in the long run it doesn't work out this info can be thought of as learning material.

First lets outline what I wanted. My mill currently has a 5 HP 3 phase motor that is relay controlled for direction and a manual adjustment for speed. Goal: get rid of the 3 phase and get mach to control direction and speed. Second is the addition of a 4th axis that is capable of both indexing and turning functions.

First came the main spindle motor and what to do with it. After some helpful advice on the board here I decided to give an AC servo motor a go for the spindle. Mechanically the switch won't be tough but the control of it soon became an issue. I selected a servo motor 2.5HP 4000RPM and plan to run it 1 to 1 with the main (Z axis) spindle. The motor has an encoder of 8000 steps per revolution. I plan to run the driver with STEP and DIR  signals, for reasons I'll explain later, so here's the first issue. To get full speed out this motor I need to feed it a Step signal at 533Khz. Mach3 parallel ports are only able, at best on my system, to go to 45Khz. Even if I got to the 100Khz max Mach3 allows I'd be well short of my goal. Two solutions came up, one software gear up the driver by multiplying the steps by a factor of 12. Second buy a smoothstepper board. The software gearing my have been OK for the main spindle but not for the A axis the resolution would be unusable. So the smoothstepper solution won out. However they are not exactly cheap and although offer a ton of benefits, in this case all it was really doing was clocking my servos for high speed rotation. In comes the next issue. So far the solutions mentioned did nothing to help with swapping between my main spindle on the Z axis and the future A axis spindle. Mach3 has the swapaxis commands but none of the motor tuning options follow the swap (Mach3 guys this is a huge deal). So if the two servos have any differences (which they will) then a complex set of macros would have to be written to move this information around. In addition the swapaxis command does not undo itself so if it's not reset then the next time you come into Mach3 your axis's will be reversed. So there is the overview.

Now for my solution. So I need a way to clock two different high speed servos using STEP and DIR signals, Also be able to index with at least the A axis (actually I can do both using C axis to index on the Z spindle, I'm sure this will come in handy some day), Lastly I need to control this all from Mach3 and not have the software get "confused" about the config it's in. What came to mind was a microcontroller. In particular an Arduino Uno. First it's cheap $30, second it has built in timers for clocking, it has a built in USB port for talking to Mach3, and it's programmable. So as things change or issues come up I can reprogram on the fly. It is well supported and I don't have to eat up a bunch of my parallel port pins run logic.

So into the junk draw I go and out comes the arduino and my proto boards. Here was the progression of events that I've gone through the past week.

First issue: Make the Arduino board talk to Mach3. Here is the beauty part of a well used open source microcontroller. Someone wrote a MODIO slave library already. It is very basic and all it does is write output holding registers to the arduino from Mach3. Took a little playing as I'd never worked with MODIO before but soon had Mach3 writing 4 registers to the arduino. Registers 1 and 2 I mapped to Outputs 8 an 9 in Mach3 with I tied to spindle relays control for CW(M3) and CCW (M4). Sweet I now have spindle direction, along with Off and On control in my Arduino. Next came speed. I wrote a quick one command brain that maps the Override speed DRO to ModIO register 4. Again success I now have the speed I need to turn my servo in my arduino. Last for the registers in number 5 which is tied via the brain to an OEM LED I put on all my screens. I added a button that calls two custom macros (M900 and M901) which turn this lLED off and on. So I have button control and well as gcode control of the LED. This is going to show the current spindle. LED off the main spindle is active and the A axis is in indexing mode. LED on and the reverse is true. (Yes it will index the main spindle too). Sweet I have control of everything I need.

Second issue: First before we get to much farther I should let anyone know that does't that MODIO is not suitable to run STEP (timing) signals for axis movement directly. There is lag time in the USB that prohibits this. That's a complete topic of it's own. Just know it doesn't work. Also what doesn't work is using the Arduino board to intercept the parallel ports pin signals and do logic control of them and spit them back out on another port. Again the response and log time just don't allow for it. But wait I need to change the STEP and DIR source for my Servos to either my external clock signal (next issue) or the STEP and DIR pins from the parallel port. The only option is to us TTL logic chips to do the swapping and control them from the arduino. A couple of AND, OR and NOT 7400 series chips later and I have a matrix to swap the control signals for the two servos. I'll probably add the INDEX pin as well for speed feedback to mach. I won't bore you all with the details of the logic just know what it does.

Third issue: So I now have all the control signals from Mach3 I need and a way to swap the controls signals between my two servo motors. All controlled by a program in the arduino. Testing on all this goes great. Now for the big issue. How do I drive the servo at the speed I need. This turned into quite a big deal. When I looked at the datasheet for the arduino MPU it mentioned that one of it's three timers has a 16bit resolution of the system clock. The system clock is 16Mhz and 16 bit (65000+ options) seemed plenty. Well not so fast. The details of how the clock works is quite involved. Basically it is a divider network of the system clock that as higher frequencies are output the gap between them gets log-rhythmically larger. After hours of trial and error and allot of math I'd forgot how to do I came up with a timer program that is reasonable for the range I needed. Using the servo motors I mentioned The worst case is about 132 RPMS variance at 4000 RPM. It gets more accurate the lower the speed. The control program also gives configurable ramp up and ramp down, as well as different encoder counts which will come into play when I gear down the A Axis. Each servo has it's own profile so they can be  totally different and the program will compensate and send the appropriate frequency to the motor based on the speed asked for in Mach3.

So it works on the bench and I'm waiting on parts to build the real deal. I'm sure there will be a ton of tweeking to make the motors spin up and down smoothly. My test setup just has a small stepper I had laying around as a test motor. A far cry from the full sized servos that will be used for real. I did bind an encoder to the stepper and grabbed the index pulse and fed it back to mach3. Test so far of the limited speed of the stepper are 100% accurate.

I'll keep you all posted on the build as it progresses. Eventually I'll post he arduino code but I'll wait for it to be tested and working. I haven't written in C for about 15 years and I had a bunch of cobwebs to clear. Bit register sets and clear, floating point variable, Arrays and pointers, just to mention a few of the problem areas.

For those interested here is some of the math involved in this project. Just FYI stuff.

Frequency of STEP signal for given RPM is figured as follow: Frequency=(RPM/60) * Encoder Count for 1 Revolution. (Note this could be different from your encoder resolution on the motor based on the gearing from the motor to the spindle.

Mach3 motor tuning for STEPS rotational axis: Mach3 wants the steps for 1 degree of rotation or unit. So a 1:1 geared servo to axis with an 8000 count encoder would be 22.222222 steps. 2:1 gearing would be 44.4444444 and so on.


2
General Mach Discussion / Opinions For Spindle HP
« on: November 12, 2011, 02:40:33 PM »
So I have an old Lagun mill that I've converted to CNC. It works great but I am considering using an AC servo for the spindle. The current setup uses a 5hp 3phase motor at 1750 rpm. It has a variable belt clutch setup that is easy for speed changes but still a manual process. Plus I'd like to get rid of the 3 Phase if possible. So here's the question. What would you consider as a minimum HP or KW rating for the new motor? My thought would be if I pickup max RPM to say 4000 I could lose some HP and keep the cost down. I'd eliminate the adjustable clutch and drive the 2 speed gear box directly.  That way I still could have good slow speed torque if needed.

This is a home system so production is not an issue. I don't mind cutting slower but I don't want to cripple the machine either.

3
General Mach Discussion / Allen Bradley Guru's
« on: November 12, 2011, 01:48:38 AM »
Doing some research on Allen Bradley AC servo drives. It appears to me that the -SE versions do not have step and dir inputs like the other models. Can anyone confirm this?

4
General Mach Discussion / Swapaxis and Spindle Relays
« on: November 10, 2011, 02:37:18 PM »
So I'm in the process of setting up a 4th axis with the capability to also run as a spindle to turn on. There is a great thread on here where such a project was done and there is a ton of good information. He utilized the swapaxis function to swap his spindle and his 4th axis and it worked great for his setup. My problem is that my spindle runs on relays and even with the swap function the relays stay active. It would be very helpful if there was a VB function to disable/enable the relays. There is a checkbox in setup for it so all I need is a function to control it.

That all said I figured a work around out using a custom brain, a User OEM LED and two unused outputs. It looks like it will work but it's kind of Rube Goldberg.

I could also use an interrupting relay on the motor relays controlled by another output and another brain or macro group. Again kinda barbaric.

So is it possible to get at the setup options from VB?

5
General Mach Discussion / Call User Button From Brain
« on: November 24, 2008, 05:42:42 AM »
Can I call a User Defined Button from a Brain? Or Even better just a saved macro?

6
General Mach Discussion / Add Delay to Reset
« on: November 22, 2008, 11:20:18 PM »
Is it possible to add a delay to the reset routine. I am using G320's and they have a delay once enabled. I'd like the system to wait for a few seconds to allow the drivers to come ready before the software will respond. Currently if I reset and immediatly jog the machine it will move the software DRO's but not the machine.


7
Just downloaded the latest copy of Mach 3  and it still has a problem I reported in ver. (.068) with power off resets. I have my spindle controls setup on two relays, one for each direction. They are controlled by pins 8&9 and are active low. When I reboot my PC and load Mach 3 Mill both pins go active after I reset. They will stay that way and even do some strange toggles until I cycle the spindle 2 times in the diag screen. I can move the other axis's and it still will not set these pins correctly. Luckily my relays prevent the possiblility of both being on at the same time so I didn't have a shop full of smoke. Obviously I do not want the machine coming up with the spindle on however so this needs addressed. After this first episode I can close and open Mach 3 all day long and it works fine. Just the first power on load causes the problem. 

Another note is that before the Mach software loades the output pins are inactive (High).

The hardware is a P4 3.2Ghz running XP. Anyone have a clue what is going on?

8
Just downloaded the latest copy of Mach 3 (.068) and it still has a problem with power off resets. I have my spindle controls setup on two relays, one for each direction. They are controlled by pins 8&9 and are active low. When I reboot my PC and load Mach 3 Mill both pins go active after I reset. They will stay that way and even do some strange toggles until I cycle the spindle 2 times in the diag screen. I can move the other axis's and it still will not set these pins correctly. Luckily my relays prevent the possiblility of both being on at the same time so I didn't have a shop full of smoke. Obviously I do not want the machine coming up with the spindle on however so this needs addressed. After this first episode I can close and open Mach 3 all day long and it works fine. Just the first power on load causes the problem.  >:(

Pages: 1