Touch sensing i2c chip

JamesyHutton

New Member
I have recently purchased this chip from digikey: http://www.cypress.com/?docID=44403
I am using the 8-pin SOIC CY8C20142 found in figure 3.

I have it all set up on a SMD to DIP adapter with 4.7k pull up resistors on the SDA and SCL lines going to pin 11 and 13 of my 20x2 picaxe.

I am trying to make a simple touch slider.
I have successfully gotten it to work using a 14m2 chip using its built in touch function and 2 of its pins.

However, the 20x2 does not support touch, forcing me to use this external chip.

I have some VERY minor experience using i2c, however after going through the datasheet as much as possible, I am realizing that I am going to need help to get this working.

Would anyone be able to give me a bit of sample code that would get the chip talking to the picaxe?

All I need is for the picaxe to be getting the values of the touch sense electrodes just like it would using the normal touch command of the m2 versions.

If I could have the values ranging from 0-255 being updated into b0-b3 (for the 4 touch sense pins) I would be able to figure out my way from there.

Thank you all!
 

hippy

Technical Support
Staff member
It looks like a rather complicated chip but the best way to start is by trying to read a register that contains a value other than $00/$FF and check that it is as expected.

The CY8C20142 claims to have device address "42" then perhaps read STATUS_HOLD_MSK0 ($0E) to see if it holds or $03 or $1F ...

HI2cSetup I2CMASTER, $42, I2CSLOW, I2CBYTE
Do
HI2cIn $0E, (b0)
SerTxd( #b0, " " )
Pause 1000
Loop
Loop
 

matherp

Senior Member
Hippy or Technical: Which if any of the picaxe chips support clock stretching which this chip seems to rely on to work best?

James: Why not use another picaxe to do the touch input and nothing else and then send the data continuously via serial to the 20X2. You can use background serial receive on the X2 to get the data which can then be used as and when by your main program. I've done a lot of i2c work but this chip does look at the top end of complexity - the dual picaxe route would probably be simpler.
 

hippy

Technical Support
Staff member
Hippy or Technical: Which if any of the picaxe chips support clock stretching which this chip seems to rely on to work best?
I would have to pass on having a definitive answer. Clock stretching would be part of the PICmicro hardware functionality and I believe all latest PICAXE do support it but would have to check the individual datasheets.

If the hardware did not support it then I2C could be bit-banged which would.
 

westaust55

Moderator
It looks like a rather complicated chip but the best way to start is by trying to read a register that contains a value other than $00/$FF and check that it is as expected.

The CY8C20142 claims to have device address "42" then perhaps read STATUS_HOLD_MSK0 ($0E) to see if it holds or $03 or $1F ...

HI2cSetup I2CMASTER, $42, I2CSLOW, I2CBYTE
Do
HI2cIn $0E, (b0)
SerTxd( #b0, " " )
Pause 1000
Loop
Loop
at page 7,
I2C Device Addressing
The device uses a seven bit addressing protocol. ....


That i2c slave address of $42 = may also need a 1 bit left shift to become $84
 

hippy

Technical Support
Staff member
That i2c slave address of $42 = may also need a 1 bit left shift to become $84
I discounted that as the entry for reading the DEVICE_ID register ($7A) shows values which could be $42/$40/$60/$80/$10 depending on chip variant and one wouldn't shift $80.

The ID value would have been more immediately clearer if the Device IDs table in the datasheet had indicated the values were hex and not decimal.
 

Rick100

Senior Member
Last edited:

JamesyHutton

New Member
Thanks for all the responses! I didnt realize how out of my league this chip was.
I think what I am going to do is just order some 28x2's which I believe do support touch.
I think that is my best option.

Which kind of brings up a point. I am wondering why on the picaxe shop page for the 20x2 it says it has "11 analogue/touch sensor channels". I realize this is more of a copy and pasted sentence throughout all the different chips, but it is a little misleading.
I bought a few 20x2's thinking they did support touch because of this, and I only found out they didn't support touch when I looked at the "applies to" list in the TOUCH command page.

So I'm left with 1 last question. The final goal is to make a scroll wheel that will dim a light using pwm. (Like the original ipods)
It needs to be extremely fluid with very fine control.
I am wondering if I should expect any noticeable lag when running the 28x2 at 64mhz (I'm assuming setting up an external resonator should be too hard?)
 

hippy

Technical Support
Staff member
I am wondering why on the picaxe shop page for the 20x2 it says it has "11 analogue/touch sensor channels". I realize this is more of a copy and pasted sentence throughout all the different chips, but it is a little misleading.
Please accept our apologies for that and you are more than likely right that it was a copy and paste error which had not been previously spotted. We have updated the store description -

www.picaxestore.com/axe012x2
 
Top