Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %!PS-Adobe-2.0
- %%Title: Postscript Quadrature Encoder Disk
- %%Creator: (C) Ricardo Seixas - [email protected]
- %%CreationDate: May 12 2000
- %%Title: Quadrature Encoder Disk
- %----------------------------------------------------------
- %%Changed to create the A & B for a quadrature encoder
- %%By Douwe Jippes - [email protected]
- %%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" [email protected]
- %%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
- /offset -2.66666 df % rotational offset per ring (per encoder)
- /slots 1 df
- /nrOfRings 10 df
- /diameter_step 10 df
- /external_diameter 55 mm df
- /internal_diameter external_diameter diameter_step nrOfRings mul sub df
- /text ( HI5-HI6_simulator [email protected] ) df % don't remove the parentheses when you change text!!!
- /text_diameter internal_diameter 1 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
- 360 #S offset mul div rotate % shift outer segments by 1/4 segment
- 0 0 iR 0 360 arc stroke
- /#S 2 #S mul def %twice as many segments each ring
- iR iR sR add #S DrawSegments
- /iR iR sR add df
- % rotate angle degrees for next ring
- } 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 216 mm df % letter
- /pageSizeY 280 mm df % letter
- /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
- nrOfRings slots iR sR DrawDiscs
- dX 0 translate
- %/offset offset 0.1 add def
- } repeat
- grestore
- 0 dY translate
- } repeat
- showpage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement