Step and direction spindle help needed

More
27 Feb 2012 07:40 #18116 by matttargett
Hi,

Im new to emc, im trying to convert from mach 3, i have a machine under mach control with a step / dir spindle, well actually its just a 1kw ac servo and i need to control it, i googled the subject and found some stuff about re connecting a stepgen in hal, i have a broad understanding of what that means, i configure my spindle as the a axis and then reconnect the stepgen so that when i issue a s1000 m03 those commands start the a axis moving, is that correct? Anyway really my question is i need help, i partially understand hal and i can see its power, particularly over and above brains in mach 3 but i really need to get on and use the machine at the moment so if someone could give directions for stupid people i would be very greatful, hopefully if i post what i did then in future it would be really easy for someone new to configure.

Thanks alot

matt

Please Log in or Create an account to join the conversation.

More
27 Feb 2012 09:07 - 27 Feb 2012 09:16 #18117 by cncbasher
you have it correct , set up the spindle as for A Axis , but change the stepgen control for that axis to v ( velocity mode ) and redirect the motor command to the Axis

you will need to add for example to a axis
...... stepgen.00.step_type 1
net Xmotor-pos-cmd => ... stepgen.00.position cmd to ... stepgen.00.velocity-cmd

i presume the servo drive also has an encoder fitted in that case , you will also need to add pid feedback
encoder.positon => A.motor-pos-fb

post you hal file and we can guide you through the process , as using stepconf will only get you part way , so you will end up hand coding the missing parts

i do not have a spindle running using step direction signals , so perhaps another forum member can post a snip of their hal file
which will assist

the approprate lines are ( supposing your A axis is stepgen 3)

net apos-cmd axis.3.motor-pos-cmd => stepgen.3.position-cmd
net apos-fb stepgen.3.position-fb => axis.3.motor-pos-fb
net astep <= stepgen.3.step
net adir <= stepgen.3.dir
net aenable axis.3.amp-enable-out => stepgen.3.enable

see this post
www.linuxcnc.org/index.php/english/compo...iew&catid=16&id=3518
Last edit: 27 Feb 2012 09:16 by cncbasher.
The following user(s) said Thank You: rpseguin

Please Log in or Create an account to join the conversation.

More
27 Feb 2012 09:24 - 27 Feb 2012 09:25 #18119 by ArcEye
Pipped to the post by cncbasher!!!

Between the 2 posts you should get it!

Hi

You can use a stepgen in velocity mode to control a spindle motor, that is what I do.

If you are talking about step / dir spindle under Mach I assume that you control your motor speed via a 0 - 10v signal?

I further guess you use speed board which takes pulse and direction feeds from the stepgen and converts them into an analogue signal voltage / triggers a relay for M4, respectively.

That would be the standard setup.

In which case, these extracts from my lathe .hal file show the stepgen connections etc to make this work.
#################################################################
#   5th stepgen for controlling the spindle.
#   Type must be set to velocity
#   Stepgens must be declared to match the ini declarations
#   even if not used, hence there is
#   one for Y even though it does not exist
#################################################################

loadrt stepgen step_type=0,0,0,0,0 ctrl_type=p,p,p,p,v

addf stepgen.make-pulses base-thread
addf stepgen.capture-position servo-thread
addf stepgen.update-freq servo-thread

####################################################################
#	This section enables the DIYCNC Spindle2 board to produce
#	0-10v scaled upon steps from axis4 and direction of 
#	rotation from Dir signal
####################################################################

#   Use a scale module for offset and scaling of the stepgen
#   Offset and scale are determined by first calculating and testing
#
setp scale.0.in 0
setp scale.0.gain 1.26  # GIVES TRUE 600 RPM in M4
setp scale.0.offset 0
addf scale.0 servo-thread
#
#   Initialise the stepgen for the spindle
#
setp stepgen.4.position-scale 1
setp stepgen.4.maxvel 2400
setp stepgen.4.steplen 1
setp stepgen.4.stepspace 0
setp stepgen.4.dirhold 20000
setp stepgen.4.dirsetup 20000
setp stepgen.4.maxaccel 200

#   Enable it
net spindle-enable <= motion.spindle-on => stepgen.4.enable 

#   Connect spindle speed to scaler
net spindle-cmd motion.spindle-speed-out => scale.0.in

#   Connect scaler output to stepgen velocity
net spindle-freq <= scale.0.out => stepgen.4.velocity-cmd 

#   Connect output to the pin for the analog voltage of spindle2 board
net spindle-out <= stepgen.4.step => parport.0.pin-09-out 

#   Activate relay to power spindle GEC controller
net spindle-enable => parport.0.pin-16-out

##  Connect DIR pin to inverted DIR signal from stepgen.4 which gives correct relay switching for CCW and CW
setp parport.0.pin-08-out-invert 1 

# Some problems setting up logic to match the reversing contactor
##   This works, connecting CCW to stepgen DIR to Spindle2 DIR
net spindle-ccw <= stepgen.4.dir => parport.0.pin-08-out

You will not be able to just cut and paste this, but it should give a good idea of how to create the stepgen and connect it up.

The complication at the end is due to how the reversing contactor for the Lenze DC spindle motor is connected.
Because I have a slant bed lathe, I turn in M4 most of the time, which is the connection I wanted when the contactor is off.
The speed boards assume that M3 will be default and M4 reverse so I had to juggle the logic to get what I wanted.

Welcome to Gates free CNC

regards
Last edit: 27 Feb 2012 09:25 by ArcEye.

Please Log in or Create an account to join the conversation.

More
28 Feb 2012 07:01 #18166 by matttargett
Thanks for the help,

Ive had a go at it, i dont use a speed control board or any of that stuff, its literally a 1kw ac servo motor with a driver that accepts step/dir signals, but i dont think that matters too much.

I have picked out what i think i need to get the signals from the spindle to the a axis, i think i have changed the a axis to velocity mode too, i deleted all of the spindle stuff from the file except one line, i wondered if that was the line that turned on output 1 when the spindle was running? thought maybe i should leave that alone for now or something.

The other problem i had is my a axis or spindle is run from my second pp, i put the address into step config but i didnt bring up a pp2 config page so i pushed the step/dir signals for the a axis into pp1 on some spare pins for now, how can i edit this ou in the hal file?

Hopefully i have attached the hal file and i would be great ful if someone could look over it.

Matt

File Attachment:

File Name: my_mill-74...56a7.hal
File Size:4 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
28 Feb 2012 09:43 - 28 Feb 2012 11:58 #18169 by ArcEye
Hi

Ive had a go at it, i dont use a speed control board or any of that stuff, its literally a 1kw ac servo motor with a driver that accepts step/dir signals, but i dont think that matters too much.

If the driver accepts pulse and dir signals and converts them to rotation and direction, it essentially incorporates a speed board, however it actually manages it internally, so the priciple is the same.

i think i have changed the a axis to velocity mode

You haven't, you have specified step_type but not ctrl_type

The other problem i had is my a axis or spindle is run from my second pp, i put the address into step config but i didnt bring up a pp2 config page so i pushed the step/dir signals for the a axis into pp1 on some spare pins for now, how can i edit this ou in the hal file?

This is the main problem at the moment.
loadrt hal_parport cfg="0x378 out df39 in " is missing the Hex notation to parport 2, should be 0xdf39
To use the 2nd parport simply specify parport.1.pin.NN remembering that pins 2-9 are now inputs

For a standardised setup you could have
parport.0.pin
1 charge pump
2 x dir
3 x step
4 y dir
5 y step
6 z dir
7 zstep
8 a dir
9 a step
10 - 17 as required limits / encoders / homing / relays etc

parport.1.pin
1 out
2-9 extra in as reqd
10 - 17 as required

I trust you have a charge pump? If you do not you will not be able to start using this file.

You do not need a pwmgen component, so you can delete the 3 lines which refer to it.

I should edit your .hal file along these lines and then try to get the axes / limits / homing working.
Once they are done, you can isolate the spindle code and address any problems more easily.

regards
Last edit: 28 Feb 2012 11:58 by ArcEye.

Please Log in or Create an account to join the conversation.

More
28 Feb 2012 19:51 #18184 by matttargett
Hi,

Thanks again for the reply,

Im getting the impression the second pp cant be used for axis control? surely not? I have modified my hal file some more and changed its address to a hex number and also specified it as out not in, is that ok? i think i have also changed the other things that you mentioned, could you have another look for me please? , yes i have a charge pump and an enable signal and all of the pins are correctly allocated.

Thanks

matt

Please Log in or Create an account to join the conversation.

More
28 Feb 2012 20:02 #18185 by matttargett
sorry, forgot the file!

File Attachment:

File Name: my_mill-e1...fe48.hal
File Size:4 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
29 Feb 2012 09:17 - 29 Feb 2012 09:17 #18192 by ArcEye
Hi

Im getting the impression the second pp cant be used for axis control? surely not?

Not at all, its just that unless you have a 5 + axis machine why would you want to waste 8 extra input pins by designating your second parport as out?
Encoders, limits, home, probes etc all need input pins and there are still plenty of outputs left to cover any relays etc.

I would suggest that you use the standard pin assignment that I outlined for the axes. At present you have A DIR on one parport and A STEP on another, that cannot be sensible.

This entry needs some explanation net spindle-pwm => parport.0.pin-08-out
Given you are controlling your spindle via step / dir commands, what is this for?

i think i have changed the a axis to velocity mode

You haven't, you have specified step_type but not ctrl_type

Still no ctrl_type specified, so you dont have a velocity type stepgen.3

Once you have amended your .hal file you need to test it by loading LinuxCNC with that configuration.

I would comment out everything specific to the spindle and concentrate on getting 3 axes plus home / limits working.
Then uncomment the spindle stuff bit by bit and the error messages you get will be specific to the spindle and more informative (or it might just work first time :laugh: )

regards
Last edit: 29 Feb 2012 09:17 by ArcEye.

Please Log in or Create an account to join the conversation.

More
29 Feb 2012 21:09 #18223 by matttargett
Hmmmmm.

I have another 2 1/2 hrs spent on it, i was hoping to get some help along the lines of, no you still havent got the correct control type, looks like you are looking in the wrong place its at the top where it says ppp, try this etc, rather than no youre still wrong, im sure i could get this working but i have limited time for my hobbies, im going to use it more effectively with mach and windows.

matt

Please Log in or Create an account to join the conversation.

More
01 Mar 2012 11:00 #18230 by ArcEye
I showed you how it needed to be set up in my first post, which is why I assumed you had forgotten to change it, rather than that you hadn't bothered to read the post.

#################################################################
# 5th stepgen for controlling the spindle.
# Type must be set to velocity
# Stepgens must be declared to match the ini declarations
# even if not used, hence there is
# one for Y even though it does not exist
#################################################################

loadrt stepgen step_type=0,0,0,0,0 ctrl_type=p,p,p,p,v

Please Log in or Create an account to join the conversation.

Time to create page: 0.764 seconds
Powered by Kunena Forum