PDA

View Full Version : INA219 conversion time



iw2fvo
- 13th November 2020, 11:12
good day to everybody on this forum,
I am using INA219 sensor with PICbasic and it is working well as far as the data accuracy is concerned.
I do have a point to discuss regarding the configuration register. I did set the register in this way:

CNFG_REG=%0011011111111111
I2CWRITE SDA,SCL,ADDR_P,$00,[CNFG_REG]

In accordance to the data sheet it will deal to 32 VDC, 128 samples at 68 mSec, continuous conversion.
I do read the sensor in this way:

HIGH SPARE_PIN ' Start the scope trace
X:
I2CREAD SDA,SCL,ADDR,$02,[PB2],no_ack ' GET BUS VOLTAGE

if pb2.1=0 then ' TEST CONVERSION READY BIT
GOTO X
ENDIF

IF PB2.0=1 THEN OVF=1
IF PB2.0=0 THEN OVF=0

'I2CREAD SDA,SCL,ADDR,$00,[PB0],no_ack 'GET CONFIG
I2CREAD SDA,SCL,ADDR,$01,[PB1],no_ack 'GET SHUNT VOLTAGE
pauseus 10
I2CREAD SDA,SCL,ADDR,$03,[PB3],no_ack 'GET POWER
pauseus 10
I2CREAD SDA,SCL,ADDR,$04,[PB4],no_ack 'GET CURRENT
pauseus 10
'I2CREAD SDA,SCL,ADDR,$05,[PB5],no_ack 'GET CALIBRATION
LOW SPARE_PIN ' STOP the scope trace

Unfortunately my scope indicates about 28 msec that is shorter than the 68 msec declared on the data sheet.
I also have conversion time that are not reasonable if I do set 64, or 32 or 16 samples average on the config register.
I need to know the conversion time exactly in my application.
What am I doing wrong on my code please ? Or am I make mistakes reading the data sheet ?
Thanks for any help on the matter.
Regards,
Bye

richard
- 13th November 2020, 12:12
you have set the device to continuous conversion mode , the conversion process did not begin when you set "SPARE_PIN and read the bus voltage"
you don't know when it started. i don't believe you are measuring conversion time. the CONVERSION READY BIT was cleared by reading the power reg
it does not trigger a new conversion that i can see.

secondly your snippet gives no indication of read frequency or how or why it would be synced to conversions ..

thirdly the registers can be read at any time after the first conversion in continuous conversion mode i have never found it to be an issue
what are you trying to do ?

iw2fvo
- 13th November 2020, 16:54
Thanks a lot Richard for the reply.
I will try to indicate what I am trying to implement .... using my limited English language.
My program applies a correction to a dc power supply by changing the duty cycle of pic pwm output. After that a change command is sent to power supply, I have to read the results from the power supply new output by reading the INA219 data: I must be sure that the reading is refered to the end of conversion to avoid any overcontrol. I also need to average ( about 128 samples ) to get a stable data reading.
I am not able to understand how implement this operation by studing the INA219 data sheet... it could be that I do not understand it well.
Thanks in advance for any help on this matter.
Regards,
Ambro

richard
- 13th November 2020, 23:54
My program applies a correction to a dc power supply by changing the duty cycle of pic pwm output.


detail is scant, lets start with
how often are these corrections applied and feedback samples taken ?
why are you thinking the free running, continuously available 128 sample averaged results are inadequate ?

iw2fvo
- 14th November 2020, 08:09
thanks,
let me try to explain....

The correction is applied every 150 msec.
let me say that at t=0 the correction is applied.
At t+50 msec the power supply output is completely set.
1> Should I wait 50 msec + 68 msec to get fitered data from INA219 ? ( without looking at the end of conversion bit ).
2> what is the operation of the end of conversion bit ? Is it relevant to What start of conversion ? How is the "start of conversion" started ?
3> what is the triggered mode ? I can not find any description on the ds.

Thanks for helping.
regards
Ambro

richard
- 14th November 2020, 08:25
The correction is applied every 150 msec.
Does that mean you take a new "reading" every 150 ms ?

1> Should I wait 50 msec + 68 msec to get fitered data from INA219 ? ( without looking at the end of conversion bit ).
in free run mode yes ,the "read" you get is the latest available

2> what is the operation of the end of conversion bit ? Is it relevant to What start of conversion ?
in free run i don't see it has any useful function



How is the "start of conversion" started ?
set the config to the triggered mode you desire




what is the triggered mode ? I can not find any description on the ds.


data sheet
BASIC ADC FUNCTIONS
Writing any of the triggered convert modes into the
Configuration Register (even if the desired mode is
already programmed into the register) triggers a
single-shot conversion. Table 7 lists the triggered
convert mode settings

iw2fvo
- 14th November 2020, 10:29
Thanks,
it is somewhat clear to me now . I will follow that inmplementation.

> "set the config to the triggered mode you desire " : Yes, it is OK , but when does the trigger start pls ?
Amb

richard
- 14th November 2020, 11:56
that is the trigger
in continuous mode the end of conversion triggers the next conversion
any other mode (single conversion) waits for user to retrigger it

iw2fvo
- 14th November 2020, 13:10
so the trigger in triggered mode is the sending of the config register ?
Amb

iw2fvo
- 14th November 2020, 13:13
the procedure is to send the conf register and wait for the end of conversion bit and read the data : is this OK?
Ambro