vikas

Simple Optical/Rotary Encoder Generator

Rating: 2 votes, 4.50 average.
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($image255,255,255);
$black imagecolorallocate($image0,0,);

$step 360 / ($count);

for(
$i=0;$i<($count);$i+=2)
{
    
imagefilledarc  $image$size/$size/$size$size,$i*$step,($i+1)*$step$black,IMG_ARC_PIE );
    if(
$size1) {
        
imagefilledarc  $image$size/$size/$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 -

http://www.roboticsindia.com/tools/e...e=300&count=12

Click image for larger version. 

Name:	encoder.php?size=300&count=12&d=.jpg 
Views:	610 
Size:	8.9 KB 
ID:	219

http://www.roboticsindia.com/tools/e...1=200&count=24

Click image for larger version. 

Name:	encoder.php?size=300&size1=200&count=24&d=.jpg 
Views:	518 
Size:	10.2 KB 
ID:	220

Hope this helps someone

Comments