Bongofish
December 17, 2017, 05:10:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can attach photos hosted by the forum rather than using an external image hosting site, this means they will stay forever and not disappear after a year or two.
 
   Home   Help Search Login Register  
Pages: 1 [2] 3 4
  Print  
Author Topic: Converting Wacom KT-0405-R from Serial to USB  (Read 32547 times)
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #15 on: January 09, 2012, 06:24:35 AM »

Next thing to try in RealTerm: check your the max resolution reported by the tablet.

Configure with 2540 DPI.

Put the display in Hex+space and have the data frame size set to 7 Bytes.  Move the pen randomly. Each line in RealTerm should match 1 packet and should look something like:

E0 25 08 00 1B 4F 40

(If stuff appears miss aligned, click the "Gulp" button a few times until it is aligned.)

Now put the pen on the active area and move it slowly towards the right side until the pen is completely out. The idea is to catch the biggest X coordinates we can get. The last packet should contain a number close to that.



Logged
Manni
New Poster
*
Posts: 19


View Profile
« Reply #16 on: January 09, 2012, 11:05:27 AM »

Just to be sure the tablet really works with 2540dpi I tried it with 1270 and 2540:

Moving in at upper left corner:

@1270dpi:                        @2540dpi:
E0 01 6C 04 00 0A 4D             E0 06 63 04 00 4C 52
E0 01 72 04 00 0F 4D             E0 06 6D 04 00 56 52
E0 01 78 00 00 14 4D             E0 06 77 00 00 5E 52
E0 01 7D 04 00 19 4D             E0 07 01 00 00 68 52
E0 02 03 04 00 1D 4D             E0 07 0C 00 00 70 52
E0 02 09 04 00 21 50             E0 07 18 00 00 7A 52



Moving out at lower right corner:

@1270dpi:                        @2540dpi:
E8 30 60 0C 25 24 5D             E8 63 7D 0C 49 08 56
E8 30 66 0C 25 2A 5D             E8 63 7D 0C 49 09 56
E8 30 6C 0C 25 30 5D             E8 63 7E 0C 49 09 56
E8 30 72 0C 25 36 5D             E8 63 7E 0C 49 0B 56
E8 30 79 0C 25 3A 5C             E8 64 00 0C 49 0D 56
A0 30 79 00 25 3A 00             A0 64 00 00 49 0D 00



If my interpretation of http://libvncserver.sourceforge.net/qemu/wacom-progman.pdf is correct, the two last lines before leaving the active area in the lower right corner can be decoded like this:

2540dpi: E8 64 00 0C 49 0D 56
E8 = 11101000 => x15...x14 = 0 => x15...x0 = 006400 = 25600
0C = 00001100 => y15...y14 = 0 => y15...y0 = 00490D = 18701


1270dpi: E8 30 79 0C 25 3A 5C
E8 = 11101000 => x15...x14 = 0 => x15...x0 = 003079 = 12409
0C = 00001100 => y15...y14 = 0 => y15...y0 = 00253A = 9530


So as one would expect, the values for 2540 are about 2x the values for 1270. I just wanted to make sure the tablet really accepts this dpi value.

Do you want me to do some more extensive testing to find even more max values or is it just to cross check it with other 4x5 tablets?

But: The x and y values seem to start at 0 in the upper left corner, don't they? There's something about it that I don't understand: With a width of 5 inch and 2540dpi the max value should be about 12700 but not 25600. Same for the height: 4x2540 = 10160 but why does the tablet report 18701? Am I missing something?
« Last Edit: January 09, 2012, 11:37:07 AM by Manni » Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #17 on: January 09, 2012, 04:51:55 PM »

But: The x and y values seem to start at 0 in the upper left corner, don't they? There's something about it that I don't understand: With a width of 5 inch and 2540dpi the max value should be about 12700 but not 25600. Same for the height: 4x2540 = 10160 but why does the tablet report 18701? Am I missing something?

If my experimental results over here are correct, there is an unclear relationship between the raw values contained in the pen position packets sent out by the tablet to the x/y points on the screen as interpreted by the Wacom driver.  So it could very well be sending out high raw values that actually correspond to 12700 X.
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #18 on: January 09, 2012, 06:18:44 PM »

Yes, x and y are 0 in the top left corner.  Yes, you missed something. In the serial protocol only 7 bits are used and you got it wrong when shifting the bits. It works. See below.

The ~C always seems to report the same values (the ones for 1270 DPI)?

6400 / 1270 DPI = ~5.04 inches
4800 / 1270 DPI = ~3.78

At 2540, we would need to double the counts in theory:

12800 / 2540 DPI = ~5.04 inches
 9600 / 2540 DPI = ~3.78

Here's the decoding logic (code from WaxBee http://code.google.com/p/waxbee/source/browse/WaxB_Adb2Usb/protocol4_serial.cpp):


penEvent.x =                 buffer[2] |
                (((uint16_t) buffer[1]        ) << 7) |
                (((uint16_t)(buffer[0] & 0x3) ) << 14);

penEvent.y =                 buffer[5] |
                (((uint16_t) buffer[4]        ) << 7) |
                (((uint16_t)(buffer[3] & 0x3) ) << 14);


If we decode one of the packet:

                  buffer: 0  1  2  3  4  5  6
For your 2540 dpi packet: E8 64 00 0C 49 0D 56

Computing X:
buffer[2] (00)                            00
buffer[1] (64) << 7                     3200
buffer[0] (E8) & 0x3) ) << 14)          0000

Total gives out 0x3200 or 12800 for X

Computing Y:
buffer[5] (0D)                            0D
buffer[4] (49) << 7                     2480
buffer[3] (0C) & 0x3) ) << 14)          0000

Total gives out 0x248D or 9357 for Y.   


...Close enough to the theorical max 9600. Normal since it is very difficult to get into
the exact corner location. (typically you would do the right side
and bottom side separately instead of trying to "aim" at the corner).

Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #19 on: January 09, 2012, 06:29:16 PM »

..so looking again at the code, most of the stuff will work -- but there is a little hickup: the code will probably recognize ROM 1.3 correctly and act correctly (no TILT support). BUT it will not recognize "KT" (looking for a "U" instead of a "K"). It will refuse to go beyond the initialization stage. This can be fixed very easily. Once you get there, I will make another version to support KT (and if I have time, test with my CT-0405-R)
Logged
Manni
New Poster
*
Posts: 19


View Profile
« Reply #20 on: January 09, 2012, 08:23:48 PM »

Oh! It's 7 Bit! Well, I never thought about this and never looked at that very closely or else I would have noticed that 16 bits don't need two and a quarter bytes... Shame on me! I never thought that this could be the case since the first bit in the first byte is used and set to one. Well, they probably use(d) it for syncronisation.

There's no need to rush, the Teensy will take some more days to arrive...
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #21 on: January 09, 2012, 09:47:24 PM »

You got it: the high bit is exactly for that. Only set to 1 in the first byte of the packet for synchronizing purposes (and this is how WaxBee synchronizes as well).  This 7 bit encoding, I think, is the main reason why the USB and serial protocol are encoded differently.
Logged
Manni
New Poster
*
Posts: 19


View Profile
« Reply #22 on: January 25, 2012, 10:27:25 PM »

Just a short update: the Teensy has arrived and now that I have all the necessary components at home I can start building a small PCB. I will post some photos as soon as it's all working. Let the soldering begin!
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #23 on: January 26, 2012, 04:09:02 AM »

Go in baby steps and test anything you can at each step. First the ground, then the power, only after that you can start playing with the serial signals.
Logged
Manni
New Poster
*
Posts: 19


View Profile
« Reply #24 on: February 04, 2012, 07:56:26 PM »

After some minor problems (old oxidized PCB, lead free solder, not enough time, ...) I finally finished it. Well, I'm not really sure if it's working, yet, or if it's really finished but I don't want to spoil this evening by trying it. Smiley Ok, I have to admit that I have connected the Teensy to USB. Just to see if it all goes up in flames. It didn't. And it's still blinking.

So, here are a few photos of today's work. It's not my best piece of soldering work but the PCB does only look so bad because I had to replace the "precision socket" I used first with some other parts where the Teensy would really fit...

Note to myself: Always try the socket before soldering!


* Teensy1.jpg (164.19 KB. 1000x590 - viewed 523 times.)



* Teensy2.jpg (144.89 KB. 1000x491 - viewed 414 times.)



* Teensy3.jpg (179.58 KB. 1000x483 - viewed 511 times.)



* Teensy4.jpg (118.03 KB. 1000x735 - viewed 500 times.)



* Teensy5.jpg (99.62 KB. 1000x527 - viewed 491 times.)


I don't really think I'm done now but I think I will give it a try without DTR.


Logged
Dragon
Full Member
***
Posts: 121



View Profile WWW
« Reply #25 on: February 04, 2012, 08:11:39 PM »

Very cool.  Can't wait to see if it works!

That's neat how you used solder to bridge between pins underneath.  I've always used little wires for that, which is a little annoying having to strip their ends and hold them in place so carefully.

Lead-free solder...  That was the bane of my existence before I realized why I could almost never get it to melt or stick to anything!
Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #26 on: February 05, 2012, 01:00:46 AM »

To know if we need to connect the handshaking signals (DTR and others) is a question of pull-ups/pull-down -- often these RS-232 drivers have an internal pull-up (or down) on the "input" side.  That is why I needed to ground a couple of pins after the removal of the driver.  So what you need to check out (for the theory at least) is read the datasheet of the rs-232 driver that's inside your wacom (not your max232 driver)  and find out about pull ups (if any). Then compare the signal that you are supposed to get and check if you are getting a ground signal on the other side of the driver (inside the wacom).

I realize that was not very clear. But with a little luck you might have followed me.
« Last Edit: February 05, 2012, 09:10:30 PM by bernard » Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #27 on: February 05, 2012, 04:53:39 PM »

@manni:  btw, in case you missed it, there was a waxbee release for support for you and your KT tablet (version 0.11+). It was never tested (you're the guinea pig), but at least it works "on paper".
« Last Edit: February 05, 2012, 09:09:32 PM by bernard » Logged
Manni
New Poster
*
Posts: 19


View Profile
« Reply #28 on: March 02, 2012, 07:50:55 PM »

I've been busy for a while but today I wanted to finally get it to work. Unfortunately I did not succeed. Sad

I've programmed the Teensy from with the configuration template for my tablet and I installed the Wacom driver for Intuos2 tablets. Unfortunately nothing happened. I then remembered that I did not connect DTR and RTS because I wanted to try if it would work without them. As it seems it does not work.

After a few minutes DTR (pin4) and RTS (pin 7) were connected to pin 2 of the MAX232, because this should be the pin that has +8.5V. Strange: with my multimeter I can see that there is only 4.65V, just like the USB power... Huh Using a second MAX232 did not change anything.

I don't know if it's the low voltage or some other mistake I made in my design, but the result is still the same: no working tablet. The tablet's LED lights up and changes its color when I tap the stylus on the active area, so I don't think it's the tablet that is not working, it has something to do with the configuration or the RS232 signals.

Windows does recognize the tablet (or better: the Teensy + Waxbee). USB View shows me something like this:

iManufacturer:        0x01    0x0904: "WACOM"
iProduct:             0x02    0x0904: "XD-0405-U - WaxBee emulation"


With the debug configuration template and hid_listen I only get this:

WaxBee -- bzz! bzz!
Serial/ADB tablet to USB converter.
 slaveXMax:12800 slaveYMax:9600 usbXMax:12700 usbYMax:10600
protocol4_serial::init()


I also used my (very simple) logic tester: About 1s after powerup I can see - as expected - some very short activity on TxD but there is no activity on RxD. TxD activity can be seen on both the TTL side and the RS232 side.

Any idea about what to try next?
« Last Edit: March 02, 2012, 08:58:48 PM by Manni » Logged
bernard
Administrator
Hero Member
*****
Posts: 2584


pato mania


View Profile
« Reply #29 on: March 03, 2012, 01:36:53 AM »

Remember that the two serial handshake signals (DTR and RTS) are required to be "active" for the tablet to talk.

Those signals are active low, it means that they must be "grounded" on the TTL side.  On the RS-232 side it needs to be a "positive voltage" (like VCC) if I recall correctly. If you do not do this, the tablet won't output anything.

The Teensy does not deal with these (it is not needed since the teensy is fast enough) and connecting to a MAX232 chip will not do anything other than converting the signal from RS-232. It will not activate it (although some line drivers activate or deactivate them by default via internal pull-ups or pull-downs, but I see nothing in the MAX232 spec that would infer that).

When we say TxD and RxD it is not always clear which side is which.  You said you saw activity on TxD -- is this coming from the tablet when you move the pen?

There is another thing you could try. Is to reprogram the teensy to be a virtual serial (COM) port and talk directly to the tablet using a terminal software like RealTerm.  check this post: http://forum.bongofish.co.uk/index.php?topic=1930.msg16413#msg16413  -- try with the different baud rates until you think you've gotten one that the tablet responds. Typically it is 9600 bauds as initial speed (can sometimes later be augmented, that depends on the tablet).

For the MAX232 voltage, maybe you did not correctly setup the capacitor charge pumps?
« Last Edit: March 03, 2012, 08:02:55 AM by bernard » Logged
Pages: 1 [2] 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!