Code:
+%!PS-Adobe-2.0 %%Title: Postscript Quadrature 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 %%Changed to create "trace_width_a & b in the middle of the line. %%Date Sept 14 2006 %%Major Change to orginate all lines from the centre. %%Thanks to the great help from "Teun" swfb@tunnissen.eu %%Date sept 16 2006 %----------------------------------------------------------- % 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 /bd {bind def} bind def /ed {exch def} bd /df {def} bd /mm {2.8346 mul} bd /pi 3.1415926536 df %Here you can change the encoder characteristics /slots 45 df /nrOfRings 2 df /diameter_step 14 mm df /external_diameter 50 mm df /internal_diameter external_diameter diameter_step nrOfRings mul sub df /text ( HI5-HI6_simulator d.jippes@hccnet.nl ) df % don't remove the parentheses when you change text!!! /text_diameter internal_diameter 2 mm sub df %/text_diameter 20 mm df /font_size internal_diameter 10 div df %/font_size 6 df /font_type (Courier) df % %Look at the end of the file for positioning /center_hole { gsave % to restore linewidth % change by tune: setlinewidth is needed only once 0.2 setlinewidth %Cross -7 mm 0 moveto 14 mm 0 rlineto stroke 0 -7 mm moveto 0 14 mm rlineto stroke %Bulls Eye 8 mm 0 0 8 mm 2 div 0 360 arc stroke %Bulls Eye 14 mm 0 0 16 mm 2 div 0 360 arc stroke grestore } bd %Don't mess around here unless you know what you're doing /iR internal_diameter 2 div df /sR diameter_step 2 div df /DrawSegments { % Ri Ro nrOfSlots -> _ %/--in-- pstack == gsave 360 1 index 2 mul div exch % Ri Ro angle nrOfSlots -> _ { % repeat % fill one slice of a ring from zero to angle degrees % with origin (0, 0), inner radius Ri and outer radius Ro % and rotate the user space 2*angle degrees % Ri Ro angle -> Ri Ro angle 2 index 0 moveto 0 0 3 index 0 4 index arc 0 0 4 index 3 index 0 arcn fill %/--i-- pstack == dup 2 mul rotate } repeat grestore pop pop pop } bd /DrawDiscs { % nrOfRings nrOfSlots Ri Rstep -> % example to debug stack: %/--ins-- pstack == 3 dict begin % local dict /sR ed % R step /iR ed % R inner /#S ed % nrOfSlots % nrOfRings gsave 0.05 setlinewidth % draw inner circle { % repeat 0 0 iR 0 360 arc stroke iR iR sR add #S DrawSegments /iR iR sR add df % rotate angle degrees for next ring 360 #S 4 mul div rotate % shift outer segments by 1/4 segment } repeat % draw outer circle 0 0 iR 0 360 arc stroke grestore end % local dict %/--outs--- pstack == center_hole } bd % 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 { % nrOfRings nrOfSlots Ri Rstep -> nrOfRings slots iR sR DrawDiscs %Comment next line to remove text Encoder_Text } def %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 % Fil a sheet with discs % /pageSizeX 210 mm df % A4 /pageSizeY 297 mm df % A4 /topMargin 15 mm df /bottomMargin 15 mm df /leftMargin 10 mm df /rightMargin 10 mm df /spaceX 10 mm df % horizontal space between images /spaceY 10 mm df % vertical space between images /dX external_diameter spaceX add df /dY external_diameter spaceY add df /#x pageSizeX leftMargin sub rightMargin sub spaceX add external_diameter spaceX add div cvi df /#y pageSizeY bottomMargin sub topMargin sub spaceY add external_diameter spaceY add div cvi df bottomMargin leftMargin translate external_diameter 2 div dup translate #y { %repeat gsave #x { %repeat Draw_Encoder dX 0 translate } repeat grestore 0 dY translate } repeat showpage
file: /Techref/member/D-Mot-l1/index.htm, 5KB, , updated: 2006/10/16 23:52, local time: 2024/11/23 02:06,
owner: D-Mot-l1,
18.224.73.157:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.sxlist.com/techref/member/D-Mot-l1/index.htm"> Member Homepage for D-Mot-l1</A> |
Did you find what you needed? From: "http://sxlist.com/member/D-Mot-l1/index.htm" |