Help needed to get my 7i76E + 7i85S + 7i73 on my mill going.

More
8 years 2 months ago #116306 by tecno
OK, so I got the comp installed on my milling machine but something is wrong. Can you guys see what is wrong here?
I was off by one digit on my inputs in HAL ;) but now corrected.

In picture below I have higear + input_b but only input pins on 7i76e shows nothing in gearcomp3



Code:
component gearcomp3 "LinuxCNC HAL component for Tecno's gearbox"; author "Rod Webster Hakan Bastedt"; pin in bit input_a "input a"; pin in bit input_b "input b"; pin in bit input_c "input c"; pin in bit input_d "input d"; pin in bit input_e "input e"; pin in bit higear "true if in high gear"; pin in bit enable_in "Enable signal. Input"; pin out bit enable_out "Enable signal. Output"; pin in float speed "Spindle speed in RPM as in Sxxx"; pin out bit gearshift "Need to shift gear, true if high"; pin out s32 wantedgear "Shift to this gear if told so"; pin out float speedratio "max RPM for machine divided by maximum RPM for gear"; param rw float maxrpm "maximum RPM for machine"; function _; license "GPL"; ;; #include <rtapi_math.h> FUNCTION(_) { int i; int inputs_sum; int gearengaged; int geartouse; // Gears are number from 1 (lowest) to 7 static double speeds[7][2] = { { 160.0, 80.0}, { 270.0, 160.0}, { 450.0, 270.0}, { 750.0, 450.0}, {1250.0, 750.0}, {1500.0, 1250.0}, {2500.0, 1500.0}, }; static double ratios[7] = { 0.064, 0.108, 0.18, 0.3, 0.5, 0.6, 1.0}; // Check which gear to use with this speed Sxxx geartouse = -1; for (i=0; i<7; i++) { if (speed <= speeds[i][0] && speed > speeds[i][1]) geartouse = i+1; } // Is at least one of the inputs active? Calculate gear from inputs. inputs_sum = 1*input_a + 2*input_b + 3*input_c + 4*input_d + 5*input_e; if (higear) gearengaged = inputs_sum + 2; // inputs_sum 4,5 => gear 6,7 else gearengaged = inputs_sum; // inputs_sum 1,2,3,4,5 => gear 1,2,3,4,5 if (inputs_sum > 0 && geartouse == gearengaged) { // Everything ok gearshift = 0; wantedgear = gearengaged; speedratio = ratios[gearengaged-1]; enable_out = enable_in; } else { // Should change gear gearshift = 1; wantedgear = geartouse; speedratio = ratios[geartouse-1]; enable_out = 0; } }

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

More
8 years 2 months ago #116309 by Hakan
Rod, you must come from the embedded environment because in Intel Linux an int has been 32 bit wide since the beginning and still is today when 64-bit cpus are the norm.
Int doesn't have a standard width one can always rely on. On 8-bits microcomputers they can be 16-bits wide but it is entirely compiler dependent.

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

More
8 years 2 months ago #116310 by Hakan

tecno wrote: OK, so I got the comp installed on my milling machine but something is wrong. Can you guys see what is wrong here?
I was off by one digit on my inputs in HAL ;) but now corrected.

In picture below I have higear + input_b but only input pins on 7i76e shows nothing in gearcomp3



Code:
component gearcomp3 "LinuxCNC HAL component for Tecno's gearbox"; author "Rod Webster Hakan Bastedt"; pin in bit input_a "input a"; pin in bit input_b "input b"; pin in bit input_c "input c"; pin in bit input_d "input d"; pin in bit input_e "input e"; pin in bit higear "true if in high gear"; pin in bit enable_in "Enable signal. Input"; pin out bit enable_out "Enable signal. Output"; pin in float speed "Spindle speed in RPM as in Sxxx"; pin out bit gearshift "Need to shift gear, true if high"; pin out s32 wantedgear "Shift to this gear if told so"; pin out float speedratio "max RPM for machine divided by maximum RPM for gear"; param rw float maxrpm "maximum RPM for machine"; function _; license "GPL"; ;; #include <rtapi_math.h> FUNCTION(_) { int i; int inputs_sum; int gearengaged; int geartouse; // Gears are number from 1 (lowest) to 7 static double speeds[7][2] = { { 160.0, 80.0}, { 270.0, 160.0}, { 450.0, 270.0}, { 750.0, 450.0}, {1250.0, 750.0}, {1500.0, 1250.0}, {2500.0, 1500.0}, }; static double ratios[7] = { 0.064, 0.108, 0.18, 0.3, 0.5, 0.6, 1.0}; // Check which gear to use with this speed Sxxx geartouse = -1; for (i=0; i<7; i++) { if (speed <= speeds[i][0] && speed > speeds[i][1]) geartouse = i+1; } // Is at least one of the inputs active? Calculate gear from inputs. inputs_sum = 1*input_a + 2*input_b + 3*input_c + 4*input_d + 5*input_e; if (higear) gearengaged = inputs_sum + 2; // inputs_sum 4,5 => gear 6,7 else gearengaged = inputs_sum; // inputs_sum 1,2,3,4,5 => gear 1,2,3,4,5 if (inputs_sum > 0 && geartouse == gearengaged) { // Everything ok gearshift = 0; wantedgear = gearengaged; speedratio = ratios[gearengaged-1]; enable_out = enable_in; } else { // Should change gear gearshift = 1; wantedgear = geartouse; speedratio = ratios[geartouse-1]; enable_out = 0; } }


Looks Ok given the input. The component want you to change gear but doesn't know to which gear, since the speed is zero,
But I see input-as, they are all zero,. Can you show the relevant parts of the hal file with loadrrt, addf and all signals where gearbox3 is involved?

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

More
8 years 2 months ago #116311 by tecno

File Attachment:

File Name: cb_gearbox...8-19.hal
File Size:17.25 KB

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

More
8 years 2 months ago #116312 by tecno
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_eth board_ip="10.10.10.10"
setp hm2_7i76e.0.watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.y,pid.z,pid.a,pid.s
loadrt charge_pump
loadrt timedelay names=brake_delay
loadrt and2 count=4
loadrt xor2 count=2
loadrt or2 count=1
loadrt siggen num_chan=2
loadrt gearcomp3

addf charge-pump servo-thread
addf hm2_7i76e.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller 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 jogincr servo-thread
addf hm2_7i76e.0.write servo-thread
addf brake_delay servo-thread
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf or2.0 servo-thread
addf siggen.0.update servo-thread
addf siggen.1.update servo-thread
addf gearcomp3.0 servo-thread

# gearbox input signals
# gearbox Hi/Lo
net gearcomp3.0.high-gear <= hm2_7i76e.0.7i76.0.0.input-14

# gearbox A - B - C - D - E
net gearcomp3.0.input_a <= hm2_7i76e.0.7i76.0.0.input-09
net gearcomp3.0.input_b <= hm2_7i76e.0.7i76.0.0.input-10
net gearcomp3.0.input_c <= hm2_7i76e.0.7i76.0.0.input-11
net gearcomp3.0.input_d <= hm2_7i76e.0.7i76.0.0.input-12
net gearcomp3.0.input_e <= hm2_7i76e.0.7i76.0.0.input-13

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

More
8 years 2 months ago - 8 years 2 months ago #116313 by tecno
Found a typo
net gearcomp3.0.high-gear >>>> net gearcomp3.0.higear
Last edit: 8 years 2 months ago by tecno.

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

Moderators: cmorley
Time to create page: 0.507 seconds
Powered by Kunena Forum