So, I have salvaged a trackpad from a insignia keyboard attachment for tablet. When I looked at the back of the board for part numbers, pins, etc. I found 4 copper dots labeled: VDD, GND, SDA, SCL. I then carefully soldered wires to the dots, being careful not to overheat the board.
Then I connected the board to my arduino uno using the following connections:
- VDD - 5v
- GND - GND
- SDA - SDA
- SCL - SCL
After making the connections, I loaded the basic i2c scanner code onto my uno and found that my touchpad's address is 0x10
Here is where I am stuck: How do I retrieve the board data?
Here are pictures:
Can you take a better picture of the chip? and/or just post the details.
@red_car The chip number is:
eKT2101
If you can find an open source driver for it, you may be able to translate that to the Arduino.
Can you give a few examples of drivers, please?
Check if there are Linux drivers provided from the manufacturer.
Also, this may help 9. Elantech Touchpad Driver — The Linux Kernel documentation
If you can get the data sheet on this chip then you will have all the information you need to be able to write a driver. There is no need for there to be one available on open source. After all how do you think the existing drivers were written?
The data sheet will tell you what structure the I2C interface has. Then all you do is to access the I2C bus in the same way.
Note a touch sensor might contain a lot of date that sets parameters, thresholds and options. They will be described in the data sheet.
So, how do you write a driver? And also I'm having a hard time understanding the datasheet........
I think you may have bitten off more than you can chew on this one... this is not a trivial undertaking if you don't have this kind of experience.
Ahh, ok. When i saw the i2c pins, i thought it would be easy, but.....
You look at the data sheet and see what registers need to be set to what values and then write the code to do that.
Sadly the Arduino experience leads you totally unprepared for this, because of all the libraries that do totally trivial things. The attitude of "why should I reinvent the wheel" leaves you with the inability to invent anything.
Have you looked at many data sheets? Again the use of trivial libraries often leads a beginner into not being able to read one.
The trick is in knowing what to read and what to ignore.
For example you don't need to read the section 4.1 because that is about the SPI interface and you want to use I2C. Then section 4.2 is about the I2C interface, which is all standard stuff about how the chip uses the I2C interface. Again this is just the standard stuff about how the I2C works and is totally compatible with the Arduino so again not much you need although it tells you the default address is 0x10, which you already found from the scan you did.
You don't need to know about changing the I2C address so don't bother with that bit.
So start by reading page 5 about the basic operation of the device. Then read section 7 about how to talk to the chip. The big takeaway from this is
After the initial process, it will send “Packet Hello” to let the host know that the touchpad is ready to work.
So I would start writing that. Read and print the message on restart using the normal I2C methods.
Then the next big section for you to understand is section 11. This tells you what to send and what you will receive. Note here that what you get back is a 32 bit value, so that means you will need to receive 4 bytes from your I2C request. Don't get too fancy just try and see if the messages you get back make sense.
That way you can explore the capabilities of the device and develop some code to talk to it. Don't bother trying to make this into a library at this stage, just get your code doing what you want.
2 Likes
Thanks for all the help! I will try what you suggested. (And no, i have not looked at many datasheet)
So, I am stuck again.
I am using the following code:
#include <Wire.h> //include wire library
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
Wire.requestFrom(0x10, 4);
if(Wire.available())
{
char rcvData = Wire.read();
Serial.println(rcvData);
}
delay(1000);
}
It is only giving me a "P" whenever my finger is on the pad and a "p" when a button is pressed. Do you know what I am doing wrong?
You are not setting the register in the sensor that you want to read from at all. That involves first sending the information to the sensor that will select the correct register to read from, and only then request the sensor sends you data.
Also, most touch sensors need quite a bit of setting up, with thresholds and the like that you have to do in the setup function or when you instantiate the library you are looking to write.
Have you got the data sheet for this device?
If so can you please post a link to it?
For an idea of what this initialisation involves, see the library designed specifically to work with the MPR121 chips, breakout in the Adafruit shop.
https://www.adafruit.com/products/
Along with the examples given in this library.
Yes this is a different touch sensor to the one you have but by looking at the code you will see the sort of stuff you need to prime the chip in order for it to work.
1 Like
Ok so I asked you to:-
Did you do this? I can't see that in the code you posted.
The data sheet says:-
After the touchpad is powered on, this controller will do initialization. The initialization includes MCU and analog parameter initialization. After the initial process, it will send “Packet Hello” to let the host know that the touchpad is ready to work.
So in the setup function you should receive this start up message. Until you do that successfully there is no point in doing anything else. Packet Hello is defined at the top of page 27.
I forgot about that. So, just to be sure, I have to send the device this code to recieve packet hello, right: 0 1010101 01010101 01010101 0101010 1
This is my first time writing a driver on a device, so sorry for the question overload.
No, you don't need to send anything you get sent this message on power up.
So, how many bytes should I expect to receive? It's fine if you don't know, it's just that the following code isn't working and I'm not sure what to do:
#include <Wire.h> //include wire library
void setup()
{
Wire.begin();
Wire.requestFrom(0x10, 10);
if(Wire.available())
{
char rcvData = Wire.read();
Serial.println(rcvData);
}
Serial.begin(9600);
}
void loop()
{
Wire.requestFrom(0x10, 10);
if(Wire.available())
{
char rcvData = Wire.read();
Serial.println(rcvData);
}
delay(1000);
}