Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing with Qprox Touch slider with SPI — Parallax Forums

Interfacing with Qprox Touch slider with SPI

Jason ShortJason Short Posts: 21
edited 2005-12-31 23:56 in BASIC Stamp
I am trying to interface with the Qprox 401 touch slider. I have the eval kit and I'm trying to get the timing right but it's been difficult. I can get the basic data out of it using the SHIFTIN command but I'm not able to do any advanced timing. The chip can take input and output commands on the rise and fall of the clock cycle. My question is this: is SHIFTIN/SHIFTOUT adequate? Or do I have another option?

Any help would be appreciated.

Thanks,
Jason


The Datasheet:
http://www.qprox.com/downloads/datasheets/qt401_1004.pdf

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-30 20:42
    You are correct that shiftout/shiftin is not adequate for simultaneous SPI communications, you will have to write your own hybrid shiftout/shiftin to accomodate recieving data at the same time as sending. But reading the documents, you can still use shiftout/shiftin because the results of a command are provided during the shiftout of the next command. So when you want to receive the data to a command you would SHIFTOUT the command byte, set the shiftout pin to 0 (this has the equivalent of shifting out $00 which is the NULL command), then SHIFTIN the response, this removes the command/response overlaping feature to make it compatible with the BS's method of doing SPI.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Jason ShortJason Short Posts: 21
    edited 2005-12-30 21:49
    Interesting thanks. I noticed that on the spec sheet the timing diagram shows the clock as high when the chip select goes low. On my little oscilloscope, I see that my clock is low before I SHIFTIN. It still works but I'm having such flakey results sometimes, I wonder...

    I would like to interface with the chip exactly how it is diagrammed but, without manually controlling every aspect of timing, I don't know how to do it. I've also never done it manually before but I read an article here that shows I2C done manually on a stamp. http://www.phanderson.com/stamp/tutorial_8.html

    Perhaps someone has had some experience making these tradeoffs before?

    Thanks,
    Jason
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-30 21:55
    Set the clock bit manually before entering CS=low, this sets the polarity of the SPI clock used by SHIFTIN/SHIFTOUT. You'll have to code your own command if you want to send and receive data simultaneously, otherwise do SHIFTOUT command, set shiftout line low, SHIFTIN response, repeat as nessesary. This gives you all the control you need to fully interact with the device, doing this turns the device from a full duplex mode to half duplex mode SPI (from 2 way simultaneous, to one way at a time).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Jason ShortJason Short Posts: 21
    edited 2005-12-31 08:14
    I finally got it humming smoothly. It's the first time using SPI to interface with anything other than a simple ADC and this chip is far more complex. I got the clock cycle looking right but I still had very wild behavior and periods of no output from the 401. Two things were getting me very confused. First the chip constantly wants to go to sleep to conserve power. Second is the proximity detect still works while it's asleep. That was really confusing me. I though for sure I could clock it when I got the prox reading. Then while messing around with the scope I pulled the DataReady line and spent another hour wondering why I could never read. It's running now and I have the satisfaction of tackling my first new IC. Oh and it's a very cool chip.
    Jason
  • OrionOrion Posts: 236
    edited 2005-12-31 14:52
    I don't suppose you could post you code that you used? I was looking at using the qt60168 until I read into the serial protocol, and the fact it only comes in a TQFP package. I still not sure I would try to solder that part. Instead I went with 2 x QT160s these are great chips but the 160 has no way to sync it with the other QTs making for some headaches if you don't lay out your keys carefully. Now I have a functioning 12 key pad which I hope to post in the project forum soon. I haven't compared the datasheets but it sounds like the qt401 and the qt60168 have a similar serial interface(going off my foggy memory).
  • OrionOrion Posts: 236
    edited 2005-12-31 15:06
    It’s coming back to me, after looking at it again there not so similar. The qt60168 uses CRC on some commands and has the same 5 wire spi interface. That’s probably more than I want to decipher. I would still like to see how you got the slider qt working, I may use it down the road.


    http://www.qprox.com/downloads/datasheets/qt60248_402.pdf


    Thank you.
  • Jason ShortJason Short Posts: 21
    edited 2005-12-31 19:27
    Sure,

    I've left out most of the code I was using the slider for but you can get the idea. I do get the occasional null or 1 back from the slider so I am saving the good value and filtering it a bit. The data-sheet recommends sending a drift command every once in a while. I've shown one command which is an end calibrate mode. It takes a half second to finish so I just pause for a moment.

    Many commands don't need the pause or the check since I already check the DATAReady in the main function.
    Right now I use the value to drive a set of 6 leds with the index number from a LOOKDOWN command. I plan on sending the value through the serial port to a Flash prototype on my computer.

    Jason

    main:
        HIGH SS
        IF DATAready = 1 THEN GOSUB readslider
    GOTO main
    
    readslider:
        HIGH CLK
        LOW SS
        IF Touch = 1 THEN
              SHIFTIN sliderIN, CLK, MSBPOST, [noparse][[/noparse]sliderValue\7] 
            HIGH CLK
              HIGH SS
            IF sliderValue > 0 THEN  savedValue = sliderValue
        ENDIF 
          RETURN
    
    endCalibrate:
        HIGH CLK
        LOW SS
          SHIFTOUT sliderOUT, CLK, MSBFIRST, [noparse][[/noparse]%00000010]
        HIGH CLK
          HIGH SS
          PAUSE 600
    RETURN
    
    
    

    Post Edited (Jason Short) : 12/31/2005 7:30:04 PM GMT
  • OrionOrion Posts: 236
    edited 2005-12-31 23:56
    Many thanks!
Sign In or Register to comment.