Showing posts with label communication. Show all posts
Showing posts with label communication. Show all posts

Sunday, February 14, 2010

Touch Me Please!

Before I dive into this post I take a moment to profusely apologize for the title of the post – it is tragically horrendous.

OK, so now that I’ve got that out of the way, lemme begin. This post is a little out of ‘order’; it would have been more appropriate had I first blogged about how I procured some of the components mentioned in this post. But heck! Lazy as I am, I guess I’ll leave that for a later date.

A friend of mine (un)fortunately busted his laptop several months back. I managed to persuade him to let me scavenge parts from the laptop. What parts did I get? That’ll be the subject of a different post :-D I managed to rescue several components; a touchpad being one of them. And as usual, I went about trying to interface it.

Electronics being my love, and today being Valentine’s Day, it is most fitting that I have successfully managed to communicate with the touchpad. Now before you start making judgements about me, and why I fool about with electronics on this most awesome day, let me tell you how I went about the interfacing.

The touchpad is a mouse replacement ubiquitous on laptops. Synaptics is by far, the biggest touchpad manufacturer. Alps Electric, Cypress, and a few others are also into the touchpad market. Most touchpads today work on the principle of capacitive sensing.

The touchpad of my trusty IBM Thinkpad R51 

The touchpad I scavenged was from an HP Pavilion dv2000 series laptop. The touchpad used is probably manufactured by Alps Electric Corporation (there is a prominent “ALPS” silkscreened onto the back of the PCB). The touchpad is a capacitive sensing type and is controlled by a 48 pin QFP. The chip is marked 1CA026A. I googled high and I googled low but I couldn’t find anything useful; no datasheets, nothing. So it became necessary that I give experimentation a shot.

There is a four wire flat cable (FFC) heading off the PCB. Having fooled about with electronics for a while now, I knew that it was but obvious that the touchpad used some sort of serial protocol. I figured that there were a few possibilities – maybe USB, possibly I2C. Again, I googled to see if touchpads followed a standard protocol. Most sites on the net said that laptop touchpads invariably use the PS/2 protocol, however, none of them said it with ‘authority’. It was always “apparently, touchpads use the PS/2 protocol” or “the PS/2 protocol is used even on laptops”.

Anyway, I thought I’d give USB a try. I used a hacked-together USB dev board, pulled out V+, Gnd, D+, D-, and connected them to what seemed like the appropriate pins on the touchpad. When the error “USB device not recognized” popped up, I reversed D+ and D-. After I still got the same error, I guessed that it was the PS/2 protocol that the device used.

I don’t have a PS/2-to-USB converter so I had to use one of my trusty PICs (a ‘628A is this case) to emulate a PS/2 host. I wrote my own driver basing my ‘read data’ code on something written by Dheera Venkatraman (who has very kindly made his code available online).

I also referred to these sites for info about the timing specs of the PS/2 protocol:
http://www.computer-engineering.org/ps2protocol/
http://www.computer-engineering.org/ps2mouse/
http://documentation.renesas.com/eng/products/mpumcu/apn/reu05b0121_h8s2100ap.pdf

 

Below are a few pics that I took.

tpboard bottom
Right: The touchpad; left and right buttons are on the PCB
Left: Bottom view of the touchpad PCB

The test rig 

Initially, when the touchpad is powered up, it sends 0xAA (‘passed self-test’), followed by 0x00 (which is the mouse ID). The ‘628 then sends the byte 0xF4, which tells the touchpad to stream data, i.e. continuously send any activity on the touchpad or the buttons. Once all commands are received/issued the PIC asserts a pin connected to an LED.

Init The initialization sequence – 0xAA(self-test OK) followed by 0x00(Mouse ID)

Here is my code if you need it. While you are free to modify it in any way you wish without permission, it would be nice if you remember to give me credit. :-D

Video to come up shortly.

Tuesday, January 26, 2010

Main(s) is a Pain

NOTE: Windows Live Write S*CKS! WYSINWYG (what you see is NOT what you get). I used to type out something, and land up with some completely vague formatting! It took me a while to fix this.

* * * * * * * * * * * *

Now who would have thought
that the powerline would be fraught
with difficulties such as these –
from an imbalanced phase
to noisy EMI
it all just seems a maze
to me!

I want to send data, I wish to communicate
betwixt and between two PIC micros -
in short, that's the scene.
How shall I do it? Well that's the debate!

The TDA5051’s the answer to my problems,
but that darn piece of silicon’s elusive, I must say!
I’ve searched Lamington Road, I’ve scoured Lajpat Rai;
drat! I can’t source it! The only recourse left is to pray.

With God on my side, and inspiration high
I sat down with paper and pen.
I scribbled here, pondered there, calculated in mid-air.
Schematics in hand, my proof-of-concept is ready,
I’m gonna TX some 1's and 0's now, Amen!

 

* * * * * * * * * * *

 

WHY in the name of the good Lord would I compose such a poem? The current project that I’m working on entails transferring packets of data bi-directionally from my laptop to an appliance using nothing but the power line that both are connected to. Communication through the power lines - Power Line Communication. PLC.

So why compose atrocious ‘electro-poetry’? People do all sorts of things in frustration. And why write such rhymes? A poet-friend of mine would chide me for writing such stuff. In my defence, my poem composing skills are not much better than a kindergartener; to me, lines in a poem must rhyme (heck, that’s how I used to remember them in KG!).

Anyway, let us set aside my inanity for the time being and note that the power line in India carries 230V RMS at 50Hz (it’s 120V RMS at 60Hz in the US). Devices using the X10 scheme wait for zero crossings of the AC signal to send data. The idea is that when the instantaneous voltage is 0V, there is the least amount of spurious ‘external signal’ on the power line. One bit, modulated by a 120kHz carrier, is sent every zero crossing. Only a single bit at a time can be transmitted, because, understandably, the time for which AC is 0V or near-about, is very short.

Now while this method works (its been implemented in several home automation devices), data rates are abysmally slow (50bps for 50Hz systems, and 60bps for 60Hz systems), and the maximum number of controllable devices is low. There does exist an extended X10 protocol which increases the number of devices supported, but the lack of speed still remains an issue.

A workaround (it isn’t really a workaround, per se; more like the obvious solution :-P) is to send data not just at zero crossings, but at all times. By modulating the data at the TX end and then demodulating it at the receiver, and adding some good error checking schemes, higher data rates can be achieved. The TDA5051 works just like this.

The TDA5051 is a 600/1200bps, ASK, half-duplex PLC modem. It is a complete solution, with an integrated analog front-end, a BPF, a decoder, and a communication module for connection with a supervisor (a microcontroller, or a PC for instance). Only a few additional external components are required.

This is all very nice and dandy, but for the misfortune that I just can’t seem to get my hands (well, tweezers actually – it’s a small chip) on a TDA5051.

So how did I get around the problem of the hard-to-find TDA chip? Simple – I rolled my own modem :-D . OK, OK, I’ll come clean. I haven’t yet built it completely, but I’m working on it. The basic testing that I’ve done seems most promising.

 

The steps involved at the TX end are:  

PLC tx TX side block diagram

*        generation of a data carrier (38kHz PWM from a PIC16F628A)..…1 38kHz PWM

38kHz PWM @ 18.5% duty, from the CCP module of a ‘628. In retrospect, I should probably have used a 50% duty cycle.

 

  

*         the data itself (300bps UART data) …..2 UART   

The graph is annotated. UARTs idle high; start-bit is low; data is streamed LSB-first; stop-bit is high, followed by idle-high.

 

 

*       modulating the carrier using the data (gating using NAND logic)…..3 Data

The final Boolean output is

(UART) AND (PWM)

 

 

*       coupling the modulated signal to the power transformer (through a 0.1uf ceramic)…..4 xfrmer

Waveform on the mains side of the transformer; secondary side is loaded with an LM317-based power supply. The waveform is probably not sinusoidal due to the 18.5% PWM duty.  

 

 data comparePWM compare
Left: raw data and its modulated inverse, juxtaposed for comparison
Right:
38kHz PWM and the transformer output viewed with the same timebase - 20us

 HardwareThe test setup

 

 

At the RX side (test data and pics will be up soon):

 plc rx

RX side block diagram

*         a transformer steps down the voltage…..5

*         a high pass filter removes 50Hz mains…..6

*         this is fed to a squaring circuit (made by NAND logic)…..7

*         the squarer drives an IR LED…..8

*         38kHz bursts are beamed at a TSOP1738 which demodulates the carrier…..9

*         the data is then fed to a microcontroller for further processing…..10

 

Using a TSOP1738 IR detector for demodulation – I admit that’s pretty smart even by my standards :-P I bet the chaps at Vishay never intended the TSOP to be used like this :-D

Tuesday, October 28, 2008

The Party Never Ends

I guess this is my first non-electronics post. Sorry, I can’t help it. I obsess about things; electronics is one of them. Most of the other stuff I think about is either too personal or rude to post to a blog. I’m not the kind of chap who would post his life on a blog. Hell, I barely tell my friends everything. Do I want to be all dark and mysterious? Do I want people to keep guessing about me? Nah, that’s not it. Its just that I don’t voice my feelings too often. This has a flipside though. Not telling people what you feel can have either of two equally bad consequences. The first being that people think you’re deliberately hiding something from them; they get angry with you – “why can’t you be more open?”, or, “Hey, why don’t you talk to him/her/them about it. It’ll be good for you.” And the second penalty that you may need to pay is that you don’t learn how to communicate with people.

I can communicate with people at an intellectual level pretty easily. Its just that things get tough for me at the personal level. Parents, sis, relatives, friends, crushes – well, with each category of individuals, the situation is different. Naturally, you would understand that with each group of people you would have different things to talk about. So what is it that makes it so hard for me to communicate with others? The raw answer – I don’t have the faintest idea! But I’ve introspected several times. Vaguely, I would say that it’s probable that I feel it’s better to let bygones be bygones, or that the matter of concern is too trivial to bring up and sour the conversation. So do I forget about the problem? Hmm, Yes and No. The thing is, that the particular group that I’m having the problem with has got to help me with that problem, for me to tide over it. So what’s the difficulty? My ego. Most of the time I’m too proud to admit I'm in a ‘situation’ and I need help. I can offer some advice – the only group that can effectively help you out with the problem you’re facing is the very group you have the problem with. This puts you into a right spot. How the eff (yes, that’s a four-letter all-purpose sentence modifier. It’s a wonder grammaticists haven’t included this ubiquitous word into the English lexicon as one kind of ‘god-word’, capable of doing anything and meaning anything!). So again, how the eff are you supposed to talk to the very people you just dissed (Google that) or with whom you have a problem? Umm, don’t ask me; that’s entirely your problem; see, I d-o-n’-t t-a-l-k a-b-o-u-t p-r-o-b-l-e-m-s.

There was recently one time I did. And I can tell you, it’s been the most rewarding thing. As with a lot of guy-problems, this one too, was created and promulgated by none other than a member of the fairer species. They are so different from humans that I consider them a completely different species. (I may have added certain justification here for this, but since this blog is in the open domain, it may be construed as rude)by some right-wingers). I had a humongous crush on this girl. And, as most crushes are prone to do, it created problems for me. Lots of problems. Many many problems. Super-big problems. I’ve run out of adjectives. I used to think of this girl day and night, putting myself (and her, of course) in fantastic and fabulous situations, and I would come to her rescue; be her proverbial knight-in-shining-armour.

What came of that relationship? Nothing. Zip. Zero. The only thing I walked away with was a brilliant friend, who understood me, and who has stood by me. She continues to do so, and I am proud of that. A few nights back I talked to this girl, and told her everything, right from how it started. We laughed about all the silly little things we did. I have many amusing anecdotes, which I promised her, would contribute to the central story of my debut romantic-comedy movie, if my engineering career bombs. It was very comforting talking to her, and I understood now why I had liked her so much. The brilliant thing is that we were both so comfortable chatting with each other – there was nothing put on or stilted about the conversation. No awkward silences. Just simple, joyous freely flowing emotions between good friends. I guess talking to her was liberating in some kind of way, and I still have a soft spot for her. That I could still talk to someone who I had such a deep crush on, and though things didn’t work out, yet be at total ease, is what I would call one of life’s little miracles.

You should try it out some day. It’s superb emotional therapy. Forget the psychologist or counselor. Your best friends are your best counselors.

Note to the aforementioned girl, if she happens to go through this blog: Drop me a mail or an offline, please, telling me what you think. Thanks for everything. You are a gem of a girl, and you can always count on me. I’m just a phone call / SMS / mail / offline away :-) .

My current Gtalk status message is

“‘Life isn't black and white, it’s in various shades of grey”, people say. But my life is 32 bit true colour!”

Live life to the fullest – it’s too short. You know how sometimes you’re so busy organizing something that you forget to enjoy the party? What do you do then? Has it all been lost forever? I don’t think so. Almost all parties have an after-party, where you can sit and savour the fruits of your hard work. You have all the time to figure out what went wrong during the party, and think of what you could have done to fix it. The problem is – you can’t fix it anymore. The party’s over! So instead of wasting time thinking of how to fix stuff that can’t be fixed, have no regrets for what you did. Yes, there may have been things that you did wrong, or things that you could have done better. So learn from those mistakes. Take with you only the experience and knowledge you got from the party. Yeah, and don’t forget to remember the fun – that’s what made it a party in the first place, right?

Visitors