1
\$\begingroup\$

I'm trying to read an analog magnetometer using the Raspberry Pi Zero. I never worked with the Pi directly before; it was always through an Arduino hooked up to the Raspberry Pi. However, through research, I found that the Pi doesn't really play well with analog sensors, so I have to convert the analog signal to a digital one in order for the Pi to read it.

Aside from reading it out through an Arduino, Adafruit mentioned that you can wire your analog sensor to the MCP3008 to convert it to a digital input. A very rough schematic is shown below:

schematic

simulate this circuit – Schematic created using CircuitLab

My choice of magnetometer aside, what design considerations should I take into account when working with ADCs? Do I need to do anything to ensure that the clock and DIN/DOUT lines are stable? Is it advisable to have AGND and DGND be hooked up to the same GND plane with the Pi? This circuit feels a little too simplistic, so is there anything else that is required to make this work?

Just in case anyone asks, I'm using a magnetometer as part of a project to measure a 10 tesla field and record the data with a Raspberry Pi.

\$\endgroup\$
  • \$\begingroup\$ The MCP3008 is just an expansion of the Raspberry Pi. It has 10 bits of resolution so your scale (rounded off) is 000 to 999. If your Magnetometer gives you very fine readings you should consider a 12 or 16 bit ADC. \$\endgroup\$ – Sparky256 Feb 5 '18 at 22:32
  • \$\begingroup\$ @Sparky256 Thanks for your reply. I'll have to look into other ADCs. Honestly, the driving factor is the magnetometer being used, cause it has to operate in a 10 tesla field. \$\endgroup\$ – user101402 Feb 6 '18 at 0:15
  • \$\begingroup\$ Ten Tesla! OMG that is a powerful magnetic field. The LHC is only 8 Tesla. \$\endgroup\$ – Sparky256 Feb 6 '18 at 0:23
  • \$\begingroup\$ @Sparky256 Well, that's what my team said. Interesting point. Nevertheless, the magnetometers that we used saturated so we had to reset them. So, putting aside my quest for a new magnetometer, given this general layout of the analog sensor and the ADC, assuming they all follow the same general layout on the digital wiring side, would any 12-16 bit ADC work here? What should I look for in an ADC that's compatible with the Pi? \$\endgroup\$ – user101402 Feb 6 '18 at 13:18
  • \$\begingroup\$ I would check out the LTC1605 16 bit ADC. Use a LT1027 Vref for it. This ADC offers the option of a 16 bit output as 8 or 16 bits. In 8 bit mode you do 2 reads to get all 16 bits. I am sure the Arduino only offers a 8 bit wide port. \$\endgroup\$ – Sparky256 Feb 7 '18 at 0:00
1
\$\begingroup\$

This isn't specifically for ADCs, but for mixing analog and digital circuits in the same device.

Digital circuits are usually fairly noisy, and you want to keep that noise away from the analog part of your circuit as much as possible, and part of that is keeping the two systems separate.

  • Firstly, you want to ensure that you have good decoupling on your power rails, and it looks like you've done that.

  • Second, you want to keep the digital signals (in your case the data lines and especially the clock) away from any analog signals if at all possible to minimize crosstalk.

  • Finally, you want to separate the digital power supply if you can, and have a single connection to a rail if you can't. In your case, this would mean connecting the AGND and ground for your magnetometer together, along with decoupling components, and having a single wire or trace connecting to the digital ground, same for power.

Depending on how accurate you're trying to be, these may not really be necessary, but they do help for more demanding analog circuits.

Edit: Regarding the single ground connection, imagine you have an analog ground plane and a digital ground plane, and your analog plane connects to the digital plane at a place where there is 0.1V noise. Assuming you have good decoupling, this shouldn't be an issue because your Vcc rail will have the same noise placed on it, and your analog signal will only see the difference between Gnd and Vcc, which should be fairly stable. Your analog signals are going to have 0.1V of noise referenced to the power supply/digital ground, but since the noise is the same for the entire analog circuitry, it doesn't matter.

Now let's assume you have your ADC connected to that same place with 0.1V noise, and your magnetometer connected to a place where there is 0.2V noise. Again, the power supply for each chip will have the same noise presented to it (because of decoupling), so separately, the chips won't see the noise. However, when you feed the signal from the magnetometer (Which has 0.2V of noise on top of it), to the ADC (whose ground has 0.1V of noise), the ADC will see 0.1V of noise on the magnetometer signal.

The situation is just as bad when you fuse the planes together, because now the ground of the analog circuits will see the large currents from the digital circuits, and every analog circuit will see a different voltage for ground.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your reply. It boils down to what magnetometer I need to use, since I'm still looking for one. The DRV5033 is just a placeholder until I find one suitable. Only analog signals are going to one side of the ADC based on how the package and pins are, so ideally, the traces of the analog and digital sides shouldn't cross except for power and ground. When you said a single trace for the DGND and power, everything's powered at 3.3 V so they would share the same line. How can I separate them? Also, DGND would just go back to the Pi, so that would effectively isolate DGND and AGND? \$\endgroup\$ – user101402 Feb 6 '18 at 0:21
  • \$\begingroup\$ A single trace means connect all your analog grounds together and connect it to the digital ground with one wire. So don't just use a global ground plane, or use more than one wire. The idea is to make sure that all the analog circuits see ground at the same potential, and the potentially high transient currents from the digital side can cause different portions of the ground to be at different voltages (because it's not perfectly conductive). \$\endgroup\$ – C_Elegans Feb 6 '18 at 2:33
  • \$\begingroup\$ Thanks for your reply. You mean connect AGND together with one trace right, and not connect that trace to DGND? The way you worded it made it seem redundant if we just connect AGND to DGND with one wire. It doesn't sound good if DGND was a ground plane keeping AGND isolated through one trace; if DGND and AGND were seeing different voltages, wouldn't that cause some capacitance build up between the two GNDs? \$\endgroup\$ – user101402 Feb 6 '18 at 13:09
  • \$\begingroup\$ No, connect all the AGND nodes together however you like, and run a single trace to DGND. You need them connected or your ADC chip won't be happy. I have edited my answer with a better explanation for why. \$\endgroup\$ – C_Elegans Feb 6 '18 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.