I2C help
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
I2C help
I started a project to measure UV-B light. I bought a sensor VEML6075 with use I2C to read the data. The datasheet is:
http://www.farnell.com/datasheets/20177 ... 1481200214
My problem is that I never before worked with I2C.
Who can help me to start the development of a flowcode 7 for it?
Be informed:
- The sensor can measure more wavelength, but I need only the UV-B part of the (sun) light.
- I do the soldering of the 4 pins of the sensor (1x2 mm)!
With kind regards
Jan Lichtenbelt
http://www.farnell.com/datasheets/20177 ... 1481200214
My problem is that I never before worked with I2C.
Who can help me to start the development of a flowcode 7 for it?
Be informed:
- The sensor can measure more wavelength, but I need only the UV-B part of the (sun) light.
- I do the soldering of the 4 pins of the sensor (1x2 mm)!
With kind regards
Jan Lichtenbelt
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C help
Hi Jan,
Good luck with the soldering, sounds like you'll need a steady hand.
This article might help to get you up to speed on using I2C.
http://www.matrixtsl.com/blog/simplifie ... c-and-spi/
Good luck with the soldering, sounds like you'll need a steady hand.
This article might help to get you up to speed on using I2C.
http://www.matrixtsl.com/blog/simplifie ... c-and-spi/
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: I2C help
Hi Ben,
That helps a lot. The difference for my is that the data needed are 16 bits. I changed the folowcode in a high and low byte, as attachment.
I have a question. The I2C Master has pins on C4 (data) and C3(clock) on the 16F1847 microchip. But this chip does not have these pins. The data sheet show SDA1 on B1 en SCL1 on B4, or SDA2 on B2 and SCL2 on B5. How do I know which pins are used? How can one change that?
With kind regards
Jan Lichtenbelt
That helps a lot. The difference for my is that the data needed are 16 bits. I changed the folowcode in a high and low byte, as attachment.
I have a question. The I2C Master has pins on C4 (data) and C3(clock) on the 16F1847 microchip. But this chip does not have these pins. The data sheet show SDA1 on B1 en SCL1 on B4, or SDA2 on B2 and SCL2 on B5. How do I know which pins are used? How can one change that?
With kind regards
Jan Lichtenbelt
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: I2C help
Hi
If you change the property for I2C master from Software to Channel 1 or 2 you will see the pins are correct as per data sheet
If you change the property for I2C master from Software to Channel 1 or 2 you will see the pins are correct as per data sheet
- Attachments
-
- 1.JPG (40.5 KiB) Viewed 7719 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C help
Hi Jan,
Hmm that's odd the definition file looks correct.
Here is the latest FCD just in case you have a different version.
Hmm that's odd the definition file looks correct.
Code: Select all
<i2c master='0' >
<sda port='1' pin='1' />
<scl port='1' pin='4' />
</i2c>
<i2c master='0' >
<sda port='1' pin='2' />
<scl port='1' pin='5' />
</i2c>
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: I2C help
It is still very hard for me to understand I2C well. Can someone help me.
Please find my flowcode the measure the UV_B light intensity of an UV sensor VEML6075. It does not work correctly, which can be due to a Flowcode error or hardware. I found a C-code programm (attached) which I use as example for the Flowcode. The read and write I2C procedure for reading/writing a word is given in the picture.
With kind regards
Jan Lichtenbelt
PS. Pay attention: The 16LF1847 microchip has been used in this Flowcode
Please find my flowcode the measure the UV_B light intensity of an UV sensor VEML6075. It does not work correctly, which can be due to a Flowcode error or hardware. I found a C-code programm (attached) which I use as example for the Flowcode. The read and write I2C procedure for reading/writing a word is given in the picture.
With kind regards
Jan Lichtenbelt
PS. Pay attention: The 16LF1847 microchip has been used in this Flowcode
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: I2C help
Hi Jan
I too think I2C can be a difficult concept. Sometimes I can get something to work fairly easily and other times I can really struggle with the device.
I bought a book on the subject from Elektor
Mastering The I2C BUS by Vincent Himpe, it does cover everything from the basics to advanced topics.
Like most of the books published by Elektor, its quite a good reference source.
I too think I2C can be a difficult concept. Sometimes I can get something to work fairly easily and other times I can really struggle with the device.
I bought a book on the subject from Elektor
Mastering The I2C BUS by Vincent Himpe, it does cover everything from the basics to advanced topics.
Like most of the books published by Elektor, its quite a good reference source.
1 in 10 people understand binary, the other one doesn't !
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: I2C help
Hi Jan,
Your flowchart looks neat, just one typo I spotted.. in Receive_Data the "Read Databyte High" has a TransmitByte that should be ReceiveByte
Hope that helps
Leigh
Your flowchart looks neat, just one typo I spotted.. in Receive_Data the "Read Databyte High" has a TransmitByte that should be ReceiveByte
Hope that helps
Leigh
- Jay Dee
- Posts: 398
- Joined: Tue Aug 18, 2009 6:42 pm
- Has thanked: 121 times
- Been thanked: 154 times
- Contact:
Re: I2C help
Hi Jan,
Foe me the bit I have to remember in i2C are,
Pull up resistors on Clock and Data Line.
Remembering its a 7 Bit Address + the Read or Write Bit.
With my current project, the external ADC Chips i2c has....
The read/write bit is 1 for Read, 0 for Write.
So if the hardware 7 bit address is ( 0x4C ) in binary 0b1001100
the actual byte sent is, the address bit shifted left by 1 + R/W bit.
thus
(0x98) 0b10011000 for a Write
and
(0x99) 0b10011001 for a Read.
+Live scope decoding is a real luxury!! J.
Foe me the bit I have to remember in i2C are,
Pull up resistors on Clock and Data Line.
Remembering its a 7 Bit Address + the Read or Write Bit.
With my current project, the external ADC Chips i2c has....
The read/write bit is 1 for Read, 0 for Write.
So if the hardware 7 bit address is ( 0x4C ) in binary 0b1001100
the actual byte sent is, the address bit shifted left by 1 + R/W bit.
thus
(0x98) 0b10011000 for a Write
and
(0x99) 0b10011001 for a Read.
+Live scope decoding is a real luxury!! J.
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: I2C help
Hi LeighM and Steve
It works! That means I can read the device ID. But this UV sensor still gives intensity of zero, probably due to the less sunshine these days.
But the soldering of the 1x2mm with 4 pins is possible even by a hobbyist like me!
With kind regards
Jan Lichtenbelt
It works! That means I can read the device ID. But this UV sensor still gives intensity of zero, probably due to the less sunshine these days.
But the soldering of the 1x2mm with 4 pins is possible even by a hobbyist like me!
With kind regards
Jan Lichtenbelt