Shop OBEX P1 Docs P2 Docs Learn Events
i2c — Parallax Forums

i2c

From StampWorks 2.1 pg. 189

Program: SW21-EX33-DS1307.BS2
.
.
'
[ Constants ]
DS1307 CON %1101 << 4
.
.
Why do the above left shift in constant definition? Why not CON %11010000 or just CON $D0




I'm trying to read SF/11 Lidar altimeter, which has address HEX 66, and it aint working!


The program from the book works with DS1307 using i2c

'
[ I/O Definitions ]
Modified for Mobo and worked w/DS1307
SDA PIN 8 'MoboStamp-pe A Port I2C serial data line
SCL PIN 9 'MoboStamp-pe A Port I2C serial clock line
'
'
'
' Further hacks below to make work with SF/11 or so I thought.
'
'
[ Constants ]
SF11 CON $66 ' SF11 I2C address
'
'
' Do a write to SF11
Write_I2C:
I2COUT SDA, SF11, 0, [0] ' Distance command " I think "
RETURN
'
' Read distance
Read_I2C:
I2CIN SDA, SF11, 0, [a,b] ' retrieve distance a VAR Byte and b VAR Byte defined in variables

RETURN


a and b come back with FF,FF

HELP!

Comments

  • kwinnkwinn Posts: 8,697
    From StampWorks 2.1 pg. 189

    Program: SW21-EX33-DS1307.BS2
    .
    .
    '
    [ Constants ]
    DS1307 CON %1101 << 4
    .
    .
    Why do the above left shift in constant definition? Why not CON %11010000 or just CON $D0



    Usually for brevity and showing just the bits required for a specific function such as a clock divider or register selection. No idea what function that is on the DS1307 without going through the data sheet. CON %11010000 or CON $D0 would work just as well.
  • m_pell_98037,

    I did a Yahoo search and Parallax was the first link listed and it includes BS2 code so try it.
    https://www.parallax.com/product/28054
    https://www.parallax.com/downloads/sf10sf11-laser-rangefinder-bs2-code-example
  • I tried the serial bs2 code example and it doesn't work. I called tech support and it didn't work for them either.
    So I'm trying i2c on a BS2pe
  • m_pell_98037,

    According to the documentation it's a 3.3V device that is 5V tolerant on the serial port but is 3.3V for I2C so you will need a voltage level translator.
    Also the documentation says that both the serial baud rate and the I2C device ID are configured through the USB port.

    The link to the Lightware Terminal Software doesn't work but you can find it on the product page.
    https://lightware.co.za/collections/lidar-rangefinders/products/sf11-c-120-m
  • Genetix,

    Speaking of the documentation, what does the excerpt below mean?

    Product manual excerpt
    ;
    If you want to use a different serial emulation program then the USB serial protocol should be set to 921600 baud with 1 stop bit and
    no parity or handshaking
    Product manual excerpt
    ;

    I read it to mean set baud rate to 921600, since I'm using the serial cable not the USB cable. Which by the way I've left at OEM length of about 10" not 4" as shown in Product manual.
    I've tried it several ways and always get FF FF returned.

    I also have already run it at 5v. Could that garble data? You don't suppose I've damaged it do you? Would that be for both data and clock lines?
    Also never built a voltage level translator, would have to Google it.

    I read the 3.3v tolerant part in the serial section and allowed it was a text omission in the I2C interface section.
    The light still comes on, and it still works through the USB Port.
  • Googled voltage level translator and found TXB0104 breakout board.
    Looks like MoBo needs to be set at 3.3v so that Prototyping Daughterboard Vdd(3.3v) and 5v pins would power TXB0104 rails. No?

    Makes me wish I could get SPI to work.
  • kwinnkwinn Posts: 8,697

    ,,,,,,,Looks like MoBo needs to be set at 3.3v so that Prototyping Daughterboard Vdd(3.3v) and 5v pins would power TXB0104 rails. No?

    Correct. If you download the data sheet from TI the bottom of the first page has a block diagram of the connections.
Sign In or Register to comment.