This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C1294XL: Not able to send ADC values to labview software via UART

Part Number: EK-TM4C1294XL

Hello all,

I'am using TM4C1294XL launchpad for my project development. I want to send the ADC data to labview software via UART. Below is my code setup

  1. MCU clock @120MHZ
  2. ADC sampling rate set to 256Hz with help of TIMER
  3. Serial transmission protocol is 115200bps, 8-N-1.
  4. Using UART0 for serial communication..

Below is while(1) loop of the main function

while(1)
        {

            ADCIntClear(ADC0_BASE, 1);


                        while(!ADCIntStatus(ADC0_BASE, 1, false))
                        {
                        }
                    ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);

                    for(j=0;j<=255;j++)
                    {
                        outputsamples1[j] = ui32ADC0Value[0] ;
                        outputsamples2[j] = ui32ADC0Value[1] ;
                        outputsamples3[j] = ui32ADC0Value[2] ;
                        outputsamples4[j] = ui32ADC0Value[3] ;

                    }

CH1DATA= outputsamples1[a];

CH2DATA= outputsamples2[a];

CH3DATA= outputsamples3[a] ;

CH4DATA= outputsamples4[a];


/**** CONVERT 12 BIT ADC DATA TO 8 BIT****/

                                                                                                                al = CH1DATA & 0xF00;
                                                                                                                al = al>>8;
                                                                                                                ah = CH1DATA & 0xFF;
                                                                                                                bl = CH2DATA & 0xF00;
                                                                                                                bl = bl>>8;
                                                                                                                bh = CH2DATA & 0xFF;
                                                                                                                cl = CH3DATA & 0xF00;
                                                                                                                cl = cl>>8;
                                                                                                                ch = CH3DATA & 0xFF;
                                                                                                                dl = CH4DATA & 0xF00;
                                                                                                                dl = dl>>8;
                                                                                                                dh = CH4DATA & 0xFF;

                      CH1D = al | (ah<<8);                   
                      CH2D = bl | (bh<<8);
                      CH3D = cl | (ch<<8);
                      CH4D = dl | (dh<<8);

UARTPrintf("%d",CH1D);

UARTPrintf("%d",CH2D);

UARTPrintf("%d",CH3D);

UARTPrintf("%d",CH4D);

a=a+1;

if(a==256)

{

a=0;

}

}

I'am testing the code by sending sinewave but at the labview part the waveform is not coming  as sinewave, instead it is some random noisy signal.

Do I need to convert the data into string before sending it to labview?If Yes, then how to do that?? Can't we send integers directly?

I also tried the UARTCharPut(UART0_BASE,CH1D) command But it is not sending anything to the PC.

Kindly help!!.

  • Sumit Mourya said:
    Do I need to convert the data into string before sending it to labview?

    That is exactly what you are already doing, when you do UARTPrintf("%d",CH1D);

    Did you try to see the data in a console program in your PC and check what is coming in? Try something like FoxTerm or even Putty to view the strings. Did you see if the CHn variables actually contain the values you expect, on the debugger?

    As for "do I need to convert", you will need to find the answer to that on the Labview documentaion. This is the forum for the microcontroller that sends the data.

    Sumit Mourya said:
    I also tried the UARTCharPut(UART0_BASE,CH1D) command But it is not sending anything to the PC

    Actually it does. It places ONE CHAR (8-bit) on the transmit uart buffer and sends it. In this case, it would be the casting to char for whatever is on our variable.

    Regards

    Bruno

  • Hello Bruno,

    Thanks for replying!

    I can see the values on serial monitor/Putty using UARTPrintf() command. I can also see the numerical values on labview but the graph is not getting plotted as sinewave .
    sinewave through a function generator is the input on ADC pin.

    When I use UARTCharPut() command and check the putty terminal, i'ma not able to see the decimal values, but I can see the data in Hex format.

    kindly provide some guidance!!
  • If you can see the values in putty, copy/paste a section of those to a chart in a spreadsheet. Are they a sine as you expected?
    Are you in control of the data rate being sent to the PC? I mean, are you sure you send enough data to send values that refer to a sine wave? Where are you capturing your data from? On what frequency? All that must be taken in consideration.
  • Hi Bruno - You've done very nice job here (it has been "liked") but may I note (again) that our poster has, "Thrown KISS to the curb" and is attempting EVERYTHING - has thus (systematically), "Tested/Verified LITTLE" - and wonders, "Why it does NOT work!"

    KISS is ABSOLUTELY REQUIRED here (and most everywhere) if the best results are sought - with the minimal amount of "Pain/Suffering!" (which always arrive when KISS is "kicked to the curb!")
  • Sumit,
    Have you noted that there is another live thread discussing a similar application?
    e2e.ti.com/.../2199164
    I've provided some further details there.
    Bruno
  • Hello Bruno,

    Thank for your guidance! I actually figured out the discrepancy in the output. Did few changes in the code and also I had to use a clamping circuit in between the function generator & ADC input pin since the ADC is unipolar hence, it was not picking the negative cycle of the sinewave!

    But, another concern now is the speed of the data transmission!! It is not coming as desired. what could be the maximum speed I could get @ 256Hz sampling rate?
  • I'm simple transmitting the data with the command
    UARTPrintf( "a%u b%u c%u d%u", ui32ADC0value[0],ui32ADC0value[1],ui32ADC0value[2],ui32ADC0value[3])
  • Hi Sumit,

    Sumit Mourya said:
    what could be the maximum speed I could get @ 256Hz sampling rate?

    It appears this is not the right question. The question is: what is triggering your data transmissions?

    Here is a list of tasks that I have happening continuously in a product based on a TM4C129 here:

    - 2300 * 4 = 9200 Hz reading 6 x 16-bit registers from SPI sensors, with numerical filtering of such sensors

    - ~320 Hz reading variable PWM duty signal from encoder sensors, with numerical filtering

    - Output of 100Hz partial measurement packages (~60 bytes each) via uart

    - Relaying (receiving and sending) ~60Hz complete measurement packages (84 bytes each) via uart

    - Monitoring and responding to external control messages

    - Various analog monitoring (power circuits and references, temperature sensor)

    - A few conditional leds and buttons

    These MCU's can do quite a lot! It is all a matter of how you control your program flow and trigger the events.

    Regards

    Bruno