项目创意

基于PC,Arduino和Processing的示波器

字号+ 作者:duino123.com 来源:未知 2016-04-26 23:40 我要评论( )

基于PC,Arduino和Processing的示波器

PLCLIVE.COM 注:本例是基于PC和arduino,processing的简易示波器,实现比较简单,可以作为平时制作的一个辅助工具。


arduinoScope.jpg


Picture of Arduino oscilloscope

特点:

  • 50K samples/second
    (actually it can go up to 110K but the signal will become noisy)
  • Auto trigger
  • Frequency counter
  • Reasonably accurate voltage readings (depending on the accuracy of the resistors used for the voltage dividers)
  • Optional: selectable voltage range: 5V, 6.6V, 10V, 20V

所需材料:

  • An Arduino Leonardo or Arduino Micro
  • 2 crocodile clamps
  • a 0.1µF capacitor (optional)
  • a 5.1V zener diode (optional)
  • a pc with Processing

分压器(可选:如果测量范围超过5V或者范围可调):

  • 2 two-pole dual throw switches
  • two 3K resistors
  • two 1.5K resistors
  • one 1K resistor
  • a small perfboard or breadboard


如果测量范围小于5V,可以跳过分压器部分,直接将探针连接到GND和A11,代码做如下改动:

In the arduino code, replace:

ADMUX =  B00000000;         // select external reference and port 5 (A0)
with:
ADMUX =  B01000000;         // select internal reference (Vcc - 5V) and port 5 (A0)
In the processing code, replace:
// read switch position & set voltage range
 boolean switch1=((buffer[writeIndex*2]&(byte)8)==8);                                                 
 boolean switch2=((buffer[writeIndex*2]&(byte)4)==4);
 if (!switch1&&!switch2) voltageRange=20;
 if (!switch1&&switch2) voltageRange=10;
 if (switch1&&!switch2) voltageRange=6.64;
 if (switch1&&switch2) voltageRange=5;
with:
voltageRange=5;
源代码下载

 

Picture of Adding voltage dividers



以上电路包括:


On the left: a 1:4 voltage divider between the probe and A1

This will bring the voltage down to 1/4 of the input voltage. The analog pins can handle 5V, so this will allow for voltages up to 20V.

Note that there are 2 input channels in the picture of the breadboard. Adding an extra channel slowed down the sampling rate dramatically (because continuous mode can't be enabled on the ADC), so I decided to leave it out in the final code.

On the right: a switched voltage divider between 5V and the Analog Reference (AREF) pin
You can use the switches to set the measuring range: 5V, 6.64V, 10V of 20V

How this works:

If configured to 'external reference', the ADC compares the voltage of the analog inputs with AREF, instead of 5V.
Here's an example: suppose the probe is measuring 5V. The voltage on the A1 will be 5V/4 = 1.25V

  • If both switches are off, the voltage on the AREF pin is 5V.
    The ADC will read 1.25/5 = 25%
  • If switch 1 is off and switch 2 is on, the voltage on AREF is 2.5V
    The ADC will read 1.25/2.5 = 50%
  • If switch 1 is on and switch 2 is off, the voltage on AREF is 1.66V
    The ADC will read 1.25/1.66 = 75%
  • If both switches are on, the voltage on AREF is 1.25V
    The ADC will read 1.25/1.25 = 100%

The second pole of each switch is connected to a digital input. We can read this pin to automatically adjust the voltage scale.

探针与接地之间的电容
Might not be necessary, but for some reason some pc's measure a lot of noise without it. The capacitor will solve that, but may slightly affect the signal when measuring high frequencies.

A0与GND之间的稳压管
To protect the arduino a little from overvoltage or reverse voltage 

注意事项:

  • If the analog reference is set to internal (default) while you are supplying voltage to the AREF pin, the arduino could get damaged. I did that, and it didn't damage mine, but better be safe and upload the proper code before connecting AREF.
  • the analog inputs can't handle negative voltages.
  • Don't exceed 5V on the arduino pinsIt's probably a good idea to test the circuit with a voltage below 5V, so

    you don't damage the arduino in case the voltage divider on A1 was wired incorrectly.




如需更详细资料,如有好资源分享,请加入QQ交流群:214461008

欢迎阅读,欢迎转载,不用注明出处!本站只提供入门和进阶资料,做您学习的小伙伴!

老司机也欢迎光临指导!有好内容请加群:214461008 不要看声明了,看内容吧!

相关文章
  • 利用电视遥控器控制Arduino

    利用电视遥控器控制Arduino

    2016-05-13 17:27

  • ESP8266 Arduino气象站

    ESP8266 Arduino气象站

    2016-04-28 18:44

  • 简化到不能再简化的Arduino

    简化到不能再简化的Arduino

    2016-04-28 16:50

  • 10块钱成本自制Arduino淘宝商家别怪我

    10块钱成本自制Arduino淘宝商家别怪我

    2016-04-28 16:24

网友点评
Arduino