Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:32 17 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite I2C 16 Bit Read / Write

Author Message
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 08:54am 07 Sep 2017
Copy link to clipboard 
Print this post

I have been slowly working on building my own weather station and wanted to use a standard Micromite to read a few sensors and send that data via rf to a reciever inside for further processing. One of the sensors is a Vishay VEML6075 UV sensor and it has a I2C interface. It uses registers that are 16 bits wide instead of 8 bits and requires 16 bit transfers.

Here is the data sheet... Vishay VEML6075

At the top of page 6 it says

"Each of the registers in the VEML6075 are 16 bit wide, so 16 bit should be written when a write command is sent, and 16 bit should be read when a read command is sent."

Using a raspberry pi and python I was able to use bus.write_word_data and bus.read_word_data to do the 16 bit read and write.

What I need to know is if the micromite can do 16 bit I2c read and write since I would like to use it to read my sensors. The VEML6075 is the only one that uses 16 bits instead of 8. I don't currently own a micromite so I can't test anything.

Thanks Max
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 12:00pm 07 Sep 2017
Copy link to clipboard 
Print this post

Hi,

Page 85 talks about it.

Seems you specify the number of Bytes to be written or read.

The Example there Writes 3 bytes,

[code]I2C WRITE &H6F, 1, 3, &H23, &H43, &H25[/code]

If it was only to write 2 bytes, or 16 bits it would be,

[code]I2C WRITE &H6F, 1, 2, &H23, &H43[/code]

or

[code]I2C WRITE &H6F, 1, 2, &B00100011, &B01000011[/code]

Correct me if I have the Hex to Bin wrong.

Phil.
 
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 03:16pm 07 Sep 2017
Copy link to clipboard 
Print this post

Not the same thing. This sensor uses 16 bit transfers or words. Your example uses 8 bit transfers or bytes.

Max
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 05:13pm 07 Sep 2017
Copy link to clipboard 
Print this post

You might need a 16-bit Cfunction to deal with that. Matherp or Geoff would be able to say for sure. MOST I2C stuff is 8-bit, so this device is being difficult.

I would have thought that even if it DOES need to send 16-bits, it would send a two-byte word rather then a 16-bit word, as just about everything can deal with 8-bit I2C....
Smoke makes things work. When the smoke gets out, it stops!
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1399
Posted: 05:33pm 07 Sep 2017
Copy link to clipboard 
Print this post

I must be reading the data sheet incorrectly.

It has 16 bit resolution and holding registers, in the timing diagrams 16 bit transfers appear to be normal HI - LO bytes transfers. Which is the norm for R/W 16 bit values in most sensors.

Once again, excuse my ignorance if I'm reading that wrong.

Mike.
It's all too hard.
Mike.
 
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 05:35pm 07 Sep 2017
Copy link to clipboard 
Print this post

  Grogster said   You might need a 16-bit Cfunction to deal with that. Matherp or Geoff would be able to say for sure. MOST I2C stuff is 8-bit, so this device is being difficult.

I would have thought that even if it DOES need to send 16-bits, it would send a two-byte word rather then a 16-bit word, as just about everything can deal with 8-bit I2C....


Vishay has to be different than everyone else! Their VELM6070 used two addresses, which is again unusual, but at least it used 8 bit transfers. But it doesn't do all the things that the VELM6075 does.

I wanted to just use a simple PICF88 but can't find any 16 bit I2C routines for that either. So that is why I was going to try the micromite in hopes it could do it without reinventing the wheel.
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 05:51pm 07 Sep 2017
Copy link to clipboard 
Print this post

Reading the datasheet shows that the data is sent/read in Low byte/High byte format to make up the 16bit word. Or in other words, 2x 8 bit transfers, not 1 x 16 bit transfer.
The MM should do it fine, and although I haven't tested it, Phil's code should be ok.

Cheers!

GTG!
...... Don't worry mate, it'll be GoodToGo!
 
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 06:23pm 07 Sep 2017
Copy link to clipboard 
Print this post

I sure hope the micromite can do this without any problems. When I was writing the code on the raspberry pi and python all I got was errors until I started using the bus.write_word_data and bus.read_word_data commands. I've never had to do that before but then again I might not know what I'm doing.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 06:35pm 07 Sep 2017
Copy link to clipboard 
Print this post

The data sheet shows the data being sent in 2 8bit bytes with the ACK between them.



All they want is for you to read/write both high and low bytes at the same time.

Jim
VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 07:12pm 07 Sep 2017
Copy link to clipboard 
Print this post

...and there you have it.
Smoke makes things work. When the smoke gets out, it stops!
 
kg4pid
Regular Member

Joined: 08/03/2015
Location: United States
Posts: 50
Posted: 06:59am 08 Sep 2017
Copy link to clipboard 
Print this post

I rewrote the code to read the raw data and have it working, so the micromite should be able to do it to. Now if I can just figure out how to finish the code to calicate the UV index. My brain is tired.

Thanks for all the help, Max
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024