Hey again,
just for completeness:
you can also use mbbiDirect records to get the individual fields,
just like you did for the
channel number. You just need to additionally define the number of
bits like this:
record( mbbiDirect, "ADC:CONVERSION:RESULT:ALERT" ) {
field( DTYP, "Raw Soft Channel" )
field( NOBT, "1" )
field( SHFT, "15" )
field( INP, "ADC:CONVERSION:RESULT__ NPP NMS" )
field( FLNK, "ADC:CONVERSION:RESULT:CHANNEL" )
}
record( mbbiDirect, "ADC:CONVERSION:RESULT:CHANNEL" ) {
field( DTYP, "Raw Soft Channel" )
field( NOBT, "3" )
field( SHFT, "12" )
field( INP, "ADC:CONVERSION:RESULT__ NPP NMS" )
field( FLNK, "ADC:CONVERSION:RESULT:VALUE" )
}
record( mbbiDirect, "ADC:CONVERSION:RESULT:VALUE" ) {
field( DTYP, "Raw Soft Channel" )
field( NOBT, "12" )
field( SHFT, "0" )
field( INP, "ADC:CONVERSION:RESULT__ NPP NMS" )
}
Cheers
Florian
On 06/28/2016 12:57 PM, Florian
Feldbauer wrote:
Hey,
you could use a CALC record to get the individual fields of the
16-bit value.
I'm using a similar ADC where bit 15 is an ALERT-flag, bits 14-12
code the channel,
and bits 11-0 hold the conversion result.
For accessing these three values I'm using:
record( longin, "AD7998:$(ID):CONVERSION:RESULT__" ) {
field( DTYP, "stream" )
field( INP, "@ad7998.proto rConv($(ID)) I2C" )
field( FLNK, "AD7998:$(ID):CONVERSION:RESULT:SPLIT__" )
}
record( calc, "AD7998:$(ID):CONVERSION:RESULT:SPLIT__" ) {
field( INPA, "AD7998:$(ID):CONVERSION:RESULT__ NPP NMS" )
field( CALC, "b := (( A & 32768 ) >> 15 ); c := (( A
& 28672 ) >> 12 ); ( A & 4095 )" )
field( FLNK, "AD7998:$(ID):CONVERSION:FANOUT__" )
}
Field B of the CALC records contains the alert flag, field C the
channel number
and VAL the actual conversion result.
Hope that helps.
Cheers,
Florian
Hello,
I am trying to read the voltag from an 8-channel adc via
I2C.
My result is a 16 bit value (for example 0010 0000 0010
0000). The bits15-12 "0010" respresent the channel (Ch1=0,
CH2=1, CH3=2 ....).
I can get the channel value with a SHFT-field:
record( longin, "ADC:RESULT" ) {
field( DTYP, "stream" )
field( INP, "@adc.proto readReg($(ID)) I2C" )
}
record( mbbiDirect, "ADC:RESULT:CHANNEL" ) {
field( DTYP, "Raw Soft Channel" )
field( INP, "ADC:RESULT.VAL")
field(SHFT, "12")
}
Now I want to get the first bits 0-12 and convert the
value to voltage-value. To convert this value I use the
"ASLO"-field.
But I don't know which is the best way to get the value
of the first 12 bits.
Thanks,
Raul
--
----------------------------------------
| Dr. Florian Feldbauer |
| |
| Helmholtz-Institut Mainz / |
| Johannes Gutenberg-Universität Mainz |
| Johann-Joachim-Becher-Weg 36 |
| D-55128 Mainz |
| |
| Office: SB1 / 00-213 |
| Phone: (+49)6131 / 39-29608 |
----------------------------------------
--
----------------------------------------
| Dr. Florian Feldbauer |
| |
| Helmholtz-Institut Mainz / |
| Johannes Gutenberg-Universität Mainz |
| Johann-Joachim-Becher-Weg 36 |
| D-55128 Mainz |
| |
| Office: SB1 / 00-213 |
| Phone: (+49)6131 / 39-29608 |
----------------------------------------
|