Shop OBEX P1 Docs P2 Docs Learn Events
I2C driver for DS1339 RTC & LSM9DS1 & Flir Lepton — Parallax Forums

I2C driver for DS1339 RTC & LSM9DS1 & Flir Lepton

RaymanRayman Posts: 14,662
edited 2020-08-20 01:09 in Propeller 2
Finally able to test out the real time clock on my first P2 board.

This reads the time and displays over serial connection.
Optionally sets the time.

The driver was converted from Spin1. That was maybe a mistake. Took a long time to work the bugs out...

This code starts a new cog to do the bit-banging in assembly.
But, I'm thinking that Spin2 (especially with Fastspin) should be plenty fast enough to do this without starting a cog.
Also, if there's probably some smartpin mode that can do this in the background.

Still, I also want it to do the LSM9DS1 9dof chip. That one may need a cog to make sure no data from the stream is lost.
The P1 code worked for LSM9DS0. I'm hoping the interface is the same, but don't have it working yet...

Update: Now works with LSM9DS1 & Flir Lepton
Update2: Now works with PNut v34 and FastSpin 4.3.0 (but for the lam9ds1 you need to replace waitcnt with waitms on the last line of code for pnut)

Comments

  • RaymanRayman Posts: 14,662
    edited 2019-12-15 17:48
    Shoot, should have known I'd find a bug as soon as I posted this...
    I wasn't floating SDA in order to read the ack/nak bit correctly on write.
    That's fixed now in updated post.


    Note: This is running at 800 kHz. For 400 kHz change the 100 to 200 here at bottom of driver code:
    cnt_400kHz              long    200
    
  • Odd synchronicity here. On a different thread (where I was banging my head about NOPs this weekend), I was porting code to the P2 for the DS3231. Similar headaches!

    Thats a nice board btw.
  • RaymanRayman Posts: 14,662
    Thanks. I got it working with LSM9DS1 and Flir Lepton today.
    Updated top post.

    But, it needs to be rewritten to use smartpins….
  • Flir lepton sounds great. Look forward to the photos
  • RaymanRayman Posts: 14,662
    This is just for the I2C part.
    Haven't started on the video part yet.
    Hoping can do the Flir 3.5 with higher resolution...
  • @Rayman

    re:Thanks. I got it working with LSM9DS1 and Flir Lepton today.

    That's great, I'm interested in the Flir Lepton as well. You did a really great job on your P2 board.

    What brand soldering paste do you use with your T- 962-A ?
  • RaymanRayman Posts: 14,662
    It was just some no-clean leaded solder from Digikey...
    Think it was Chip Quick brand.
    But, I've used others before... Doesn't seem to matter...
    The no-clean leaded solder always seems to work well...
  • RaymanRayman Posts: 14,662
    Updated top post with code that works with PNut v34 and FastSpin 4.3.0.

    Tested with DS1339 RTC.

    Need to make sure still works for 9DOF Mems and Flir Lepton.
  • Rayman wrote: »
    Thanks. I got it working with LSM9DS1 and Flir Lepton today.
    Updated top post.

    But, it needs to be rewritten to use smartpins….

    Thanks Rayman, those are very useful modules, and I am sure the coding will be well appreciated.

    Some of us like the BNO055 because it also does the 3D calculations and produces Euler angles and Quaternions. - any chance of cracking that interface/code?
  • RaymanRayman Posts: 14,662
    That’s a neat chip. Didn’t know about that one. Looks like it does all the math for you...
  • Yup,
    There is some serious maths involved in calculating Euler angles and Quaternions from raw IMU readings.
    I would rather focus my coding on controlling the platform than background maths coding.
  • RaymanRayman Posts: 14,662
    It is tempting to "cheat" and just get that chip...
    But first, I think I'll try this Madgwick filter thing I found at Adafruit...
    Looks fairly straightforward to implement...

    The LSM9DS1 code needs some work first though.
    Was adapting, LSM9DS0 driver, but there are some big differences to work out...
  • RaymanRayman Posts: 14,662
    I updated top post with test code for the LSM9DS1 and a slightly updated driver.
  • Hi Ray

    Did you ever post the driver for the Flir lepton? Which generation leptop did you use?

    I've been playing with a purethermal board and also my friends board, both use STM32s to decode the "video over spi". I'm interested in hooking this up to the P2
  • RaymanRayman Posts: 14,662
    edited 2020-11-01 02:34
    Good question. Maybe I didn't post yet for some reason...
    I'm meaning to do this in FlexProp C this time.
    But, maybe with the I2C in .spin2.

    Been meaning to do the new Flir Lepton with higher resolution too.
    Have all the bits and parts, just need to find time to put it all together...
  • RaymanRayman Posts: 14,662
    I just got the P1 FLIR Lepton driver working on the P2.

    Wasn't too hard to adapt, but I got hung up for a while on this business of P2 bit banging time difference between OUT and IN...
    Had to insert some NOPs after SPI clock falling edge to get good data.

    Think I'll see about showing this on VGA next.

    Also, want to try with new higher resolution version.

  • Awesome, yes displaying temperatures in text while coloring background to convey temperature would be the ultimate I think




Sign In or Register to comment.