Orient component revised

More
01 Feb 2020 07:22 #156286 by nkp
Replied by nkp on topic Orient component
/* sudo halcompile --install shome.comp */
component shome "Provides a PID command input used for spindle homing";

pin out  bit   homing     ;
pin out  bit   homed     ;

pin in   bit   enable     ;
pin io   bit   index_enable ;

pin out float command         ;
pin in  float velocity = 100 ;

variable int   last_enable = 0;

option fp yes;

function _ "Spindle homing helper. Sets the encoder index-enable and waits for the falling of this signal.";
author "Diego Weizel";


description "";

license "GPL";
;;

FUNCTION(_) {
    
    if (enable) {
       if (enable ^ last_enable) {     // positive edge on enable
	    homed = 0;
	    homing = 1;                  
	    index_enable=1;
	    command=velocity;
       }              
       if (homing && !index_enable) {     // falling edge on enable
	    homed = 1;
	    homing = 0;      
    	    command=0;            
       }                     
    }
    else
    {
        homed = 0;
	homing = 0;                  
	command=0;            	
    }
    
    last_enable = enable;
}

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

More
01 Feb 2020 07:27 - 01 Feb 2020 07:45 #156287 by nkp
Replied by nkp on topic Orient component
loadrt orient
addf orient.0 servo-thread

loadrt mux2 count=2
addf   mux2.0 servo-thread 
addf   mux2.1 servo-thread 

loadrt shome
addf   shome.0    servo-thread

loadrt near count=2
addf near.0 servo-thread
addf near.1 servo-thread

loadrt not count=1
addf not.0 servo-thread

# reley 5
setp near.1.in1  0.0
net spindle-cmd  near.1.in2 
net reley-5 near.1.out not.0.in  

net reley not.0.out hm2_7i92.0.7i77.0.0.output-01 



#-spindle-at-speed
net spindle-vel-cmd => near.0.in1
net spindle-vel => near.0.in2
#  10%
setp near.0.scale 1.1

loadrt or2  count=2
addf or2.0 servo-thread #
addf or2.1 servo-thread

net or2-0-in0   or2.0.in0 <= near.0.out
net orient-mode or2.0.in1 
#net spindle-at-speed motion.spindle-at-speed  or2.0.out 
setp motion.spindle-at-speed 1

# encoder feedback
setp hm2_7i92.0.encoder.05.counter-mode 0
setp hm2_7i92.0.encoder.05.filter 1
setp hm2_7i92.0.encoder.05.index-invert 0
setp hm2_7i92.0.encoder.05.index-mask 0
setp hm2_7i92.0.encoder.05.index-mask-invert 0

setp  hm2_7i92.0.encoder.05.scale  4096



# spindle HOME
net spindle-index shome.0.index-enable  hm2_7i92.0.encoder.05.index-enable


# PWM Generator signals/setup
setp   hm2_7i92.0.7i77.0.1.analogout5-scalemax  1500
setp   hm2_7i92.0.7i77.0.1.analogout5-minlim    -1500
setp   hm2_7i92.0.7i77.0.1.analogout5-maxlim    1500

# spindle enable
setp    hm2_7i92.0.7i77.0.1.spinena  1
##################################################

#loadrt pid  (main.hal)
addf pid.vel.do-pid-calcs servo-thread # Velocity
addf pid.pos.do-pid-calcs servo-thread # Position



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

net shome-enable0  axis.2.homed   classicladder.0.in-00
net shome-enable1  shome.0.enable classicladder.0.out-00

net mux1in0 mux2.1.in0  pid.vel.output
net mux1in1 mux2.1.in1  shome.0.command
net mux1sel mux2.1.sel  shome.0.homing
setp shome.0.velocity   -3

net spindle-vel 	    pid.vel.feedback hm2_7i92.0.encoder.05.velocity 
net spindle-vel-cmd 	motion.spindle-speed-out pid.vel.command
net spindle-vel-pid 	mux2.1.out mux2.0.in0

net spindle-pos 	    pid.pos.feedback orient.0.position  hm2_7i92.0.encoder.05.position 
net spindle-pos-cmd 	orient.0.command pid.pos.command
net spindle-angle 	    motion.spindle-orient-angle orient.0.angle
net spindle-pos-pid 	pid.pos.output mux2.0.in1




# this switches modes
net orient-mode 	motion.spindle-orient orient.0.enable pid.pos.enable mux2.0.sel
net velocity-mode	motion.spindle-on pid.vel.enable 


setp scale.0.gain -1


##+++++++++++   
loadrt limit2 
addf   limit2.0 servo-thread
setp   limit2.0.maxv 1000
net    spindle-cmd  mux2.0.out => scale.0.in  
net    scaleout  scale.0.out   hm2_7i92.0.7i77.0.1.analogout5 
 
#net    spindle-ramped <= limit2.0.out  => hm2_7i92.0.7i77.0.1.analogout5



# Tune the PID from the INI values
setp pid.vel.Pgain [SPINDLE]PGAIN_V
setp pid.vel.Igain [SPINDLE]IGAIN_V
setp pid.vel.Dgain [SPINDLE]DGAIN_V
setp pid.vel.FF0	 [SPINDLE]FF0_V
setp pid.vel.FF1     [SPINDLE]FF1_V

setp pid.pos.Pgain [SPINDLE]PGAIN_P
setp pid.pos.Igain [SPINDLE]IGAIN_P
setp pid.pos.Dgain [SPINDLE]DGAIN_P
setp pid.pos.FF0	 [SPINDLE]FF0_P
setp pid.pos.FF1     [SPINDLE]FF1_P
Last edit: 01 Feb 2020 07:45 by nkp.

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

More
01 Feb 2020 07:32 #156288 by nkp
Replied by nkp on topic Orient component
this hal file is still being edited, inaccuracies may be present

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

More
01 Feb 2020 07:47 #156290 by nkp
Replied by nkp on topic Orient component
INI:
[SPINDLE]
PGAIN_V = 			0
IGAIN_V = 			0
DGAIN_V = 			0
FF0_V 	= 			1
FF1_V 	= 			0
PGAIN_P = 			150
IGAIN_P = 			1
DGAIN_P = 			0
FF0_P 	= 			0
FF1_P	=			1

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

More
03 Feb 2020 02:35 - 06 Feb 2020 11:24 #156412 by alkabal
Replied by alkabal on topic Orient component
Hi

Regarding to your component i have try to add something similar.

Attached is the revision with the spindle home after machine homing included.

HAL patrs need to add a or2 component for pid enable.
#####################################################################
# Spindle orient mode
#####################################################################
loadrt orientv4 names=orient.orient-spindle
loadrt pid      names=pid.orient-spindle
loadrt or2      names=or2.orient-spindle-pid-ena

addf orient.orient-spindle                  servo-thread
addf pid.orient-spindle.do-pid-calcs        servo-thread
addf or2.orient-spindle-pid-ena             servo-thread

# setup Orient Spindle PID
setp pid.orient-spindle.Pgain     [ORIENT]P
setp pid.orient-spindle.Igain     [ORIENT]I
setp pid.orient-spindle.Dgain     [ORIENT]D
setp pid.orient-spindle.FF0       [ORIENT]FF0
setp pid.orient-spindle.FF1       [ORIENT]FF1
setp pid.orient-spindle.FF2       [ORIENT]FF2
setp pid.orient-spindle.bias      [ORIENT]BIAS
setp pid.orient-spindle.deadband  [ORIENT]DEADBAND
setp pid.orient-spindle.maxerror  [ORIENT]MAX_ERROR
setp pid.orient-spindle.maxerrorI [ORIENT]MAX_ERROR_I
setp pid.orient-spindle.maxoutput [ORIENT]MAX_OUTPUT

setp orient.orient-spindle.vel-speed [ORIENT]VEL_SPEED
setp orient.orient-spindle.tolerance [ORIENT]AT_ANGLE_TOL

# Set asked mode from M19 P0/1/2
net spindle-orient-mode <= motion.spindle-orient-mode
net spindle-orient-mode => orient.orient-spindle.mode

# pid output mux with regular spindle modul
net DAC-ctrl-out-orient   <= pid.orient-spindle.output
net DAC-ctrl-out-orient   => orient.orient-spindle.cmd-orient
net DAC-ctrl-out-velocity => orient.orient-spindle.cmd-velocity
net DAC-computed-ctrl-out <= orient.orient-spindle.cmd-out
net DAC-computed-ctrl-out => hpg.pwmgen.00.out.00.value

# enable out for controler from regular spindle or orient mode
net spindle-enable          => orient.orient-spindle.ena-velocity
net spindle-orient-enable-out  <= orient.orient-spindle.ena-out
net spindle-orient-enable-out  => fur.do-6            # enable output for VFD muxed with regular spindle modul

# encoder connections index + feedback
net spindle-index-enable => pid.orient-spindle.index-enable             # need investigation
net spindle-pos      => orient.orient-spindle.position
net spindle-pos-deg  <= orient.orient-spindle.scaled-angle-out

# Spindle orient control signals
net spindle-orient-enable <= motion.spindle-orient
net spindle-orient-enable =>  orient.orient-spindle.enable

net spindle-orient-enable => or2.orient-spindle-pid-ena.in0     
net spindle-orient-home-enable <= orient.orient-spindle.homing
net spindle-orient-home-enable => or2.orient-spindle-pid-ena.in1
net spindle-orient-or2home-ena <= or2.orient-spindle-pid-ena.out
net spindle-orient-or2home-ena => pid.orient-spindle.enable

net spindle-index-enable <=> orient.orient-spindle.index-enable
net machinehomed <= axis.0.homed
net machinehomed => orient.orient-spindle.machine-is-homed

# Is oriented near signal + link position asked to component
net spindle-orient-degree-cmd <= motion.spindle-orient-angle
net spindle-orient-degree-cmd => orient.orient-spindle.angle
net spindle-is-oriented <= orient.orient-spindle.is-oriented
net spindle-is-oriented => motion.spindle-is-oriented


## Command to pid from component by velocity and velocity feedback
net spindle-orient-vel <= orient.orient-spindle.command
net spindle-orient-vel => pid.orient-spindle.command
net spindle-vel-fb-rps => pid.orient-spindle.feedback

In my opinion this is not the cleanest way for homing the spindle because motion or halui do no know what append.
I think is better to think about adding this feature in motion and or halui.

Edit : homing does not work correctly
Attachments:
Last edit: 06 Feb 2020 11:24 by alkabal.

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

More
11 Feb 2020 14:51 #157063 by andypugh
Replied by andypugh on topic Orient component

tommylight wrote: You can speak here, that is OK, but you might have to wait till Andy gets to read this as he is the original programmer of the orient component.


Actually, it was Michael Haberler: linuxcnc.org/docs/2.7/html/man/man9/orient.9.html

Part of the reason for adding the multi-spindle changes (actually the main reason) is that I wanted to add spindles to the homing sequence.
But I simply have not done that yet.

If anyone fancies it, I imagine sections in the INI
[SPINDLE_0]
HOME_SEQUENCE 4
HOME_VELOCITY 10
And then the system sets spindle index-enable, rotates at the given speed, then stops the spindle when the index resets.
The following user(s) said Thank You: tommylight

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

More
11 Feb 2020 16:06 #157074 by bbsr_5a
Replied by bbsr_5a on topic Orient component
hi can i use this component also for a Racktoolchanger with steppers
or is it fixed on 360 deg Rotation axis only

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

More
11 Feb 2020 16:09 #157075 by andypugh
Replied by andypugh on topic Orient component

bbsr_5a wrote: hi can i use this component also for a Racktoolchanger with steppers
or is it fixed on 360 deg Rotation axis only


I am not sure what question you are asking, but you want to orient a spindle for a rack toolchanger then "orient" would be appropriate.

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

More
11 Feb 2020 17:34 #157082 by alkabal
Replied by alkabal on topic Orient component
Hi

Without the use of ini file i have try to add spindle homing immediatly after axis.0.homed = 1

But i have many trouble understanding what append with the spindle index-enable status and the checking process.

You suggest to check elsewhere in the linuxcnc code regarding to the homing sequence ?

Can i ask what do you think about :
1 - including some new pin for more easy setup in the actual component
2 - changing the command logic like i try to do with orientv4

Br

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

More
26 Feb 2020 13:54 #158538 by andypugh
Replied by andypugh on topic Orient component
Sorry, I have been away from the forums for a while.

If you can be sure that the spindle will always turn past the index before the first tool change, then you could simply

sets spindle-index-enable 1

in the HAL file. (but spindle-index-enable should be replaced by whatever the signal that is attached to your spindle index really is called in your config)

A custom HAL component that the spindle speed commands pass through could work. It would also need a HAL pin to toggle and sense the index-enable.
ie, it sees asis.N.home go true, it over-rides the pass-through spindle commands to a low speed and sets the spindle-index-enable. It then returns to passive pass-through mode when the index-enable goes false.

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

Time to create page: 0.191 seconds
Powered by Kunena Forum