ON 20061010@1:33:18 PM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm#39000.5647916667 Douwe Jippes[D-Mot-l1] Code:
%!PS-Adobe-2.0
%%Title: Encoder Disk  
%%Creator: (C) Ricardo Seixas - rseixas@pobox.com 
%%CreationDate: May 12 2000

%%Title: Quadrature Encoder Disk 
%----------------------------------------------------------
%%Changed to create the A & B for a quadrature encoder
%%By Douwe Jippes - d.jippes@hccnet.nl
%%Date  Sept 10 2006
%%EndComments
%-----------------------------------------------------------
% You can freely distribute and use this file as long as you maintain the original copyright 
% This file is provided as is and there's NO WARRANTY
% Use it at your own risk

/mm {2.8346 mul} def   
/pi 3.1415926536 def   

%
%
%Here you can change the encoder characteristics

/slots 45 def

/external_diameter_a 50 mm def
/internal_diameter_a external_diameter_a 14 mm sub def
%/internal_diameter_a 36 mm def 

/external_diameter_b internal_diameter_a def
/internal_diameter_b external_diameter_b 14 mm sub def
%/internal_diameter_a 22 mm def

/text ( HI5-HI6_simulator d.jippes@hccnet.nl ) def 	% don't remove the parentheses when you change text!!!  
/text_diameter internal_diameter_b 2 mm sub def
%/text_diameter 20 mm def
/font_size internal_diameter_b 10 div def 
%/font_size 6 def
/font_type (Courier) def
%/internal_circle 18 mm def
/internal_circle internal_diameter_b font_size mm sub def
%
%Look at the end of the file for positioning

/center_hole {
	%Cross
	-7 mm 0 moveto 14 mm 0 rlineto 0.2 setlinewidth stroke
	0 -7 mm moveto 0 14 mm rlineto 0.2 setlinewidth stroke

	%Bulls Eye 8 mm
	0 0 8 mm 2 div
	0 360 arc .2 setlinewidth stroke  
		 
	%Bulls Eye 14 mm
	0 0 16 mm 2 div
	0 360 arc .2 setlinewidth stroke 
	
	%Draw External Circle
	%Comment the two lines below if you don't want external line  	
	0 0 external_diameter_a 2 div
	0 360 arc .05 mm setlinewidth stroke 
	
	%Draw middel Circle
	%Comment the two lines below if you don't want external line  	
	0 0 external_diameter_b 2 div
	0 360 arc .05 mm setlinewidth stroke 
	
	%Draw internal Circle
	%Comment the two lines below if you don't want external line  	
	0 0 internal_diameter_b 2 div
	0 360 arc .05 mm setlinewidth stroke 
			
	} def
	
%Don't mess around here unless you know what you're doing

/angle {360 slots div} def
/trace_width_a {internal_diameter_a pi mul slots div 2 div} def

/shift {angle 4 div} def
/shift_last 360 shift add def
/trace_width_b {internal_diameter_b pi mul slots div 2 div} def

/Draw_Disc {
		0 0 moveto  
		gsave
		angle 2 div rotate
		
		0 angle 360
		 	{
			gsave 
			rotate
			internal_diameter_a 2 div 0 rmoveto
			external_diameter_a internal_diameter_a sub 2 div 0 rlineto
			trace_width_a setlinewidth
			stroke
			grestore
			} for
		shift angle shift_last
		 	{
			gsave 
			rotate
			internal_diameter_b 2 div 0 rmoveto
			external_diameter_b internal_diameter_b sub 2 div 0 rlineto
			trace_width_b setlinewidth
			stroke
			grestore
			} for	
		grestore
		center_hole
		} def

% Text routine borrowed from Adobe Blue Book Program 10, on page 167
/insidecircletext
  { circtextdict begin
	  /radius exch def  /centerangle exch def
	  /ptsize exch def  /str exch def
	  
	  /xradius radius ptsize 3 div sub def
	  gsave
	    centerangle str findhalfangle sub rotate
	    str
		  { /charcode exch def
		    ( ) dup 0 charcode put insideplacechar
		  } forall
	  grestore
	end
  } def
  
/circtextdict 16 dict def
circtextdict begin
/findhalfangle
	{ stringwidth pop 2 div
	  2 xradius mul pi mul div 360 mul
	} def
	
/insideplacechar
  { /char exch def
	/halfangle char findhalfangle def
	gsave
	  halfangle rotate
	  radius 0 translate
	  90 rotate
	  char stringwidth pop 2 div neg 0 moveto
	  char show
	grestore
	halfangle 2 mul rotate
  } def
  
end


/font_type findfont font_size scalefont setfont
/Encoder_Text {
		text 18 -90 text_diameter 2 div insidecircletext
	       } def	

/Draw_Encoder {
	  Draw_Disc
	  %Comment next line to remove text
	  Encoder_Text
	  } def

%Here you can change where you want to put the disk on the sheet
%TODO automagicaly fill a A4 or A3 sheet

%automatic placement
%external_diameter_a 2 div 15 mm add external_diameter_a 2 div 15 mm add translate Draw_Encoder
%external_diameter_a 2 div 15 mm add external_diameter_a 2 div 15 mm add translate Draw_Encoder

%manual placement, you can put more than one encoder on the same sheet				
%30 mm 30 mm translate Draw_Encoder
%52 mm 0 mm translate Draw_Encoder

/ctoc external_diameter_a 15 mm add def

/hor_1 external_diameter_a 2 div 15 mm add def
/vert_1 external_diameter_a 2 div 15 mm add def

hor_1 vert_1 translate Draw_Encoder
3 {
	 2  {
	     ctoc 0 translate Draw_Encoder
	    } repeat
0 ctoc 2 mul neg ctoc translate Draw_Encoder
  } repeat
2 {
   ctoc 0 translate Draw_Encoder
  } repeat
showpage
ON 20061014@5:31:43 AM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm# Douwe Jippes[D-Mot-l1] edited the page. Difference: http://www.sxlist.com/techref/diff.asp?url=H:\techref\member\D-Mot-l1\index.htm&version=1 ON 20061015@5:47:15 AM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm# Douwe Jippes[D-Mot-l1] edited the page. Difference: http://www.sxlist.com/techref/diff.asp?url=H:\techref\member\D-Mot-l1\index.htm&version=2 ON 20061017@12:20:05 AM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm# Douwe Jippes[D-Mot-l1] edited the page. Difference: http://www.sxlist.com/techref/diff.asp?url=H:\techref\member\D-Mot-l1\index.htm&version=3 ON 20061017@1:49:52 AM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm# Douwe Jippes[D-Mot-l1] edited the page. Difference: http://www.sxlist.com/techref/diff.asp?url=H:\techref\member\D-Mot-l1\index.htm&version=4 ON 20061017@1:52:10 AM at page: http://www.sxlist.com/techref/member/D-Mot-l1/index.htm# Douwe Jippes[D-Mot-l1] edited the page. Difference: http://www.sxlist.com/techref/diff.asp?url=H:\techref\member\D-Mot-l1\index.htm&version=5