
Everyone has probably heard of ChatGPT, but have you heard of ChatPDF? ChatPDF is a tool that allows you to have a "chat" with a PDF file. In this topic, I will try to use them to search for information in the catalog note of a certain port expander, we will see what the result will be. Could an era be coming when electronics engineers will no longer read catalog notes because AI will do it for them? Let`s find out!
Experiment - catalog note MCP23017
So we upload the PDF and talk - we`ll see what this AI can do. The first port expander with an I2C interface, MCP23017, was launched.
After loading the document, AI immediately describes what the document is:
Chat wrote:
Hello and welcome to the MCP23017/MCP23S17 PDF file! This document provides detailed information about the features and specifications of these 16-bit remote bidirectional I/O ports. With high-speed I/O interfaces, configurable interrupt output pins, and low standby current, these devices offer versatile and efficient solutions for your project needs.
Example questions:
What are the different package types available for the MCP23017/MCP23S17 devices?
How can the interrupt output pins be configured on these I/O ports?
What is the operating voltage range for the MCP23017/MCP23S17 devices in different temperature conditions?
Time for the first question. Maybe we can ask about the address section:

Can AI "understand" how these addresses are created?
p.kaczmarek2 wrote:
Which I2C addresses can have this chip?
Chat wrote:
The MCP23017/MCP23S17 devices support 7-bit slave addressing for I2C communication. The slave address consists of four fixed bits and three user-defined hardware address bits (pins A2, A1, and A0). Therefore, with these three address pins, you can configure up to eight different I2C addresses for the chip.
By setting the states of pins A2, A1, and A0, you can select one of the following I2C addresses for the MCP23017/MCP23S17 devices:
0b0100000 (A2=0, A1=0, A0=0)
0b0100001 (A2=0, A1=0, A0=1)
0b0100010 (A2=0, A1=1, A0=0)
0b0100011 (A2=0, A1=1, A0=1)
0b0100100 (A2=1, A1=0, A0=0)
0b0100101 (A2=1, A1=0, A0=1)
0b0100110 (A2=1, A1=1, A0=0)
0b0100111 (A2=1, A1=1, A0=1)
These addresses allow you to communicate with multiple MCP23017/MCP23S17 devices on the same I2C bus by assigning unique addresses to each device .
The response also included a link to page 15:

For readability, I added spaces myself:
0b010 0000 (A2=0, A1=0, A0=0)
0b010 0001 (A2=0, A1=0, A0=1)
0b010 0010 (A2=0, A1=1, A0=0)
0b010 0011 (A2=0, A1=1, A0=1)
0b010 0100 (A2=1, A1=0, A0=0)
0b010 0101 (A2=1, A1=0, A0=1)
0b010 0110 (A2=1, A1=1, A0=0)
0b010 0111 (A2=1, A1=1, A0=1)
The answer is pretty good. The AI provided 7-bit addresses correctly, I wonder if it also remembers the Read/Write bit?
p.kaczmarek2 wrote:
Assume that I want to write data to this chip via I2C with A2, A1 and A0 high. Which byte would I need to send first?
I expect a reply with a list of bits, and what will I receive?
Chat wrote:
If you want to write data to the MCP23017/MCP23S17 chip via I2C with A2, A1, and A0 set to high, you would need to send the control byte first. The control byte consists of the 7-bit slave address (including the R/W bit) followed by the register address you want to write to.
For the MCP23017/MCP23S17 devices with A2, A1, and A0 set to high, the slave address in binary form would be 0b0100111 (A2=1, A1=1, A0=1). Since this is a write operation, the R/W bit would be 0.
Therefore, the control byte you would need to send first for writing data to the MCP23017/MCP23S17 chip with A2, A1, and A0 high would be:
Slave Address: 0b01001110 (R/W = 0)
After sending this control byte, you can proceed with sending the data bytes to write to the desired registers on the MCP23017/MCP23S17 chip
Pretty good! Let`s separate:
0b010 0111 (A2=1, A1=1, A0=1).
Here the AI correctly added the R/W bit, in this case zero:
Slave Address: 0b0100 1110 (R/W = 0)
Now let`s ask about connections. Let`s see if AI knows about pull-up resistors, for example:
p.kaczmarek2 wrote:
Ok, can you specify how can I connect MCP23017 via I2C to Arduino UNO? Which signals do I need to connect, do I need to connect anything else?
Answer (in the form of an image due to formatting):

So the AI remembered about:
- power supply and ground
- SDA and SCL (correctly specified Arduino pins A4 and A5)

- about address pins A0, A1, A2
- and even about pull-up resistors
- additionally repeated about the power supply
Maybe let`s ask about the power supply:
p.kaczmarek2 wrote:
How to power this circuit, do I need any extra components?
Answer:

The AI remembers that we are talking about Arduino and implicitly assumed that it was Arduino UNO, which is a rather correct assumption. AI also remembers about decoupling capacitors.
I wonder what the AI will do if I change my mind.
p.kaczmarek2 wrote:
I changed my mind. I want to use Arduino Mega instead. How can I connect MCP23017 to Arduino Mega?
I expect a response along these lines:

And this is what I got:

This proves that this language model simply knows the pinouts of Arduino Mega .
p.kaczmarek2 wrote:
Ok, on Arduino Mega, can you show a sample code that will set MCP23017 GPA1 to high state and all other port A pins to low state?
Answer:


Code as text:
Code: C / C++
I don`t have the hardware configuration to run it, but what do we have here... it hasn`t entered anything into IOCON AI, but it sets the registers responsible for PORT A. It doesn`t set the pull up resistors (third register), but the addresses match, I`m also looking at MCP support libraries from Github:

Looks ok...
Let`s check if the AI knows how to set the pull up resistor:

Looks ok.
Maybe it`s something more difficult - let`s try to transfer the code to the mikroC platform for PIC. Here is the documentation for the I2C library there:
https://download.mikroe.com/documents/compilers/mikroc/pic/help/i2c_library.htm
Let`s see what the AI generated:

Well, here`s the problem. I don`t think it`s possible to do it all in one I2C transaction. Even if subsequent bytes were to be placed in subsequent registers in memory (via pointer auto-increment), this would work, but here we want to write to separate registers. Anyway, even this mode would have to be turned on:


Well, I`m not convinced by this code. I`m afraid it won`t work like that, what do you think?
Summary
Basically, I have two conclusions:
- this language model is actually able to find information in PDF
- this language model also has quite a large set of knowledge beyond the given PDF, it knows, for example, which Arduino pins are I2C, etc., it knows more or less the Arduino libraries
However, the model is not perfect and, as is usually the case, it "hallucinates" or "makes things up", in the case of less known languages or problems, it may create answers that look correct but do not actually work.
Nevertheless, I wonder what it will look like in a year or 10 years, I invite you to comment. Do you see potential in such an "AI helper" for reading catalog notes?
Cool? Ranking DIY Helpful post? Buy me a coffee.