On Monday 16 March 2020 19:28:59 andrew beck wrote:

> ok gene just a update
>
> I have the mesa card connected to the vfd now.
>
> currently the analog signal is working fine I can it being read by the
> vfd which is good.
>
> I am having trouble with the control signals though.
>
> I currently have the 7i76 spindle enable pin switching the forward pin
> on the vfd
> the spindle direction pin on 7i76 switches reverse pin on vfd
>
> I am a bit stuck with what I need to do to connect up the hal
> signals.. any help there would be appreciated.  and let me know what
> info you need from me.
>
> regards
>
> Andrew
>
> On Mon, Mar 16, 2020 at 7:02 PM andrew beck <[email protected]>
>
> wrote:
> > I have a schiender vfd made in France so a proper manual lol.
> >
> > It's just the Mesa card I'm not sure about lol
> >
> > On Mon, Mar 16, 2020, 9:10 PM Gene Heskett <[email protected]> 
wrote:
> >> On Monday 16 March 2020 00:28:43 andrew beck wrote:
> >> > Hey guys..
> >> >
> >> > this has probably been rehashed a few times but did some google
> >> > searches and couldn't find it so am asking here
> >> >
> >> > I just want to connect my mesa 7i76 spindle outputs to my vfd.
> >> >
> >> > I will use 0-10 volts control speed reference and a forward pulse
> >> > and reverse pulse.
> >> >
> >> > I am not sure what actual pins I should be using though and am
> >> > slightly confused.
> >> >
> >> > any help would be appreciated
> >>
> >> There are pins designated for that on the 7i76D, what seems to
> >> confuse folks is that the spindle speed is an electronic resistor
> >> that acts exectly like the arm of the front panel speed pot on the
> >> vfd, but the vfd must be programmed to use it that way. Print the
> >> 7i76 manual and reread it, it is explained.
> >>
> >> Less clearly done is the explanation in the vfd manual as most are
> >> chinglish or engrish translations that are only half-assedly done.
> >> Sometimes they switch halves in mid sentence too, just to make it
> >> interesting :-[
> >>
> >> > regards
> >> >
Get the Sheldon package from my web site, my vfd is being fed from pwmgen 
0, follow that to where the pwm feeds a spinx1, bypass that, and feed 
the pwmgen to the spindle-speed on the 7i76. I'll also attach the hal 
file for my G0704, but it doesn't have a vfd as its useing a pico 
pwm-servo to run its pmdc motor. But between those 2 files, that should 
show you how the analog signal gets from point A to point B on a 7i76.

If not, yelp again.

Take care, avoid this virus if you can.
> >> > Andrew
> >> >
> >> > _______________________________________________
> >> > Emc-users mailing list
> >> > [email protected]
> >> > https://lists.sourceforge.net/lists/listinfo/emc-users
> >>
> >> Cheers, Gene Heskett
> >> --
> >> "There are four boxes to be used in defense of liberty:
> >>  soap, ballot, jury, and ammo. Please use in that order."
> >> -Ed Howdershelt (Author)
> >> If we desire respect for the law, we must first make the law
> >> respectable. - Louis D. Brandeis
> >> Genes Web page <http://geneslinuxbox.net:6309/gene>
> >>
> >>
> >> _______________________________________________
> >> Emc-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/emc-users
>
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>
# Generated by PNCconf at Tue Jun 30 22:44:28 2015
# If you make changes to this file, they will be
# overwritten when you run PNCconf again, so it never gets run again
# when the encoder arrives, I will need to setup 2 more mux4's to select
# the encoders.vel and .pos values, and scales to set the gains fed to
# the mux4's. So I'll need 4 more scale modules and 2 more mux4's.
# One could use gearchange for that also.
loadrt [KINS]KINEMATICS
#autoconverted  trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD 
num_joints=[KINS]JOINTS num_dio=12
loadrt hostmot2
loadrt hm2_pci          config="num_encoders=1 num_pwmgens=2 num_stepgens=4"
# this means that a BoB on P2 is all gpio starting at hm2_5i25.0.gpio.017.
loadrt boot                     names=boot.spindle
loadrt sample_hold      names=sample_dirchg,sample_spndlchg
loadrt conv_bit_u32     names=conv-DirF,conv-DirR
loadrt conv_u32_float   names=float-boot,conv-float.DirF,conv-float.DirR
loadrt conv_s32_float   
names=S32_float_cmd,S32_float_spndl,S32_float-cntr,S32_float-cal
loadrt pid                      names=pid_x,pid_y,pid_z,pid_s,pid_a
loadrt abs                      
names=abs_spindle,abs_vel,abs_tachplus,abs_encdir,abs_piddir,abs_delay
loadrt comp                     
names=comp_drvbooted,comp_cal0,comp_cal1,comp_encdir
loadrt limit2           count=3
loadrt limit3           names=rvsaccel
loadrt not                      names=not_load,not_spndl
loadrt or2                      names=or2.0,or2.1,or2.Z,or2.A,or2.B
# preparatory to making the charge-pump multi-use
loadrt xor2                     names=mist-osc-ctrl # mister osc control
loadrt and2             
names=and_vac,and_lube,and_pid_s_en,steeron,steeroff,and-prb
loadrt mux2             
names=mux2.fwd-rev,mux2_spndl,mux2cal0,mux2cal1,frz_mux2,frz_cnt
# mux4vel and mux4pos will be used to set the scales into motion once the new 
encoder is on the motor
loadrt mux4 names=mux4cmd,mux4pos,mux4tach,mux4_ovrtrvl,mux4_ovrtrvl2
loadrt scale 
names=scale_s_limit,scale_pidmaxerr,scale_tach,scale_motion,scaleX60,scale_pos,scale_cmd,scale_ovrtrvl,dyn_ovrtvl
loadrt near                     names=near_speed
loadrt debounce         cfg=4,1
loadrt lut5                     names=lut5-fwd,lut5-rvs,lut5-protect
loadrt sum2                     names=sum2_ovrtrvl,sum2_bias,spndl_tally
loadrt conv_float_s32   count=1
loadrt timedelay        names=pwr-delay-soft,pwr-delay-hard,mist-osc
loadrt oneshot          names=forOn,forOff,frz_1shot
loadrt flipflop         names=camonoff
# for spindle gear calibrations
#loadrt updown          names=spndl_cntr
loadrt invert           names=recip.0
loadrt select8          count=1
loadrt charge_pump      #but doesn't un w/o a base thread, so coolants etc 
don't work
# addf stuff, mostly order sensitive
addf    hm2_5i25.0.read_gpio servo-thread
addf    hm2_5i25.0.read servo-thread #trigger scope on this
addf    debounce.0              servo-thread # is z home switch
#addf   debounce.1              servo-thread # might be y home switch
addf    select8.0               servo-thread # to control probe sensing
addf    and-prb                 servo-thread # fix for broken select8
addf    conv-DirF               servo-thread # is bit-u32
addf    conv-DirR               servo-thread # is bit-u32
addf    conv-float.DirF servo-thread #
addf    conv-float.DirR servo-thread
addf    S32_float_spndl servo-thread # is conv-s32-float
addf    S32_float-cntr  servo-thread # ditto
addf    S32_float_cmd   servo-thread
addf    float-boot              servo-thread # is conv-s32-float

# all this ordered so it all falls thru
addf    and_pid_s_en    servo-thread
addf    comp_encdir             servo-thread

# end of encoder filter
addf motion-command-handler     servo-thread
addf motion-controller  servo-thread

# cmds to pid_s
addf    scale_cmd               servo-thread
addf    mux4cmd                 servo-thread
addf    scale_s_limit   servo-thread

# data from encoder
#addf   scale_vel               servo-thread
addf    scale_pos               servo-thread
#addf   mux4vel                 servo-thread
addf    mux4pos                 servo-thread

addf sum2_bias                  servo-thread
addf not_load                   servo-thread

addf limit2.2                   servo-thread
addf comp_drvbooted             servo-thread
addf boot.spindle               servo-thread
addf abs_piddir                 servo-thread
addf rvsaccel                   servo-thread

#***********************************
addf lut5-fwd                   servo-thread
addf lut5-rvs                   servo-thread
addf lut5-protect               servo-thread
addf scale_pidmaxerr    servo-thread
addf mux2_spndl                 servo-thread
addf mux4tach                   servo-thread
addf mux2.fwd-rev               servo-thread
addf scale_tach                 servo-thread
addf scaleX60                   servo-thread
addf pid_x.do-pid-calcs servo-thread
addf pid_y.do-pid-calcs servo-thread
addf pid_z.do-pid-calcs servo-thread
addf pid_a.do-pid-calcs servo-thread
addf pid_s.do-pid-calcs servo-thread
addf abs_spindle                servo-thread
addf abs_vel                    servo-thread
addf abs_tachplus               servo-thread
addf not_spndl                  servo-thread
addf limit2.1                   servo-thread
addf or2.0                              servo-thread
addf or2.1                              servo-thread
addf or2.Z                              servo-thread
addf or2.A                              servo-thread
addf or2.B                              servo-thread
addf near_speed                 servo-thread
addf charge-pump        servo-thread
addf and_vac                    servo-thread
addf and_lube                   servo-thread
addf mist-osc-ctrl              servo-thread
addf mist-osc                   servo-thread
addf pwr-delay-soft             servo-thread
addf pwr-delay-hard             servo-thread
addf forOn                              servo-thread
addf forOff                             servo-thread
addf steeron                    servo-thread
addf steeroff                   servo-thread
addf camonoff                   servo-thread

# for G33.1 overtravel display
addf    sample_dirchg   servo-thread
addf    sample_spndlchg servo-thread
addf    sum2_ovrtrvl    servo-thread
#addf   spndl_cntr              servo-thread
addf    spndl_tally             servo-thread
addf    comp_cal0               servo-thread
addf    comp_cal1               servo-thread
addf    S32_float-cal   servo-thread
addf    mux2cal0                servo-thread
addf    mux2cal1                servo-thread
addf    frz_cnt                 servo-thread
addf    scale_ovrtrvl   servo-thread
addf    mux4_ovrtrvl    servo-thread
addf    frz_1shot               servo-thread
addf    frz_mux2                servo-thread
# need reciprocal of encoder scale
addf    recip.0                 servo-thread
# switch gears for overtravel
addf    mux4_ovrtrvl2   servo-thread
# this is a scale module
addf    dyn_ovrtvl      servo-thread
# and finally, update machine
addf hm2_5i25.0.write_gpio      servo-thread
addf hm2_5i25.0.write   servo-thread

# external input signals
setp    hm2_5i25.0.watchdog.timeout_ns 6000000
setp    hm2_[HOSTMOT2](BOARD).0.dpll.01.timer-us -50
#**********************************************************************
#  HOME switches                                                      *
setp    debounce.0.delay  1 # sets them all
# switches are now independent, not common, and normally closed to 12 volts 
field power
# feed 12 volt field power on red wire, ground shields
# white wire of BW pair is Z home switch
# black wire of BW pair is Y home switch
# black wire of BR pair is X home switch
net z-home-switch <= hm2_5i25.0.7i76.0.0.input-02-not => debounce.0.0.in # 
bottom of TB6-3
net y-home-switch <= hm2_5i25.0.7i76.0.0.input-01-not => debounce.0.1.in # 
bottom of TB6-2
net x-home-switch <= hm2_5i25.0.7i76.0.0.input-00-not => debounce.0.2.in # 
bottom of TB6-1
net debncd-home-z <= debounce.0.0.out => joint.2.home-sw-in
net debncd-home-y <= debounce.0.1.out => joint.1.home-sw-in
net debncd-home-x <= debounce.0.2.out => joint.0.home-sw-in
# as more home switches are added as in one on A, reserve TB6-4 for it

#******************************************************
# hook up probe signal but disable if motion type not 5
#******************************************************
net probe-ctl   <=      motion.motion-type      => select8.0.sel # disable out5 
if not probe move
net probe-sense <=      hm2_5i25.0.gpio.032.in_not => and-prb.in0 # s/b correct 
action
net probe-hit1  <=      select8.0.out5 =>  and-prb.in1
net probe-hit2  <=      and-prb.out => motion.probe-input # signal source is 
NOT p3-15 anymore

#****************************
# set up speed control inputs
#*****************************************************************************
# hook up back gear switches. There is a notch in the rim of the knob to     *
# accept the roller of one of 2 switches, so that the nc contact of only one *
# when it is fully engaged in that gear. But must find pins that are inputs  *
# on the b.o.b.  According to dmesg, gpio.020, pin p2-12 and gpio.033, p2-13 *
# are available. Assume switch is closure to INPUT ground. gpio's are inputs *
# ON THE 5I25 unless set otherwise.                                             
                                         *
#*****************************************************************************
net gear-sw-high        <=      hm2_5i25.0.gpio.033.in_not      =>      
mux4cmd.sel0
net     gear-sw-high    =>      mux4_ovrtrvl2.sel0
net gear-sw-high        =>      mux4tach.sel0 mux4pos.sel0 mux4_ovrtrvl.sel0
net gear-sw-low         <=      hm2_5i25.0.gpio.020.in_not      =>      
mux4cmd.sel1
net gear-sw-low         =>      mux4tach.sel1 mux4pos.sel1 mux4_ovrtrvl.sel1
net     gear-sw-low             =>      mux4_ovrtrvl2.sel1


#***************************************************************************
# out 4 mist air ctrl don't forget free-wheel diode on this air solenoid!!!
#***************************************************************************
setp hm2_5i25.0.gpio.024.is_output true
net mist-on <= iocontrol.0.coolant-mist
net mist-on  => hm2_5i25.0.7i76.0.0.output-07 #last one on right end
net mist-on => mist-osc-ctrl.in0 # turn on pump motor speed ctrl
net osc-fdbck <= mist-osc-ctrl.out => mist-osc.in # make oscillator
net to-mist-pump  <= mist-osc.out


#********************************************
# align, calibrate stuff, still being tuned *
#********************************************

setp    forOn.width .1
setp    forOn.falling 0
setp    forOn.rising 1
setp    forOff.width .1
setp    forOff.falling 1
setp    forOff.rising 0

#**********************************
# ENCODER feedback signals setup  *
#**********************************
setp hm2_5i25.0.encoder.00.counter-mode         false
setp hm2_5i25.0.encoder.00.index-enable         true
setp hm2_5i25.0.encoder.00.index-invert         false
setp hm2_5i25.0.encoder.00.index-mask           false
setp hm2_5i25.0.encoder.00.scale                        [SPINDLE]ENCODER_SCALE_H
setp recip.0.in                                                         
[SPINDLE]ENCODER_SCALE_H
setp hm2_5i25.0.encoder.sample-frequency        [SPINDLE]ENCODER_SAMPLE

#*********************************************
# calibrate spindle to new encoder           *
# use halshow to reset updown for new count  *
# this code is not part of normal operation  *
# used only to determine working gear ratios *
#*********************************************
# sample rate now turned up so filter can be used
setp hm2_5i25.0.encoder.00.filter true
#net    scalibrate0     mux2cal0.out    mux2cal0.in1 spndl_tally.in0 # make it 
a sample-hold
#net scalibrate1        mux2cal1.out    mux2cal1.in1 spndl_tally.in1 # ditto
#net ztrack     <= hm2_5i25.0.gpio.016.in       spndl_cntr.countup
#net ztrakS32 spndl_cntr.count S32_float-cntr.in
#net ztrackF  S32_float-cntr.out comp_cal0.in1 comp_cal1.in1
# spndl_tally is a sum2
#setp spndl_tally.gain0 -1.00000000000
#setp spndl_tally.gain1  1.00000000000
#** set to log 100 indexes
#setp comp_cal0.in0     5.5
#setp comp_cal1.in0     105.5
#net Scounter-in hm2_5i25.0.encoder.00.rawcounts        S32_float-cal.in
#net Fcounter-in S32_float-cal.out mux2cal0.in0 mux2cal1.in0
#net shhold0    comp_cal0.out mux2cal0.sel
#net shhold1    comp_cal1.out mux2cal1.sel

# when mux2-cal1.out is frozen, do [spndl-tally.out / 100] to get scale.
# repeat for other gear for 2nd scale factor. When done, comment it all out

#***********************
# setup gear shifting  *
#***********************
# Now, set up sources for signals needed for spindle control
# and it was found yesterday Dec 28th 2017, that scaleing the feedback
# vel was wrong so thats been removed
setp    scale_cmd.gain          [SPINDLE]SCALE_UP
setp    scale_pos.gain          [SPINDLE]SCALE_DOWN
setp    scale_tach.gain         [SPINDLE]SCALE_DOWN
setp    scaleX60.gain           60.000000000

# Establish, enforce max drive but scale it
setp    scale_s_limit.in        [SPINDLE]PWMGEN_S_SCALE
setp    scale_s_limit.gain      [SPINDLE]SCALE_S_MAX_PWM
net             maxdrive                        scale_s_limit.out       
pid_s.maxoutput

#*************************************************
# now, reboot the servo amp at every spindle start
net spindle-enable  <= spindle.0.on
#**************************************************************
# send original signal to spinENA                             *
net spindle-enable   => hm2_5i25.0.7i76.0.0.spinena          #*
net spindle-enable       => boot.spindle.enable and_pid_s_en.in0 #*
#**************************************************************
net spindle-enable => hm2_5i25.0.pwmgen.00.enable hm2_5i25.0.pwmgen.01.enable
# back to old code
setp comp_drvbooted.in1     4.500000
net spindle-boot0     <= boot.spindle.state     =>      float-boot.in
net spindle-boot1     <= float-boot.out         =>      comp_drvbooted.in0
net spindle-booted    <= comp_drvbooted.out     =>      not_spndl.in 
net spindle-boot-inv  <= not_spndl.out          =>      and_pid_s_en.in1

# send selected speed to spindle and motion, but if running when switched,
# slow way down only for easy gear meshing
setp    mux4cmd.in0             .15
setp    mux4cmd.in3             .15
# for testing at higher command speeds w/o gear switches wired up!!!!!!!!!!

# This speed up the motor in low is good
net requested_speed <= spindle.0.speed-out-rps  => mux4cmd.in1 scale_cmd.in
net adjusted_speed  <= scale_cmd.out => mux4cmd.in2
net final_speed     <= mux4cmd.out      =>      rvsaccel.in
net cntrld-reverse  <= rvsaccel.out     =>      pid_s.command
net cntrld-reverse-out <= pid_s.output =>       boot.spindle.pid0
net spindir-ctl     <= abs_piddir.sign  hm2_5i25.0.7i76.0.0.spindir
# setup some signals for the gui these signals from motion I believe
net spindle-cw    <= spindle.0.forward
net spindle-ccw   <= spindle.0.reverse
net spindle-brake <= spindle.0.brake

#******************************
#  SPINDLE PID_s setup, pid_s *
#******************************
# First, tie all pid.enables to spindle.0.on
net spndl-en    and_pid_s_en.out pid_s.enable
setp pid_s.Pgain     [SPINDLE]P
setp pid_s.Igain     [SPINDLE]I
setp pid_s.Dgain     [SPINDLE]D
setp pid_s.FF0       [SPINDLE]FF0
setp pid_s.FF1       [SPINDLE]FF1
setp pid_s.FF2       [SPINDLE]FF2
setp pid_s.deadband  [SPINDLE]DEADBAND
setp pid_s.error-previous-target true

# slow down a spindle reversal by turning the fwd-rev-fwd from motion into
# a sine-squared waveform both the servo and z can keep up with
setp rvsaccel.maxa      [SPINDLE]SP_MAXA 
setp rvsaccel.maxv      [SPINDLE]SP_MAXV

# ---PWM Generator signals/setup---
# default output type is 1, don't muck with it
setp hm2_5i25.0.pwmgen.00.scale [SPINDLE]PWMGEN_S_SCALE
setp hm2_5i25.0.pwmgen.01.scale [SPINDLE]PWMGEN_S_SCALE
setp hm2_5i25.0.pwmgen.pwm_frequency [SPINDLE]PWMGEN_S_FREQ

# Peter explained how this works
setp hm2_5i25.0.7i76.0.0.spinout-minlim 0.00000000
setp hm2_5i25.0.7i76.0.0.spinout-maxlim [SPINDLE]PWMGEN_S_SCALE
setp hm2_5i25.0.7i76.0.0.spinout-scalemax [SPINDLE]PWMGEN_S_SCALE
# might as well put all this sort of shit in one place
setp hm2_5i25.0.7i76.0.0.output-15-invert false
setp hm2_5i25.0.7i76.0.0.output-14-invert false
# who know how many more I'll have to add.

# now feed both pwmgens
net spindle-output1     <= boot.spindle.pout0 => hm2_5i25.0.pwmgen.00.value 
abs_piddir.in
net spindle-output1 => hm2_5i25.0.pwmgen.01.value hm2_5i25.0.7i76.0.0.spinout
net spindle-index-enable <=> spindle.0.index-enable <=> 
hm2_5i25.0.encoder.00.index-enable
# ---Setup spindle at speed signals---
net spindle-index       <=>     hm2_5i25.0.encoder.00.input-index 
pid_s.index-enable
# SPINDLE REVERSE and friction control helpers-do I still need them???
#************************
setp sum2_bias.in0       [SPINDLE]FBIAS
setp sum2_bias.in1       [SPINDLE]RBIAS
net  is-plus0   <=      abs_piddir.is-positive  =>      conv-DirF.in # TRUE 
converted to 1
net  is-plus1   <=      conv-DirF.out                   =>      
conv-float.DirF.in  # still a 1 when m3
net  is-neg0    <=      abs_piddir.is-negative  =>      conv-DirR.in # this 
works in m4 too
net  is-neg1    <=      conv-DirR.out                   =>      
conv-float.DirR.in # ditto for m4
net  bias-dirF  <=      conv-float.DirF.out             =>      sum2_bias.in0
net  bias.DirR  <=      conv-float.DirR.out             =>      sum2_bias.in1
net  pid-s.bias <=      sum2_bias.out                   =>      pid_s.bias

# now hook up encoder velocity to motion etc BUT THIS DOES NOT NEED SCALED!!!!!
net vel_source <=       hm2_5i25.0.encoder.00.velocity pid_s.feedback
net vel_source  =>      spindle.0.speed-in

# hook up position, after scaleing for gear change, to motion for rigid tapping
# this was a direct connection with old single gear encoder
net     pos_source              <=      hm2_5i25.0.encoder.00.position => 
scale_pos.in mux4pos.in1
net     scaled_pos_s    <=      scale_pos.out   => mux4pos.in2
net     position_scaled <=      mux4pos.out             =>      spindle.0.revs

# fix tach calibration
net vel_source          =>      scale_tach.in   =>      mux4tach.in1
net corrected_tach  <=  scale_tach.out  =>      mux4tach.in2
net crct_tach-bidir <=  mux4tach.out    =>      abs_spindle.in
net corrected_tach_abs  <=      abs_spindle.out =>      scaleX60.in # to 
post_gui stuffs

# hook up near for spindle synchronized moves
setp near_speed.difference      [SPINDLE]NEAR_TOL
setp near_speed.scale           [SPINDLE]NEAR_SCALE
net crct_tach-bidir             =>      near_speed.in1
net requested_speed             =>      near_speed.in2
net spindle-at-speed    <=      near_speed.out => spindle.0.at-speed

#***************************************************************************************
# utility for measureing spindle travel overshoot at bottom of a g33.1
# uses vel_source as feed for comp to determine when spindle has reversed
# uses spindle-ccw to freeze first S&H spndl_dirchg
# and vel_source to comp to detect0 spindle actually getting reversed, 
freezeing 2nd S&H  
setp sum2_ovrtrvl.gain0      -1.000000 # make sub2 out of sum2
# feed accumulated counts to both sample-holds
net ovrtrvl1    <= hm2_5i25.0.encoder.00.count => sample_dirchg.in 
sample_spndlchg.in # checks
net spindle-ccw => sample_dirchg.hold # checks

setp    comp_encdir.in1 0.0000000
net     vel_source              => comp_encdir.in0
net stop-cntr           <= comp_encdir.out      => sample_spndlchg.hold
# that takes care of measuring reversal distance, HOWEVER, it also measures the 
other end
# of the travel, so the halmeter jumps to a higher value at the end of the 
retract move as it
# reverses to fwd again. SO KEEP THAT IN MIND!
#*******************************************
# first, develop overshoot in encoder counts
#*******************************************
net ovrtrvl2 <= sample_dirchg.out       =>      S32_float_cmd.in # checks
net ovrtrvl3 <= S32_float_cmd.out       =>      sum2_ovrtrvl.in0 # checks
net ovrtrvl4 <= sample_spndlchg.out     =>      S32_float_spndl.in # checks
net ovrtrvl5 <= S32_float_spndl.out     =>      sum2_ovrtrvl.in1 # checks
net ovrtrvl6 <= sum2_ovrtrvl.out        =>      mux4_ovrtrvl.in1 
scale_ovrtrvl.in
# wrong??
setp scale_ovrtrvl.gain [SPINDLE]SCALE_DOWN

net ovrtrvl7    <=      scale_ovrtrvl.out       =>      mux4_ovrtrvl.in2
net overtravel  <= mux4_ovrtrvl.out
#**************************************************
# but we need to freeze it at max counts per stroke
# and hold it till next update
#**************************************************
setp frz_1shot.width 0.005
net stop-cntr   =>      frz_1shot.in
net frz_count   <=      frz_1shot.out-not       => frz_mux2.sel
net overtravel  =>  frz_mux2.in0
net save_ovrtvl <=      frz_mux2.out    =>      frz_mux2.in1
#*******************************************************
# save_ovrtvl should  now have a frozen overtravel count
# until next  backout move updates it
#*******************************************************
net save_ovrtvl => dyn_ovrtvl.in

#****************************************************************************
# THIS IS TPMM FROM GCODE, exported by M68E0Q#<_tpmm> and is z travel per rev
#****************************************************************************
net ovrtrvl8    <= motion.analog-out-00 => dyn_ovrtvl.gain
# watch with halmeter or maybe scale to turns for display OR EVEN DISTANCE
# now check at dyn_ovrtvl.out for effect, works but is fleeting, latch it 
somehow
# but lets see about getting the multipliers we need to change gears
# SET UNITY IN HIGH GEAR
setp mux4_ovrtrvl2.in2 1.000000000
# SCALE IT DOWN IN LOW GEAR
setp mux4_ovrtrvl2.in1 [SPINDLE]SCALE_DOWN
net recip_enc_scale     <=      mux4_ovrtrvl2.out =>    recip.0.in
#net recip_scale_out <= recip.0.out => ovrtvl8.in
# only output, src wayyy up file
#net    stop_cnt        =>      ovrtvl9.in
#********************************************************************************
# END OF SPINDLE STUFF

#********************
#  AXIS X = joint_0 *
#********************
# setup pid_x
setp   pid_x.Pgain     [JOINT_0]P
setp   pid_x.Igain     [JOINT_0]I
setp   pid_x.Dgain     [JOINT_0]D
setp   pid_x.bias      [JOINT_0]BIAS
setp   pid_x.FF0       [JOINT_0]FF0
setp   pid_x.FF1       [JOINT_0]FF1
setp   pid_x.FF2       [JOINT_0]FF2
setp   pid_x.deadband  [JOINT_0]DEADBAND
setp   pid_x.maxoutput [JOINT_0]MAX_OUTPUT
setp   pid_x.error-previous-target true
setp   pid_x.maxerror  [JOINT_0]MIN_FERROR

#*****************************
# Step Gen signals/setup for X
#*****************************
setp   hm2_5i25.0.stepgen.00.dirsetup        [JOINT_0]DIRSETUP
setp   hm2_5i25.0.stepgen.00.dirhold         [JOINT_0]DIRHOLD
setp   hm2_5i25.0.stepgen.00.steplen         [JOINT_0]STEPLEN
setp   hm2_5i25.0.stepgen.00.stepspace       [JOINT_0]STEPSPACE
setp   hm2_5i25.0.stepgen.00.position-scale  [JOINT_0]STEP_SCALE
setp   hm2_5i25.0.stepgen.00.step_type        0
setp   hm2_5i25.0.stepgen.00.control-type     1
setp   hm2_5i25.0.stepgen.00.maxaccel         [JOINT_0]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.00.maxvel           [JOINT_0]STEPGEN_MAXVEL

#****************************************
# ---closedloop stepper signals for X---*
# 1st 2 from motion
#****************************************
net x-pos-cmd           <=      joint.0.motor-pos-cmd   =>      pid_x.command
net x-vel-cmd           <=      joint.0.vel-cmd       #  =>  pid_x.command-deriv
net x-pos-fb            <=      hm2_5i25.0.stepgen.00.position-fb       =>      
pid_x.feedback  joint.0.motor-pos-fb
net x-output            pid_x.output => hm2_5i25.0.stepgen.00.velocity-cmd
net x-index-enable      <=>     pid_x.index-enable
net x-enable            <=      joint.0.amp-enable-out  =>      
hm2_5i25.0.stepgen.00.enable    pid_x.enable
# do not hook this back up!!!!!
net x-vel-cmd           =>  pid_x.command-deriv
#********************
#  AXIS Y = joint_1 *
#********************
setp   pid_y.Pgain     [JOINT_1]P
setp   pid_y.Igain     [JOINT_1]I
setp   pid_y.Dgain     [JOINT_1]D
setp   pid_y.bias      [JOINT_1]BIAS
setp   pid_y.FF0       [JOINT_1]FF0
setp   pid_y.FF1       [JOINT_1]FF1
setp   pid_y.FF2       [JOINT_1]FF2
setp   pid_y.deadband  [JOINT_1]DEADBAND
setp   pid_y.maxoutput [JOINT_1]MAX_OUTPUT
setp   pid_y.error-previous-target true
setp   pid_y.maxerror .0005


#**********************************
# Step Gen signals/setup for Y axis
#**********************************
setp   hm2_5i25.0.stepgen.01.dirsetup        [JOINT_1]DIRSETUP
setp   hm2_5i25.0.stepgen.01.dirhold         [JOINT_1]DIRHOLD
setp   hm2_5i25.0.stepgen.01.steplen         [JOINT_1]STEPLEN
setp   hm2_5i25.0.stepgen.01.stepspace       [JOINT_1]STEPSPACE
setp   hm2_5i25.0.stepgen.01.position-scale  [JOINT_1]STEP_SCALE
setp   hm2_5i25.0.stepgen.01.step_type        0
setp   hm2_5i25.0.stepgen.01.control-type     1
setp   hm2_5i25.0.stepgen.01.maxaccel         [JOINT_1]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.01.maxvel           [JOINT_1]STEPGEN_MAXVEL

#*********************************
# ---closedloop stepper signals---
#*********************************
# 1st 2 from motion
net y-pos-cmd    <= joint.1.motor-pos-cmd
net y-vel-cmd    <= joint.1.vel-cmd  #  =>  pid_y.command-deriv
net y-output     <= pid_y.output => hm2_5i25.0.stepgen.01.velocity-cmd
net y-pos-fb     <= hm2_5i25.0.stepgen.01.position-fb
net y-pos-fb     => joint.1.motor-pos-fb
net y-enable     <= joint.1.amp-enable-out
net y-enable     => hm2_5i25.0.stepgen.01.enable
net y-index-enable  <=> pid_y.index-enable
net y-enable        =>  pid_y.enable
net y-pos-cmd       =>  pid_y.command
net y-pos-fb        =>  pid_y.feedback
net y-output        =>  pid_y.output

#********************
#  AXIS Z = joint 2 *
#********************

setp   pid_z.Pgain     [JOINT_2]P
setp   pid_z.Igain     [JOINT_2]I
setp   pid_z.Dgain     [JOINT_2]D
setp   pid_z.bias      [JOINT_2]BIAS
setp   pid_z.FF0       [JOINT_2]FF0
setp   pid_z.FF1       [JOINT_2]FF1
setp   pid_z.FF2       [JOINT_2]FF2
setp   pid_z.deadband  [JOINT_2]DEADBAND
setp   pid_z.maxoutput [JOINT_2]MAX_OUTPUT
setp   pid_z.error-previous-target true
setp   pid_z.maxerror   [JOINT_2]MIN_FERROR

#*****************************
# Step Gen signals/setup for Z
#*****************************
setp   hm2_5i25.0.stepgen.02.dirsetup        [JOINT_2]DIRSETUP
setp   hm2_5i25.0.stepgen.02.dirhold         [JOINT_2]DIRHOLD
setp   hm2_5i25.0.stepgen.02.steplen         [JOINT_2]STEPLEN
setp   hm2_5i25.0.stepgen.02.stepspace       [JOINT_2]STEPSPACE
setp   hm2_5i25.0.stepgen.02.position-scale  [JOINT_2]STEP_SCALE
setp   hm2_5i25.0.stepgen.02.step_type        0
setp   hm2_5i25.0.stepgen.02.control-type     1
setp   hm2_5i25.0.stepgen.02.maxaccel         [JOINT_2]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.02.maxvel           [JOINT_2]STEPGEN_MAXVEL

#*************************************
# ---closed loop stepper signals for Z
#*************************************
# 2 sigs from motion
net z-pos-cmd    <= joint.2.motor-pos-cmd       =>  pid_z.command
net z-vel-cmd    <= joint.2.vel-cmd             =>  pid_z.command-deriv
net z-output     <=  pid_z.output
net z-output     => hm2_5i25.0.stepgen.02.velocity-cmd
net z-pos-fb     <= hm2_5i25.0.stepgen.02.position-fb
# back to motion etc
net z-pos-fb     => joint.2.motor-pos-fb
net z-pos-fb     =>  pid_z.feedback
net z-enable     <= joint.2.amp-enable-out
net z-enable     => hm2_5i25.0.stepgen.02.enable
net z-index-enable  <=> pid_z.index-enable
net z-enable        =>  pid_z.enable

# do not hook this back up!!!!!!net z-vel-cmd =>  pid_z.command-deriv

#********************************************************
#  AXIS A, joint_3 was spwr control use but now  moved  *
#  spwr control to other p2 connector, same pins        *
#********************************************************

setp   pid_a.Pgain     [JOINT_3]P
setp   pid_a.Igain     [JOINT_3]I
setp   pid_a.Dgain     [JOINT_3]D
setp   pid_a.bias      [JOINT_3]BIAS
setp   pid_a.FF0       [JOINT_3]FF0
setp   pid_a.FF1       [JOINT_3]FF1
setp   pid_a.FF2       [JOINT_3]FF2
setp   pid_a.deadband  [JOINT_3]DEADBAND
setp   pid_a.maxoutput [JOINT_3]MAX_OUTPUT
setp   pid_a.error-previous-target true
setp   pid_a.maxerror .0005

net a-index-enable  <=> pid_a.index-enable
net a-enable        =>  pid_a.enable
net a-output        =>  pid_a.output

# Step Gen signals/setup

setp   hm2_5i25.0.stepgen.03.dirsetup        [JOINT_3]DIRSETUP
setp   hm2_5i25.0.stepgen.03.dirhold         [JOINT_3]DIRHOLD
setp   hm2_5i25.0.stepgen.03.steplen         [JOINT_3]STEPLEN
setp   hm2_5i25.0.stepgen.03.stepspace       [JOINT_3]STEPSPACE
setp   hm2_5i25.0.stepgen.03.position-scale  [JOINT_3]STEP_SCALE
setp   hm2_5i25.0.stepgen.03.step_type        0
setp   hm2_5i25.0.stepgen.03.control-type     1
setp   hm2_5i25.0.stepgen.03.maxaccel         [JOINT_3]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.03.maxvel           [JOINT_3]STEPGEN_MAXVEL

# ---closedloop stepper signals---
net a-pos-cmd    <= joint.3.motor-pos-cmd
net a-vel-cmd    <= joint.3.vel-cmd
net a-output     <= hm2_5i25.0.stepgen.03.velocity-cmd
net a-pos-fb     <= hm2_5i25.0.stepgen.03.position-fb
net a-pos-fb     => joint.3.motor-pos-fb pid_a.feedback
net a-enable     <= joint.3.amp-enable-out
net a-enable     => hm2_5i25.0.stepgen.03.enable
net a-pos-cmd    => pid_a.command
net a-vel-cmd    => pid_a.command-deriv

#********************************
# connect miscellaneous signals *
#********************************
#  ---HALUI signals---
net joint-select-a              <=      halui.axis.x.select
net x-is-homed                  <=      halui.joint.0.is-homed
net jog-x-pos                   <=      halui.axis.x.plus
net jog-x-neg                   <=      halui.axis.x.minus
net jog-x-analog                <=      halui.axis.x.analog
net joint-select-b              <=      halui.axis.y.select
net y-is-homed                  <=      halui.joint.1.is-homed
net jog-y-pos                   <=      halui.axis.y.plus
net jog-y-neg                   <=      halui.axis.y.minus
net jog-y-analog                <=      halui.axis.y.analog
net joint-select-c              <=      halui.axis.z.select
net z-is-homed                  <=      halui.joint.2.is-homed
net jog-z-pos                   <=      halui.axis.z.plus
net jog-z-neg                   <=      halui.axis.z.minus
net jog-z-analog                <=      halui.axis.z.analog
# Axis A stuff
net joint-select-d              <=      halui.axis.a.select
net a-is-homed                  <=      halui.joint.3.is-homed
net jog-a-pos                   <=      halui.axis.a.plus
net jog-a-neg                   <=      halui.axis.a.minus
net jog-a-analog                <=      halui.axis.a.analog
net jog-selected-pos    <=      halui.axis.selected.plus
net jog-selected-neg    <=      halui.axis.selected.minus
# Spindle.0. stuff
net spindle-manual-cw   <=      halui.spindle.0.forward
net spindle-manual-ccw  <=      halui.spindle.0.reverse
net spindle-manual-stop <=      halui.spindle.0.stop
net machine-is-on               <=      halui.machine.is-on
net jog-speed                   <=      halui.axis.jog-speed 
net MDI-mode                    <=      halui.mode.is-mdi

#************dual use of mist/flood**********************************
# this should be true=low at P2-17 when mist is on,                 *
# or when an M7 has been encountered in the g-code.                 *
# M9 turns it all off                                               *
# need to assign another output pin to flood, to be used to control *
# a vacuum cleaner to suck up the sawdust.                          *
#********************************************************************

# and here, we open a 10 lb can of worms, because charge-pump is a single 
# instance module.  So to be able to use it for other controls, we will
# have to enable it permanently, and drive any number of and2's so we get
# an output to send to a pin of the BoB, or not, by setting the other
# input to the and2, effectively using that for the enable  signal on a 
# per output basis.  or2's could also be used, seting the 2nd input true
# to disable the output toggling.  And2's make more sense to me however.

# but with the added 7i76, I don't need the charge pump for these two functions
# as the 7i76d is sink only so rewire to feed 12 volts to + term of both SSR's
# and sink the - terminals to enable in sequence
#***************************************************0*************************

# setup charge-pump full time
setp charge-pump.enable true  # just leave it running.
net             pwr-pump                <=      charge-pump.out => and_vac.in0
net             coolant-flood   <=      iocontrol.0.coolant-flood => and_vac.in1
net             vac-control1    <=      and_vac.out => hm2_5i25.0.gpio.022.out
# an M8 turns it on, M9 shuts both off
# and it seems to work as written but I just inverted the mist output
# hopefully the bar will stay out when lcnc shuts down. It did.

#*************************************************
# Now setup the spindles psu on/off sequencing   *
#*************************************************
# first, set the time delays, on in order of execution
setp pwr-delay-soft.on-delay    0.1 # initial on, but thru the resistor
setp pwr-delay-hard.on-delay    3.0 # seconds, to full on, bypassing the 
resistor

# now its on, shut it off in order of execution 
setp pwr-delay-hard.off-delay   0.1 # go back to resistor limited power
setp pwr-delay-soft.off-delay   0.2 # to full off
# turn on spindle power softly by starting both timers
net  spndl-power                <=      motion.motion-enabled   =>      
pwr-delay-hard.in       pwr-delay-soft.in
# both time-delays now started
net  spndl-pwr-soft   <= pwr-delay-soft.out => hm2_5i25.0.7i76.0.0.output-15
# to 7i76 output pin TB-5-24, pulling it down/on, enabling soft start
# which turns on toroids thru a 51 ohm 200 watt resistor to start charging 
supply caps

# 3 secs later, bypass the resistor by linking hard delay out to
net             spndl-pwr-hard  <=      pwr-delay-hard.out =>  
hm2_5i25.0.7i76.0.0.output-14
# at 7i76-TB5-23
# sets up to feed full power
# all done and understandable spindle psu controls.

#********************pncconf set stuffs*****************
# connect max velocity overide increments - switches
setp halui.max-velocity.count-enable true
setp halui.max-velocity.direct-value true
setp halui.max-velocity.scale 20.000000
# no src signal! is this my problem?
net max-vel-override-incr   =>  halui.max-velocity.counts

# connect spindle overide increments 
setp halui.spindle.0.override.count-enable true
setp halui.spindle.0.override.direct-value true
setp halui.spindle.0.override.scale .01
net spindleoverride-incr  =>  halui.spindle.0.override.counts

#  ---motion control signals---
net in-position         <=  motion.in-position

#  ---digital in / out signals---

#  ---estop signals---
# P2-pin 10 is usually the estop input, but haven't sussed how to
# net that yet.

net estop-out           <=      iocontrol.0.user-enable-out
# see if we can we use gpio.029 supposedly p2-09 to switch main power
setp hm2_5i25.0.gpio.029.is_output true
setp hm2_5i25.0.gpio.029.is_opendrain false
setp hm2_5i25.0.gpio.029.invert_output true 
net estop-out   =>      iocontrol.0.emc-enable-in
net estop-out   =>      hm2_5i25.0.gpio.029.out

#  ---manual tool change signals---

loadusr -W hal_manualtoolchange
net tool-change-request         <=      iocontrol.0.tool-change       =>  
hal_manualtoolchange.change
net tool-change-confirmed       <=      iocontrol.0.tool-changed      =>  
hal_manualtoolchange.changed
net tool-number                         <=      iocontrol.0.tool-prep-number  
=>  hal_manualtoolchange.number
net tool-prepare-loopback       <=      iocontrol.0.tool-prepare      =>  
iocontrol.0.tool-prepared
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to