Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1 2 3 ... 5
Send Topic Print
Adding optical mouse sensor for dead reckoning (Read 69726 times)
Lefteris
Senior Member
****




Posts: 271
Adding optical mouse sensor for dead reckoning
08/01/08 at 7:17am
 
Hello all,
 
I bumped on the problem of having a proprioceptive sensor on the robot so that it can understand where it understand in which direction and how much it moves and give that data back to the blackfin in a way that can be measured.
 
In my books I saw lots of ways, like shaft encoder in the wheels, GPS, INS(inertial navigation system - VERY expensive Cheesy ) e.t.c.
 
Admin though suggested something quite simpler which has even been tried before. Interfacing 2 optical mouse sensors in the SRV to measure how much it moves. So I made this thread so that it can be discussed with the community since I guess more people could be interested to this after being pointed out by admin.
 
Well the people who already tried it were kind enough to write some articles.
Here is a page with link to 3 other references about the same optical mouse hack. It was done by Mac. A. Cody. As you can see he gives directions to make a whole new sensor which does not even need to touch the ground.
 
Here you can see a detailed explanation with additional photos of the inner workings of that same mouse used in the above guide.
 
The problem is how to add such a thing in the SRV. Do you go so far as to make a whole new sensor from a mouse like the 1st link guy did? Or could it be done in a lot more simple way by opening a mouse, reducing it to the very minimum and addding it to the SRV. Where would you add it?  
 
To discuss questions like these with people who might be interested is the reason I made this thread.
 
For example I opened a USB optical Microsoft Mouse I had from 3 years ago resting in a shelf unused. It has many differences from the one detailed in the 2nd link but it is practically the same thing, but it uses a USB connection. Strange thing is that when you look at the usb cable you see all the 4 cables mentioned in the usb pinouts plus 1 more which is a lot thicker from the other 4. I don't know what it is.
 
So problem is how can you make the SRV understand these data? the D+ and D- (if you are using a USB mouse) and the DATA and CLK signals if it is a PS/2 mouse. Moreover where in the SRV could it be placed?  I was thinking front and back strapped with something (like a velcro) under the SRV.
 
So ... any ideas/input?
Back to top
 
 

WWW   IP Logged
henryhallam
Junior Member
**




Posts: 76
Re: Adding optical mouse sensor for dead reckoning
Reply #1 - 08/01/08 at 8:12am
 
PS/2 would be much easier to deal with from an electronics/software point of view.  That said, many USB mice actually include the signals for PS/2, which allows the use of "adapters" like this one: http://www.cheapcomputerlots.com/images/USB-PS2-unit.jpg which have no active components.
 
Even with PS/2 you'd probably want to have a PIC or similar microcontroller to deal with the incoming signals and take the burden away from the Blackfin.
Back to top
 
 
hhchicken2   IP Logged
Lefteris
Senior Member
****




Posts: 271
Re: Adding optical mouse sensor for dead reckoning
Reply #2 - 08/01/08 at 8:23am
 
Hmm ... I see. Unfortunately I don't have any PICs lying around nor any programmers for PIC microcontrollers. On the contrary I have an AVR programmer and an Atmega8-16Pu.
 
Wonder if something can be done with that. Actually what you suggest looks like this which I just stumbled upon. I wonder ... is it really that much of a burder for the blackfin ti add another microcontroller?
Back to top
 
 

WWW   IP Logged
NickK1066
Senior Member
****




Posts: 296
Re: Adding optical mouse sensor for dead reckoning
Reply #3 - 08/01/08 at 9:23am
 
I agree with henry.
 
Possibly the best way todo this would be to have one sensor at front-left and one at back-right corners. Then have a small programmable device maintain the sum of the detected vectors since last read.
 
The reason, as discussed, is that optical flow sensors used in mice don't normally scan for rotation around points in their field of view and usually scan for whole-scale shifts. With the two sensors an SRV rotation (50,-50) would show up better (although still technically a rotation.
 
I looked at these too a while ago.
 
It's possible to get the small sensor chip separately but then you have to get the optics, emitter, and deal with the raw signals..
 
Oddly enough I used to have to use an FDTI chip to interface between USB and TTL for my old CMUCam2+.
 
Just check the power - IIRC TTL was 5V rather than 3.3v.
 
 
If you have a sensitive enough accelerometer that can provide an idea of travel although by detecting the acceleration.
 
Back to top
 
« Last Edit: 08/01/08 at 9:38am by NickK1066 »  

  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding optical mouse sensor for dead reckoning
Reply #4 - 08/01/08 at 12:25pm
 
BYU and others have used these sensors quite effectively for ground speed measurement with UAV's:
    www.ee.byu.edu/faculty/beard/papers/preprints/BarberGriffithsMcLainBeard05.pdf
    www.barnardmicrosystems.com/L4E_FMU_sensors_2.htm
 
I purchased some chips and crystals, as they are very cheap, but never got around to building a circuit.  So I am glad to see this discussion topic.  My personal preference for a coprocessor is ARM7 - an NXP LPC2103 costs around $3 (other versions with less memory are cheaper) and uses the GNU toolchain.  You could configure it as an I2C or SPI slave.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Lefteris
Senior Member
****




Posts: 271
Re: Adding optical mouse sensor for dead reckoning
Reply #5 - 08/03/08 at 4:55am
 
Hey admin, nice to hear that you like the idea. Actually the second link you gave contains the answer to everything. The ADNS 2610 optical sensor found (as some people from avrfreaks told me) in almost every cheap mouse out there.
 
I was lucky. I went and bought 2 ps/2 optcial mice and found it inside.  This link contains some nice ideas about connectin the sensor itself to a microcontroller bypassing the whole mouse circuit. Just needs you to indentify the SCLK and the DATA pins of the sensor and send them directly to the PS/2 SCLK and DATA cables. Then all you gotta do is connect the PS/2 Wires to a microcontroller. We could even connect them directly to the blackfin? I am wondering, do you think it could be done? I am experimenting connecting it to an AVR atmega8 first. Got the circuit up and running, gonna test it soon.
Back to top
 
 

WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding optical mouse sensor for dead reckoning
Reply #6 - 08/05/08 at 6:49am
 
There used to be a C version of code posted with Cody's hack  - http://home.roadrunner.com/~maccody/robotics/croms-1/croms-1.html - though now he is using Forth.  It was set up for interfacing on a Linux system with parallel port.  I suspect it would not be difficult to modify the interface code to instead use one of the Blackfin GPIO pins.  I put a copy of the code on our website - here is the link  
    http://www.surveyor.com/blackfin/ADNS-2610.c
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Lefteris
Senior Member
****




Posts: 271
Re: Adding optical mouse sensor for dead reckoning
Reply #7 - 08/05/08 at 12:14pm
 
Thanks a lot admin, that looks like the code I wrote for my AVR to read the sensor's data. Reading the datasheet it is a process which resembles I2C(TWI) but it is not exactly that. I hope to finish speaking with the sensor with my AVR controller by the end of the week. Then I will just connect it with the blackfin instead and port the code.
 
The one problem I can't seem to find an optimal solution to is where on SRV1 I should put the sensors to touch the ground. It can not go under the SRV since there is no room. It could be attached to the front right and back lef with some velcro though. OR so I think. Not tried it yet.
 
Any other ideas for where to put the sensors and how to place them on the SRV-1?
Back to top
 
 

WWW   IP Logged
spikey
YaBB Newbies
*




Posts: 43
Re: Adding optical mouse sensor for dead reckoning
Reply #8 - 08/11/08 at 8:36am
 
I've been looking into using an optical mouse sensor on my SRV too, and I found a "microsoft notebook optical mouse 2.0A" in a drawer... it uses a chip that looks like the adns2610 but I'm not sure it really is. It has the same "sun" pattern  and all, the only thing that differs is that it says "s2083 C0541C" (and not s2610 as I expected) on the top. I can't find any information from this, and I'm suspecting it's the same chip...
 
Does anybody own a adns2610 chip and could confim this please?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding optical mouse sensor for dead reckoning
Reply #9 - 08/11/08 at 9:05am
 
Mine says "A2610 D0704C"
 
There's some really good information about the S2083 on this site -  
    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1154816099/26
 
 
 
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
spikey
YaBB Newbies
*




Posts: 43
Re: Adding optical mouse sensor for dead reckoning
Reply #10 - 08/11/08 at 9:34am
 
datasheet aquired, thanks a bunch!
Back to top
 
 
  IP Logged
Lefteris
Senior Member
****




Posts: 271
Re: Adding optical mouse sensor for dead reckoning
Reply #11 - 08/11/08 at 9:39am
 
Mine says exactly the same with the admin >_<.
 
Actually I read somewhere that almost all cheap optical mice have this sensor in them. I just went into a computer supply store, took 2 old Logitech mice (PS/2) and both have this sensor in them.
 
Here is just one the places you can find the datasheet for this sensor.
 
I had some problems interfacing it with Atmega8, now I am going to interface it with the blackfin and the SRV directly. With the AVR Atmega8 I could write to the sensor's registers succesfully (could turn it from awake to sleep mode or reset it anytime) but could not read. I have no idea why this thing happened. Some people told me it might be the wire was too long ( this thing was supposed to be done onboard the mouse chip with its onboard microcontroller which I so happily killed :p.
 
Or it could be a clock problem. Who knows ...
Back to top
 
 

WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3602
Re: Adding optical mouse sensor for dead reckoning
Reply #12 - 08/11/08 at 10:10am
 
Avago makes quite a range of optical mouse sensors, and I think the ADNS-2610 is a fairly old design, so it would not be surprising to find variations.  I actually bought a few optical mice in hopes of finding one with an ADNS-2610, but did not succeed, so you have more luck with this than I had.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
spikey
YaBB Newbies
*




Posts: 43
Re: Adding optical mouse sensor for dead reckoning
Reply #13 - 08/11/08 at 12:17pm
 
I found this page when I was looking for the chip, it shows alot of different mice from different vendors and what chip they use. Might be handy if you're looking for a special type of chip.
 
I've been trying to get my hands on an adns3060 or adns3080 but they're not available in Sweden, and the shipping from US costs about 10 times the item price, wich makes it feel abit expensive. I've asked Avago for some free samples, but I'm still waiting for an answer =)
Back to top
 
 
  IP Logged
Lefteris
Senior Member
****




Posts: 271
Re: Adding optical mouse sensor for dead reckoning
Reply #14 - 08/14/08 at 1:30am
 
Ok so I guess I should post it in this topic instead of the gcc inline assembly one since it is sensor communication source code related.
 
So here goes:
 
Remember this delay function from the gcc inline assembly topic:
Code:
void delay(u8 value)
{
	//for 250ns value should be around 28
	//should take in mind though all the other calculations
	//happening too, so we could wait for less
	int start= 0;
	int current = 0;
	start = *pTIMER4_COUNTER;
	//*pTIMER_ENABLE |= TIMEN4;
	if(*pTIMER4_COUNTER<start) //we had overflow and timer reset
			current = 4294967295/*2^32-1*/-start+*pTIMER4_COUNTER;
		else
			current = *pTIMER4_COUNTER;
	while((current-start) < value)
	{
		if(*pTIMER4_COUNTER<start) //we had overflow and timer reset
			current = 4294967295/*2^32-1*/-start+*pTIMER4_COUNTER;
		else
			current = *pTIMER4_COUNTER;
	}
	//we are done so disable the timer
	//*pTIMER_DISABLE |= TIMDIS4;
} 


 
Notice that I have commented out both timer enable and disable. Why? It seems to get the microprocessor stuck when I enable and disable the timer in the delay function so I am forced to leave it running all the time after an initTMR4(). If anyone knows why it would be a great help.
 
Now for the main part. Communicating with the sensor. I had managed to do it with an ATMega8 microcontroller. Now with the blackfin it does not seem to go all that well.
 
Here is how I raise and lower clock and data:
Code:
#define	raiseClock()		*pPORTHIO_SET |= 0x2000
#define lowerClock()		*pPORTHIO_CLEAR |= 0x2000
#define raiseData()			*pPORTHIO_SET |= 0x8000
#define lowerData()			*pPORTHIO_CLEAR |= 0x8000
 


 
Tried it with PORTHIO too but reading the manual I saw these registers as more friendly to use.
 
As for the write to the sensor operation:
Code:
void opticalWrite(u8 rAddr,u8 value)
{
	int i = 0 ;
	//we set the appropriate direction to the direction register
	*pPORTHIO_DIR |= 0xC000; //pins 14 and 15 as output
	
	//we make sure the address has '1' as its MSB
	rAddr |= 0x80;
	raiseClock();
	//we send the register's address
	for(i=8;i>=1;i--)
	{
		delay(28); 
		if(isSet(rAddr,i-1))
			raiseData();
		else
			lowerData();
		lowerClock();//SDA is changed on falling edges of the clock
		
		delay(28);
		raiseClock(); //and the sensor reads it on rising edges
		
		
	}
	
	//now follows the data
	for(i=8;i>=1;i--)
	{
		delay(28); 
		if(isSet(value,i-1))
			raiseData();
		else
			lowerData();
		
		lowerClock();//SDA is changed on falling edges of the clock
		
		delay(28);
		raiseClock();//and the sensor reads it on rising edges
		 
		
	}
	//the sensor's datasheet asks for 100us seconds delay between writes. Remember that
	 //when using the function

		
}
 


This should work? Right? Well it does not Sad . Trying opticalWrite(0x00,0x01) which should force the sensor to awake mode(much more bright led) did nothing when with the ATmega8 with the same functions it worked.
 
I would like to ask for your input. Honestly I don't know how to proceed from here. I would also really appreciate tips for debugging embedded code. This summer is the first time I find myself working with such kind of code. It is very very interesting but debugging is hell.  
 
As for the physical hardware connections I checked them and they are correct. Sensor's CLK pin is connected to PH14 and Data pin to PH15.
Back to top
 
 

WWW   IP Logged
Pages: 1 2 3 ... 5
Send Topic Print