好人帮帮忙!英文翻译!

好人帮帮忙!英文翻译!,第1张

塑造

A RBF神经网络有输入层数,非线性暗藏

layer和线性产品层数。 在每层数之内的结

are充分地连接了到早先层数结。 输入变数其中每一被分配到在输入层数的结并且被连接直接地到暗藏的层数,不用重量。 暗藏的层数结是RBF单位。 结计算中心和网络输入传染媒介之间的欧几里德的距离,并且通过结果一个非线性作用[17]。 产品层数结是RBF的被衡量的线性组合在暗藏的层数的。 一个RBF神经网络的The结构与n输入的,

one输出了,并且q暗藏的结在图1.被给。

Where,输入x = [x1、x2,…, xn] T和w = [w1, w2,…, wq] T是神经网络重量。 ui是a

nonlinear作用和这里,它被选择作为高斯

activation作用

where ci = (ci1, ci2,…, cij) T, j=1, 2,…, n,是ith RBF暗藏的单位的中心,并且双是ith RBF暗藏的单位的宽度。 然后ith RBF网络产品可以代表作为q依据作用的一个线性地被衡量的总和

Let y (k)代表网络的指标值在时间k。 网络的The错误在时间k的被定义如下:

The网络的价值函数是被摆正的错误之间

the目标和被预言的价值,以下等式给:

The使被摆正的错误减到最小的学习算法目标

using梯度下降做法。 因此,变动的

output重量wi、中心cij和宽度双是坚定的 根据以下等式的 :

where α是动量期限,并且η是学习的率, α ∈ [0,1], η ∈ [0, 1]。 期限_wi、_cij和_bi被定义如下: 我们编程体会RBF算法的When,怎么

choose以下三个参量的最宜的原始价值在Eqs的。 (5)–(7) : 产品重量wi、中心cij和宽度双,是非常重要的。 如果他们没有适当地被选择, RBF神经网络也许贬低塑造的有效性和准确性。 因此一种基因算法被用于优选RBF神经网络参量。

Agenetic算法是维护的一个交互式做法 构成套候选人解答对具体串的a人口[第18个问题]。 在每个世代时,在当前人口的串为他们的有效率是额定的作为解答。 通过使用基因 *** 作,例如选择、天桥和变化,根据这些评估,候选人解答的新的人口被形成。 有要求的四主要步使用基因算法解决问题,包括,健身的编码,评估,基因 *** 作和终止标准。

PIC单片机的你看一下

//*********************************************************************************

#include <pic.h>

#include <pic16f684.h>

#include <math.h>

#include <stdlib.h>

void Init()

void PID()

void Set_Constants()

bit flag1,do_PID,int_flag

signed char en0, en1, en2, en3, term1_char, term2_char, off_set

unsigned char temp

short int temp_int

unsigned short int ki, kd, kp

signed int SumE_Min, SumE_Max, SumE, integral_term, derivative_term, un

signed long Cn

// __CONFIG _CP_OFF &_CPD_OFF &_BOD_OFF &_MCLRE_ON &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_FCMEN_ON

//***************************************************************************

// Positional PID 256 Hz

//***************************************************************************

//***************************************************************************

//Main() - Main Routine

//***************************************************************************

void main()

{

Init() //Initialize 12F629 Microcontroller

Set_Constants() //Get PID coefficients ki, kp and kd

while(1) //Loop Forever

{

if(do_PID){

PID()

}

}

}

//***************************************************************************

//Init - Initialization Routine

//***************************************************************************

void Init()

{

PORTA = 0

TRISA = 0b00101101 // Set RA4 and RA2 as outputs

PORTC = 0

TRISC = 0b00000011 // Set RC0 and RC1 as inputs, rest outputs

CMCON0 = 0x07 // Disable the comparator

IRCF0 = 1 // Used to set intrc speed to 8 MHz

IRCF1 = 1 // Used to set intrc speed to 8 MHz

IRCF2 = 1 // Used to set intrc speed to 8 MHz

CCP1CON = 0b01001100 // Full bridge PWM forward

ECCPAS = 0 // Auto_shutdown is disabled for now

PR2 = 0x3F // Sets PWM Period at 31.2 kHz

T2CON = 0 // TMR2 Off with no prescale

CCPR1L = 0 // Sets Duty Cycle to zero

TMR2ON = 1 // Start Timer2

ANSEL = 0b00110101 // Configure AN0,AN2,AN4 and AN5 as analog

VCFG = 0 // Use Vdd as Ref

ADFM = 1 // Right justified A/D result

ADCS0 = 1 // 16 TOSC prescale

ADCS1 = 0

ADCS2 = 1

CHS0 = 0 // Channel select AN0

CHS1 = 0

CHS2 = 0

ADON = 1 //Turn A/D on

en0 = en1 = en2 = en3 = term1_char = term2_char =0

ki = kd = 0

kp = off_set = 0

temp_int = integral_term = derivative_term = un =0

SumE_Max = 30000

SumE_Min = 1 - SumE_Max

do_PID = 1 // Allowed to do PID function

T0CS = 0 // Timer0 as timer not a counter

TMR0 = 10 // Preload value

PSA = 0 // Prescaler to Timer0

PS0 = 0 // Prescale to 32 =>256 Hz

PS1 = 0

PS2 = 1

INTCON = 0

PIE1 = 0

T0IE = 1 // Enable Timer0 int

GIE = 1

return

}

void PID() // The from of the PID is C(n) = K(E(n) + (Ts/Ti)SumE + (Td/Ts)[E(n) - E(n-1)])

{

integral_term = derivative_term = 0

// Calculate the integral term

SumE = SumE + en0 // SumE is the summation of the error terms

if(SumE >SumE_Max){ // Test if the summation is too big

SumE = SumE_Max

}

if(SumE <SumE_Min){ // Test if the summation is too small

SumE = SumE_Min

} // Integral term is (Ts/Ti)*SumE where Ti is Kp/Ki

// and Ts is the sampling period

// Actual equation used to calculate the integral term is

// Ki*SumE/(Kp*Fs*X) where X is an unknown scaling factor

// and Fs is the sampling frequency

integral_term = SumE / 256 // Divide by the sampling frequency

integral_term = integral_term * ki // Multiply Ki

integral_term = integral_term / 16 // combination of scaling factor and Kp

// Calculate the derivative term

derivative_term = en0 - en3

if(derivative_term >120){ // Test if too large

derivative_term = 120

}

if(derivative_term <-120){ // test if too small

derivative_term = -120

} // Calculate derivative term using (Td/Ts)[E(n) - E(n-1)]

// Where Td is Kd/Kp

// Actual equation used is Kd(en0-en3)/(Kp*X*3*Ts)

derivative_term = derivative_term * kd // Where X is an unknown scaling factor

derivative_term = derivative_term >>5 // divide by 32 precalculated Kp*X*3*Ts

if(derivative_term >120){

derivative_term = 120

}

if(derivative_term <-120){

derivative_term = -120

}

// C(n) = K(E(n) + (Ts/Ti)SumE + (Td/Ts)[E(n) - E(n-1)])

Cn = en0 + integral_term + derivative_term // Sum the terms

Cn = Cn * kp / 1024 // multiply by Kp then scale

if(Cn >= 1000) // Used to limit duty cycle not to have punch through

{

Cn = 1000

}

if(Cn <= -1000)

{

Cn = -1000

}

if(Cn == 0){ // Set the speed of the PWM

DC1B1 = DC1B1 = 0

CCPR1L = 0

}

if(Cn >0){ // Motor should go forward and set the duty cycle to Cn

P1M1 = 0 // Motor is going forward

temp = Cn

if(temp^0b00000001){

DC1B0 = 1

}

else{

DC1B0 = 0

}

if(temp^0b00000010){

DC1B1 = 1

}

else{

DC1B1 = 0

}

CCPR1L = Cn >>2 // Used to stop the pendulum from continually going around in a circle

off_set = off_set +1 // the offset is use to adjust the angle of the pendulum to slightly

if(off_set >55){ // larger than it actually is

off_set = 55

}

}

else { // Motor should go backwards and set the duty cycle to Cn

P1M1 = 1 // Motor is going backwards

temp_int = abs(Cn) // Returns the absolute int value of Cn

temp = temp_int // int to char of LS-Byte

if(temp^0b00000001){

DC1B0 = 1

}

else{

DC1B0 = 0

}

if(temp^0b00000010){

DC1B1 = 1

}

else{

DC1B1 = 0

}

CCPR1L = temp_int >>2 // Used to stop the pendulum from continually going around in a circle

off_set = off_set -1

if(off_set <-55){

off_set = -55

}

}

en3 = en2 // Shift error signals

en2 = en1

en1 = en0

en0 = 0

do_PID = 0 // Done

RA4 = 0 // Test flag to measure the speed of the loop

return

}

void Set_Constants()

{

ANS2 = 1 // Configure AN2 as analog

ANS4 = 1 // Configure AN4 as analog

ANS5 = 1 // Configure AN5 as analog

ADFM = 1 // Right justified A/D result

CHS0 = 0 // Channel select AN4

CHS1 = 0

CHS2 = 1

temp = 200 // Gives delay

while(temp){

temp--

}

GODONE = 1

while(GODONE){

temp = 0 // Does nothing.....

}

ki = ADRESH <<8 // Store the A/D result to Integral Constant

ki = ki + ADRESL

CHS0 = 1 // Channel select AN5

CHS1 = 0

CHS2 = 1

temp = 200 // Gives delay

while(temp){

temp--

}

GODONE = 1

while(GODONE){

temp = 0 // Does nothing.....

}

kd = ADRESH <<8 // Store the A/D result to Differential Constant

kd = kd + ADRESL

CHS0 = 0 // Channel select AN2

CHS1 = 1

CHS2 = 0

temp = 200 // Gives delay

while(temp){

temp--

}

GODONE = 1

while(GODONE){

temp = 0 // Does nothing.....

}

kp = ADRESH <<8 // Store the A/D result to Proportional Constant

kp = kp + ADRESL

CHS0 = 0 // Channel select AN0

CHS1 = 0

CHS2 = 0

}

void interrupt Isr()

{

if(T0IF&&T0IE){

TMR0 = 10 // Preload value

T0IF = 0 // Clear Int Flag

// flag1 = (!flag1)

RA4 = 1

temp_int = 0

temp_int = ADRESH <<8 // Store the A/D result with offset

temp_int = temp_int + ADRESL - 512

en0 = temp_int + off_set/8 // Store to error function asuming no over-flow

do_PID = 1 // Allowed to do PID function

GODONE = 1 // Start next A/D cycle

}

else

{

PIR1 = 0

RAIF = 0

INTF = 0

}

if(temp_int >180){ //Check if error is too large (positive)

DC1B0 = DC1B1 = 0 // Stop PWM

CCPR1L = 0

en0 = en1 = en2 = en3 = term1_char = term2_char = off_set = 0 // Clear all PID constants

Cn = integral_term = derivative_term = SumE = RA4 = 0

do_PID = 0 // Stop doing PID

}

if(temp_int <-180){ //Check if error is too large (negative)

DC1B0 = DC1B1 = 0 // Stop PWM

CCPR1L = 0

en0 = en1 = en2 = en3 = term1_char = term2_char = off_set = 0 // Clear all PID constants

Cn = integral_term = derivative_term = SumE = RA4 = 0

do_PID = 0 // Stop doing PID

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8116503.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存