I have an idea, but need confirmation
TC
Posts: 1,019
Hello all,
I am working on a project for a friend, that has 1000 touch sensors. I am using microchip's CAP1188 touch sensor chip. I am going to talk to them using SPI, and I think I have come up with an idea on how to control up to 256 chips, that are each on there own board (256 chips, 256 PCBs)
My idea is to use buffers for the output of each board, and to use a digital comparator to control each Chip Select of each chip.
I want to ask others if this idea would work before I spend the money to get parts. Or if anyone would have a better idea. I included a quick design, please ignore that there is no pullu ps/pull downs, or that the enables are floating. It was just a quick design, just to show my idea.
Thanks
TC
I am working on a project for a friend, that has 1000 touch sensors. I am using microchip's CAP1188 touch sensor chip. I am going to talk to them using SPI, and I think I have come up with an idea on how to control up to 256 chips, that are each on there own board (256 chips, 256 PCBs)
My idea is to use buffers for the output of each board, and to use a digital comparator to control each Chip Select of each chip.
I want to ask others if this idea would work before I spend the money to get parts. Or if anyone would have a better idea. I included a quick design, please ignore that there is no pullu ps/pull downs, or that the enables are floating. It was just a quick design, just to show my idea.
Thanks
TC
Comments
How many mcu/prop pins do you want maximum to be used?
16pins for data, reading 16 spi boards at the same time,
1 pin for clock fanned out.
maybe using i2c 4bit expanders for ChipSelect, they often have 3 pin for address.
And you could use 74hc 3-to-8 decoder after that.
So 16*8*8 = 1024
Should use the chips i2c mode in the first place, plenty of i2c fanout and extension ic's is out there.
Thanks Tony,
The chip is I2C, but it only allows 5 different addresses. Way to little for 1000 touch sensors. That was my first choose.
At this point it is not clear how far each chip will be from each other, but I dont really see more than a meter away. That is why I was thinking buffers might help if each chip was a meter away. I was thinking of using parallel printer cables to connect between each board.
The only other thing hooked to the prop is an SD card, and left/right audio out. So including the standard prop pins, I would be using 10 pins, the rest is open game.
I do like the idea of using a I2C expander though. Might look into it more.
I do want to make these somewhat universal, and convertible. At this point we do not know if one prop would manage all 1000 sensors, and play the audio. Or if we will have to use a handful of props, with each of them reading some of the sensors and playing its own audio. It depends on how large (size) this art project ends up being.
TC
http://www.mouser.com/Sensors/Capacitive-Touch-Sensors/_/N-1b8oy?P=1yzvta4Z1yx7npqZ1ypwvr6Z1yx7p5oZ1yx7nm1Z1yx7ni6&Ns=Pricing|0
Say you do four i2c masters on the Prop (maybe all share one clk pin)
5-channel I2C-bus hub on each (PCA9516APW etc) 1in-4out with enables
2bit address on each i2c slave = 4
4*4*4*16channel= 1024
Most of those chips are only made for touch, I have to have proximity sensing. And not just an inch or so, I need about 3-4 inches distance from the touch sensor. Another reason I went with the CAP1188, is because I could get a cheap dev board from Adafruit, that would allow me to work with the chip to see if it will do what we need. And it does. I am on a small time crunch with getting a small setup working. I have about 20 days to design boards, get them made, assembled, make the code (that part I am slow at), and figure out an easy way to change settings.
I have to follow the K.I.S.S. model for this project. Others have tried to help my friend using an Arduino, and a RaspberryPi, both could not detect a hand, and play audio reliably and consistently. I knew the prop could do this with no problem.
TC
mix and match to get to the goal
7 prop i2c *4 hub switch *5 address *8channel= 1120
20 prop i2c *5 address *8channel= 800
I like the idea. I never knew there were I2C bus switches.
I am wondering, what is the down side to my original idea? Here is my thinking..... set 7 prop IO pins to select the chip I want using a standard binary format, and the 8th pin to enable/disable the chip. Send register address select command, then read/write. Then do all over again. And I can make up 256(max, but not really) PCBs that can be used from if I need 1 sensor, all the way up to 2048 sensors if I want.
Im not questioning you option in any way, Im just trying to understand the down side to my idea.
TC
Could get a xbox Kinect and read the hands virtually cheaper.
Parallel wires for address on 1 meter, there is a reason why SATA is serial (sure it's differential) and parallel ide cables are gone.
Now I understand from a cost point.
I thought SATA used a differential pair for TX and RX to help with noise, and to increase the bandwidth. What I would really like to use is a Ethernet setup, but the cost, and the code would be insane.
Not sure what refresh rate you're looking at, If you get as many parallels bits going out from Prop, the better.
When you have 125 units in series and need to send 24bit data, refresh rate is starting to be a problem.
You only had one single SPI master, getting 8 of them sharing one clk-pin would use 17 Prop pins.
A I2C version sharing one clock pin (as I hope there is no slave clock stretching) would only use 9 pins.
spi would be faster if it can do 250KHz and I2C only 100KHz, but at the cost of pins.
In both version you should buffer the clk-out for fanout.
>TX and RX to help with noise, and to increase the bandwidth
First ATA-IDE was 40wire and then they had to make it 80, just to put a ground wire between every data line.
noise is what limit bandwidth, parallel wires may not reach destination at the same time and it's not differential, as noise should show up on both pairs and be ignored in sata
For the prop pins, I am not that concerned about using all the pins. This project will only be doing is look for a touch, then if touched play an audio file for that touch. There is going to be no displays, LEDs, motors, etc... Just the sensor communication, audio left/right, and a SD card.
One benefit of using SPI, is if I need the bandwidth. When in 4 line SPI mode, the CAP1188 can output data at the same time data is inputting. That means, I can write to an address, and read from an different address at the same time. But it is hard to say if I really need that at all. I dont think I will ever need that kind of bandwidth.
I wish I had the knowledge to use a PIC, but I dont. I only know SPIN and some PBASIC(not used it in years). And with this project I just dont have the time to spend on learning a new system and/or language. If I did know how to use PIC's it would be easy. I could just use a PIC to detect proximity sensing, save the order the touch was detected (if more than one touch), and pass the data along some kind of buss (maybe CAN or something). Or even use USB to communicate the data.
I've talked with TI about this, and they could not give me a lot of options that would work with the prop, since it is the only thing I know how to program.
I have considered that option. But I was concerned about the prop being $8 each. What I am going to do is seeing how far the touch sensor can be before the CAP1188 can not detect a touch. I am using a shielded single conductor wire to connect between each touch sensor input, and a bare single sided PCB (as the touch area). Hopefully I can get some good amount of distant out of the setup. That way I could put 30 or so touch sensors on one board with a prop to control and monitor them.
Msp430 is pretty simple to get started in C, or in Energia that is even simpler than Spin.
2 SPI with 8 touch cost 60cents at @1K: (even DIP version is avail)
http://www.ti.com/product/msp430g2233
http://www.ti.com/product/msp430g2203
Step1: set 8 pins as capsence
Step2: read them 100/sec, if variation from running average is above 10% it have sense external capacitance.
if less that 10%, just use the new reading for the running average {pad0=(pad0*3 + readvalue)/4}, this allows for slow drifts.
Step3: SPI1 IRQ waits for a address byte, if it does not match its own, it will repeat it out on SPI2.
Step4: how the spi daisychain will work takes some planning as each step will create a lag.
Not sure if distance of 3" (with big pad) is the same as your ic.
But if you don't want to learn C on a new MCU, I would go with I2C hubs to fanout to as many you want.
best part is you can do multicast out a setting on all IC's with that address at the same time
https://www.ee.usyd.edu.au/tutorials/digital_tutorial/part2/register02.html
You reset the system by setting data high, then sending numerous clock pulses *units in series.
then low data, single clock pulse, unit1 is ready for spi communication.
then high data,single clock pulse, unit2 is ready for spi communication.
single clock pulse, unit3 is ready for spi communication.........................
I would do 4 spi masters on prop, so each branch does 32 boards in series.
put a 3bit buffer on each board for spiclk/mosi/miso, probably could get away by just doing in on every 4th board,
but to keep all boards the same, example use NL37WZ17USG (20cents)
or 74LVC3G34DP,125 (if above 0.50mm it to small)
I like that idea, its simple, cheap, and I can continue using the code I have made so far.
I was planing on adding non-inverting drivers/buffers on the output of each board. I was also going to have a 3.3V regulator on each board, that way I would not have to worry about the voltage loss along the wires. I hope this is understandable.
TC
Basically the same as what I had in mind. The spi signals to the CAP1188 would connect to the boards in parallel in groups of 32 to 64, and the clock and data signals for the chip select flip-flops would go in to one board, be buffered, and go out to the next board.
Don't really want to have the spi signals from the CAP1188 looping through a buffer on each board. The delay through each buffer may limit the maximum speed of the spi bus.
I did not even think of the delay through the buffer. That would add up real fast. Thanks for the help, now to get designing.
TC
The simplest would be 6 lines per 32 board branch. Straight forward coding, the fastest, but needs 24 prop pins.
Next would be 3 lines for the sel_bus and 3 per board branch. Fewer pins (15) but somewhat slower scan speed and slightly more complex code.
Then there is the slowest but fewest pins choice. It would require a bit of extra hardware on the propeller board but would only require four pins. Unfortunately it would also be one fourth the speed of the fastest choice.
This was the exact idea I was thinking. Its so nice the prop has so many pins at my disposal. And that option also allows me to be able to use 6 controller boards (if needed) without changing much code. The picture was exactly what I was seeing when you suggested it.
Thank you so much for all your (past and present) help.
TC
Since it is unknown at this time how long the wireing could be from the prop and the sensor chips, I was a little worried about losing data from the voltage drop on the wires, and outside noise. I would like to use a twisted pair for the data lines, but that would turn out to be very costly. Then I remembered about "current loops". Where and analog current signal is used to send information over long wires. Most industrial equipment, and auto manufacturers use it. A pair of wires have a set current flowing through them. 4ma for the low end, and 20ma for the high end. One wire is the current source, and the other is the return(ground I'm most cases).
I figured, why could that not work for what I need? I could have a simple, cheap op-amp measuring the voltage drop across a resistor (1 Ω for example). That would give me 4mV as a low signal, and 20mV for a high signal. I could setup the op-amp so it amplifies the voltage, say x50 gain. That would make
4ma / 1 Ω = 4mv * 50 = 200mV (low)
20mA / 1 Ω = 20mv * 50 = 1v (high)
And I could also make the prop monitor the loop. If there is less than 4mA on the loop, that would mean the loop is open.
Signals coming from the prop I have figured out, but signal going to the prop I have no figured out yet. Might do something along the lines where the prop measures the voltage needed to maintain the 4mA - 20mA range, for the data in. Not sure yet, just an idea.
What does everyone think? Could it be a good idea? I could iliminate the need for buffers, and I would not have to worry about the propagation delays with using buffers in series. All the data in(to sensor chip), clock, and reset lines could be tied together.
I could draw up a quick schematic to help explain my idea if it is needed.
Thanks
TC
Also, do you have any idea of how far apart the CAP modules will be placed.
I will have to check into RS422/RS485, so I dont know off hand the cost differences.
I will draw up something a little later. Right now it is all hands on deck at work. So I dont have a lot of free time during the day.
Right now, with just a single conductor wire, I can have about 4ft before the sensor chip can not calibrate. I am playing with shielded wire, and adding resisters and capacitors to the sensor inputs, to help with filtering the input. But I am still playing with that.
TC
If you mean that you are placing the touch pads at the end of a 4 foot wire coming from the CAP1188 chip then you may have a problem. The capacitive touch chips are intended to work with touch pads that are typically on the same board as the chip, or at most a few inches away. How far away from the chip did you plan to have the sensors?
Unfortunately, I dont have that many options to work with. My friend casted a lot of faces before he came up with the idea of making them play audio. And since they are concrete, we cant drill into them to add some form of button(could crack them). So I have to use capacitive touch in proximity mode.
I wanted to have a sensor for each face, but that is not cost effective. It is hard to find single channel cap sensor, that can be setup for proximity. And one that can calibrate and adjust for changes in environment.
I used the 4 foot as an example of how far I could get the touch pad away from the sensor chip. I am trying to keep the wires as short as I possibly can.
TC