Jump to content
43oh

hemangjoshi37a

Members
  • Content Count

    39
  • Joined

  • Last visited

Posts posted by hemangjoshi37a

  1. Dear developers,

    I am simply using

    Serial.println();

    command, but I get some weird characters in the serial port display window.

    Code : 

    #include <Wire.h>
    // HIH6130 I2C address is 0x27(39)
    #define Addr 0x27
    
    int tzero = 196;
    int tspan = 17;
    int hzero = 196;
    int hspan = 17;
    
    void setup()
    {
    Wire.setModule(1);
    Wire.begin();
    pinMode(P1_3,OUTPUT);
    pinMode(P1_2,OUTPUT);
    pinMode(P1_6,OUTPUT);
    Serial.begin(9600);
    Serial.println("OK");
    delay(300);
    }
    
    void loop()
    {
      
      unsigned int data[4];
    
      // Start I2C Transmission
      Wire.beginTransmission(Addr);
      // Select data register
      Wire.write(0x00);
      // Stop I2C Transmission
      Wire.endTransmission();
      // Request 4 bytes of data
      Wire.requestFrom(Addr, 4);
    
      // Read 4 bytes of data
      // humidity msb, humidity lsb, temp msb, temp lsb
      if (Wire.available() == 4)
      { data[0] = Wire.read();
        data[1] = Wire.read();
        data[2] = Wire.read();
        data[3] = Wire.read();
      }
    
      // Convert the data to 14-bits
      float humidity = ((((data[0] & 0x3F) * 256) + data[1]) * 100.0) / 16383.0;
      float temp = ((data[2] * 256) + (data[3] & 0xFC)) / 4;
      float  cTemp = (temp / 16384.0) * 165.0 - 40.0;
    
      // Output data to serial monitor
      Serial.print("Relative Humidity :");
      Serial.println(humidity);
      Serial.println(" %RH");
      Serial.print("Temperature in Celsius :");
      Serial.println(cTemp);
      Serial.println(" C");
      Serial.println("=============================================================== ");
    
      int VcTemp = map(cTemp, -5, 125, tzero, tspan );
      int vhumidity = map (humidity, 0, 100, hzero, hspan);
    
      analogWrite(P1_2, VcTemp);
      analogWrite(P1_6, vhumidity);
    
      delay(1000);
    }

    Serial Output : 

    Quote

    ������������ 

    (in one single line, means it keeps  printing these characters in just one line on and on.picture : 

    Quote

    Screenshot : 

    59c0ca7a90fff_Screenshotfrom2017-09-1913-08-25.thumb.png.784949bb18e4ab2d2a6a5fd9b4f4a9fb.png

     

    Thax.

  2. I don't know why but my energia is running very slow. All the other apps are running at good speed. I am using windows 10 64-bit version. I am using Energia V17.

    Pictures from my task manager are attached here, please take a look at it.task_mgr.png.b9241b8bbd6890993cbc120e44bfa6f8.png

    task_mgr2.png.ccaa33f928398a7ad7f675a06443a323.png

    task_mgr3.png.4847ae3da2d0a2bf550eed7f512d4f8f.png

     

    Thax and peace.

  3. On 2014-1-7 at 2:16 AM, Rei Vilo said:

    Is there a specific reason for using C instead of C++?

     

    The official IDE from Texas Instruments in Code Composer Studio, based on Eclipse.

     

    This is a professional grade IDE but I faced many difficulties when installing and maintaining it.

     

    If you're familiar with Eclipse, this could be a good choice.

     

    The other option is Energia, which actually combines different elements.

     

    Energia uses the Wiring framework, adapted to the MSP430 and Stellaris now Tiva C Series, which provides all the libraries for managing I

    Code composer studio is not detecting my MSP Launchpad while Energia easily detects it and loads program on it. Does anyone know why CCS is not detecting Launchpad??

  4. look man just forget about connection to PC, because arduino and MSP both are connected to PC through USB cable, Not using RS232 connection.

    And very basic question is why MSP is not able to develop any signal on TX pin while I am transmitting some data. however Arduino generates signal on TX pin when I try to transmit some data using same code.

  5. Dear Developers,

    I want to send data from MSP430F5529 to my Arduino Nano through UART connection. But somehow it is not working filne. I have used voltage devider circuit to convert Arduino's 5V to MSP's 3.3V. 

    Connection

    Arduino's RX -> MSP's TX

    Arduino's TX -> MSP's RX

    Ground of Both -> ground of voltage devicer.

    Code of Arduino :

    const int chipSelect = 10;
    
    String inByte = " ";
    void setup() {
      // initialize both serial ports:
      Serial.begin(9600);
    
    }
    
    void loop() {
      if(Serial.available())
     {
        char b = Serial.read();
        Serial.println(b);
      }
      
      delay(50);
    }

    Code of MSP430F5529

    void setup() {
    
      Serial.begin(9600);
    }
    
    void loop() {
      Serial.write("Hii");
    
      delay(50);
    }

    Please Help me.

    Thank you.

  6. Dear Engineers,

    Please help me send data to Arduino from my MSP430F5529 using SPI interface. I want to use SPI iterface because in future I want to use the modified code for Attiny13A instead of the Arduino Leonardo. Details are given below. Thank you for  your support.

    Information to Provide When Asking for Help:

    • Model of LaunchPad used and revision number : MSP430F5529 Launchpad Rev 1.6 & Arduino Leonardo
    • Model of the MCU used : MSP430F5529 & ATMEGA32U4~AU at  15Mhz
    • Name and version of the IDE used  : Energia 1.6.10E18 & Ardduino IDE 1.8.2
    • OS the IDE is running on : Linux Mint 18
    • Whenever possible, minimal code to replicate the issue : Required from good developer
  7. 1 hour ago, hemangjoshi37a said:

    Actually I can successfully do data logging with same SD card and same SD card shield from Arduino, so I dont think the card is locked.

    I found very weird solution for this problem. If I have some number of characters pre-written in the t_write.txt file than Hello world will get written on that file.

    Is it not possible to write something in empty file?? 

  8. My code for writing "hello world" to the sd card is running successfully but the SD card is not showing anything inside the written file.

    Please somebody hepl me.

    Thank you.

    Regards,

    Hemang Joshi.

    Code :
    
    /*----------------------------------------------------------------------*/
    /* Petit FatFs sample project for generic uC  (C)ChaN, 2010             */
    /*----------------------------------------------------------------------*/
    /* ported to Energia */
    /* copy the two files t_read.txt and t_write.txt from the example folder in the root of the sd card*/
    
     
    #include "SPI.h" 
    #include "pfatfs.h"
    
    #define cs_pin      P2_6             // chip select pin 
    #define read_buffer 128             // size (in bytes) of read buffer 
    
      unsigned short int bw, br;//, i;
      char buffer[read_buffer];
      int rc;
      FSDIR dir;                /* Directory object */
      FILINFO fno;            /* File information object */
    
    void setup() {
    
             pinMode(PUSH2, INPUT_PULLUP);
             
             Serial.begin(9600);            // initialize the serial terminal
             FatFs.begin(cs_pin);             // initialize FatFS library calls
             }
    void die (        /* Stop with dying message */
             int pff_err    /* FatFs return value */
             )
             {
             Serial.println();Serial.print("Failed with rc=");Serial.print(pff_err,DEC);
             for (;;) ;
      }
    
    
    /*-----------------------------------------------------------------------*/
    /* Program Main                                                          */
    /*-----------------------------------------------------------------------*/
    
    void loop()
    {
            Serial.println();
            Serial.println("Press button to start...");
            while(digitalRead(PUSH2)==1){}
            delay(100);
            while(digitalRead(PUSH2)==0){}
            
            Serial.println();
        Serial.println("Open a test file (t_read.txt).");
            delay(100);
        rc = FatFs.open("T_READ.TXT");
        if (rc) die(rc);
    
        Serial.println();
            Serial.println("Type the file content.");
            delay(100);
        for (;;) {
            rc = FatFs.read(buffer, sizeof(buffer), &br);    /* Read a chunk of file */
            if (rc || !br) break;            /* Error or end of file */
            for (uint16_t i = 0; i < br; i++)        /* Type the data */
                Serial.print(buffer[i]);
                            delay(100);
        }
        if (rc) die(rc);
    
            Serial.println();
        Serial.println("Open a file to write (t_write.txt).");
        delay(100);
            rc = FatFs.open("T_WRITE.TXT");
        if (rc) die(rc);
    
        Serial.println();
            Serial.println("Write a text data. (10 x Hello world!)");
            delay(100);
            bw=0;
            for (uint16_t i=0;i<10;i++) {
            rc = FatFs.write("Hello world!\r\n", 14, &bw);
                    if (rc || !bw) break;
        }
        if (rc) die(rc);
        
        rc = FatFs.write(0, 0, &bw);  //Finalize write
        if (rc) die(rc);
    
         
            delay(100);
            Serial.println();
        Serial.println("Verify the write process (t_write.txt).");
            delay(100);
        rc = FatFs.open("T_WRITE.TXT");
        if (rc) die(rc);
    
        Serial.println();
            Serial.println("Type the file content.");
            delay(100);
        for (;;) {
            rc = FatFs.read(buffer, sizeof(buffer), &br);    /* Read a chunk of file */
            if (rc || !br) break;            /* Error or end of file */
            for (uint16_t i = 0; i < br; i++)        /* Type the data */
                Serial.print(buffer[i]);
                            delay(100);
            }
        if (rc) die(rc);
            
            Serial.println();
        Serial.println("Open root directory.");
        delay(100);
            rc = FatFs.opendir(&dir, "");
        if (rc) die(rc);
    
        Serial.println();
            Serial.println("Directory listing...");
            delay(100);
        for (;;) {
            rc = FatFs.readdir(&dir, &fno);    /* Read a directory item */
            if (rc || !fno.fname[0]) break;    /* Error or end of dir */
            if (fno.fattrib & AM_DIR) {Serial.print("<dir>\t"); Serial.println(fno.fname);delay(100);}
            else {Serial.print(fno.fsize);Serial.print("\t"); Serial.println(fno.fname);delay(100);}
        }
        if (rc) die(rc);
    
            Serial.println();
        Serial.print("Test completed.");
        //for (;;) ;
    }

    OUTPUT on serial termianl :

    Quote


    Press button to start...

    Open a test file (t_read.txt).

    Type the file content.

    Open a file to write (t_write.txt).

    Write a text data. (10 x Hello world!)

    Verify the write process (t_write.txt).

    Type the file content.

    Open root directory.

    Directory listing...
    0    T_READ.TXT
    0    T_WRITE.TXT

    Test completed.

     

     

  9. Hi frineds,

    Issue :

    I am data logging into my 1 gb sd card using given code.

    In my serial terminal window it shows that the data is being written in the sd card, but when i take it out  from microcontroller interface and put it in the computer it shows nothing buy empty file (log.txt). Well i know one thing that can be causing this issue that is the log.txt file shows read only in my linux mint environment but still i can write anything in that file. I have attached a screen recording and screen shot file of the issue down below. Please help me...

    Thank you in advance...

    Code : 

    #include <pfatfs.h>
    #include <pffconf.h>

    /*----------------------------------------------------------------------*/
    /* Petit FatFs sample project for generic uC  (C)ChaN, 2010             */
    /*----------------------------------------------------------------------*/
    /*-----------------------------------------------------------------------
       Ported to Energia by calinp
       Copy the file LOG.txt from this file's location to the root of the 
       SD-Card.

       12/21/2013
       Modified by bluehash(43oh) to log temperature data from the MSP430G2553
       internal temperature sensor and log it to a file on the SD-Card
       References:
      http://forum.43oh.com/topic/3209-energia-library-petit-fatfs-sd-card-library/
     */

     
    #include "SPI.h" 
    #include "pfatfs.h"

    #define cs_pin      P2_3           // chip select pin 
    #define read_buffer 128             // size (in bytes) of read buffer 
    #define LOG_DELAY   5000          // 5000ms -> 5sec

    unsigned short int bw, br;//, i;
    char buffer[read_buffer];
    int rc;
    //DIR dir;        /* Directory object */
    FILINFO fno;      /* File information object */

    uint32_t ui32_ReadTemp = 0;
    uint8_t StringLength = 0;
    char buf[30];
    uint32_t counter = 0;
    uint32_t AccStringLength = 0;

    void setup()
    {
       pinMode(PUSH2, INPUT_PULLUP);
       Serial.begin(9600);                // initialize the serial terminal
       analogReference(INTERNAL1V5);
       analogRead(TEMPSENSOR);           // first reading usually wrong
       FatFs.begin(cs_pin);              // initialize FatFS library calls
       Serial.print("\n\n\n MSP430 Temperature Logger \n\r"); 
       Serial.println("Press S2 button to start...");
       while(digitalRead(PUSH2)==1){}
       delay(100);
       while(digitalRead(PUSH2)==0){}
    }
             
    /* Stop with dying message */         
    void die ( int pff_err  )
    {
       Serial.println();
       Serial.print("Failed with rc=");
       Serial.print(pff_err,DEC);
       for (;;) ;
    }

    void printDec(uint32_t ui) 
    {
       Serial.print(ui/10, DEC);
       Serial.print(".");
       Serial.print(ui%10, DEC);
    }

    /*-----------------------------------------------------------------------*/
    /* Program Main                                                          */
    /*-----------------------------------------------------------------------*/
    void loop()
    {
       #if 0
       Serial.println();
       Serial.println("Press button to start...");
       while(digitalRead(PUSH2)==1){}
       delay(100);
       while(digitalRead(PUSH2)==0){}
       #endif

       ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;

       #if DEBUG
       Serial.println();
       Serial.println("Opening log file to write temperature(LOG.txt).");
       delay(100);
       #endif
       
       rc = FatFs.open("LOG.TXT");
       if (rc) die(rc);

       delay(100);
       bw=0;
       ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;
       sprintf( buf, "%lu Current temperature is %lu.%lu\r\n", counter, ui32_ReadTemp/10, ui32_ReadTemp%10 );
       counter++;
       StringLength =  strlen(buf);
       Serial.println(buf);        

       #if DEBUG
       Serial.print(StringLength, DEC);
       Serial.println();
       Serial.print(AccStringLength, DEC);
       #endif

       rc = FatFs.lseek(  AccStringLength );
       if (rc) die(rc);
       AccStringLength =  AccStringLength + 512;
       rc = FatFs.write(buf, StringLength,&bw);
       if (rc) die(rc);
       rc = FatFs.write(0, 0, &bw);  //Finalize write
       if (rc) die(rc);
       rc = FatFs.close();  //Close file
            if (rc) die(rc);

           
       #if READ         
       delay(100);
       Serial.println();
       Serial.println("Read Temp data from the log file (LOG.txt).");
       delay(100);
       rc = FatFs.open("LOG.TXT");
       if (rc) die(rc);

       delay(100);
       for (;;) {
       rc = FatFs.read(buffer, sizeof(buffer), &br);  /* Read a chunk of file */
       if (rc || !br) break;      /* Error or end of file */
       for (uint16_t i = 0; i < br; i++)    /* Type the data */
       Serial.print(buffer);
       delay(100);
       }
       if (rc) die(rc);
       #endif

       // Log delay
       delay(LOG_DELAY);
    }

     

    Screenshot 2017-05-27 15:50:27.png

    Screencast_2017-05-27_15:45:33.mp4

×
×
  • Create New...