Other Parts Discussed in Thread: ENERGIA,
Dear all,
I have the following code , I want to display the value of the variable y22 but nothing shows up in the serial monitor (com16), I tried to dispaly it in LCD but nothing shows up as well, I'm using Energia 1.6, the folder under C and I reorient the jumpers TXD and RXD.
Could you please verify that for me.
Thank you.
#include <LCD_Launchpad.h>
#include <driverlib.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include <driverlib.h> // Required for the LCD
//#include <LiquidCrystal_I2C.h>
//LiquidCrystal lcd;
void setup() {
// put your setup code here, to run once:
//analogFrequency(10000);
Serial.begin(9600);
SPI.begin();
}
float y11=0.0;
float y12=0.0;
float y13=0.0;
float y21=0.0;
float y22=0.0;
float y23=0.0;
float y31=0.0;
float y32=0.0;
float y33=0.0;
float Ub11,Ub12,Ub13,Ub21,Ub22,Ub23,Ub31,Ub32,Ub33;
float IN11,IN12,IN13,IN21,IN22,IN23,IN31,IN32,IN33;
float y11New,y12New,y13New,y21New,y22New,y23New,y31New,y32New,y33New;
void loop() {
// put your main code here, to run repeatedly:
// //Diagonal input
// float U11=1; float U12=-1; float U13=1;
// float U21=-1; float U22=1; float U23=-1;
// float U31=1; float U32=-1; float U33=1;
//Cross input
float U11=-1.0; float U12=1.0; float U13=-1.0;
float U21=1.0; float U22=1.0; float U23=1.0;
float U31=-1.0; float U32=1.0; float U33=-1.0;
//Templates A and b
//A:
float A11=0.045404; float A12=0.046816; float A13=0.046482;
float A21=0.046741; float A22=4.0472; float A23=0.046741;
float A31=0.046482; float A32=0.046816; float A33=0.045404;
//b
float b11=0.063908; float b12=-0.061448; float b13=0.079005;
float b21=-0.061448; float b22=0.052166; float b23=-0.061448;
float b31=0.079005; float b32=-0.061448; float b33=0.063908;
//I
float I=0.047155;
// float y11 = analogRead(A0);
// float y12 = analogRead(A1);
// float y13 = analogRead(A2);
// float y21 = analogRead(A3);
// float y22 = analogRead(A0.7);
// float y23 = analogRead(A5);
// float y31 = analogRead(A6);
// float y32 = analogRead(A7);
// float y33 = analogRead(A8);
int counter=0;
if ( counter==0)
{
y22New=y11*A11+y12*A12+y13*A13+y21*A21+y22*A22+y23*A23+y31*A31+y32*A32+y33*A33;
Ub22=U11*b11+U12*b12+U13*b13+U21*b21+U22*b22+U23*b23+U31*b31+U32*b32+U33*b33;
y11New=y11*A11+y12*A12+y21*A21+y22*A22;
Ub11=U11*b11+U12*b12+U21*b21+U22*b22;
y12New=y11*A11+y12*A12+y13*A13+y21*A21+y22*A22+y23*A23;
Ub12=U11*b11+U12*b12+U13*b13+U21*b21+U22*b22+U23*b23;
y13New=y12*A12+y13*A13+y22*A22+y23*A23;
Ub13=U12*b12+U13*b13+U22*b22+U23*b23;
y21New=y11*A11+y12*A12+y21*A21+y22*A22;
Ub21=U11*b11+U12*b12+U21*b21+U22*b22;
y23New=y12*A12+y13*A13+y22*A22+y23*A23+y32*A32+y33*A33;
Ub23=U12*b12+U13*b13+U22*b22+U23*b23+U32*b32+U33*b33;
y31New=y21*A21+y22*A22+y31*A31+y32*A32;
Ub31=U21*b21+U22*b22+U31*b31+U32*b32;
y32New=y21*A21+y22*A22+y23*A23+y31*A31+y32*A32+y33*A33;
Ub32=U21*b21+U22*b22+U23*b23+U31*b31+U32*b32+U33*b33;
y33New=y22*A22+y23*A23+y32*A32+y33*A33;
Ub33=U22*b22+U23*b23+U32*b32+U33*b33;
IN11=y11New+Ub11;
IN12=y12New+Ub12;
IN13=y13New+Ub13;
IN21=y21New+Ub21;
IN22=y22New+Ub22;
analogWrite(35,IN22);//pin 2.2
IN23=y23New+Ub23;
IN31=y31New+Ub31;
IN32=y32New+Ub32;
IN33=y33New+Ub33;
y11=0.7*tanh(2.0*IN11);
y12=0.7*tanh(2.0*IN12);
y13=0.7*tanh(2.0*IN13);
y21=0.7*tanh(2.0*IN21);
y22=analogRead(A8);//0.7*tanh(2*IN22)+I; pin 9.0
delay(500);
y23=0.7*tanh(2.0*IN23);
y31=0.7*tanh(2.0*IN31);
y32=0.7*tanh(2.0*IN32);
y33=0.7*tanh(2.0*IN33);
counter=1;
}
else{
y22New=y11*A11+y12*A12+y13*A13+y21*A21+y22*A22+y23*A23+y31*A31+y32*A32+y33*A33;
Ub22=U11*b11+U12*b12+U13*b13+U21*b21+U22*b22+U23*b23+U31*b31+U32*b32+U33*b33;
y11New=y11*A11+y12*A12+y21*A21+y22*A22;
Ub11=U11*b11+U12*b12+U21*b21+U22*b22;
y12New=y11*A11+y12*A12+y13*A13+y21*A21+y22*A22+y23*A23;
Ub12=U11*b11+U12*b12+U13*b13+U21*b21+U22*b22+U23*b23;
y13New=y12*A12+y13*A13+y22*A22+y23*A23;
Ub13=U12*b12+U13*b13+U22*b22+U23*b23;
y21New=y11*A11+y12*A12+y21*A21+y22*A22;
Ub21=U11*b11+U12*b12+U21*b21+U22*b22;
y23New=y12*A12+y13*A13+y22*A22+y23*A23+y32*A32+y33*A33;
Ub23=U12*b12+U13*b13+U22*b22+U23*b23+U32*b32+U33*b33;
y31New=y21*A21+y22*A22+y31*A31+y32*A32;
Ub31=U21*b21+U22*b22+U31*b31+U32*b32;
y32New=y21*A21+y22*A22+y23*A23+y31*A31+y32*A32+y33*A33;
Ub32=U21*b21+U22*b22+U23*b23+U31*b31+U32*b32+U33*b33;
y33New=y22*A22+y23*A23+y32*A32+y33*A33;
Ub33=U22*b22+U23*b23+U32*b32+U33*b33;
IN11=y11New+Ub11;
IN12=y12New+Ub12;
IN13=y13New+Ub13;
IN21=y21New+Ub21;
IN22=y22New+Ub22;
analogWrite(35,IN22);//p.n 2.2
IN23=y23New+Ub23;
IN31=y31New+Ub31;
IN32=y32New+Ub32;
IN33=y33New+Ub33;
y11=0.7*tanh(2.0*IN11);
y12=0.7*tanh(2.0*IN12);
y13=0.7*tanh(2.0*IN13);
y21=0.7*tanh(2.0*IN21);
y22=analogRead(A8);//0.7*tanh(2*IN22)+I; pin9.0
float voltage =Serial.println(y22*3.0/1023.0);
y23=0.7*tanh(2.0*IN23);
y31=0.7*tanh(2.0*IN31);
y32=0.7*tanh(2.0*IN32);
y33=0.7*tanh(2.0*IN33);
}
}