自平衡莱洛三角形 RGB版 HW:Ver 1.5 FW:Ver 1.1.1
RGB版本程序 https://gitee.com/muyan3000/RGBFOC 基于45°(https://gitee.com/coll45/foc/)程序修改master
parent
f3efa8eb12
commit
e36bb8fbf5
|
@ -0,0 +1,28 @@
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
|
void Command::run(char* str){
|
||||||
|
for(int i=0; i < call_count; i++){
|
||||||
|
if(isSentinel(call_ids[i],str)){ // case : call_ids = "T2" str = "T215.15"
|
||||||
|
call_list[i](str+strlen(call_ids[i])); // get 15.15 input function
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Command::add(char* id, CommandCallback onCommand){
|
||||||
|
call_list[call_count] = onCommand;
|
||||||
|
call_ids[call_count] = id;
|
||||||
|
call_count++;
|
||||||
|
}
|
||||||
|
void Command::scalar(float* value, char* user_cmd){
|
||||||
|
*value = atof(user_cmd);
|
||||||
|
}
|
||||||
|
bool Command::isSentinel(char* ch,char* str)
|
||||||
|
{
|
||||||
|
char s[strlen(ch)+1];
|
||||||
|
strncpy(s,str,strlen(ch));
|
||||||
|
s[strlen(ch)] = '\0'; //strncpy need add end '\0'
|
||||||
|
if(strcmp(ch, s) == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
// callback function pointer definiton
|
||||||
|
typedef void (* CommandCallback)(char*); //!< command callback function pointer
|
||||||
|
class Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void add(char* id , CommandCallback onCommand);
|
||||||
|
void run(char* str);
|
||||||
|
void scalar(float* value, char* user_cmd);
|
||||||
|
bool isSentinel(char* ch,char* str);
|
||||||
|
private:
|
||||||
|
// Subscribed command callback variables
|
||||||
|
CommandCallback call_list[20];//!< array of command callback pointers - 20 is an arbitrary number
|
||||||
|
char* call_ids[20]; //!< added callback commands
|
||||||
|
int call_count;//!< number callbacks that are subscribed
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
|
||||||
|
|
||||||
|
This software may be distributed and modified under the terms of the GNU
|
||||||
|
General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
on this software must also be made publicly available under the terms of
|
||||||
|
the GPL2 ("Copyleft").
|
||||||
|
|
||||||
|
Contact information
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Kristian Lauszus, TKJ Electronics
|
||||||
|
Web : http://www.tkjelectronics.com
|
||||||
|
e-mail : kristianl@tkjelectronics.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Kalman.h"
|
||||||
|
|
||||||
|
Kalman::Kalman() {
|
||||||
|
/* We will set the variables like so, these can also be tuned by the user */
|
||||||
|
Q_angle = 0.001f;
|
||||||
|
Q_bias = 0.003f;
|
||||||
|
R_measure = 0.03f;
|
||||||
|
|
||||||
|
angle = 0.0f; // Reset the angle
|
||||||
|
bias = 0.0f; // Reset bias
|
||||||
|
|
||||||
|
P[0][0] = 0.0f; // Since we assume that the bias is 0 and we know the starting angle (use setAngle), the error covariance matrix is set like so - see: http://en.wikipedia.org/wiki/Kalman_filter#Example_application.2C_technical
|
||||||
|
P[0][1] = 0.0f;
|
||||||
|
P[1][0] = 0.0f;
|
||||||
|
P[1][1] = 0.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
// The angle should be in degrees and the rate should be in degrees per second and the delta time in seconds
|
||||||
|
float Kalman::getAngle(float newAngle, float newRate, float dt) {
|
||||||
|
// KasBot V2 - Kalman filter module - http://www.x-firm.com/?page_id=145
|
||||||
|
// Modified by Kristian Lauszus
|
||||||
|
// See my blog post for more information: http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it
|
||||||
|
|
||||||
|
// Discrete Kalman filter time update equations - Time Update ("Predict")
|
||||||
|
// Update xhat - Project the state ahead
|
||||||
|
/* Step 1 */
|
||||||
|
rate = newRate - bias;
|
||||||
|
angle += dt * rate;
|
||||||
|
|
||||||
|
// Update estimation error covariance - Project the error covariance ahead
|
||||||
|
/* Step 2 */
|
||||||
|
P[0][0] += dt * (dt*P[1][1] - P[0][1] - P[1][0] + Q_angle);
|
||||||
|
P[0][1] -= dt * P[1][1];
|
||||||
|
P[1][0] -= dt * P[1][1];
|
||||||
|
P[1][1] += Q_bias * dt;
|
||||||
|
|
||||||
|
// Discrete Kalman filter measurement update equations - Measurement Update ("Correct")
|
||||||
|
// Calculate Kalman gain - Compute the Kalman gain
|
||||||
|
/* Step 4 */
|
||||||
|
float S = P[0][0] + R_measure; // Estimate error
|
||||||
|
/* Step 5 */
|
||||||
|
float K[2]; // Kalman gain - This is a 2x1 vector
|
||||||
|
K[0] = P[0][0] / S;
|
||||||
|
K[1] = P[1][0] / S;
|
||||||
|
|
||||||
|
// Calculate angle and bias - Update estimate with measurement zk (newAngle)
|
||||||
|
/* Step 3 */
|
||||||
|
float y = newAngle - angle; // Angle difference
|
||||||
|
/* Step 6 */
|
||||||
|
angle += K[0] * y;
|
||||||
|
bias += K[1] * y;
|
||||||
|
|
||||||
|
// Calculate estimation error covariance - Update the error covariance
|
||||||
|
/* Step 7 */
|
||||||
|
float P00_temp = P[0][0];
|
||||||
|
float P01_temp = P[0][1];
|
||||||
|
|
||||||
|
P[0][0] -= K[0] * P00_temp;
|
||||||
|
P[0][1] -= K[0] * P01_temp;
|
||||||
|
P[1][0] -= K[1] * P00_temp;
|
||||||
|
P[1][1] -= K[1] * P01_temp;
|
||||||
|
|
||||||
|
return angle;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Kalman::setAngle(float angle) { this->angle = angle; }; // Used to set angle, this should be set as the starting angle
|
||||||
|
float Kalman::getRate() { return this->rate; }; // Return the unbiased rate
|
||||||
|
|
||||||
|
/* These are used to tune the Kalman filter */
|
||||||
|
void Kalman::setQangle(float Q_angle) { this->Q_angle = Q_angle; };
|
||||||
|
void Kalman::setQbias(float Q_bias) { this->Q_bias = Q_bias; };
|
||||||
|
void Kalman::setRmeasure(float R_measure) { this->R_measure = R_measure; };
|
||||||
|
|
||||||
|
float Kalman::getQangle() { return this->Q_angle; };
|
||||||
|
float Kalman::getQbias() { return this->Q_bias; };
|
||||||
|
float Kalman::getRmeasure() { return this->R_measure; };
|
|
@ -0,0 +1,59 @@
|
||||||
|
/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
|
||||||
|
|
||||||
|
This software may be distributed and modified under the terms of the GNU
|
||||||
|
General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
on this software must also be made publicly available under the terms of
|
||||||
|
the GPL2 ("Copyleft").
|
||||||
|
|
||||||
|
Contact information
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Kristian Lauszus, TKJ Electronics
|
||||||
|
Web : http://www.tkjelectronics.com
|
||||||
|
e-mail : kristianl@tkjelectronics.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _Kalman_h_
|
||||||
|
#define _Kalman_h_
|
||||||
|
|
||||||
|
class Kalman {
|
||||||
|
public:
|
||||||
|
Kalman();
|
||||||
|
|
||||||
|
// The angle should be in degrees and the rate should be in degrees per second and the delta time in seconds
|
||||||
|
float getAngle(float newAngle, float newRate, float dt);
|
||||||
|
|
||||||
|
void setAngle(float angle); // Used to set angle, this should be set as the starting angle
|
||||||
|
float getRate(); // Return the unbiased rate
|
||||||
|
|
||||||
|
/* These are used to tune the Kalman filter */
|
||||||
|
void setQangle(float Q_angle);
|
||||||
|
/**
|
||||||
|
* setQbias(float Q_bias)
|
||||||
|
* Default value (0.003f) is in Kalman.cpp.
|
||||||
|
* Raise this to follow input more closely,
|
||||||
|
* lower this to smooth result of kalman filter.
|
||||||
|
*/
|
||||||
|
void setQbias(float Q_bias);
|
||||||
|
void setRmeasure(float R_measure);
|
||||||
|
|
||||||
|
float getQangle();
|
||||||
|
float getQbias();
|
||||||
|
float getRmeasure();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* Kalman filter variables */
|
||||||
|
float Q_angle; // Process noise variance for the accelerometer
|
||||||
|
float Q_bias; // Process noise variance for the gyro bias
|
||||||
|
float R_measure; // Measurement noise variance - this is actually the variance of the measurement noise
|
||||||
|
|
||||||
|
float angle; // The angle calculated by the Kalman filter - part of the 2x1 state vector
|
||||||
|
float bias; // The gyro bias calculated by the Kalman filter - part of the 2x1 state vector
|
||||||
|
float rate; // Unbiased rate calculated from the rate and the calculated bias - you have to call getAngle to update the rate
|
||||||
|
|
||||||
|
float P[2][2]; // Error covariance matrix - This is a 2x2 matrix
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,314 @@
|
||||||
|
<!--
|
||||||
|
自平衡莱洛三角形 RGB版
|
||||||
|
HW:Ver 1.5
|
||||||
|
FW:Ver 1.2
|
||||||
|
-->
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<title>自平衡莱洛三角形</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
|
||||||
|
<style>
|
||||||
|
/*input框*/
|
||||||
|
input, button {
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.tl-input{
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 7px 0;
|
||||||
|
background: #F4F4F7;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding-left:5px;
|
||||||
|
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
||||||
|
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
|
||||||
|
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
|
||||||
|
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
|
||||||
|
}
|
||||||
|
.tl-input:focus{
|
||||||
|
border-color: #66afe9;
|
||||||
|
outline: 0;
|
||||||
|
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn {
|
||||||
|
line-height: 1.499;
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
font-weight: 400;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.015);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.015);
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-transition: all .3s cubic-bezier(.645, .045, .355, 1);
|
||||||
|
transition: all .3s cubic-bezier(.645, .045, .355, 1);
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
-ms-touch-action: manipulation;
|
||||||
|
touch-action: manipulation;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: rgba(0,0,0,0.65);
|
||||||
|
background-color: #fff;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1890ff;
|
||||||
|
border-color: #1890ff;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0,0,0,0.12);
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
}
|
||||||
|
.ant-btn-red {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #FF5A44;
|
||||||
|
border-color: #FF5A44;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0,0,0,0.12);
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function loadXMLDoc(path,element)
|
||||||
|
{
|
||||||
|
var xmlhttp;
|
||||||
|
if (window.XMLHttpRequest)
|
||||||
|
{
|
||||||
|
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
|
||||||
|
xmlhttp=new XMLHttpRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// IE6, IE5 浏览器执行代码
|
||||||
|
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
}
|
||||||
|
xmlhttp.onreadystatechange=function()
|
||||||
|
{
|
||||||
|
if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
||||||
|
{
|
||||||
|
document.getElementById(element).innerHTML=xmlhttp.responseText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.open("GET",path,true);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function UpdateInfo()
|
||||||
|
{
|
||||||
|
var xmlhttp;
|
||||||
|
if (window.XMLHttpRequest)
|
||||||
|
{
|
||||||
|
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
|
||||||
|
xmlhttp=new XMLHttpRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// IE6, IE5 浏览器执行代码
|
||||||
|
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
}
|
||||||
|
xmlhttp.onreadystatechange=function()
|
||||||
|
{
|
||||||
|
if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
||||||
|
{
|
||||||
|
var arr=xmlhttp.responseText.split(",");
|
||||||
|
|
||||||
|
document.getElementById('TimeDiv').innerHTML=arr[0];
|
||||||
|
document.getElementById('CurrentMillis').innerHTML=arr[1];
|
||||||
|
|
||||||
|
document.getElementById('BAT_VOLTAGE').innerHTML=arr[2];
|
||||||
|
|
||||||
|
if(document.getElementById('log_control').value=="1"){
|
||||||
|
document.getElementById('Shaft_Velocity').innerHTML =arr[3]+"<br>"+document.getElementById('Shaft_Velocity').innerHTML;
|
||||||
|
document.getElementById('motor_voltage_q').innerHTML=arr[4]+"<br>"+document.getElementById('motor_voltage_q').innerHTML;
|
||||||
|
document.getElementById('target_velocity').innerHTML=arr[5]+"<br>"+document.getElementById('target_velocity').innerHTML;
|
||||||
|
document.getElementById('pendulum_angle').innerHTML=arr[6]+"<br>"+document.getElementById('pendulum_angle').innerHTML;
|
||||||
|
document.getElementById('target_angle').innerHTML=arr[7]+"<br>"+document.getElementById('target_angle').innerHTML;
|
||||||
|
document.getElementById('kalAngleZ').innerHTML=arr[8]+"<br>"+document.getElementById('kalAngleZ').innerHTML;
|
||||||
|
document.getElementById('gyroZrate').innerHTML=arr[9]+"<br>"+document.getElementById('gyroZrate').innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('target_angle_ROM').innerHTML=arr[10];
|
||||||
|
document.getElementById('swing_up_voltage').innerHTML=arr[11];
|
||||||
|
document.getElementById('swing_up_angle').innerHTML=arr[12];
|
||||||
|
document.getElementById('v_i_1').innerHTML=arr[13];
|
||||||
|
document.getElementById('v_p_1').innerHTML=arr[14];
|
||||||
|
document.getElementById('v_i_2').innerHTML=arr[15];
|
||||||
|
document.getElementById('v_p_2').innerHTML=arr[16];
|
||||||
|
|
||||||
|
if(document.getElementById('target_angle_ROM2').value=="") document.getElementById('target_angle_ROM2').value=arr[10];
|
||||||
|
if(document.getElementById('swing_up_voltage2').value=="") document.getElementById('swing_up_voltage2').value=arr[11];
|
||||||
|
if(document.getElementById('swing_up_angle2').value=="") document.getElementById('swing_up_angle2').value=arr[12];
|
||||||
|
if(document.getElementById('v_i_12').value=="") document.getElementById('v_i_12').value=arr[13];
|
||||||
|
if(document.getElementById('v_p_12').value=="") document.getElementById('v_p_12').value=arr[14];
|
||||||
|
if(document.getElementById('v_i_22').value=="") document.getElementById('v_i_22').value=arr[15];
|
||||||
|
if(document.getElementById('v_p_22').value=="") document.getElementById('v_p_22').value=arr[16];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.open("GET",'/update',true);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function MyAutoRun()
|
||||||
|
{
|
||||||
|
UpdateInfo();
|
||||||
|
}
|
||||||
|
setInterval("MyAutoRun()",1000);
|
||||||
|
|
||||||
|
function clearLog()
|
||||||
|
{
|
||||||
|
document.getElementById('Shaft_Velocity').innerHTML ="";
|
||||||
|
document.getElementById('motor_voltage_q').innerHTML ="";
|
||||||
|
document.getElementById('target_velocity').innerHTML ="";
|
||||||
|
document.getElementById('pendulum_angle').innerHTML ="";
|
||||||
|
document.getElementById('target_angle').innerHTML ="";
|
||||||
|
document.getElementById('kalAngleZ').innerHTML ="";
|
||||||
|
document.getElementById('gyroZrate').innerHTML ="";
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkNum(obj) {
|
||||||
|
//检查是否是非数字值
|
||||||
|
if (isNaN(obj.value)) {
|
||||||
|
obj.value = "";
|
||||||
|
}
|
||||||
|
if (obj != null) {
|
||||||
|
//检查小数点后是否对于两位
|
||||||
|
if (obj.value.toString().split(".").length > 1 && obj.value.toString().split(".")[1].length > 2) {
|
||||||
|
//alert("小数点后多于两位!");
|
||||||
|
obj.value = Number(obj.value).toPrecision(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body style="background-color:black;color:white">
|
||||||
|
|
||||||
|
|
||||||
|
<font size=6>自平衡莱洛三角形
|
||||||
|
<div id="TimeDiv" hidden>datetime</div>
|
||||||
|
</font>
|
||||||
|
</div>
|
||||||
|
<div id="OperationHit"><h2></h2></div>
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td height="50">已启动:<span id=CurrentMillis></span> 电池电压:<span id="BAT_VOLTAGE" style="color:#de87b8;"></span> V
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td height="50">
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=0','OperationHit')" class="ant-btn ant-btn-red">开灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=1','OperationHit')" class="ant-btn ant-btn-red">+</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=2','OperationHit')" class="ant-btn ant-btn-red">-</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=3','OperationHit')" class="ant-btn ant-btn-red">关灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=99&Operation=0','OperationHit')" class="ant-btn ant-btn-red">电机启停</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=4','OperationHit')" class="ant-btn ant-btn-red">重启</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left">
|
||||||
|
<table border="1" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#398ad9;">期望角度TA</span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;">摇摆电压SV</span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;">摇摆角度SA</span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;">速度环P1</span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;">速度环I1</span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;">速度环P2</span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;">速度环I2</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;" id="target_angle_ROM"></span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;" id="swing_up_voltage"></span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;" id="swing_up_angle"></span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;" id="v_p_1"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;" id="v_i_1"></span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;" id="v_p_2"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;" id="v_i_2"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" type="text" name="target_angle_ROM" id="target_angle_ROM2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('target_angle_ROM2').value=Number(document.getElementById('target_angle_ROM2').value)+0.5;">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('target_angle_ROM2').value=Number(document.getElementById('target_angle_ROM2').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=0&Operation='+document.getElementById('target_angle_ROM2').value,'OperationHit')">发送</button></td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="swing_up_voltage" id="swing_up_voltage2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_voltage2').value=Number(Number(document.getElementById('swing_up_voltage2').value)+0.10).toPrecision(2);">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_voltage2').value=Number(Number(document.getElementById('swing_up_voltage2').value)-0.10).toPrecision(2);">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=1&Operation='+document.getElementById('swing_up_voltage2').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="swing_up_angle" id="swing_up_angle2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_angle2').value=Number(document.getElementById('swing_up_angle2').value)+1;">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_angle2').value=Number(document.getElementById('swing_up_angle2').value)-1;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=2&Operation='+document.getElementById('swing_up_angle2').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_p_1" id="v_p_12" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_12').value=Number(Number(document.getElementById('v_p_12').value)+0.1).toPrecision(2);">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_12').value=Number(Number(document.getElementById('v_p_12').value)-0.1).toPrecision(2);">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=3&Operation='+document.getElementById('v_p_12').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_i_1" id="v_i_12" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_12').value=Number(document.getElementById('v_i_12').value)+0.5;">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_12').value=Number(document.getElementById('v_i_12').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=4&Operation='+document.getElementById('v_i_12').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_p_2" id="v_p_22" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_22').value=Number(Number(document.getElementById('v_p_22').value)+0.1).toPrecision(2);">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_22').value=Number(Number(document.getElementById('v_p_22').value)-0.1).toPrecision(2);">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=5&Operation='+document.getElementById('v_p_22').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_i_2" id="v_i_22" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_22').value=Number(document.getElementById('v_i_22').value)+0.5;">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_22').value=Number(document.getElementById('v_i_22').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="loadXMLDoc('/Control?Type=1&Index=6&Operation='+document.getElementById('v_i_22').value,'OperationHit')">发送</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td height="50">
|
||||||
|
<button type="button" onclick="document.getElementById('loglist').style.display='block';">显示记录</button>
|
||||||
|
<button type="button" onclick="document.getElementById('loglist').style.display='none';">隐藏记录</button>
|
||||||
|
<button type="button" onclick="clearLog()">清除记录</button>
|
||||||
|
<button type="button" onclick="document.getElementById('log_control').value=1;loadXMLDoc('/Control?Type=0&Index=5&Operation=1','OperationHit')">开启记录</button>
|
||||||
|
<button type="button" onclick="document.getElementById('log_control').value=0;loadXMLDoc('/Control?Type=0&Index=5&Operation=0','OperationHit')">停止记录</button>
|
||||||
|
<input type="hidden" name="log_control" id="log_control" value="1">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left">
|
||||||
|
<table border="1" cellspacing="0" cellpadding="0" ID="loglist" width="100%">
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;">Shaft Velocity</span></td>
|
||||||
|
<td align="center"><span style="color:#398ad9;">motor voltage q</span></td>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;">target_velocity</span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;">pendulum_angle</span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;">target_angle</span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;">kalAngleZ</span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;">gyroZrate</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;" id="Shaft_Velocity"></span></td>
|
||||||
|
<td align="center"><span style="color:#398ad9;" id="motor_voltage_q"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;" id="target_velocity"></span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;" id="pendulum_angle"></span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;" id="target_angle"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;" id="kalAngleZ"></span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;" id="gyroZrate"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,199 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>根据JAVASCRIPT设置innerHTML</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
|
||||||
|
<style>
|
||||||
|
/*input框*/
|
||||||
|
input, button {
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.tl-input{
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 7px 0;
|
||||||
|
background: #F4F4F7;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding-left:5px;
|
||||||
|
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
||||||
|
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
|
||||||
|
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
|
||||||
|
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
|
||||||
|
}
|
||||||
|
.tl-input:focus{
|
||||||
|
border-color: #66afe9;
|
||||||
|
outline: 0;
|
||||||
|
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn {
|
||||||
|
line-height: 1.499;
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
font-weight: 400;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.015);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.015);
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-transition: all .3s cubic-bezier(.645, .045, .355, 1);
|
||||||
|
transition: all .3s cubic-bezier(.645, .045, .355, 1);
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
-ms-touch-action: manipulation;
|
||||||
|
touch-action: manipulation;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: rgba(0,0,0,0.65);
|
||||||
|
background-color: #fff;
|
||||||
|
border-color: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1890ff;
|
||||||
|
border-color: #1890ff;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0,0,0,0.12);
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
}
|
||||||
|
.ant-btn-red {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #FF5A44;
|
||||||
|
border-color: #FF5A44;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0,0,0,0.12);
|
||||||
|
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
box-shadow: 0 2px 0 rgba(0,0,0,0.045);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#FFFFFF" text="#000000">
|
||||||
|
<form name=form1>
|
||||||
|
<br>
|
||||||
|
<table id="loglist">
|
||||||
|
<tr align="left" valign="middle" bgcolor="#eeeeee">
|
||||||
|
<td bgcolor="#eeeeee" height="92">
|
||||||
|
<li> 设置个数<br>
|
||||||
|
<span id="Shaft_Velocity"></span>
|
||||||
|
<input type="text" name="upcount" value="1" id="Shaft_Velocity2">
|
||||||
|
<input type="button" name="Button" οnclick="setid();" value="· 设定 ·">
|
||||||
|
<input type="button" name="ButtonAdd" οnclick="setSetAddOne();" value="· 增加 ·">
|
||||||
|
</li>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr align="center" valign="middle">
|
||||||
|
<td align="left" id="upid" height="122">
|
||||||
|
请选择操作项:<select name=select1><option value=1>中国人打死日本人</option><option value=2>中国人踢死日本人</option><option value=3>中国人玩死日本人</option></select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<div>
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" type="text" placeholder="最低价"></div>
|
||||||
|
<div style="width: 20px;float: left;text-align: center">-</div>
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" type="text" placeholder="最高价"></div>
|
||||||
|
<div style="width: 60px;float: left;margin-left: 20px"><button class="ant-btn ant-btn-red">确定</button></div>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=0','OperationHit')" class="ant-btn ant-btn-red">开灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=1','OperationHit')" class="ant-btn ant-btn-red">+</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=2','OperationHit')" class="ant-btn ant-btn-red">-</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=3','OperationHit')" class="ant-btn ant-btn-red">关灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=4','OperationHit')" class="ant-btn ant-btn-red">重启</button>
|
||||||
|
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td height="50">已启动:<span id=CurrentMillis></span> 电池电压:<span id="BAT_VOLTAGE" style="color:#de87b8;"></span> V
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td height="50">
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=0','OperationHit')" class="ant-btn ant-btn-red">开灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=1','OperationHit')" class="ant-btn ant-btn-red">+</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=2','OperationHit')" class="ant-btn ant-btn-red">-</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=3','OperationHit')" class="ant-btn ant-btn-red">关灯</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=1&Index=99&Operation=0','OperationHit')" class="ant-btn ant-btn-red">电机启停</button>
|
||||||
|
<button type="button" onclick="loadXMLDoc('/Control?Type=0&Index=0&Operation=4','OperationHit')" class="ant-btn ant-btn-red">重启</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left">
|
||||||
|
<table border="1" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#398ad9;">期望角度TA</span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;">摇摆电压SV</span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;">摇摆角度SA</span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;">速度环P1</span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;">速度环I1</span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;">速度环P2</span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;">速度环I2</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><span style="color:#ff5c5c;" id="target_velocity"></span></td>
|
||||||
|
<td align="center"><span style="color:#5bec8d;" id="swing_up_voltage"></span></td>
|
||||||
|
<td align="center"><span style="color:#fd42ac;" id="swing_up_angle"></span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;" id="v_p_1"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;" id="v_i_1"></span></td>
|
||||||
|
<td align="center"><span style="color:#4b8200;" id="v_p_2"></span></td>
|
||||||
|
<td align="center"><span style="color:#ff33ff;" id="v_i_2"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" type="text" name="target_velocity" id="target_velocity2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('target_velocity2').value=Number(document.getElementById('target_velocity2').value)+0.5;">+</button>
|
||||||
|
<button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('target_velocity2').value=Number(document.getElementById('target_velocity2').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="alert('/Control?Type=1&Index=0&Operation='+document.getElementById('target_velocity2').value)">发送</button></td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="swing_up_voltage" id="swing_up_voltage2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_voltage2').value=Number(Number(document.getElementById('swing_up_voltage2').value)+0.10).toPrecision(2);">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_voltage2').value=Number(Number(document.getElementById('swing_up_voltage2').value)-0.10).toPrecision(2);">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="swing_up_angle" id="swing_up_angle2" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_angle2').value=Number(document.getElementById('swing_up_angle2').value)+1;">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('swing_up_angle2').value=Number(document.getElementById('swing_up_angle2').value)-1;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_p_1" id="v_p_12" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_12').value=Number(document.getElementById('v_p_12').value)+0.1;">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_12').value=Number(document.getElementById('v_p_12').value)-0.1;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_i_1" id="v_i_12" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_12').value=Number(document.getElementById('v_i_12').value)+0.5;">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_12').value=Number(document.getElementById('v_i_12').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_p_2" id="v_p_22" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_22').value=Number(document.getElementById('v_p_22').value)+0.1;">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_p_22').value=Number(document.getElementById('v_p_22').value)-0.1;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<div style="width: 90px;float: left"><input class="tl-input" name="v_i_2" id="v_i_22" size="2" onchange="checkNum(this)"><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_22').value=Number(document.getElementById('v_i_22').value)+0.5;">+</button><button type="button" class="ant-btn ant-btn-primary" onclick="document.getElementById('v_i_22').value=Number(document.getElementById('v_i_22').value)-0.5;">-</button><br>
|
||||||
|
<button type="button" class="ant-btn ant-btn-red" onclick="">发送</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<script>
|
||||||
|
function checkNum(obj) {
|
||||||
|
//检查是否是非数字值
|
||||||
|
if (isNaN(obj.value)) {
|
||||||
|
obj.value = "";
|
||||||
|
}
|
||||||
|
if (obj != null) {
|
||||||
|
//检查小数点后是否对于两位
|
||||||
|
if (obj.value.toString().split(".").length > 1 && obj.value.toString().split(".")[1].length > 2) {
|
||||||
|
//alert("小数点后多于两位!");
|
||||||
|
obj.value = Number(obj.value).toPrecision(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.getElementById('Shaft_Velocity').innerHTML +="11"+"<br>";
|
||||||
|
document.getElementById('Shaft_Velocity').innerHTML +="22"+"<br>";
|
||||||
|
document.getElementById('Shaft_Velocity2').value="aa";
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
|
||||||
|
|
||||||
|
This software may be distributed and modified under the terms of the GNU
|
||||||
|
General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
on this software must also be made publicly available under the terms of
|
||||||
|
the GPL2 ("Copyleft").
|
||||||
|
|
||||||
|
Contact information
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Kristian Lauszus, TKJ Electronics
|
||||||
|
Web : http://www.tkjelectronics.com
|
||||||
|
e-mail : kristianl@tkjelectronics.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
const uint8_t IMUAddress = 0x68; // AD0 is logic low on the PCB
|
||||||
|
const uint16_t I2C_TIMEOUT = 1000; // Used to check for errors in I2C communication
|
||||||
|
|
||||||
|
uint8_t i2cWrite(uint8_t registerAddress, uint8_t data, bool sendStop) {
|
||||||
|
return i2cWrite(registerAddress, &data, 1, sendStop); // Returns 0 on success
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t i2cWrite(uint8_t registerAddress, uint8_t *data, uint8_t length, bool sendStop) {
|
||||||
|
Wire.beginTransmission(IMUAddress);
|
||||||
|
Wire.write(registerAddress);
|
||||||
|
Wire.write(data, length);
|
||||||
|
uint8_t rcode = Wire.endTransmission(sendStop); // Returns 0 on success
|
||||||
|
if (rcode) {
|
||||||
|
Serial.print(F("i2cWrite failed: "));
|
||||||
|
Serial.println(rcode);
|
||||||
|
}
|
||||||
|
return rcode; // See: http://arduino.cc/en/Reference/WireEndTransmission
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t i2cRead(uint8_t registerAddress, uint8_t *data, uint8_t nbytes) {
|
||||||
|
uint32_t timeOutTimer;
|
||||||
|
Wire.beginTransmission(IMUAddress);
|
||||||
|
Wire.write(registerAddress);
|
||||||
|
uint8_t rcode = Wire.endTransmission(false); // Don't release the bus
|
||||||
|
if (rcode) {
|
||||||
|
Serial.print(F("i2cRead failed: "));
|
||||||
|
Serial.println(rcode);
|
||||||
|
return rcode; // See: http://arduino.cc/en/Reference/WireEndTransmission
|
||||||
|
}
|
||||||
|
Wire.requestFrom(IMUAddress, nbytes, (uint8_t)true); // Send a repeated start and then release the bus after reading
|
||||||
|
for (uint8_t i = 0; i < nbytes; i++) {
|
||||||
|
if (Wire.available())
|
||||||
|
data[i] = Wire.read();
|
||||||
|
else {
|
||||||
|
timeOutTimer = micros();
|
||||||
|
while (((micros() - timeOutTimer) < I2C_TIMEOUT) && !Wire.available());
|
||||||
|
if (Wire.available())
|
||||||
|
data[i] = Wire.read();
|
||||||
|
else {
|
||||||
|
Serial.println(F("i2cRead timeout"));
|
||||||
|
return 5; // This error value is not already taken by endTransmission
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; // Success
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue