MCP3421 I2C 18bit ADC help

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

MCP3421 I2C 18bit ADC help

Post by STibor »

Hello to everyone!
Can you help someone example program uses the MCP3421 analog digital converter?
I looked at the datasheet, but I can not find a solution.
Thank you for your help!

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: MCP3421 I2C 18bit ADC help

Post by Gary Freegard »

Hi Simpi
http://ww1.microchip.com/downloads/en/D ... 22003b.pdf
I haven’t used this device but I have had a look at the datasheet, its slightly confusing if not familiar with I2C. Here is what I can get from it.
The slave address is $68, though it is possible to order the device with a different address (add 1 to 7), see bottom of page 12
The correct address to be used in I2C is the $68 <<1 (left shift), for a write operation use this and for a read operation add 1 to the address. i.e. write operation address is $D0 and read is $D1.
page 11 describes the configuration register. The key point about this register is bit 7 , this is used to start a conversion in one shot and is used to show that a conversion has taken place in continuous mode.

One shot mode (config 10001000, One shot, 15sps, 1v/v)
  • MI2C_Start
    MI2C_Transmit_Byte($D0)
    MI2C_Transmit_Byte($88)
    MI2C_Stop
    Delay(1/15)
    MI2C_Start
    MI2C_Transmit_Byte($D1)
    MI2C_Receive_Byte-hi byte
    MI2C_Receive_Byte-lo byte
    MI2C_Receive_Byte-config byte
    MI2C_Stop
MI2C_Recieve_Byte
For continuous conversion
  • MI2C_Start
    MI2C_Transmit_Byte($D0)
    MI2C_Transmit_Byte($18)
    MI2C_Stop
    Delay(1/15)
    MI2C_Start
    MI2C_Transmit_Byte($D1)
    MI2C_Receive_Byte-hi byte
    MI2C_Receive_Byte-lo byte
    MI2C_Receive_Byte-config byte
    MI2C_Stop
In 18 bit mode there are three bytes of data plus the config byte.
  • MI2C_Receive_Byte-hi byte
    MI2C_Receive_Byte-mid byte
    MI2C_Receive_Byte-lo byte
Using table 5-2 you would be able to determine if the data received was from a new conversion, if it is not new then read again.

Hope this helps

Gary

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: MCP3421 I2C 18bit ADC help

Post by STibor »

Hi!
Thank you for your answer, really helped a lot! :D
Charged flowchart simulator works.
Attachments
mcp3421 single.fcf
(10.5 KiB) Downloaded 473 times

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: MCP3421 I2C 18bit ADC help

Post by STibor »

J or K type thermocouple thermometer. 0 to 450 ° C degrees.
The thermocouple measures the MCP3421 18-bit ADC.
The MCP3421 and MCP9701 measured of cold junction compensation.
The program is 450 variable stored in data array of temperature / voltage compensation.
Gary Freegard Thanks for your help!
https://profiles.google.com/simonfitibo ... 3828111122

Post Reply