Let's Make Robots!

Simple Optical/Rotary Encoder Generator

Was building a simple Rotary Encoder for the ARP platofrm yesterday. Could not find a simple tool to generate the pattern according to my needs, there were some Postscript based tools but they did not work on Windows.

So here is my little script to generate it ...

PHP Code:

header("Content-type: image/gif");
$size = isset($_GET['size'])?intval($_GET['size']):200;
$size1 = isset($_GET['size1'])?intval($_GET['size1']):0;
$count = isset($_GET['count'])?intval($_GET['count']):10;


$image = imagecreate( $size, $size );
$size = $size - 2;
$white = imagecolorallocate($image, 255,255,255);
$black = imagecolorallocate($image, 0,0,0 );
$step = 360 / ($count);

for($i=0;$i<($count);$i+=2)
{
imagefilledarc ( $image, $size/2 , $size/2 , $size, $size,$i*$step,($i+1)*$step, $black,IMG_ARC_PIE );
if($size1) { imagefilledarc ( $image, $size/2 , $size/2 , $size1, $size1,$i*$step,($i+1)*$step, $white,IMG_ARC_PIE );
}
}
imagegif($image);

Anyhow you can make your own as i have also put it online

Usage =

http://www.roboticsindia.com/tools/encoder.php?size={size of image}&count={No of divisions}&size1={Inner circle size}

Examples -

Rotary Encoder

Rotary Encoder