After your breadboard comes, do some tests and let us know what you find out!
Yasssss, I would love too! Please take a moment to be thankful you (probably) live somewhat near civilization and can get packages in a timely fashion. ![]()
I figured out I was looking at 16:16 MUXes, which are pretty damn cool, but I need only 16:1 (16 in, 1 out). The MAX396 looks perfect for my needs, so I'll order her up now. I have to think way ahead to reduce wait times.
The MAX396 looks good, if a bit spendy. If you're stuck on going the charge pump, op amp, etc. route, you could also use two of these: SparkFun Multiplexer Breakout - 8 Channel (74HC4051) - BOB-13906 - SparkFun Electronics US$2.75 each.
BTW, regarding the voltage on the charge pump supply pin in your +3.3v->sensor->charge pump->op amp scenario...take a look at Figure 11 of the charge pump datasheet by TI.
The charge pump controller alternately opens and closes switch pairs S1 & S3 and S2 & S4.
When S1 & S3 are closed (and S2 & S4 are open), 10 uF capacitor Cp is charged via voltage applied at pin 8 (V+) in series with the Tekscan sensor (2.5 Mohm to, say, 100kohm under full weight on the stair). In that case, one RC time for Cp varies from 25 sec to 1 sec.
The controller cycles the switch pairs at 10 kHz, or every 0.1 ms, which is between 4x10^-6 and 1x10^-4 "RC times." Even at the best case 1x10^-4 RC time, only 0.3 mV would build up in Cp during one cycle. Hence the measured voltage at pin 8 will be zero, for practical purposes.
Then, when switches S1 & S3 open and S2 & S4 close, capacitor Cp will be shorted to "ground" (assuming that the op amp does its job), so Cp will:
- dump most or all of its charge to ground
- be unable to deliver any charge to capacitor Cr (which is also shorted out to ground)
- start over at or near 0 v at the beginning of the next charging cycle
You could test this, but you may risk damaging your charge pump.
My practice has been to buy at least two of everything when venturing into unknown territory. ![]()
Haha, yep I had ordered 2 LMC7660 and 2 MCP6002. Just one $8 digi pot and $19 extremely fancy MUX though.
Oooh, that SparkFun board is a good find! I looked at it a while ago but didn't notice (and didn't know I needed) the VEE back then. Ah well. I'll have to fit the massive MAX396 somewhere. MAX is a fitting name (28-DIP, 15.24mm).
Your description of the charge pump helped my understanding, thanks (no thanks to that nasty LMC7660 datasheet). I also came across some 555-based charge pumps, which seem to work the same way.
Your hypothesis is interesting. If true, wouldn't the same happen with +3.3v->charge pump->sensor->op amp?
The op amp "virtual ground" magic is hard to grasp. Dave explains here that the current is sinked through the negative feedback configuration to the output. Maybe the op amp virtual ground differs from real ground, somehow only sinking what's necessary? I'll definitely see if it lets the smoke out of my extra charge pump.
No, because with the +3.3v (low impedance) source connected directly to capacitor Cp, it charges to +3.3v very quickly. And with a high impedance load (the Tekscan FSR), it can easily charge capacitor Cr up to the same value (and Cr will retain most of its charge when not being charged by Cp).
Well damn, that's a bit tricky. Glad it should work though.
I managed to cram it all into one board:
As items trickle in, I get to play more. It'll still be at least 3 days before I have the ICs. The force sensors are super neat. I'll ramble about some of my findings, in case it helps me or others in the future:
- I tested 5-6 sensors and found them all to behave roughly the same for my needs, which is to detect about 35+ lb (16+ kg) of force. Differences between them would be more important if using them for an exact weight.
- With 100lb sensors and 100K feedback resistance, I find I can step on a sensor with ~150 lbs and not max it out. 147K is pretty insensitive and I'd probably not want to use lower resistance (which makes it less sensitive). 247K is pretty sensitive, it maxes out with 40-50 lbs.
- My digi pot has two 100K pots, so I'll use both of them in series to get 0-200K. I'll also add 100K to that, so my adjustable range will be 100K to 300K. That should cover all my needs! I'm not yet sure if I want the stair to trigger when the dog uses them. If I could reliably detect her, I could have a doggy mode.
- I got the Tekscan prototype kit so I can give it to my builder, so when they install the sensors they can ensure they aren't too smashed and trigger appropriately (I'm remote and can't be there). I'll give it to them with 200K ohms, the center of my range. It'll be installed with minimal (<6%) to no load.
- Interestingly, the parts Tekscan uses in the prototype key are an Arduino Nano, PDM1-S5-D12-S for negative voltage, LM358P op amp, MCP4911 DAC, and CD4053BE multiplexer.
- The dual supply op amp circuit gives nice, linear results. The single supply circuit is the same, except has half the resolution -- the values start at 50% of the dual supply circuit and go to 100%. Of course you can stretch these over the whole range, but it's still half the resolution. The voltage divider circuit is pretty poor. It gives ~1/3 of the dual supply circuit resolution and it's nonlinear, so the top 20% isn't very useful, making it more like 1/4 the resolution. It is likely still good enough to detect if a stair is stepped on though.
In other news, to further complicate my life I've added a fancy ADC with SPI. It still fits on my tiny board! The best part is I can't add anything else!
I've already written all the code to control the mux, digi pots, ADC, and provide control/events over a TCP socket.
Very cool! Thanks for the update. How do you know what force the as-installed sensors will see when someone steps on a stair tread (and when they are unloaded)? Did you build a mock-up?
I cheated and used the Tekscan prototype kit, since I will send that to the builder. In hindsight it would have been more fun to build it, but I didn't know back then how far down the rabbit hole I'd end up. Here's a video:
I tested just by putting a board over the sensor and stepping on it, so nearly 100% of weight got to the sensor. The real install will differ (Z-clips, etc) so a lot depends on how much force the stair tread transfers into the sensor versus the construction underneath. Only thing to do is build it and adjust if it doesn't work out. With the prototype kit @ 200K ohms, the builder will be able to see if their install gets the LED to green/orange/red under load. If so, it should be good and I can adjust the sensitivity up/down a fair amount.
Regarding a mock-up: seems like you could get in the ballpark with a single tread, supported at each end (where the z-clips will be), and at the middle along the long edge (opposite the sensor).
But, your digital potentiometers do give you considerable flexibility, and if needed, you can even use a different feedback resistance for each step.
Good luck!
Thanks!!
Made some progress on the project box.
Making the ethernet hole so nice and square was tricky. A fret saw is an amazing tool!
I've got the standoffs upside down and I'm hoping to drill holes in the right places to use countersunk screws from the bottom. Could just hot glue or epoxy them, but it's not quite as nice.
Nice work (he says as he googles "fret saw"...)! How did you get the saw blade to not drift away from your line?
I used masking tape so only the part to cut out was uncovered, then sawed very near the tape and filed away the rest. The fret saw blade cuts precisely and is very thin (thinner than a coping saw). It's so thin it made the 90 degree corner at the bottom with a tight radius, leaving only a little material to file.
It was my first time using a fret saw and I'm impressed! Normally I'd take a dremel to it, but this was a lot easier.
I see, thx. Turned out looking good.
I HAVE ICS! And toys! Finally!
So far the charge pump and multiplexer are working fine. I'm having trouble with the I2C potentiometer though. Datasheet shows:
I've grounded the A2, A1, and A0 pins, so the "device select" bits are 000. My code:
#include <Wire.h>
void setup () {
Wire.begin();
}
void loop () {
Wire.beginTransmission(0x01010000); // 0101 (device ID) 000 (device select) 0 (write).
Wire.write(0b10101111); // 1010 (command) 1111 (write value to both pots)
Wire.write(127); // half
Wire.endTransmission();
delay(3000);
}
Result: pot wipers stay in the default low position. Wire.endTransmission() returns 2, which means NACK, ie the IC didn't respond.
Could it be I'm using the wrong pins? The wESP32 pins show two sets of I2C pins. I'm trying to use pins 17 and 15 (IO15 and IO4). What pins will be used with Wire.begin()? I tried Wire.begin(15, 4) to no avail.
I tried reversing the bits. Then I tried decoding the I2C with an oscilloscope, but wasn't able to get it to read the values I write. I think I am looking at SCL (varying) and SDA (goes high when my code starts and stays high) but it doesn't seem like my code results in SDA changing. It could also be that I'm a noob with the scope.
Not sure WTH is going on! Any ideas?
You may want to try an I2C scanner. Here's an example:
PS: accidentally connecting two outputs together (by randomly trying pins, switching pins, etc.) could kill one or both devices if, say, one outputs a HIGH and the other is LOW simultaneously.
try
Wire.beginTransmission(0b0101000)
a 7 bit address as required
I tried Wire.beginTransmission(0x0101000) but still get NACK. It seemed promising, as this post says beginTransmission appends a 0 for the read/write bit.
Interesting, thanks. It found a device at 0x28 aka 0b0101000. The scanner is doing only begin then end, so maybe the IC doesn't like my Wire.write() calls? Seems odd. Or maybe it's that I sent the 7-bit device address, but not the RW bit?
EDIT: Wire.beginTransmission(0x28); works! WTF?
Oh man, at some point I typed 0x in my code instead of 0b and didn't notice! It's even in my code above. fuuuuuu... Glad it's working now though, thank you both for your help! Now I can go to bed with closure.
Beyond me, sorry.
Oops...I see it works!
Had some fun today. Got everything setup on the breadboard:
All the software works! Can control the potentiometer (I2C), multiplexer (4 pins), and ADC (SPI).
The pot had me confused for a while. I wanted to verify the resistance, but of course the digi pot has to be in a circuit which screws with testing its resistance. The multimeter was all over the place. If I moved 2 feet to one side, the values would double. Eventually I found this page where someone is having my exact problem, even with my exact IC! Once I grounded the multimeter lead I got stable numbers. Now from software I can get values from 1022Ω to 181.4KΩ (plus a 100KΩ resistor).
The ADC was also a pain. Whoever writes these datasheets is pretty bad at clearly explaining such a simple API. SPI wasn't a problem, but interpreting the 2 bytes from the ADC should have been a lot easier. It writes a 1 for some godawful reason that needs to be ignored, then 12 bytes, then zeros.
Next I drilled holes in the project box to mount the standoffs. It was pretty stressful getting them in exactly the right place, especially since the wESP32 fits in the ethernet hole and can't move at all. It worked out in the end! Standoffs are upside down and I countersunk screws on the bottom.
Next I soldered the ICs. I loooove my JBC iron, wow it is amazing! So much better than the junk I've used in the past.
I should be able to finish the rest tomorrow. Though I'm torturing myself to fit everything on a tiny 1.9"x1.75" protoboard, so maybe I fail, scrap everything, and need to wait weeks to get a bigger box. ![]()











