Author Topic: PAN31010A optical mouse sensor  (Read 5507 times)

0 Members and 1 Guest are viewing this topic.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
PAN31010A optical mouse sensor
« on: April 03, 2008, 02:38:32 AM »
finaly i baught a cheap optical mouse and i did open it and got this sensor ,,,checking google i found the datasheet of
PAN3101 ,,it should be the same right? i dunno what the 0A stands for ...
anyways reading through the datasheet about the serial interfacing the chip has 2 wire serial interface
SDIO for data
SCK for clockin
apparently this is not the same protocol as I2C or TWI(in avrs) so i have to build the protocol by software.
no problem.
the problem is they didnt mention an optimal frequency to work with
,,would this chip work at whatever freq thatt the micro supply at SCK?

some minimum times is mentioned for some operation,,but still no clue about serial clock freq.

anyone has an idea?
good ol' BeNNy

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #1 on: April 03, 2008, 03:37:51 PM »
well forgot to say that the sheet says maximum serial clock freq is 10MHZ
im afraide i cant get this chip a 10 mhz , i can offer less
and they didnt mention anything about minimum freq !!!!!!!
good ol' BeNNy

Offline AndrewM

  • Robot Overlord
  • ****
  • Posts: 254
  • Helpful? 0
    • I Am.  When?
Re: PAN31010A optical mouse sensor
« Reply #2 on: April 03, 2008, 09:22:17 PM »
Is this a pixart chip?  That's the only datasheet I could find off google.  Anyway, it looks like the SCLK pin is used to set the frequency that will be used for serial communications with your MCU and is only used for the communications timing.  If that is the case, which I am 98% certain it is, then you can go below 10MHz, just not above.  Just make sure you match the timing on your in/out pins on your mpu to match.
blog: www.iamwhen.com
Saving the world from humanity one robot at a time.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #3 on: April 04, 2008, 03:51:42 AM »
mm yea i thought the same, and yea its a pixart chip ,,
now i got another thing to worry about

my micro electrical char

VIH = 0.6*VCC =0.6 * 5 = 3 volt
VIL = 0.2*VCC =0.2 * 5 = 1 volt

the PAN3101 el;ectrical char

VOH= 2.4 v   (PROBLEM OCCURED as 2.4 < 3 )
VOL=0.6 v  (no problem as 0.6 <1 )

that means when the PAN3101 is going to output HIGH (1 LOGIC)(2.4 V) the micro may couldnt read it as HIGH(1 LOGIC)

any solution??

i though of using an ATmega8L ,the L stands for LowPower so i can power it with 4 volts
and i get VIH=0.6 * 4 = 2.4 v  ;D
it also will keep the VOL working as VIL = 0.2 * 4 = 0.8  (0.6 < 0.8)
good ol' BeNNy

paulstreats

  • Guest
Re: PAN31010A optical mouse sensor
« Reply #4 on: April 04, 2008, 05:13:41 AM »
The communications does look like i2c, just without the ACK bit in the transfer protocol. the reason i mention it is because most i2c devices cant pull the data or clock line high enough and so you use pull up resistors on the lines. It will still be able to drive the i/o line low and when its transmitting a 1 or high bit the pull up resistor does the work of increasing the voltage.

It also means that in your communication protocol, you dont set the ports to high, you just dereference them (set them to input), that way you can monitor the slave device and wether it is holding the clock line (i dont think this is an issue with your device though)

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #5 on: April 04, 2008, 07:53:38 AM »
i dont think i can use I2C with this as the r/w bit is the first transmitted in the sensor protocol while it is the last one(of the address byte) in I2C .

VOH for sensor means that when the pin is OUTPUT it outs a voltage of 2.4
even if you have a pull up res on the microcontroller side (input) it wont putt it up to vcc because the 2.4 v comes from an OUTPUT pin.
thats what i suppose,,,, arnt i right?
good ol' BeNNy

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: PAN31010A optical mouse sensor
« Reply #6 on: April 04, 2008, 10:29:26 AM »
Ok, so here you have the microcontroller pin tied through a rezistor to Vcc. The microcontroller will read +5V. Now you connect the sensor that when it is an Output will put out a High or Low voltage. If it is High, the 2.4V voltage will pull the microcontroller's pin towards that value, but the pull up rezistor will not let it go that far, so it will settle somewhere between 2.4V and 5V, mos likely higher than 3V that you need to read a High logic signal. If it is Low, the microcontroller pin will be pulled to the ground and the voltage will settle under 1 volt. All clear now?
Check out the uBotino robot controller!

paulstreats

  • Guest
Re: PAN31010A optical mouse sensor
« Reply #7 on: April 04, 2008, 12:18:35 PM »
Also, it is worth trying i2c directly. the standard protocol doesnt matter you can use :

i2cputByte((char)0b00000001)

or

i2cputByte((char)0b10000000)

it only sends the byte data that you tell it to

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #8 on: April 04, 2008, 12:23:59 PM »
Quote
but the pull up rezistor will not let it go that far
why not? wouldnt it be like this?

+5v --------/\/\/\/\/\--------(micro pin & sensor out)

so its the same node, i suppose the current will be (5 - 2.4)/R
this current will get out the micro pin towards the sensor out
actually its very low as the R for the ATmega is about 100kohm

am i wrong?
 
is it you are saying i should put a resistor between the micro in and sensor out?
this way would work to increase the voltage from 2.4 to 3 for example but it would increase the LOW voltage as well
so this isnt a good way to solve this
plus im not sure if such a resistor would affect the serial communication speed.
good ol' BeNNy

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #9 on: April 04, 2008, 12:28:00 PM »
Code: [Select]
i2cputByte((char)0b00000001)
can you tellwhat  this function does in hardware ?
like how is the form of signal transmitted?

doesnt it send only this byte?no additional bits for synch,error,,,,etc ?

and in what library can i find it?
im using codevision as a compiler and not sure if i have this library,
i would be glad too if you can post how this function works,(the code inside it)

thanks a lot
good ol' BeNNy

paulstreats

  • Guest
Re: PAN31010A optical mouse sensor
« Reply #10 on: April 04, 2008, 01:32:18 PM »
the i2c functions are usually part of a header file called i2c.h if you look at the standard header folder for the compiler that you use you probably find something like it. Open the file and see what functions are defined.

if you wanted to make your own functions for this like bit banging style you would do something like:

Code: [Select]
i2cputByte(unsigned char byte)
{
signed char i;

for(i=7; i>=0; i--)
{
PORTB.0 = 0; //send clock low


                                SDA_DIR = ((byte>>i)&0x01);
                                if ((byte>>i)&0x01) {                            // bit to send
PORTB.1 = 1;                                       //place data line high
                                }else {
PORTB.1 = 0;                                      //place data line low
                                }
DelayUs(I2C_TM_DATA_SU);
TRISB.0 = 1; //float the clock so it gets pulled up to 5v through resistor

while(PORTB.0 == 0){ // see if device has held the clock low - and wait for it.
}                      

Delay(whatever) //put in a delay so you are not exceeding the i2c bus limit
                                             
                               
}

return FALSE;
}


The above would be to bit bang sending 1 byte over the 2wire bus using portb.0 as the clock and portb.1 as the data. Obviously the transfer needs initiating first, this is usually done by setting the data line high and clock low and then setting the clock high, then the data low (starting and ending the transfers are the only time that the data line state should change if the clock is high)

 I would really look into using the actual ssp buffer if you have it available on the mcu though and standard header functions otherwise it might get to be a bit of a headache.

p.s. The pull up resistors do slow the 2wire data transfers down, that is why they have speed limits on them. you should place one for each wire, the data wire and the clock wire. From memory i think the most efficient to use is 1.45kohm  the higher the resistance the slower the reaction time. but too low resistance might affect the actual communication.
« Last Edit: April 04, 2008, 01:43:45 PM by paulstreats »

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: PAN31010A optical mouse sensor
« Reply #11 on: April 04, 2008, 02:34:16 PM »
well this way (bit banging) is like teaching the micro how to do i2c ,if i want to use i2c then i would use the TWDR and the TWINT .
there is no point in building an i2c function like you did,,
if i want to do bit banging which i would prefer for this case then i would build it depending on the sensor serial format not i2c protocol.
so about the pullup resistors, i2c devices pins takes wether 0 volts or tri-state, when both are tristated then the pull up resistor
pulls the line up to 5 volts, this is not the case here as the sensor outs a voltage which is 2.4 volts so this would never be left up to 5 .
so i dont think there is a need for pull up resistors, but anyways i will use the micro pull up resistors when i put the pin as input.

what i was just saying is when i make bit banging i would choose 2 pins that can be pulled up internally.

thanks for your code anyways it would help me building my sensor functions.

if there are any notes i would be glad to hear about
good ol' BeNNy

 


data_list