Jump to content
Forum sending old emails Read more... ×
Salibensuleiman

MSP430FR6989: Serial port monitor is not working

Recommended Posts

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.

I want also to display the value of IN22 inside analogWrite(35,IN22).

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);


}

}

Share this post


Link to post
Share on other sites

Hi @Salibensuleiman

Wow! That's a wall of text that is impossible to understand.

Please use the code "<>" tags on your software.

For example,  here is your code

#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);

  }

}

 

 

Share this post


Link to post
Share on other sites

Concentrate on one problem at a time.

Create a new project.

Write a program that tests out only the serial port.

Create another project that tests out only the LCD.

Divide and conquer!!!

Once you have those working then you can get back to that crazy math you are trying to do!

 

Share this post


Link to post
Share on other sites

Thanks for the replies, yes it is a lot of calculations, I posted the whole code because I thought it might help but the issue is  :

I want to display two voltages, one of them I read it through analogRead function "y22" and the other I calculated it inside the code "IN22"  , in serial monitor but I found the serial monitor is empty.

 

I tried this small code from Energia examples but nothing shows up, I just changed the pin A3 to A8

void setup() {
    Serial.begin(9600); // msp430g2231 must use 4800
}

void loop() {
   int sensorValue = analogRead(A8);
   Serial.println(sensorValue);
  delay(1); // delay in between reads for stability
}

Share this post


Link to post
Share on other sites

Couple quesitons:

  1. You mentioned "I reorient the jumpers TXD and RXD.". In what way did you reorient them? If you are indeed using the MSP430FR6989 LaunchPad then you do _not_ need to change the jumpers.
  2. Are you sure about the COM port number?
  3. What version of the MSP430 core do you have installed. Make sure you update to the latest (1.0.3) using the Energia boards manager.

Share this post


Link to post
Share on other sites

You should be using COM16. What baudrate do you have set in the Sketch (the number in Serial.begin(....)) and does that match the baudrate in the Serial monitor (lower right corner).

Can you please try the Sketch "File->Examples->04.Communication->ASCIITable". The baudrate is set to 9600 so make sure that it matches the baudrate set in the Serial monitor.

Robert

Share this post


Link to post
Share on other sites

I just verify it I'm using COM16 and the baudrate  is 9600 in both Serial.begin(....) and in the monitor.

I tried the example but nothing shows up in the monitor.

Does the USB version in the laptop has any effect? please check the attached file, if so how to know my USB version? and does the existence of CCS has any effect as well.  

Capture5.PNG

Share this post


Link to post
Share on other sites

I think the issue is resolved now, so the first thing is to update MSP430 core as you mentioned before.

The 2nd thing is I put pack the jumpers TXD and RXD in their original orientation as when I bought the board first time.

Thank you so much for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×