Recommended Posts

I'm quite new to FPGA's and am usually fairly good at matching hardware specs, but this seems like a whole new boat to me. Can anyone tell me if the below accelerometer/ magnetometer will work well with the Papilio One. I'm trying to create a custom PID controller using this as my main input.

Any help is greatly appreciated.

Link to comment
Share on other sites

IMO, I2C isn't that hard provided that you are only designing a single master or a slave.  According to the LSM303DLHC data sheet, it's an I2C slave so you only have to implement an I2C master on the FPGA.  The Wikipedia page on I2C has links to the I2C specification and other useful docs, and this overview at NXP (formerly Philips, which invented I2C) may be useful: AN10216.


Take a look at the standard and see if you're comfortable dealing with the waveforms.  You will probably need a digital oscilloscope for debugging.  It doesn't have to be fast, but you will need to capture single traces to make sure the ACKs are happening correctly.  I2C uses open-drain drivers to prevent bus contention, but that means that if two drivers are on at the same time you can't tell which one is misbehaving.


There's probably open-source I2C master Verilog or VHDL available somewhere.  A single I2C master is easier than slave, since you don't need to filter the inputs.  A single I2C master is the only source for the clock SCL, so you don't need to tri-state it.  You only need to deal with tri-stating the bidirectional data signal SDA.

Link to comment
Share on other sites

Please correct my terminology, as I said I am brand new to FPGA boards so here goes:


I was planning to use the ZAP interface, which as far as I can tell means I would load a pre-made bit file, which basically spoofs an Arduino at a possible faster clock speed and with more IO ports (the main reason I chose the Papilio One over the Arduino Uno; all around more flexibility it seemed). Does this make this issue better (there already exists an Arduino lib for all of the accels on Adafruit)? Does it still warrant preferring a different accelerometer?. From what I understand after some brief reading is that I2C differs from SPI in that I would have to do some minor parsing of the stream to get the output using I2C (searching for packet starts and logging them; filtering the input channel), whereas SPI is already direct output.


I don't mind springing for a more straight forward card but would want to move to the 2021, because the added magnetometer will give me a global coordinate system frame (I can use for added autonomy later... maybe).

Link to comment
Share on other sites

If you wanted a little bit of H/W assistance you could to that. I've got a project that reads from a HMC5883L Triple Axis Magnetometer over I2C (e.g.,


You could do something like that to store the data in a bank of memory-mapped registers, allowing the CPU to pick up and use them with minimal fuss. You could even stamp sequence numbers on the registers, ensuring that you never miss an update...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.