Many of us start our digital sensor projects with the hopeful assumption that "all I need to do is hook up some wires and and write some code." Sometimes, it really is that easy. Connector pin assignments between the sensor and processor board match, example code provides the necessary protocol and we are off and running that afternoon. However, we often find that there is a lot more to developing reliable communications between a sensor and a master system processor. Here is a quick list of things that can delay our success in our sensor integration work, using the SPI interface on a MEMS IMU as our object lesson. Some of them are directly influenced by code, others are not. Successful integration requires that all of these needs be met.
- Power Supply: All digital mixed signal devices have switching noise and some sort of transient current demands during start-up. Make sure the power conversion devices can meet these needs and make sure that the delivery of this power (between converter and sensor) doesn't introduce excessive series impedance or change the transient responses of the system. Assume that you are can just hook any +3.3V source up to your sensor at your own peril!
- Correct Serial Interface Connections: Check for this in the sensor's datasheet. For a SPI, get used to seeing things like "master in, slave out" as MISO....Here is an example:
- Serial command structures: Things like bit order (MSB or LSB first?), addressing and distinguishing between a read and a write are all important. Looks for diagrams like this to help:
- Clock, phasing and timing: Again, check the datasheet for timing diagrams and tables of information that might be helpful:
- Physical connections: Does your setup look like a rat's nest of wires or have you run twisted pairs (one signal/one ground) for each sensitive signal through the shortest distance possible?
- Signal integrity: Ringing, random spikes, persistent noise, low signal strength are all things that often need careful probing with an oscilloscope for troubleshooting when their are unexpected results. Use stable test patterns to study signals and make sure there is no opportunity. Here is an example test pattern:
I hope that this helps! Remember, it takes more than a few lines of code to assure reliable digital communications.