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.

https://www.adafruit.com/products/1120

Any help is greatly appreciated.

Share this post


Link to post
Share on other sites

i2c is notoriously difficult to get right mostly both busses are bidirectional so you have to muck around with tristating a lot. If you can afford the adafruit 1231 or something else with spi you will probably have a better experience (all the sognalling in spi is unidirectional).

Share this post


Link to post
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.

Share this post


Link to post
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).

Share this post


Link to post
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. https://www.sparkfun.com/products/10530),

 

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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now