⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex27 - adc0831.bs2

📁 proteus得一些经典例子
💻 BS2
字号:
' {$STAMP BS2}
' ==============================================================================
'
' File...... Ex27 - ADC0831.BS2
' Purpose... Analog to Digital conversion
' Author.... Parallax
' E-mail.... stamptech@parallaxinc.com
' Started...
' Updated... 01 MAY 2002
'
'
' ==============================================================================
' ------------------------------------------------------------------------------
' Program Description
' ------------------------------------------------------------------------------
' This program deomstrates reading a variable voltage with an ADC0831 analog-
' to-digital convertor chip.
' ------------------------------------------------------------------------------
' I/O Definitions
' ------------------------------------------------------------------------------
A2Ddata CON 0 ' A/D data line
A2Dclock CON 1 ' A/D clock
A2Dcs CON 2 ' A/D chip select (low true)
' ------------------------------------------------------------------------------
' Variables
' ------------------------------------------------------------------------------
result VAR Byte ' result of conversion
mVolts VAR Word ' convert to millivolts
' ------------------------------------------------------------------------------
' Initialization
' ------------------------------------------------------------------------------
Initialize:
HIGH A2Dcs
' ------------------------------------------------------------------------------
' Program Code
' ------------------------------------------------------------------------------
Main:
GOSUB Read_0831
mVolts = result */ $139C ' x 19.6 (mv / unit)
DEBUG Home
DEBUG "ADC..... ", DEC result, " "
DEBUG "volts... ", DEC mVolts DIG 3, ".", DEC3 mVolts, CR
PAUSE 100 ' delay between readings
GOTO Main ' do it again
' ------------------------------------------------------------------------------
' Subroutines
' ------------------------------------------------------------------------------
Read_0831:
LOW A2Dclock
LOW A2Dcs
SHIFTIN A2Ddata, A2Dclock, MSBPost, [result\9]
HIGH A2Dcs
RETURN

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -