Spinx1 to 7i85

More
28 Nov 2015 17:25 #65960 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
net spindle-pwm pwmgen.0.pwm paraport.0.pin-nn-out
I'm trying to replace with hm2_5i25.0.pwmgen.00. or something related to hm2. It tells me the pin does not exist. How do I connect properly to net spindle-pwm?

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

More
28 Nov 2015 20:28 #65971 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
I'm re-attaching work in progress. I'm stuck with the basics of connecting the cw/ccw and pwm. I'm trying to replace the paraport examples in the file with hm2_5i25 that works.
# HAL config file for vismach simulation of vertical milling machine
# This file deomstrates closed-loop spindle control in both position and 
# Velocity modes. 

# see http://wiki.linuxcnc.org/cgi-bin/wiki.pl?SpindleOrient for a diagram

# Note that the connections of the signals to "hardware" are all in the 
# sim_vmc.hal file rather than here

# First load 2x pid components. These would normally have to be loaded at
# the same time as the Axis PID components

#loadrt pid num_chan=2 
#addf pid.0.do-pid-calcs servo-thread # Velocity
#addf pid.1.do-pid-calcs servo-thread # Position

loadrt orient
addf orient.0 servo-thread

#loadrt mux2 -- This has already been loaded in the sim_vmc.hal
addf mux2.0 servo-thread # chooses which pid output goes to the spindle speed control

#Use this to detect that the spindle is oriented
#in the 2.8 release there will be a pin for this as an output of the orient comp
#and the edge-detector isn't needed

#loadrt near count=1  (loaded in sim_vmc.hal)
loadrt edge
addf near.0 		servo-thread
addf edge.0         servo-thread
setp edge.0.both 0
setp edge.0.in-edge 0
setp edge.0.out-width-ns 10000000

net spindle-pos pid.1.feedback orient.0.position


net spindle-vel 	pid.0.feedback hm2_5i25.0.encoder.03.velocity
#net spindle-vel 	pid.0.feedback.0.encoder.03.velocity
net spindle-vel-cmd 	motion.spindle-speed-out pid.0.command
net spindle-vel-pid 	pid.0.output mux2.0.in0

net spindle-pos 	pid.1.feedback orient.0.position near.0.in1 hm2_5i25.0.encoder.03.position
#net spindle-pos 	pid.1.feedback orient.0.position near.0.in1 encoder.03.position
net spindle-pos-cmd 	orient.0.command pid.1.command near.0.in2
net spindle-angle 	motion.spindle-orient-angle orient.0.angle
net spindle-pos-pid 	pid.1.output mux2.0.in1
setp near.0.difference  0.0005
net spindle-in-pos-raw near.0.out edge.0.in #not needed v2.8+, use orient.0.is-oriented
net spindle-in-pos 	edge.0.out motion.spindle-is-oriented

# this switches modes
net orient-mode 	motion.spindle-orient orient.0.enable pid.1.enable mux2.0.sel
#net velocity-mode	motion.spindle-on pid.0.enable pwmgen.0.enable 
  net velocity-mode	motion.spindle-on pid.0.enable hm2_5i25.0.pwmgen.00.enable

###############################################################################################
#I'm stuck here: net spindle-pwm and net spindle-fwd/rev. I'm trying to replace paraport examples with hm2_5i25
###############################################################################################
# this is simple for the simulated spindle.
#net spindle-cmd 	mux2.0.out

#for a real spindle run by a VFD
loadrt abs
addf abs.0 servo-thread
net spindle-cmd 	mux2.0.out abs.0.in
#net spindle-cmd-abs 	abs.0.out pwmgen.0.value
net spindle-cmd-abs     abs.0.out hm2_5i25.0.pwmgen.00.value
#net spindle-pwm 	pwmgen.0.pwm parport.0.pin-NN-out
    #net spindle-pwm         hm2_5i25.0.pwmgen.00.enable
# net spindle-fwd 	abs.0.is-positive parport.0.pin-NN-out
# net spindle-rev 	abs.0.is-negative parport.0.pin-NN-out
net spindle-cw  	abs.0.hm2_5i25.0.gpio.002.invert_output 1 
net spindle-ccw 	abs.0.hm2_5i25.0.gpio.002.is_output 1 

#setp    hm2_5i25.0.encoder.03.velocity
setp    hm2_5i25.0.encoder.03.counter-mode 0
setp    hm2_5i25.0.encoder.03.filter 1
setp    hm2_5i25.0.encoder.03.index-invert 0
setp    hm2_5i25.0.encoder.03.index-mask 0
setp    hm2_5i25.0.encoder.03.index-mask-invert 0
#setp    hm2_5i25.0.encoder.03.scale  [SPINDLE]ENCODER_SCALE
#setp    hm2_5i25.0.encoder.03.scale  [SPINDLE]OUTPUT_MIN_LIMIT

##################################################################################################
#This worked before for cw/ccw, pwm and enable can't figure out how to link that to the above cw/ccw
##################################################################################################
# ---PWM Generator signals/setup from Andy---
# PWM/dir mode and PWM rather than PDM
setp   hm2_5i25.0.pwmgen.00.output-type 1
setp   hm2_5i25.0.gpio.002.invert_output 1 


# spindle speed at 10v output, ie max spindle speed
setp   hm2_5i25.0.pwmgen.00.scale 3600

# set the PWM frequency to 5khz
setp   hm2_5i25.0.pwmgen.pwm_frequency 5000

# connect the spindle speed command to the pwmgen
        #net spindle-speed motion.spindle-speed-out => hm2_5i25.0.pwmgen.00.value

# connect the spindle enable to GPIO 018. 
#net spindle-enable motion.spindle-on => hm2_5i25.0.gpio.018.out
net spindle-enable => hm2_5i25.0.gpio.018.out
    

#the SPINX1 has an enable (active low)
setp  hm2_5i25.0.gpio.018.invert_output 1  
setp  hm2_5i25.0.gpio.018.is_output 1 
  
#net spindle-vel-cmd-rpm     => hm2_5i25.0.pwmgen.00.value
       #net spindle-enable      => hm2_5i25.0.pwmgen.00.enable

#############################################################################################

# Tune the PID from the INI values
setp pid.0.Pgain [SPINDLE]PGAIN_V
setp pid.0.Igain [SPINDLE]IGAIN_V
setp pid.0.Dgain [SPINDLE]DGAIN_V
setp pid.0.FF0	 [SPINDLE]FF0_V
setp pid.0.FF1   [SPINDLE]FF1_V
setp pid.1.Pgain [SPINDLE]PGAIN_P
setp pid.1.Igain [SPINDLE]IGAIN_P
setp pid.1.Dgain [SPINDLE]DGAIN_P
setp pid.1.FF0	 [SPINDLE]FF0_P
setp pid.1.FF1   [SPINDLE]FF1_P

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

More
29 Nov 2015 00:45 #65981 by andypugh
Replied by andypugh on topic Spinx1 to 7i85
Thinking about this...

For closed loop speed control you might need to use the motion.spindle-speed-out-rps pin, because the encoder velocity feedback is in revs per second.

That also means setting up the pwmgen scale to max speed in revs-per-sec, not rpm.

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

More
29 Nov 2015 17:43 #66019 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
I changed the pwm scale.
Where exactly do I add the motion.spindle-speed-out-rps and connect it? I'm still not getting the pwm or dir out when I check with the hal meter.

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

More
29 Nov 2015 17:46 #66020 by andypugh
Replied by andypugh on topic Spinx1 to 7i85

Where exactly do I add the motion.spindle-speed-out-rps and connect it?


Use it instead of motion.spindle-speed-out throughout the file.

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

More
29 Nov 2015 17:52 #66021 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
Okay, I will try that now.

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

More
29 Nov 2015 19:37 #66030 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
Still not getting motion. I'm going to clean up the hal and re-attach.
What is working when I check the config, pwm gen values are changing, I can influence them by manually rotating the spindle, M19 R180 changes the status led for the orient mode, spindle-cmd-abs values are the same as pwmgen values.
I'm assuming cw/ccw is working as clicking cw/ccw on the UI initiates the pwm values. the enable led is on as well, just not on the spin x.
I need to re-connect my hm2_5i25.0.gpio.018.out (my enable to the spinx).

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

More
29 Nov 2015 20:32 #66034 by OT-CNC
Replied by OT-CNC on topic Spinx1 to 7i85
Andy,
I'm sorry to eat up your time. Can you have another look at this? I tried cleaning it up a bit. It loads but no spindle rotation.
I'm having trouble with the net spindle-pwm line and the enable out to the gpio.018 below it.
Thank you.
# HAL config file for vismach simulation of vertical milling machine
# This file deomstrates closed-loop spindle control in both position and 
# Velocity modes. 

# see http://wiki.linuxcnc.org/cgi-bin/wiki.pl?SpindleOrient for a diagram

# Note that the connections of the signals to "hardware" are all in the 
# sim_vmc.hal file rather than here

# First load 2x pid components. These would normally have to be loaded at
# the same time as the Axis PID components

#loadrt pid num_chan=2 
#addf pid.0.do-pid-calcs servo-thread # Velocity
#addf pid.1.do-pid-calcs servo-thread # Position

# ---PWM Generator signals/setup from Andy---
# PWM/dir mode and PWM rather than PDM
setp   hm2_5i25.0.pwmgen.00.output-type 1
setp   hm2_5i25.0.gpio.002.invert_output 1 

# spindle speed at 10v output, ie max spindle speed in revs per second
setp   hm2_5i25.0.pwmgen.00.scale 216000

# set the PWM frequency to 5khz
setp   hm2_5i25.0.pwmgen.pwm_frequency 5000

############ Spindle Encoder###################################################
setp    hm2_5i25.0.encoder.03.counter-mode 0
setp    hm2_5i25.0.encoder.03.filter 1
setp    hm2_5i25.0.encoder.03.index-invert 0
setp    hm2_5i25.0.encoder.03.index-mask 0
setp    hm2_5i25.0.encoder.03.index-mask-invert 0

#################################################################################

loadrt orient
addf orient.0 servo-thread

#loadrt mux2 -- This has already been loaded in the sim_vmc.hal
addf mux2.0 servo-thread # chooses which pid output goes to the spindle speed control

#Use this to detect that the spindle is oriented
#in the 2.8 release there will be a pin for this as an output of the orient comp
#and the edge-detector isn't needed

#loadrt near count=1  (loaded in sim_vmc.hal)
loadrt edge
addf near.0 		servo-thread
addf edge.0         servo-thread
setp edge.0.both 0
setp edge.0.in-edge 0
setp edge.0.out-width-ns 10000000

net spindle-pos pid.1.feedback orient.0.position

net spindle-vel 	pid.0.feedback hm2_5i25.0.encoder.03.velocity
net spindle-vel-cmd 	motion.spindle-speed-out-rps pid.0.command
net spindle-vel-pid 	pid.0.output mux2.0.in0

net spindle-pos 	pid.1.feedback orient.0.position near.0.in1 hm2_5i25.0.encoder.03.position
net spindle-pos-cmd 	orient.0.command pid.1.command near.0.in2
net spindle-angle 	motion.spindle-orient-angle orient.0.angle
net spindle-pos-pid 	pid.1.output mux2.0.in1
setp near.0.difference  0.0005
net spindle-in-pos-raw near.0.out edge.0.in #not needed v2.8+, use orient.0.is-oriented
net spindle-in-pos 	edge.0.out motion.spindle-is-oriented

# this switches modes
net orient-mode 	motion.spindle-orient orient.0.enable pid.1.enable mux2.0.sel
net velocity-mode	motion.spindle-on pid.0.enable hm2_5i25.0.pwmgen.00.enable

# this is simple for the simulated spindle.
#net spindle-cmd 	mux2.0.out

#for a real spindle run by a VFD
loadrt abs
addf abs.0 servo-thread
net spindle-cmd 	mux2.0.out abs.0.in
net spindle-cmd-abs     abs.0.out hm2_5i25.0.pwmgen.00.value
#net spindle-pwm         hm2_5i25.0.pwmgen.00.value ###### this section needs looking at and the one below ###

# connect the spindle enable to GPIO 018. #### this does not work #######
net spindle-pwmgen.00.enable => hm2_5i25.0.gpio.018.out

#the SPINX1 has an enable (active low)
setp  hm2_5i25.0.gpio.018.invert_output 1  
setp  hm2_5i25.0.gpio.018.is_output 1 
  

# Tune the PID from the INI values
setp pid.0.Pgain [SPINDLE]PGAIN_V
setp pid.0.Igain [SPINDLE]IGAIN_V
setp pid.0.Dgain [SPINDLE]DGAIN_V
setp pid.0.FF0	 [SPINDLE]FF0_V
setp pid.0.FF1   [SPINDLE]FF1_V
setp pid.1.Pgain [SPINDLE]PGAIN_P
setp pid.1.Igain [SPINDLE]IGAIN_P
setp pid.1.Dgain [SPINDLE]DGAIN_P
setp pid.1.FF0	 [SPINDLE]FF0_P
setp pid.1.FF1   [SPINDLE]FF1_P

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

More
29 Nov 2015 20:50 #66047 by andypugh
Replied by andypugh on topic Spinx1 to 7i85

the enable led is on as well, just not on the spin x.


<confused> Which Enable LED?

The SPIN1X enable is active-low. You will need to invert the output on that pin.

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

More
29 Nov 2015 20:53 #66048 by PCW
Replied by PCW on topic Spinx1 to 7i85
Also, unless you have a air bearing spindle, 216000 RPM is probably a bit fast

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

Moderators: PCWjmelson
Time to create page: 0.103 seconds
Powered by Kunena Forum