Jump to content

Recommended Posts

MCP2221A library


There it is.

The complete library for the MCP2221A. I2c adapter, I/O in a single IC. I love that one.

Let me know if any bug is found.

I try to make that library as much convenient as possible to use. Two version available 32 bit and 64 bit. little note: to open by serial number, the enumeration need to be activated on the device first. (open by index, enable the enumeration) It needs to be done only once in the life time of the device.

PLEASE do not take ownership of this work since it is not yours. You have it for free, but the credit is still mine... I spent many hours of my life to make it works.


  • Submitter
  • Submitted
    05/29/2018
  • Category
  • LabVIEW Version
    2017
  • License Type
    BSD (Most common)

 

Link to comment
  • 8 months later...

Hi Benoit,

I have downloaded this package and it looks like you've put a lot of work into it! But, I can't use the VIs on the older version of LabVIEW, which is all I currently have available. Please could you provide a version compatible with LabVIEW 2015?

It would be very much appreciated.

All the best,

Matthew

Link to comment
  • 10 months later...

Apparently @Benoit does not have access to LabVIEW anymore. At least until the Community Edition is released...

 

I took the liberty of backsaving to LV 2013 and correcting the *char GpioValues bit representation as described in the programmer manual. (Only for 32-bit library)

Microchip MCP2221A_x86 (2013).zip

 

*Please note that I have never used this library and have no way of testing whether the 2013 version works.

Link to comment
  • 3 months later...
  • 1 month later...

I used this library to measure ADT7410 (Analog Devices) and BME280 (Bosch).
The Sample code can be found at the end of the link.

https://momijimomimomi.com/makers/LabVIEW_MCP2221A_I2C_ADT7410.html
https://momijimomimomi.com/makers/LabVIEW_MCP2221A_I2C_BME280.html
(Sorry, these are the Japanese language)

  • Like 1
Link to comment
  • 7 months later...
  • 3 months later...

Hello Mr. Benoit,

 

I am using the MCP2221 to read analog values from an ADC MCP3424, and noticed a bug when reading bytes from the analog data register.

 

The problem only happens when reading i2c and the first bytes are 0x00, but even trying to read 5 bytes, it does not reply any further bytes that aren't 0x00.

Please see images below.

First received byte is 0x00:

image.png.376b2154206a8f93b3329d913e2bd756.pngimage.png.498516db113516551c5bacd533cc47eb.png

First received byte is 01:

image.png.31f9d09a6b338789e7c1ba327ae95285.pngimage.png.40e27cadb62c4a80c0552fccce08e0c8.png

 

Do you have any workaround for this issue? I tried to download latest driver and DLL, but still no luck solving this.

Note: It works fine inside MCP3331 I2C/SMBus Terminal (see below)

image.png.d09af23b78137abc64c2fc0ababb2a47.png

 

Thank you, Fabio Nicolas

Link to comment
  • 3 weeks later...

Dear All

I would like to set only one GPIO (configured as output) at once, not touching other 3. 

VIs "set gpio values" and "set gpio settings" only setting all 4 together, right? Or am I missing something?

 

Is there any solution for my problem? 

 P:S: i could read the GPIO status before every setting, and then set the needed one, leaving other 3 unchanged... but this is very "hacky" solution. 

P.P.S. i'm not very familiar with Labview drivers. How could i create a "set one GPIO" - VI, with GPIO Number and value being set? 

Link to comment
On 4/16/2021 at 12:12 PM, Dimitri Becker said:

Dear All

I would like to set only one GPIO (configured as output) at once, not touching other 3. 

VIs "set gpio values" and "set gpio settings" only setting all 4 together, right? Or am I missing something?

 

Is there any solution for my problem? 

 P:S: i could read the GPIO status before every setting, and then set the needed one, leaving other 3 unchanged... but this is very "hacky" solution. 

P.P.S. i'm not very familiar with Labview drivers. How could i create a "set one GPIO" - VI, with GPIO Number and value being set? 

The underlaying API does not support that and it is quite logical. I2C and SPI are not really designed as bit protocols but as byte protocols. They address typical multiples of 8 or 16 bit per data transfer.

The method to do what you want to do involves reading back the full 8 bit port, modify the bit in question and send back everything.

Link to comment
On 4/17/2021 at 6:59 PM, Rolf Kalbermatter said:

The underlaying API does not support that and it is quite logical. I2C and SPI are not really designed as bit protocols but as byte protocols. They address typical multiples of 8 or 16 bit per data transfer.

The method to do what you want to do involves reading back the full 8 bit port, modify the bit in question and send back everything.

Thank you for the response. I've checked the *.dll and you are right

 

I found out, there is an "unchage" option in the "Set GPIO Values" VI, so it's very easy to implement one Pin opereations, simply making the rest "unchange" ;)

Edited by Dimitri Becker
Link to comment
3 hours ago, Dimitri Becker said:

Thank you for the response. I've checked the *.dll and you are right

 

I found out, there is an "unchage" option in the "Set GPIO Values" VI, so it's very easy to implement one Pin opereations, simply making the rest "unchange" ;)

The unchange is in other solutions called mask. And it is in reality simply doing a read, with a boolean combined OR of the value and an AND of the mask and then writing it back.

Link to comment
  • 2 years later...
On 3/25/2021 at 2:45 PM, Fábio Nicolas Schmidt said:

I am using the MCP2221 to read analog values from an ADC MCP3424, and noticed a bug when reading bytes from the analog data register.

image.png.40e27cadb62c4a80c0552fccce08e0c8.png

 

Do you have any workaround for this issue? I tried to download latest driver and DLL, but still no luck solving this.

This library has a bug. The underlying Read VI should use byte arrays as input and output data and the Call Library Node should be configured accordingly for this parameter to be Array, 8 bit unsigned Integer, Pass as C array pointer.

With the current C String configuration in the Call Library Node, LabVIEW will scan the string after the Call Library Node has finished, and terminate it after the first 0 byte  (since that is how in C strings are terminated).

  • Like 1
Link to comment
  • 3 months later...

Dear Benoit,

Thank you for providing the library.

I noticed that I cannot write 27 byte or more. Mcp2221 I2C Write.vi (x86) stops right after 27th byte transaction and no STOP condition generated nor further byte generated for 28 byte or more transaction. Would it be possible to duplicate on your end? 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.