vikas
Simple Optical/Rotary Encoder Generator
by
, 03-14-2010 at 10:02 AM (17250 Views)
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 ...
Anyhow you can make your own as i have also put it onlinePHP 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);
Usage =
http://www.roboticsindia.com/tools/encoder.php?size={size of image}&count={No of divisions}&size1={Inner circle size}
Examples -
http://www.roboticsindia.com/tools/e...e=300&count=12
http://www.roboticsindia.com/tools/e...1=200&count=24
Hope this helps someone