树叶实验室实验室ADC

树叶实验室实验室ADC

原链接
树叶实验室实验室——搬运(返回主页)

Analog to digital conversion is the process of reading a physical voltage as a number. Maple can convert voltages between 0 and 3.3V to numbers between 0 and 4095.

ADC On Maple

Doing analog-to-digital conversion on the Maple is simple. Maple IDE contains a basic example. To see it, choose Analog > AnalogInSerial from the examples menu.

In order to set up your board for conversion, first connect the wire (potentiometer, etc.) with the voltage you want to measure to a pin which can perform ADC. Each pin which can do ADC has “AIN” (or “ain”) written next to the the pin number. Then, as in the example program, set the chosen pin’s pin mode to INPUT_ANALOG by calling pinMode(<your_pin>, INPUT_ANALOG). You will usually do this in your setup() function. Now you can use analogRead() to perform an ADC reading.

Function Reference

analogRead()
pinMode()
adc.h(low-level ADC support)

Noise and Bias

Maple has a large number of pins which are capable of taking 12-bit ADC measurements, which means that voltages from 0 to 3.3V are read as numbers from 0 to 4095. In theory, this means that a change in voltage of about 1 millivolt should change the numeric voltage reading by 1. In reality, however, a number of issues introduce noise and bias into this reading, and a number of techniques must be used to get good precision and accuracy.

In order to allow for good readings, LeafLabs has tried to isolate at least some of each board’s ADC pins and traces from strong noise sources. However, there are always trade-offs between noise, additional functionality, cost, and package size. More information on these isolated pins is available in each board’s hardware documentation:

Maple
Maple RET6 Edition
Maple Mini
Maple Native Beta

That said, there are a number of more general things you can do to try to get good readings. If your input voltage changes relatively slowly, a number of samples can be taken in succession and averaged together, or the same voltage can even be sampled by multiple ADC pins at the same time.

Another important factor when taking a voltage reading is the reference voltages that the sample is being compared against. For Maple, the high reference is VDDA and the low reference is ground. This means that noise or fluctuations on either VDDA or ground will affect the measurement. It also means that the voltage you are trying to sample must be between ground and 3.3 V.

In the case of a variable reading, it is best if the voltage varies over the entire range of 0 through 3.3 V; otherwise, only a fraction of the sensitivity is being used. Some basic tools to accomplish this are resistor dividers and Zener diodes. However, operational amplifiers and other powered components can also be used if greater precision is required.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值