Hey all, I have been designing a flex sensor glove but unfortunately have next to no knowledge of electrical circuits. I am doing this because I want to use the glove for a particular application. I know exactly what controls I want on it, just no idea how to wire it (or if it is even possible).
I have an arduino Mega. In total, I would like to wire:
Yes it looks like it is.
The Mega has 16 analogue inputs so OK for flex sensors.
Wire between analogue input and ground with a pull up resistor to 5V.
The Accelerometers are I2C so only two lines needed to read both of them.
The rest is just shrapnel.
The Accelerometers are I2C so only two lines needed to read both of them.
I was browsing around to see how exactly to wire the accelerometers.
From my basic understanding, each one needs SCL as an input. But since they send 3-dimensional data, how should I wire the output data into the Arduino? (SDA can only take one stream of input, right?)
No.
You wire the two SDA lines together to the arduino's SDA, the same with the SCL line.
You need a 4K7 resistor from each line to +5V ( that's two resistors in total )
Then wire each accelerometer to have a different address by wiring SA0 to +5V on one and ground on the other.
You software will then be able to read all three dimensions from each device.
I just want to make sure I have everything right before I actually wire it. Thanks again for your help, it has been extremely useful and I am very grateful.
Is this the correct circuit diagram? It excludes all the ground to ground wires.
The pins in green, which are on both accelerometers, do I need to do anything with them?
Do I need to put 4K7 resistors between the VDDIO (pin 1 on accelerometers) and +5V?
Basically no.
The chips are 3V3 powered and you have it as 5V so you will blow them.
They need to be powered by 3V3 and need a voltage levell shifter on the I2C lines. Either that or a pull up to 3V3 and a libary that does not enable the internal pull ups.
Again, my knowledge of this subject is very limited, but I did my best to draw another circuit diagram (attached). Assuming all grounds are connected, would this work? Would I need the decoupling capacitors (in green) on the voltage translators?
Thanks.
You only need one of those chips for driving the two accelerometers.
You need to connect the input referance directly to the 3V3 line. Otherwise good.
At this point I am stumped. I realized, reading the data sheet for the voltage translator, that they would rather have the higher voltage at Vref2 in order for the EN switch to work. They mention it on page 3.
So I switched around everything, you will see in the picture.
Can I use these green connections to make VDDIO the same as VDD? Or do I still need VDDIO to come from a +5V source through resistors?
Do I need 2 sets of pull resistors (4 total) to connect the SDA and SCL between the accelerometers and the voltage translator? Or just connect the accelerometers' lines together and use only 2 bigger resistors? (I didn't draw these in yet)
Are the 2K7s between arduino and voltage translator OK still or do I need to switch back to 4K7?
I have added flex sensors in. I drew 2 but plan to connect 12 in parallel. I used an op-amp as suggested online in order to limit noise levels. Here are the components.
You have to have Vddio connected to Vdd and wired up to the 3V3 supply.
You need to have all the pins on the two accelerometer connected together apart from SA0. On one chip this connects to 3V3 and the other connects to ground. Also there is no need to connect INT1 and INT2.
Have only one set of pull up resistors connected from the two SDA and SDL lines to 3V3. Use 4K7 like it says in the data sheet.
Then connect them to your level shifter chip outputs, the level shifter then goes to your arduino again have a set of 4K7 pull up resistors from the I2C lines on your arduino.
The flex sensor amp looks fine at first glance but is the gain too high?
I think it may be. I did more research on op amp gain and such, and it looks like I don't want any extra gain because the analog pins on the arduino are by default accepting a voltage range of 0 to +5V. Is that assumption correct?
In the diagram I used the circuit from the op amp data sheet (page 11: non-inverting DC gain).
It says the gain will come from 1 + R2/R1... should I just get rid of my R2? It corresponds to the 1M resistor.
the arduino are by default accepting a voltage range of 0 to +5V. Is that assumption correct?
Yes.
The LM358 is not a rail to rail device so you might have problems at the extreme ends.
To have a gain of one simply connect the output back to the inverting input. This is known as a voltage follower.
Cool. Since I will get messed up readings at the extreme ends of the scale, what would be the best way to fix it besides using rail to rail op-amps? it's sort of a budget project so I don't want to spend more than $3 per.
-just changing the code's voltage input range to compensate
-add a little gain, adjust the pins' input range, and then alter the code
-another way?
The best way is not to use the end readings, you can't anyway as they don't change so there is nothing you can do appart from giving the op amp a higher +ve and lower -ve. The. You have to protect the input pin with diodes to stop it going outside the rails.
Why do you want to use an op amp anyway? Why not connect the sensors directly?
From the flex sensor data sheet:
"The impedance buffer in the [Basic Flex Sensor Circuit] (above) is a single sided operational amplifier, used with these
sensors because the low bias current of the op amp reduces errer due to source impedance of the flex sensor as
voltage divider. Suggested op amps are the LM358 or LM324."
I looked at basic flex sensor circuits online and saw that most circuits included an op amp.
I don't know if I need one, but the idea is that this is going to be as delicate as a musical instrument, so I thought extra sensitivity couldn't hurt (without really knowing how an op amp makes it more sensitive - now I understand that using it will just get rid of noise). What do you think?
Also, here is the diagram with the corrections you suggested on the accelerometer side.