Page 1 of 1

Code execution does not seem to follow if else and o numbers

Posted: Thu Apr 02, 2020 3:10 pm
by gearond
Running firmware:
v0.4.11

In the attached pgm, in the subroutine starting at line 215, I get both msgs inside if the o302 if else endif structure in one pass, i.e., it's ignoring the else and falling through.

now as I write this this seems to ring a bell as maybe a bug report I submitted earlier for a different program. Unfortunately I can't test any of the later versions of the firmware because they have a different problem https://github.com/buildbotics/bbctrl-f ... issues/254 that affects my programs.

IST LINE IS NEXT
;http://linuxcnc.org/docs/html/gcode/g-
code.html#gcode:g2-g3

;temporary


;------------------------------------------------------------------------------
;set all program parameters
;------------------------------------------------------------------------------

; ONLY ADJUST THESE PARAMETERS!!!!!
;fractions must be in square brackets!!
#<_wood_thickness>= [5/8]
#<_tool_diam>= 0.240 ;actual cut, nominal is 0.2362204724409/6mm
#<_bit_protrusion>=0.235
#<_ntch_btm_width>=4.0
;#<_ntch_sides_angle>=30 ;From vertical

;##DO NOT GO MORE THAN 1.2 IN AS BIT WILL HIT THE TABLE
#<_ntch_depth>=1.2
#<_ntch_corner_radius>=0.50000
#<_x_ntch_enter_n_exit_distance>=2.00000
#<_y_ntch_enter_n_exit_distance>=1.0000
#<_notch_feed_rate>= 23;18.4 ;23 previoisly ; inches/min

;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; DO NOT ADJUST PARAMETERS BELOW HERE!!!
#<_X_offset_to_piece>=0.0
#<_Y_offset_to_piece>=2.355 ;s2.355 ;2.375

#<_tool_tip_zero_pos_z_spacing>= 0.10
#<_tool_tip_zero_pos_y_spacing>= 0.00
#<_tool_tip_zero_pos_z_compensation>= 0.022 ;used during setting of offset coordinate system

#<_X_max>=36.0
#<_Y_max>=5.25
#<_Y_min_while_cutting>=1.5
#<_Z_max>=7.9

#<_z_safe_height>=4.0
#<_motor_spin_up_time>=10.0
#<_tool_max_rotation_speed>=20000
;------------------------------------------------------------------------


;------------------------------------------------------------------------------
;Subroutine addresses
;------------------------------------------------------------------------------

#<_do_cut_ntch>=150
#<_do_start_motor>=175
#<_do_stop_motor>=200
#<_do_build_notch_coordinates>=225
#<_do_init_pgm_and_machine>=275
#<_do_probe_drawer_width>=300

;------------------------------------------------------------------------------
;START of subroutines
;------------------------------------------------------------------------------

;====================
;#<_do_cut_ntch>=150
;====================

o150 sub
f18
g90 ;absolute mode
g54 ; normal, nonoffst coordinate system
G0 Z[#<_z_safe_height>]

G64 P0.0110 ;(set path following to be contiinuous motion within 0.010 of the actual path)
g55 ;offset coordinate system

g0 x[#<_x_ntch_angle_in_rt_pos>] y[#<_y_ntch_angle_in_rt_pos> ]
;G0 Z[ #<_tool_tip_zero_pos_z_spacing> + #<_wood_thickness> + #<_bit_protrusion>]
;assumes feed rate set in main program
g1 x[#<_x_ntch_arc_in_beg_rt_pos>] y[#<_y_ntch_arc_in_beg_rt_pos>]
g3 x[#<_x_ntch_arc_in_end_rt_pos>] y[#<_y_ntch_arc_in_end_rt_pos>] I[0.000000] J[-0.720000]
g1 x[#<_x_ntch_arc_to_btm_beg_rt_pos>] y[#<_y_ntch_arc_to_btm_beg_rt_pos>]
g2 x[#<_x_ntch_arc_to_btm_end_rt_pos>] y[#<_y_ntch_arc_to_btm_end_rt_pos>] I[-0.48000] J[0.000000]
g1 x[#<_x_ntch_arc_from_btm_beg_lft_pos>] y[#<_y_ntch_arc_from_btm_beg_lft_pos>]
g2 x[#<_x_ntch_arc_from_btm_end_lft_pos>] y[#<_y_ntch_arc_from_btm_end_lft_pos>] I[0.00000] J[0.480000]
g1 x[#<_x_ntch_arc_out_beg_lft_pos>] y[#<_y_ntch_arc_out_beg_lft_pos>]
g3 x[#<_x_ntch_arc_out_end_lft_pos>] y[#<_y_ntch_arc_out_end_lft_pos>] I[-0.720000] J[0.00000]

g1 x[#<_x_ntch_angle_out_lft_pos>] y[#<_y_ntch_angle_out_lft_pos>]

g54 ; normal, inoffst coordinate system
G61 ;exact stop mode
G0 Z[#<_z_safe_height>]

o150 endsub

;====================
;#<_do_start_motor>=175
;====================

o175 sub

S[ #<_tool_max_rotation_speed>]
; m3

o175 endsub

;====================
;#<_do_stop_motor>=200
;====================

o200 sub

m5

o200 endsub

;====================
;#<_do_build_notch_coordinates>=225
;====================

;NOTE:--cntr drawer edge is (0,0, 0) orgin of coordinates in G55 coordinate system
o225 sub ;#<_do_build_notch_coordinates>=225

;NOTE:--cntr drawer edge is (0,0, 0) orgin of coordinates in G55 coordinate system

;1
#<_x_ntch_angle_in_rt_pos>= 3.600000
#<_y_ntch_angle_in_rt_pos>= 0.170000
;2
#<_x_ntch_arc_in_beg_rt_pos>= 2.60000
#<_y_ntch_arc_in_beg_rt_pos>= 0.120000
;3
#<_x_rt_top_ntch_arc_cntr> = 2.60000
#<_y_rt_top_ntch_arc_cntr> = -0.600000
;4
#<_x_ntch_arc_in_end_rt_pos>= 1.880000
#<_y_ntch_arc_in_end_rt_pos>= -0.600000
;5
#<_x_ntch_arc_to_btm_beg_rt_pos>= 1.880000
#<_y_ntch_arc_to_btm_beg_rt_pos>= -0.600000
;6
#<_x_rt_btm_ntch_arc_cntr> = 1.400000
#<_y_rt_btm_ntch_arc_cntr> = -0.600000
;7
#<_x_ntch_arc_to_btm_end_rt_pos>= 1.400000
#<_y_ntch_arc_to_btm_end_rt_pos>= -1.0800000
;------------------------------------------------------------------
;-7
#<_x_ntch_arc_from_btm_beg_lft_pos>= -1.4000000 ; -1.00000 * #<_x_ntch_arc_to_btm_end_rt_pos>
#<_y_ntch_arc_from_btm_beg_lft_pos>= #<_y_ntch_arc_to_btm_end_rt_pos>
;-6
#<_x_lft_btm_ntch_arc_cntr> = -1.400000 ; -1.00000 * #<_x_rt_btm_ntch_arc_cntr>
#<_y_lft_btm_ntch_arc_cntr> = #<_y_rt_btm_ntch_arc_cntr>
;-5
#<_x_ntch_arc_from_btm_end_lft_pos>= -1.880000; -1.00000 * #<_x_ntch_arc_to_btm_beg_rt_pos>
#<_y_ntch_arc_from_btm_end_lft_pos>= #<_y_ntch_arc_to_btm_beg_rt_pos>
;-4
#<_x_ntch_arc_out_beg_lft_pos>= -1.880000; -1.00000 * #<_x_ntch_arc_in_end_rt_pos>
#<_y_ntch_arc_out_beg_lft_pos>= #<_y_ntch_arc_in_end_rt_pos>
;-3
#<_x_lft_top_ntch_arc_cntr> = -2.600000; -1.00000 * #<_x_rt_top_ntch_arc_cntr>
#<_y_lft_top_ntch_arc_cntr> = #<_y_rt_top_ntch_arc_cntr>
;-2
#<_x_ntch_arc_out_end_lft_pos> = -2.600000 ;-1.000000 * #<_x_ntch_arc_in_beg_rt_pos>
#<_y_ntch_arc_out_end_lft_pos>= #<_y_ntch_arc_in_beg_rt_pos>
;-1
#<_x_ntch_angle_out_lft_pos>= -3.60000; -1.000000 * #<_x_ntch_angle_in_rt_pos>
#<_y_ntch_angle_out_lft_pos>= #<_y_ntch_angle_in_rt_pos>

o249 if [ #<_y_ntch_arc_in_end_rt_pos> LT #<_y_ntch_arc_to_btm_beg_rt_pos> ]
(msg, Radius of corners too large for depth of ntch! Program ending!)
m2
o249 endif

o225 endsub

;====================
;#<_do_init_pgm_and_machine>=275
;====================
;test for #5000 to be non zero
o275 sub

o276 if [ [ #5000 eq 0 ] OR [ #<_x_homed> eq 0 ] ]
(msg, MACHINE NOT HOMED using 'zero.nc' program! PROGRAM EXITING!)
m2
o276 endif
o277 if [ [ #<_y_homed> eq 0 ] OR [ #<_z_homed> eq 0 ] ]
(msg, MACHINE NOT HOMED using 'zero.nc' program! PROGRAM EXITING!)
m2
o277 endif

G17 ;xy plane
G20 ;inch units
g40 ;Cutter compensation off
; the first below is the default unoffset coordinate system
G10 L2 P1 X0 Y0 Z0 ; erase offsets coordinate system 1
G10 L2 P2 X0 Y0 Z0 ; erase offsets coordinate system 2
g20 ; in inches
g54 ;use default (P1) machine coordinate offset system coordinate system 1
G90 ;absolute distance mode using current coordinate system
g92.1 ;clear and disable G92 global offset system
G94 ;feeds in units per minute
G0 z[#<_z_safe_height>]
g0 x0 y0

; set x value of drawer probe to zero to prepare for first probe
#5061=0
; set probe success not successful
#5070 = 0

;-------for tool tip----------
g10 L2 p2 y[ -1 * [ #<_Y_offset_to_piece> + #<_tool_tip_zero_pos_y_spacing> ] ]
g10 L2 p2 z[ -1 * [#5000 - #<_tool_tip_zero_pos_z_spacing> +#<_tool_tip_zero_pos_z_compensation>] ]

o275 endsub

;====================
;#<_do_probe_drawer_width>=300
;====================

o300 sub
; #5070 probe success flag
; #5061 x value of last probe
; both above set to 0 at start of program

#<drawer_width_probe_x_offset>= -0.035 ;-0.045
#<drawer_width_probe_y_pos>=0
#<measurement_done> = 0

g54
g90
g0 z[#<_z_safe_height>]
g0 y[#<drawer_width_probe_y_pos>]

o301 do
; First or missed probe
;#5061 is 0 at startup and pgm start
;but isset to a noƱ zero value for X after a probe command
o302 if[ #5061 eq 0 ]
g0 x0
g38.6 p18 x[#<_X_max> - #<_x> + .0100] f150
g91
g0 x-1.5
g90
G38.6 p18 x2 f6
#<measurement_done> = 1

o302 else
; start probe just short of last one
g0 x[#5061 - 0.250]
o303 if [ [#5061 + 0.250 ] gt #<_X_max> ]
G38.7 p18 x[#<_X_max> - #<_x> + .0100] f6
o303 else
g38.7 p18 x[#<_x> + 0.500] f6
o303 endif

; probe success on 2nd plus drawer
o304 if [ #5070 eq 1 ]
(msg, got to 5070=1 for probe success)
m0
; backup to avoid a possible start in measuring bar width
; also, cant go to zero due machine design
; no need to tst for that

; in case drawer slightly smaller and
;probe did not travel, back up width
;of measuement tab/bearing holder
G38.8 p18 x-3 f12
g91
; a little more to get out of hysterisis band
g0 x-0.100
g90
o305 if [ [#<_x> + 0.100 ] gt #<_X_max> ]
G38.6 p18 x[#<_X_max> - #<_x> + .0100] f6
o305 else
g38.6 p18 x[0.3500] f6
o305 endif
#<measurement_done> = 1

;no probe success, means drawer a diff size
o304 else
(msg, got to NO probe success)
m0
; erase previous drawer size, start fresh
#5061 = 0
o304 endif

o302 endif

o301 while [ #<measurement_done> eq 0 ]

g0 x[#5061]
(debug, value of 5061 is #5061)
(msg, going to 5061 measured position)
m0
g0 x0
(msg, now going to x0)
m0
g0 x[ [ [#5061 + #<drawer_width_probe_x_offset> ] / 2 ] ]
(msg, now going to midpoint)
m0

g10 L2 p2 x[ -1 * [ [#5061 + #<drawer_width_probe_x_offset> ] / 2 ] ]

o300 endsub
;---------------
;END of subroutines
;---------------

;==============================================================================
;---------------
;PROGRAM START
;---------------
o[#<_do_init_pgm_and_machine>] call
o[#<_do_build_notch_coordinates>] call
o[#<_do_start_motor>] call
g4 P[#<_motor_spin_up_time>]
F[#<_notch_feed_rate>]
;---------------
;MAIN LOOP
;---------------
#<_main_loop>=1
o999 while [#<_main_loop> EQ 1]

(msg, To machine a roll out ntch, clamp drawer, wait till dovetail fingers are FULLY SEATED!! Then press 'Continue'. To Quit, press 'Stop')
m0 ;pause, wait for 'Continue' button

o[#<_do_probe_drawer_width>] call
o[#<_do_cut_ntch>] call

(msg, DRAWER DONE! Remove drawer. Click 'Continue' when ready to do another, or 'Stop' to quit.)
m0 ;pause, wait for play button

;---------------
;END MAIN LOOP
;---------------
o999 endwhile ; end of main loop

;---------------
;END PGM
;---------------
o[#<_do_stop_motor>] call
m2 ;end program ;end program statement

Re: Code execution does not seem to follow if else and o numbers

Posted: Thu Apr 02, 2020 3:32 pm
by gearond
I just put a msg command in every if else endif location, and it DOES just fall thru an ELSE at about 4 levels deep.