How does the NCD I2C 4-Channel 4-20mA board stores data in I2C memory?

Hello NCD Support;

Is there any documentation NCD I2C 4-Channel 4-20mA board and how:

*It stores data in I2C memory
*How the four channel values are mapped into memory ?
*How those channel values are mapped to current?

I’ve looked at the data sheet for the MCP3428-10 A/D converter used by this board, and it discusses the data representation that is uses for digitized voltages. Is there additional documentation that discusses what/where/how values are stashed in i2C memory?

To illustrate: I connected the board to a BeagleBone Black’s I2C bus via a Grove Shield set for 5V logic. The NCD device has no 4-20mA inputs connected at this time.

I was able to find the board’s address and then dump the I2C memory - results are below.

Might anyone have insight in how to interpret this dump vs. the four channels of this device?

Thanks!

$ i2cdetect -r 2
Continue? [Y/n] Y

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: – -- – -- – -- – -- – -- – -- –

10: – -- – -- – -- – -- – -- – -- – -- – --

20: – -- – -- – -- – -- – -- – -- – -- – --

30: – -- – -- – -- – -- – -- – -- – -- – --

40: – -- – -- – -- – -- – -- – -- – -- – --

50: – -- – -- UU UU UU UU – -- – -- – -- – --

60: – -- – -- – -- – -- 68 – -- – -- – -- –

70: – -- – -- – -- – --

debian@beaglebone:~$ i2cdump -y 2 0x68 w

 0,8  1,9  2,a  3,b  4,c  5,d  6,e  7,f

00: b302 b302 b302 b302 b302 b302 b302 b302

08: b302 b302 b302 b302 0200 0200 0200 0200

10: b302 b302 b302 b302 b302 b302 b302 b302

18: b302 b302 b302 b302 0200 0200 0200 0200

20: b302 b302 b302 b302 b302 b302 b302 b302

28: b302 b302 b302 b302 0200 0200 0200 0200

30: b302 b302 b302 b302 b302 b302 b302 b302

38: b302 b302 b302 b302 0200 0200 0200 0200

40: b302 b302 b302 b302 b302 b302 b302 b302

48: b302 b302 b302 b302 0200 0200 0200 0200

50: b302 b302 b302 b302 b302 b302 b302 b302

58: b302 b302 b302 b302 0200 0200 0200 0200

60: b302 b302 b302 b302 b302 b302 b302 b302

68: b302 b302 b302 b302 0200 0200 0200 0200

70: b302 b302 b302 b302 b302 b302 b302 b302

78: b302 b302 b302 b302 0200 0200 0200 0200

80: b302 b302 b302 b302 b302 b302 b302 b302

88: b302 b302 b302 b302 0200 0200 0200 0200

90: b302 b302 b302 b302 b302 b302 b302 b302

98: b302 b302 b302 b302 0200 0200 0200 0200

a0: b302 b302 b302 b302 b302 b302 b302 b302

a8: b302 b302 b302 b302 0200 0200 0200 0200

b0: b302 b302 b302 b302 b302 b302 b302 b302

b8: b302 b302 b302 b302 0200 0200 0200 0200

c0: b302 b302 b302 b302 b302 b302 b302 b302

c8: b302 b302 b302 b302 0200 0200 0200 0200

d0: b302 b302 b302 b302 b302 b302 b302 b302

d8: b302 b302 b302 b302 0200 0200 0200 0200

e0: b302 b302 b302 b302 b302 b302 b302 b302

e8: b302 b302 b302 b302 0200 0200 0200 0200

f0: b302 b302 b302 b302 b302 b302 b302 b302

f8: b302 b302 b302 b302 0200 0200 0200 0200

here is a python l;ib whihc can be used to read all 4 channels of the mcp3428


or you can look into this python sample code as well. this will read all 4 channel and return 4-20mA data.

Hi Bhaskar;

Thank you for the code - I’ve tried running the 2nd code on my BeagleBone Black, and I’ve run into a peculiar issue when talking to the NCD I2C 4-Channel 4-20mA via I2C.

I put in a known 10mA DC signal into Channel 2 (DROK 4-20mA SIgnal Generator, output verified with a multimeter). I then ran the code from:

bhaskar-anil429/MCP3428_4_20mA/blob/master/MCP3428_4-20mA_G2.py

Modified to used bus = smbus.SMBus(2)

The code is putting out the following channel 2 values, which obviously do not track the input. Any thoughts on what might be happening or causing this problem?

Also, is there sample Linux i2cget and i2cset commands I could run to read the NCD board independently?

Thanks!

-Bruce M.

Current Output channel 2 : 0.85
Current Output channel 2 : 13.86
Current Output channel 2 : 1.10
Current Output channel 2 : 21.36
Current Output channel 2 : 0.55
Current Output channel 2 : 1.08
Current Output channel 2 : 14.75
Current Output channel 2 : 0.82
Current Output channel 2 : 21.23
Current Output channel 2 : 3.12
Current Output channel 2 : 2.72
Current Output channel 2 : 10.10
Current Output channel 2 : 1.09
Current Output channel 2 : 19.72
Current Output channel 2 : 0.37
Current Output channel 2 : 15.09
Current Output channel 2 : 6.40
Current Output channel 2 : 1.06
Current Output channel 2 : 12.44
Current Output channel 2 : 1.05
Current Output channel 2 : 22.39
Current Output channel 2 : 1.44
Current Output channel 2 : 7.75
Current Output channel 2 : 8.22
Current Output channel 2 : 0.94
Current Output channel 2 : 14.57
Current Output channel 2 : 3.43
Current Output channel 2 : 0.47
Current Output channel 2 : 18.07
Current Output channel 2 : 4.82
Current Output channel 2 : 1.73
Current Output channel 2 : 10.93

The measured value is oscillating quite a bit.

Hi Bruce,
can you print the raw i2c value and also post a picture of your setup?
Yes, you can use the i2c set, get, detect commands on the BB. if you type i2c and “tab” key it will show all supported commands.

Thanks

Hi Bhaskar;

The pictures show the connections between the power supply - the DROK 4-20 mA Signal Generator - and Channel 2 on the NCD board. A Grove Cape V2 I2C connector is wired o the NCD board input.

I used these statements to print the value for Chan 2 in the code’s loop

print "Chan 2, data[0] = %02x" % data[0]
print "Chan 2, data[1] = %02x" % data[1]

Here is the code section that prints out the Channel 2 values:

####### channel 2
bus.write_byte(address, 0x31)
time.sleep(DL1)

MCP3428 address, 0x68(104)

Read data back from 0x00(0), 2 bytes

raw_adc MSB, raw_adc LSB

    data = bus.read_i2c_block_data(address, 0x00, 2)

print "Chan 2, data[0] = %02x" % data[0]
print "Chan 2, data[1] = %02x" % data[1]

Convert the data to 12-bits

    raw_adc = (data[0] & 0x0F) * 256 + data[1]
    if raw_adc > 2047 :
            raw_adc -= 4095
    current = (raw_adc * 0.01109)

Output data to screen

    print "Current Output channel 2 : %.2f" %current
    time.sleep(DL)

And here are the values printed as the code executes:

Current Output channel 1 : 0.07
Chan 2, data[0] = 00
Chan 2, data[1] = 1e
Current Output channel 2 : 0.33
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03
Current Output channel 1 : 0.07

Chan 2, data[0] = 03
Chan 2, data[1] = e7
Current Output channel 2 : 11.08
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03
Current Output channel 1 : 0.07

Chan 2, data[0] = 05
Chan 2, data[1] = 02
Current Output channel 2 : 14.22
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03

Current Output channel 1 : 0.07
Chan 2, data[0] = 00
Chan 2, data[1] = 32
Current Output channel 2 : 0.55
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03

Current Output channel 1 : 0.07
Chan 2, data[0] = 05
Chan 2, data[1] = 96
Current Output channel 2 : 15.86
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03

Current Output channel 1 : 0.07
Chan 2, data[0] = 03
Chan 2, data[1] = 9d
Current Output channel 2 : 10.26
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03

Current Output channel 1 : 0.07
Chan 2, data[0] = 00
Chan 2, data[1] = 39
Current Output channel 2 : 0.63
Current Output channel 3 : 0.03
Current Output channel 4 : 0.03

is the 4-20mA signal generator producing 10mA all the time.
from the data log it looks like the 4-20mA is connecting disconnecting.

Hi Bhaskar;

I’ll do another test where I put my multimeter in the current loop, but when I tested the signal generator by itself, it was producing a constant 10mA.

Are there any test points on the board that we could monitor for status - or is there some jumpering that we neglected?

-Bruce M.

Hi Bruce,
Everything looks good. i dont see any issue with it.

From the adc readings looks like there is a lot of noise there.
Add a 10uF cap to the channel 2 and see if it improves the results.

what kind of power supply are you using to power the board and the 4-20mA signal?

Thanks

Hi Bhaskar;

Jut to double-check - 10 micro-Farad capacitor - just put it across the board + and - jacks? Any particular type of capacitor (electrolytic)?

The signal generator is powered by an Alitov 24V, 5A power adapter, Model LJH138

The NCD board is powered by a power adapter purchased from NCD 12V, 1.5A, Model BYX-1201500E.

I’ve put my multimeter in line with the current signal - no dramatic bouncing around that I can see.

I’ve read the 3428 A/D converter data sheet, and it mentions that "when the device receives a read command, it output two data bytes followed by a configuration register ". I’ve modified the code to block read three bytes, but the third byte is coming back all zeros - is that expected?

Here is a photo of the board - is there any chance that jumpering is an issue?

Thank you for your help!

-Bruce M.

Hi Bruce,
Add the cap where you connect the 4-20mA inputs. Electrolytic will work.
I will need to take a look at the datasheet to know about the configuration value. personally i never used in past.

Thanks

Hi Bhaskar;

I was also wondering whether:

*What is the maximum input voltage allowed to the board?
*Could the jumper settings could affect the reliability of a reading?

Thanks!

-Bruce M.

Hi Bruce,
The max input voltage is 32V.
Jumper settings are there to change the address and setup pull ups.

In past i seen similar issue. its always due to noisy power supply or noisy 4-20mA input. Generally the values will be jumping 1-2mA but in your case they are all over.

Do you have a pi or arduino ?

Thanks

Hi Bhaskar;

I’ll try the capacitor this afternoon and let you know how it goes.

I’m using a BeagleBone Black with a Grove Cape V2 providing the I2C interface.

-Bruce M.

Looks like the i2c voltage level of the Cape is 3.3V and the board I2C voltage level is 5V. This might create the random value issue.
You might consider using this one

Thanks

Hi Nick - I put the capacitor across the leads - no improvement.

The Grove Cape allegedly has a switch that boosts logic levels to 5V, but haven’t heard back from Grove on whether that also applies to the i2C jacks.

WIll order the shield to see if that makes a difference.

-Bruce M.

Hello again - I added the Grove Cape to my Beaglebone, with the default jumpering (pins 19 & 20) and it directly connects to my NCD 4-20mA board. However, I’m having the same issue as before - for a known input current (monitored with a multimeter), I cannot get a stable value back via the python code.

I also tried querying the device via the i2ctools in a Bash script, for continuous mode and for for one-shot mode. Again, no consistency of the readings. (see below)

Saw the same issues when we had the board connected to our pressure sensor.

I’m really not sure what to do next, and wondering whether the boards are malfunctioning. Any thoughts?

-Bruce M.

debian@beaglebone:~/temp$ cat p_continuous_12bit.bash
#!/bin/bash

Bash script p_continuous_12bit.bash

read continously from the NCD 4-channel 4-20mA board

on channel 1, 12-bit resolution, 240 samples/second, x2 gain

Written for BeagleBone Black Rev C, running Debian 9.4 (Stretch) LXQT

To run:

bash -x p_continuous_12bit.bash

List the I2C devices exist in the Linux system

ls /dev/i2c*

Verify that the i2c-2 bus is available

i2cdetect -l

Get the versions of each i2c command

i2cdetect -V
i2cset -V
i2cget -V

Scan bus 2 for devices

i2cdetect -y -r 2

Configure the NCD 3428 chip for

12-bit conversion at 240 samples/second,

Continuous conversion

gain 2

i2cset -y 2 0x68 0x00 0x11 b #Write to address in byte mode

Now continuously read

for (( ; ; ))
do
i2cget -y 2 0x68 0x00 w # Get the value as a 16-bit word
sleep 1
done

debian@beaglebone:~/temp$ bash -x p_continuous_12bit.bash

  • ls /dev/i2c-0 /dev/i2c-1 /dev/i2c-2
    /dev/i2c-0 /dev/i2c-1 /dev/i2c-2
  • i2cdetect -l
    i2c-1 i2c OMAP I2C adapter I2C adapter
    i2c-2 i2c OMAP I2C adapter I2C adapter
    i2c-0 i2c OMAP I2C adapter I2C adapter
  • i2cdetect -V
    i2cdetect version 3.1.2
  • i2cset -V
    i2cset version 3.1.2
  • i2cget -V
    i2cget version 3.1.2
  • i2cdetect -y -r 2
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: – -- – -- – -- – -- – -- – -- –
    10: – -- – -- – -- – -- – -- – -- – -- – --
    20: – -- – -- – -- – -- – -- – -- – -- – --
    30: – -- – -- – -- – -- – -- – -- – -- – --
    40: – -- – -- – -- – -- – -- – -- – -- – --
    50: – -- – -- UU UU UU UU – -- – -- – -- – --
    60: – -- – -- – -- – -- 68 – -- – -- – -- –
    70: – -- – -- – -- – --
  • i2cset -y 2 0x68 0x00 0x11 b
  • i2cget -y 2 0x68 0x00 w
    0x8b00
  • i2cget -y 2 0x68 0x00 w
    0xad04
  • i2cget -y 2 0x68 0x00 w
    0x0701
  • i2cget -y 2 0x68 0x00 w
    0x8902
  • i2cget -y 2 0x68 0x00 w
    0x8d01
  • i2cget -y 2 0x68 0x00 w
    0xbc04
  • i2cget -y 2 0x68 0x00 w
    0x8400
  • i2cget -y 2 0x68 0x00 w
    0xb604
  • i2cget -y 2 0x68 0x00 w
    0x0e00
  • sleep 1
  • i2cget -y 2 0x68 0x00 w
    0xca03
  • sleep 1
  • i2cget -y 2 0x68 0x00 w
    0x4700
  • i2cget -y 2 0x68 0x00 w
    0xea04
  • i2cget -y 2 0x68 0x00 w
    0x0a00
  • i2cget -y 2 0x68 0x00 w
    0x7902
  • i2cget -y 2 0x68 0x00 w
    0x1c00
  • i2cget -y 2 0x68 0x00 w
    0x4704

===========================================
p_oneshot_16bit.bash

#!/bin/bash

Bash script p_oneshot_16bit.bash to read continously from the NCD 4-channel 4-20mA board

Channel #1, Gain 1, One-Shot Mode, 16-bit conversion

Written for BeagleBone Black Rev C, running Debian 9.4 (Stretch) LXQT

To run:

bash -x p_oneshot_16bit.bash

List the I2C devices exist in the Linux system

ls /dev/i2c*

Verify that the i2c-2 bus is available

i2cdetect -l

Scan bus 2 for devices, the ncd board address should be 0x68

i2cdetect -y -r 2

Get the versions of each i2c command

i2cdetect -V
i2cset -V
i2cget -V

Configure the NCD 3428 chip for

16-bit one-shot conversion at 15 Samples/Second, Gain=1

(Configuration byte for these settings is 0x08)

i2cset -y 2 0x68 0x00 0x08 b #Write to address in byte mode

Now continuously read

for (( ; ; ))
do
i2cset -y 2 0x68 0x00 0x88 b #Write a 1 to the msb to initiate a conversion
sleep 0.25
i2cget -y 2 0x68 0x00 w # Get the value as a 16-bit word
sleep 1
done

==================================================================
bash -x p_oneshot_16bit.bash

debian@beaglebone:~/temp$ vi p_oneshot_16bit.bash
debian@beaglebone:~/temp$ bash -x p_oneshot_16bit.bash

  • ls /dev/i2c-0 /dev/i2c-1 /dev/i2c-2
    /dev/i2c-0 /dev/i2c-1 /dev/i2c-2

  • i2cdetect -l
    i2c-1 i2c OMAP I2C adapter I2C adapter
    i2c-2 i2c OMAP I2C adapter I2C adapter
    i2c-0 i2c OMAP I2C adapter I2C adapter

  • i2cdetect -y -r 2
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: – -- – -- – -- – -- – -- – -- –
    10: – -- – -- – -- – -- – -- – -- – -- – --
    20: – -- – -- – -- – -- – -- – -- – -- – --
    30: – -- – -- – -- – -- – -- – -- – -- – --
    40: – -- – -- – -- – -- – -- – -- – -- – --
    50: – -- – -- UU UU UU UU – -- – -- – -- – --
    60: – -- – -- – -- – -- 68 – -- – -- – -- –
    70: – -- – -- – -- – --

  • i2cdetect -V
    i2cdetect version 3.1.2

  • i2cset -V
    i2cset version 3.1.2

  • i2cget -V
    i2cget version 3.1.2

  • i2cset -y 2 0x68 0x00 0x08 b

  • i2cset -y 2 0x68 0x00 0x88 b

  • i2cget -y 2 0x68 0x00 w
    0x5d00

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x9600

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x3402

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x0405

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x2100

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x2d03

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0x3400

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0xd301

  • i2cset -y 2 0x68 0x00 0x88 b

  • sleep 0.25

  • i2cget -y 2 0x68 0x00 w
    0xdd00


Hi Bruce,
Do you have arduino or Pi you can use for testing?
If not i will recommend sending it back for further testing
https://ncd.io/contact-us/product-returns/

Thanks