I'm working on my arduino/raspberry pi FYP and I have a quick question on de-coupling.
I'm using SR-04 ultrasonic sensor and the sharp IR sensor (10-80cm) as well as a few servos. I'm powering the Pi and arduino off of a 9.6V battery pack.
I've de-coupled the arduino and pi power circuit using a 47uF electrolytic and two 100nf ceramic capacitors.
Do I also need to de-couple the arduino sub-circuit?
Yeah the issue I'm running into is an unreliable serial connection between the arduino and the pi in addition to incorrect readings on my SR-04.
I'm using screen to read the output from the sensor on the pi for now but I occasionally drop reports or screen terminates. I'm pretty sure de-coupling will help with this but electronics aren't my strong suit.
where would I place the electrolytic capacitor on the arduino? Or should I run the 5v onto a circuit and do everything there, just relying on the arduino to read the results?
For the converter I'm just feeding the pi 3.3v directly into the arduino RX
That is your unreliability problem right there. For an arduino (and many other devices) the minimum value of a logic high need to be 0.7 of the supply voltage. For a 5V arduino that translates into a 3.5V signal in. You have only a 3.3V signal, hence the unreliable operation.
Is the arduino driving the SR04, those things are not very accurate or consistent you know.
I've de-coupled the arduino and pi power circuit using a 47uF electrolytic and two 100nf ceramic capacitors.
I'm not even sure what this means, since both Arduino and r.Pi board certainly have their own capacitors
on-board already. So, ???
where would I place the electrolytic capacitor on the arduino? Or should I run the 5v onto a circuit and do everything there, just relying on the arduino to read the results?
You should add said capacitors out at the power feed to the servos, since that is where the motor noise
is being generated.
You have a good system here, in that you have both 5V and 3.3V controllers. You just need to be sure
to connect the 5V extra components [sensors, sonars, etc] to the Arduino and the 3V devices to the
r.Pi. Then, all you need are 3 wires TX,RX,gnd going between the 2 controller bds, plus a level-shifter as
G_M mentioned on the TX pin from the r.Pi.
Electronics aren't really my thing, I'm doing this for a software degree final year project. I'll be implementing a genetic algorithm based evolutionary robot with an onboard simulator feeding the fittest population members to the arduino for online testing. Thanks for the info on decoupling good to know I can drop those extra caps off of the power circuit.
Would I need to buy an IC to shift the logic or can I do a home-made version like my voltage divider?
The issue also occurs when only reading arduino feedback on the pi, do I also need to adjust the divider ratios to bring it closer to 3.3 input on the pi or could this be due to the software side of the serial setup?
Would I need to buy an IC to shift the logic or can I do a home-made version like my voltage divider?
The simplest bi-directional level shifter can be done with two npn transistors ( emitter/collector connected and base all pulled up to their respective rails). Using an ic is neater but functionally the same as the npn pair.
It is really that simple: get two npn. tie npn1's emitter to npn2's collector, and npn1's collector to non2's emitter, and their bases together. Pull the collector/emitter pairs to their respective rails (3.3v and 5v), and the bases can be pulled to either 3.3v (the shifter is permanently enabled) or to a pin if you wish to controll when / if the shifter will be enabled.
dhenry:
It is really that simple: get two npn. tie npn1's emitter to npn2's collector, and npn1's collector to non2's emitter, and their bases together. Pull the collector/emitter pairs to their respective rails (3.3v and 5v), and the bases can be pulled to either 3.3v (the shifter is permanently enabled) or to a pin if you wish to controll when / if the shifter will be enabled.
As described, that won't level shift a 3.3V output to a 5V input. Worse, when either side of that "level shifter" is pulled low, it effectively shorts the 3.3V supply (the one the bases are tied to) to ground via a base-emitter junction.
However, I can see that it might work with the following modifications:
Don't tie the bases direct to +3.3V (or a pin), connect them to +3.3V (or a 3.3V output pin) via a resistor instead (1 resistor for both, 10K will do).
If the 5V side is an input, connect a pullup resistor (e.g. 1K) between the 5V side of the level shifter and +5V, or enable the internal pullup resistor inside the mcu.
You probably refer to this one: http://www.hagtech.com/pdf/translator.pdf
Seeing the connections is easier than reading a simplified text:
sure there are both rails and signals of the 3V and 5V sides.
Different people advocate different level-shifter solutions. I always gravitate to the simplest
solution that accomplishes the job.
A 5V->3.3V voltage divider will work well on the receive side, although this runs the risk that the RX
input to the r.Pi will be sitting at 0V if the Arduino is disconnected. Normally RX pins are high at idle
[no signalling], not low.
For the 3.3V->5V side, I've been using a pullup R [4.7K or so] to 5V on the RX, and a regular 1N4148
diode wired over to the 3.3V TX pin. This provides hi=4V and lo=0.7V, which is perfectly adequate.
Basically, half of a wired-And diode ckt,