chipKIT onboard I2C device access?

edited November 2015 in Cyton
Hi all!

I'm completely new to the OpenBCI kit, and not so good at programming, so please bear with me. :-) For a project, I'd like to read the ADC data directly to a PIC microcontroller; how would I begin doing this?  The SPI bus is my first thought, but I wasn't sure what I'd have to do in the OpenBCI firmware to make it work (or if it would work).  Any suggestions are appreciated, and I'm sorry if this is an obvious problem!  Thanks!   

Comments

  • biomurphbiomurph Brooklyn, NY
    @marvins42,

    the OpenBCI 32bit Board comes with at PIC32 on it already! That chip talkes to the RFduino radio moudule, and sends the data over-air to your PC with USB dongle attached.
  • Hi biomurph, thanks for the answer!  I'd like to bypass the computer part; I would use the PIC32, but the I2C bus isn't accessible (I want to use the data to control a separate device that requires I2C control). 
  • I would like to second this. Reading through the PIC32 docs it is actually confusing to me which actual pins on the OpenBCI layout correspond to I2C. The other option is to use one of the GPIOs exposed as a chip select for another SPI line.
  • biomurphbiomurph Brooklyn, NY
    edited November 2015
    We had to juggle alot of priorities when laying out the 32bit board. Unfortunately, the I2C pins are defined in hardware on the PIC32 we're using. Adding another SPI device to the OpenBCI is definitely easier, but we also want to work with I2C devices.

    One issue is timing. We don't want to get in the way of reading the ADS1299. Samples are coming in at 250Hz, that's one every 4mS.
    If the I2C bus is running at 400KHz, we could theoretically get over 1000 I2C clock cycles in between ADS samples. That's plenty of time to do stuff. I'm going down this road, because I'm thinking of bit-banging the I2C. I've done it before, many years ago, working with PIC chips and PIC Basic Pro. In house, I have an RGB color sensor that I want to try to drive... 

  • edited November 2015
    At the moment, I plan to hang a Teensy off the back of the OpenBCI board so I can process the data at rate. SPI should be fine for that purpose but native I2C would be nice. I2C allows for connection to a ton of useful things like a time & date chip so I can accurately timestamp readings or an IMU like the BNO055 to get head orientation vs gravity (you need to fuse accelerometer and gyro for that).
  • biomurphbiomurph Brooklyn, NY
    @aronrubin,
    I agree that I2C is valuable to have access to, and getting access to that is a priority in any future hardware revision. 
    Until then, we will see what can be done with bitbanging.
  • rkennettrkennett Sydney, Australia
    Did anyone have success using I2C bitbanging? Any code examples?
  • biomurphbiomurph Brooklyn, NY
    @rkennett
    We have not done any internal work on this yet.
    There is a soft I2C library that might work out of the box?
  • rkennettrkennett Sydney, Australia
    Thanks biomurph. 
    The other solution seems to be using a SPI RTC module and I have found this one https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS3234.html which might be even simpler than bit banging.
    Interferring with the data streaming should not be an issue as I will only be talking to the RTC just prior to streaming the data to the SD card.


  • wjcroftwjcroft Mount Shasta, CA
    RKennett, your SPI RTC sound like the best solution.

    I also realized, there are things called SPI to I2C bridge chips,


    Regards,

    William
Sign In or Register to comment.