You are viewing outdated content for BUG. If you have a BUG Y.T. edition or 2.0 series device, please visit our updated wiki: http://wiki.buglabs.net



ADC HOWTO

From BUG Wiki

Jump to: navigation, search

Introduction

The datasheet is a bit difficult to read for someone that is not familiar with low level computer science or that don't have some experience with reading datasheets.

If something is wrong or unclear the datasheet has the final word.

Input commands

In the datasheet they tell you that:

up to two words may be written into the device

It means that if you want to send a full 16bit command you have to do it in 2 times.But the bug device handle it transparently,and you can issue a full 16bit command in one line of code like this:

vhc.writeADC(IVonHippelModuleControl.VH_ADC_W1_EN| IVonHippelModuleControl.VH_ADC_W1_CH01 | 0x200 |0x8000 );

vhc beeing a IVonHippelModuleControl instance

In order to write an input command using the firt part (the first 8bits(of the first command) ) you have to use IVonHippelModuleControl.VH_ADC_W1_EN ,that contains the first 3 bits: 1,0 and EN(that is set to 1)

In the command(vhc.writeADC(...) ) we can see some '|',theses are bitwise or,that is to say it's doing an or on the each bits

here's how the table appear in the datasheets:

1 0 EN SGL ODD A2 A1 A0 EN2 IM FA FB SPD GS2 GS1 GS0
first 8bits(of the first command) remaining 8 bit(of the second command)
first bit,

always set to 1

second bit,

always set to 0

Enable bit

(for the first part of the command)

selects the channels configurations Enable bit

(for the second part of the command)

Temperature

(selects internal temperature sensor)

rejection frequency Speed

of the capture (1x or 2x available)

gain configuration
  • The frequency rejection seem used to reject the noise associated with the 220V But I'm not shure
  • The Gain acts like an amplifier,increasing the precision of low voltages mesurements


But here's how you should understand them:

EN2 IM FA FB SPD GS2 GS1 GS0 1 0 EN SGL ODD A2 A1 A0
higher part of the number (most significant bits) lower part of the number (least significant bits)
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
0x8000 0x4000 0x2000 0x1000 0x800 0x400 0x200 0x100 0x80 0x40 0x20 0x10 0x8 0x4 0x2 0x1

In order to construct a command you can use the constant fields values or make them by hand

For instance if you want the first 0,the first 1 and the enable bit of the first it will be:

  • 0x80|0x20

we omited 0x40 because this bit was set to 0