On 11 June 2015 at 02:07, Gene Heskett <[email protected]> wrote:
> I find that the 2 or 3 yo code that
> cut the encoder disk for my toy lathe, will not load into the 2.7.0-sim
> on this machine.

The G-code standard hasn't changed. What is the error message?
Box contents are not copy/pastable, but read like this:

Near line 69 of
/net/shop/home/gene/linuxcnc/nc_files/genes-encoder.ngc
bad character 'y' used

The file itself is attached, if the server doesn't strip it.  It also 
loads just fine on the local machine running a 2.8.0-pre.


-- 
atp
If you can't fix it, you don't own it.
http://www.ifixit.com/Manifesto

------------------------------------------------------------------------------
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

( spindle-encoder.ngc )
( by Lawrence Glaister VE7IT )
( Sept 15 2007 )
( lerman - thankyou for named variables and owords.... very cool )
( Cut from arborite stock with 0.049" endmill. )
( This encoder ring mounts on the lathe spindle drive pulley. )
( Ring encoder provides A,B,Z phases using 3 H21TLB slot sensors. )
( The H21TLB sensor use 5v and can directly drive parallel port pins. )
( The sensor apeture is 0.035", so I used double that for the slot length )
( to allow for some runout on mounting the ring. )
( The main constraint is that the main track opto has to be able to physically )
( read the inner track... reaching over the outer index track )
( To preview what it will look like, set _endmill_dia = 0.0 below. )
( With a high speed spindle you may be able to cut to depth in 1 pass. )
( Edited heavily to make a much smaller wheel with fewer slots by Gene Heskett )

(======================================================================)
(============================= Subroutines ============================)
( cuts a circle at request diameter around x,y to requested depth )
o100 sub
  (Subroutine to do a circle)
  ( P1=X center P2=Y center P3-diameter P4=depth P5=feedrate )
  g0 z#<_safe_Z>
  g0 x[#1-[#3* 0.5]] y#2
  g0 z#4
  g2 F[#5/1.5] x[#1-[#3/2]] y#2 i[#3/2] j0
  g0 z#<_safe_Z>
o100 endsub

(======================================================================)
(=================== Define Constants/Variables =======================)
#<_restartZ> = -0.0000
#<_lexan>       = 0
#<_endmill_dia> = 0.03125                       (  endmill diameter )
#<_endmill_rad> = [#<_endmill_dia> * 0.50]      ( endmill radius )
( Here, was .34, but the leds need to be run pretty hard to get a 50% duty 
cycle, see what .38 does)
#<_duty_cycle_finish>   = .38                   ( adjust for 50% at output )
#<_duty_cycle_start>    = .36                   (start a bit narrow, polish out 
at end)
#<_duty_cycle>          = #<_duty_cycle_start>
#<_safe_Z> = 0.050                              ( safe Z height )
#<_zstart> = 0.0025                             ( run down to there fast, then 
ramp into slot)
#<_zend> = -0.025
#<_feedrate> = 10                               ( cutting feedrate,start pgm at 
50%!!!!! )
S2500                                           ( spindle speed, wide open )
( define characteristics of encoder and index tracks )
#<_main_track_dia> = 2.2765                     ( center diameter of main 
signal track )
#<_index_track_dia> = [#<_main_track_dia> - 0.155] ( diameter of index track )
( May 30, 14:14 GH fix this to compensate for bit radii, needs 1.054 ID hole )
#<_inside_cutout> = [1.0530 - #<_endmill_dia>]  ( diameter of interior cutout = 
inside of pulley)
#<_outside_cutout> = 2.432                      ( diameter of exterior cutout 
~= enough space for tracks)
#<_encoder_cycles> = 50                         ( better fit with photo-cells )
#<_slotlen> = 0.098               ( finished slot length for 1 encoder element 
~= sensor aperture + runout )

( define 3 params for the mounting arrangement )
(#<_mount_circle> = 1.650)                                ( mounting bolt 
circle diameter )
(#<_mount_holes> = 6)                                     ( number of holes to 
mill for mounting bolts )
(#<_mount_hdia> = 0.130)                                  ( sloppy #6 or a #8 
bolt )

#<_PI> = 3.14159265359 (more decimal places can't hurt GH)
#<_encoder_theta>=[360.0/#<_encoder_cycles>]  ( angular step around circle )

(======================================================================)
(========================= Start of Main Code =========================)

G20 G90 G49 G54 G61.1
G64 P.0002
G0 Z#<_safe_Z>
G0 X0 Y0
M06 T9 ( 0.03125 mill )
G54

m0(DEBUG,spindle_encoder.ngc: #<_encoder_cycles> cycle disk uses 
#<_endmill_dia> dia endmill, material top,center at 0,0,0 ... unpause[S] when 
ready)
M03 (start spindle)
( ==========show outer circle on display if not a restart========== )
o101 if [#<_restartZ> gt -0.001 ]
o100 call [0.0] [0.0] [#<_outside_cutout>+#<_endmill_rad>] [#<_safe_Z>] [75.0]
o101 endif
#<finish_depth> = #<_zend>
(=====================================================================)
o20     if[#<_lexan>]
#<finish_depth> = -0.04500
#<tmpOD>        = [#<_outside_cutout> + .050]
#<tmpdepth>     = 0.000
#<depth_dec>    = [#<finish_depth> / 10.0]
o22     while [#<tmpdepth> gt #<finish_depth>]
#<tmpdepth>     = [#<tmpdepth> + #<depth_dec>]
#<OD_dec>       = -0.019
o24 while [#<tmpOD> gt 1.800]
o100  call [0.0] [0.0] [#<tmpOD>] [#<tmpdepth>] [15.0]
#<tmpOD>        = [#<tmpOD> + #<OD_dec>]
o24 endwhile
(reset for next deeper pass)
#<tmpOD>        = [#<_outside_cutout> + .050]
o22 endwhile
G0 Z #<_safe_Z>
o20 endif
( set to skip to #<finish_depth to start slotting)

(=======================cut the main encoder slots====================)

( compute angular size of cutter at cutting extremes )
#<_inner_dia> = [#<_main_track_dia> - #<_slotlen> +  #<_endmill_rad>]
#<_outer_dia> = [#<_main_track_dia> + #<_slotlen> -  #<_endmill_rad>]
#<_icutter_deg> = [[#<_endmill_rad>*360.0/[#<_inner_dia>*#<_PI>]] + 0.995000] ( 
make global! )
#<_ocutter_deg> = [[#<_endmill_rad>*360.0/[#<_outer_dia>*#<_PI>]] + 0.995000] ( 
ditto )
#<_icutter_bakup> = #<_icutter_deg>  ( save for restoration inside the loop )
#<_ocutter_bakup> = #<_ocutter_deg>  ( ditto )

( split in half, we'll cut both sides of the slot )
#<_slot_deg> = [#<_encoder_theta>*#<_duty_cycle> ]
(debug, slot width is #<_slot_deg>)

#<_slots> = #<_encoder_cycles>     ( counter for cutting this many slots )

( setup for main loop depth repeats )
#<_ztmp> = 0.000
o102 if [#<_restartZ> lt -0.001]
 #<_ztmp> = #<_restartZ>
o102 endif

#<_zinc> = [#<_zend> / 8.000] ( should give < 2.5 thou )

( main loop to cut encoder slots around disk )

o300 while [#<_ztmp> gt #<_zend>]
#<_angle> = 360
 #<_ztmp> = [#<_ztmp> + #<_zinc>]
 #<_slots> = #<_encoder_cycles>
( main loop to cut encoder slots )
o10 do
  #<_centerx> = [#<_main_track_dia> * 0.50 * cos[#<_angle>]]    ( x center of 
slot )
  #<_centery> = [#<_main_track_dia> * 0.50 * sin[#<_angle>]]    ( y center of 
slot )
  g0 z#<_safe_Z>
  g0 x[#<_centerx>] y[#<_centery>]

o11 if [#<_ztmp> lt -0.0145 ]
        #<_duty_cycle> = #<_duty_cycle_finish>  ( now shave inside of slot 
smoother )
o11 else
        #<_duty_cycle> = #<_duty_cycle_start>   ( slightly narrow till about 
done )
o11 endif

  ( do a cut to the final depth at the cw inner corner of the slot )
  #<myangle> = [#<_angle> + [#<_slot_deg> * #<_duty_cycle>] - [#<_icutter_deg> 
* #<_duty_cycle>]]
(debug, myangle for descent to depth is now #<myangle>)

  #<myx> = [#<_inner_dia> * 0.50 * cos[#<myangle>]]
  #<myy> = [#<_inner_dia> * 0.50 * sin[#<myangle>]]

  ( goto old depth )
  g0 z[#<_ztmp> - #<_zinc>]

  ( cut to new depth at CW inside corner )
  g1 x[#<myx>] y[#<myy>] z[#<_ztmp>] f[#<_feedrate>]  ( descend to cut depth )

( calculate new angle for CW end of inside slot )
  #<myangle> = [#<_angle> - [#<_slot_deg> * #<_duty_cycle>] + [#<_icutter_deg> 
* #<_duty_cycle>]]
(debug, myangle for inside, CW end of slot is now #<myangle>)

  #<myx> = [#<_inner_dia> * 0.50 * cos[#<myangle>]]
  #<myy> = [#<_inner_dia> * 0.50 * sin[#<myangle>]]
  #<myr> = SQRT[#<myx>*#<myx> + #<myy>*#<myy>]

( calculate worthless corner curve for inside end of slot )
  g2 x[#<myx>] y[#<myy>]  r[#<myr>] f[#<_feedrate>] ( cut inside edge of slot )

  #<myangle> = [#<_angle> - [#<_slot_deg>*#<_duty_cycle>] + 
[#<_ocutter_deg>*#<_duty_cycle>]]
(debug, CW end of inside slot is now #<myangle>) 

  #<myx> = [#<_outer_dia> * 0.50 * cos[#<myangle>]]
  #<myy> = [#<_outer_dia> * 0.50 * sin[#<myangle>]]
  g1 x[#<myx>] y[#<myy>]                  ( cut cw edge of slot )

  #<myangle> = [#<_angle> + [#<_slot_deg>*#<_duty_cycle>] - 
[#<_ocutter_deg>*#<_duty_cycle>]]
(debug, myangle for outside end of slot is now #<myangle>)

  #<myx> = [#<_outer_dia> * 0.50 * cos[#<myangle>]]
  #<myy> = [#<_outer_dia> * 0.50 * sin[#<myangle>]]
  #<myr> = SQRT[#<myx>*#<myx> + #<myy>*#<myy>]
  g3 x[#<myx>] y[#<myy>] r[#<myr>]                ( cut outer edge of slot )

  #<myangle> = [#<_angle> + [#<_slot_deg>*#<_duty_cycle>] - 
[#<_icutter_deg>*#<_duty_cycle>]]
(debug, myangle for run back to inner end of slot is now #<myangle>)

  #<myx> = [#<_inner_dia> * 0.50 * cos[#<myangle>]]
  #<myy> = [#<_inner_dia> * 0.50 * sin[#<myangle>]]
  g1 x[#<myx>] y[#<myy>]                  ( cut back to inner cw point of slot )

  g0 z#<_safe_Z>
  #<_slots> = [#<_slots> -1]
  #<_angle> = [#<_angle> - #<_encoder_theta>]
o10 while [#<_slots> GT 0]

( cutout index hole)

( compute angular size of cutter at cutting extremes )
#<_inner_dia> = [#<_index_track_dia> - #<_slotlen> +  #<_endmill_rad>]
#<_outer_dia> = [#<_index_track_dia> + #<_slotlen> -  #<_endmill_rad>]
#<_angle> = 0                    ( s/b but make sure starting angle to cut )

#<_centerx> = [#<_index_track_dia> * 0.50 * cos[#<_angle>]]     ( x center of 
slot )
#<_centery> = [#<_index_track_dia> * 0.50 * sin[#<_angle>]]     ( y center of 
slot )
g0 z#<_safe_Z>
g0 x[#<_centerx>] y[#<_centery>] (good cut) 
( do a cut to the final depth at the cw inner corner of the slot )

#<_myangle>     =       0.09
#<myx> = [#<_inner_dia> * 0.50 * cos[#<_myangle>]]
#<myy> = [#<_inner_dia> * 0.50 * sin[#<_myangle>]]
g0 z[#<_ztmp> - #<_zinc>]  (good cut)
g1 x[#<myx>] y[#<myy>] z[#<_ztmp>] f[#<_feedrate>]  ( decend to cut depth at CW 
inside corner )
( GOOD CUT to CW inside corner )
#<_myangle>     =       0.09

#<myx> = [#<_inner_dia> * 0.5 * cos[#<_myangle>]]
#<myy> = [#<_inner_dia> * 0.5 * sin[#<_myangle>]]  
g1 x[#<myx>] y[#<myy>] f[#<_feedrate>] ( cut inside end of slot to CCW of 
inside corner )
(GOOD CUT to CCW inside corner)
#<_myangle>     =       0.09

#<myx> = [#<_outer_dia> * 0.5 * cos[#<_myangle>]]
#<myy> = [#<_outer_dia> * 0.5 * sin[#<_myangle>]]
g1 x[#<myx>] y[#<myy>]                  ( cut ccw edge of slot to outside end )
( GOOD CUT to outside CCW corner )
#<_myangle>     =       -0.09
( T'was wrong angle, not the global one above )

#<myx> = [#<_outer_dia> * 0.5 * cos[#<_myangle>]]
#<myy> = [#<_outer_dia> * 0.5 * sin[#<_myangle>]]
g1 x[#<myx>] y[#<myy>]              ( cut outer end of slot )

#<myx> = [#<_inner_dia> * 0.5 * cos[#<_myangle>]]
#<myy> = [#<_inner_dia> * 0.5 * sin[#<_myangle>]]
g1 x[#<myx>] y[#<myy>]                   ( cut back to inner cw point of slot )

g0 z#<_safe_Z>

( mill some mounting bolt holes )

(#<_holes> = #<_mount_holes>)
(#<myangle> = 0) ( note, this is NOT global )
(o20 do)
(    #<myx> = [#<_mount_circle> * 0.5 * cos[#<myangle>]])
(    #<myy> = [#<_mount_circle> * 0.5 * sin[#<myangle>]])
              ( X )      ( Y )             ( Diameter )           ( Depth )    
( Feed )
(    o100 call [#<myx>] [#<myy>] [#<_mount_hdia>-#<_endmill_dia>] [#<_ztmp>] 
[#<_feedrate>]) ( one mounting hole )
(    #<myangle> = [#<myangle> + [ 360.0 / #<_mount_holes>] ])
 (   #<_holes> = [#<_holes> -1] )
(o20 while [ #<_holes> GT 0 ] )

( cutout encoder ring interior )
          ( X ) ( Y )             ( Diameter )             ( Depth )    ( Feed )
o100 call [0.0] [0.0] [#<_inside_cutout>] [#<_ztmp>]  [#<_feedrate>]      ( 
interior cutout )
( restore screwed up stuff for next pass!)
#<_inner_dia> = [#<_main_track_dia> - #<_slotlen> +  #<_endmill_rad>]
#<_outer_dia> = [#<_main_track_dia> + #<_slotlen> -  #<_endmill_rad>]

o300 endwhile

(reset for outer ring cutout )
#<_ztmp> = 0.00
o400 while [#<_ztmp> gt #<_zend>]
#<_ztmp> = [#<_ztmp> + #<_zinc>]
o100 call [0.0] [0.0] [#<_outside_cutout> + #<_endmill_rad>] [#<_ztmp>] 
[#<_feedrate>]      ( exterior cutout )
o400 endwhile
M5
M2
------------------------------------------------------------------------------
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to