Filter 消除CC3200上传感器读数的噪音?
一步一步我到目前为止做了什么 1) 微控制器采用德克萨斯仪器公司的CC3200(wifi内置微控制器) 2) 导电橡胶线拉伸传感器-连接到微控制器的模拟引脚 **传感器行为=(拉伸导电橡胶时电阻增加) 现在,下面是我调试到微控制器以运行传感器的参考代码(使用energia工具IDE)。 代码只不过是为web服务器编写的(我提供了可用的wifi ssid和密码,您可以在下面的程序“iPhone和passowrd”中看到),传感器的代码也被写入其中 该Web服务器读取并生成微控制器的IP地址以及拉伸传感器的值 Web服务器代码:Filter 消除CC3200上传感器读数的噪音?,filter,webserver,client,noise,Filter,Webserver,Client,Noise,一步一步我到目前为止做了什么 1) 微控制器采用德克萨斯仪器公司的CC3200(wifi内置微控制器) 2) 导电橡胶线拉伸传感器-连接到微控制器的模拟引脚 **传感器行为=(拉伸导电橡胶时电阻增加) 现在,下面是我调试到微控制器以运行传感器的参考代码(使用energia工具IDE)。 代码只不过是为web服务器编写的(我提供了可用的wifi ssid和密码,您可以在下面的程序“iPhone和passowrd”中看到),传感器的代码也被写入其中 该Web服务器读取并生成微控制器的IP地址以及拉伸
#include <SPI.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
// which analog pin to connect
#define RUBBERPIN A3
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
// your network name also called SSID
char ssid[] = "iPhone";
// your network password
char password[] = "123456789";
// your network key Index number (needed only for WEP)
int keyIndex = 0;
WiFiServer server(3000);
void setup() {
Serial.begin(115200); // initialize serial communication
analogReference(EXTERNAL);
pinMode(RED_LED, OUTPUT); // set the LED pin mode
// attempt to connect to Wifi network:
Serial.print("Attempting to connect to Network named: ");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP
network:
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
Serial.print(".");
delay(300);
}
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE) {
// print dots while we wait for an ip addresss
Serial.print(".");
delay(300);
}
// you're connected now, so print out the status
printWifiStatus();
Serial.println("Starting dataerver on port 3000");
server.begin(); // start the web server on port
80
Serial.println("Dataserver started!");
}
void loop() {
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(RUBBERPIN);
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.println(average);
client.println(average);
delay(10);
}
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("Network Name: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
运行以下程序后的结果:
服务器发送数据,客户端以无线方式接收数据——一切正常
我能够看到我期望的输出信号。i、 例如,当我的传感器处于静止位置时,输出必须是直线,如果我拉伸传感器,电压信号必须增加-我能够看到所有这些。但是,
这里有一个小问题
输出信号发出噪声(请查看下图)
所以我的问题是,即使传感器处于静止位置——没有任何拉伸——也会出现峰值
请帮助我请先格式化您的代码。首先,代码闻起来很像,而且无论如何都不是这样的。与硬件相关的东西,或者至少与信号数字滤波器有关。这不是C代码!语言正确。请先格式化你的代码。首先,代码闻起来很像,而且无论如何都不是这样的。与硬件相关的东西,或者至少与信号数字滤波器有关。这不是C代码!使语言正确。
import processing.net.*;
Client c;
String input;
int data[];
int posx;
void setup()
{
size(1000, 500);
background(204);
stroke(0);
frameRate(5); // Slow it down a little
// Connect to the server's IP address and port
c = new Client(this, "192.168.23.2", 3000); // Replace with your server's IP
and port
posx =2;
data = new int[3];
}
void draw()
{
posx++;
// Receive data from server
if (c.available() > 0) {
input = c.readString();
input = input.substring(0, input.indexOf("\n")); // Only up to the newline
println(input);
data[0]=data[1];
data[1] = int(input); // Split values into an array
// Draw line using received coords
stroke(0);
line(posx-1, data[0]+10, posx, data[1]+10);
}
}