04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADIN16<br />

<strong>Syntax</strong><br />

adin16 pin, result<br />

• Pin - is a constant, variable or expression of an analog capable pin. See table from ADIN.<br />

Commands<br />

• Result - is a word (or larger) sized variable where the analog to digital sample will be store.<br />

Supported<br />

• BA - Supported<br />

• BAN - Supported<br />

• BAP - Supported<br />

• BAP40 - Supported<br />

Description<br />

ADIN16 was create to generate a more accurate reading from the analog to digital hardware. The<br />

typical A/D reading has a value range of 0 to 1024. ADIN16 drastically improves this by over sampling<br />

which results in a higher resolution A/D range. It sets up the A/D converter and stores the sum of 64<br />

conversions in a result variable. The result variable will contain a 16 bit sum of all the conversions.<br />

This value can be used as a 16 bit resolution A/D reading which will be some what noisy. The noise<br />

can be cleaned up by right shifting the value. This produces better results than a standard A/D<br />

conversion value.<br />

Notes<br />

1. 64 readings are taken which increase the time need to produce a result. The A/D is a separate<br />

piece of hardware which functions outside of the main MCU. ADIN16 will have little affect on the<br />

processing speed as the multiple conversions happen very fast relative to the entire instruction<br />

time.<br />

Example<br />

The following example will load the result into the variable temp then right shift it 4 times. This gives<br />

an A/D range of 0 to 4095 which is 4 times better than a standard 0 to 1023 reading.<br />

temp var word<br />

main<br />

adin16 p0,temp<br />

temp = temp>>4 ;temp will hold a 12bit decimated A/D conversion<br />

serout s_out,i9600,[“Conversion = “,dec temp,13]<br />

pause 100<br />

goto main<br />

Schematic<br />

See ADIN.<br />

87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!