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.

sending sine wave from function generator using TIMAC

Other Parts Discussed in Thread: TIMAC, MSP430F5438A

hi,

i am using TIMAC protocol stack  for sensor data transfer.now i want to send a sine wave generated by the function generator at the transmitter side and display the sine graph on the monitor attached at  the receiver side by using python language.

i will be using the same pins to transmit the sine wave components as that for the sensor data.I am i correct in my approach.

plz suggest .thank you.

  • Hi,

    Please give more setup details : h/w etc. Do you want to  transmit un-modulated carrier wave on TI device or have external function generator connected to it's ADC pin ?

    Saurabh

  • hi ,

    I am using external function generator connected to ADC pin.I am sending the ADC code also.plz check and tell whether it is correct or wrong.actually i want to send an accelerometer sensor signal of the range (0.15hz to 1000 hz).what sampling frequency can i set to get correct output.I want to check the proper working of ADC so i am checking it with external function generator by giving input sine of 20hz and settings frequency 226.9hz.

    i am seeing the display using python plotting.i am attaching the snap shot of the plot also.plz check .

    6521.sens2.c
    #include "msp430f5438A.h"
    #include<stdio.h>
    #include<string.h>
    #include <stdint.h>
    
    
    
    char buffer[100];
    static uint8_t SavedADC12MEM1;           //To store ADC outputs
    
    int16_t x_new,y_new;
    float values;
    float factor=0.000714285714; int volt;
    
    
    /*************************************************************************************/
    /*
    #pragma vector=TIMER1_A0_VECTOR
    __interrupt void TIMER1_A0_ISR(void)
    {
      P1OUT ^= 0x01;                                // Toggle P1.0
      ADC12CTL0 |= ADC12ENC;                        // Enable conversions
      ADC12CTL0 |= ADC12SC;                         // Start conversion
    }
    */
    
    /*---------------------------------------------------------------------------*/
    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12_ISR(void)
    {
      ADC12CTL0 &= ~ADC12ENC;                       // Disable ADC12 conversions
      REFCTL0 &= ~REFON;                            // Disable reference (if enabled)
    
      SavedADC12MEM1 = ADC12MEM1;                   // Store the sampled data
      
      __bic_SR_register_on_exit(LPM0_bits);
    }
     
     /*---------------------------------------------------------------------------*/
    void accelerometerInit(void)
    {
      P7SEL |= BIT5;                                // Pin 7.6 and 7.7 are inputs from the accelerometer to the ADC => they are configured as inputs to the ADC
      P7DIR &= ~BIT5;
      
      UCSCTL8 |= MODOSCREQEN;                       // ADC is clocked by the ACLK in the UCS module
      ADC12CTL0 &= ~ADC12ENC;                       // Disable conversion  
      
      ADC12CTL0 = ADC12ON + ADC12SHT0_7 + ADC12MSC;  // Turn on ADC, Sample once every 1024 cycles, Multisample conversion
      ADC12CTL1 = ADC12CSTARTADD_1 + ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_1;
      ADC12CTL2 = ADC12RES_2;                       // Resolution=12 bits, 13 clock cycle conversion time
                            //select channel 13(pin 7.5)
      ADC12MCTL1 = ADC12INCH_13;
      
      ADC12IE = 0x00;
    
        __delay_cycles(200000);                     // Allowing reference voltage to stabilize
    }
    /*---------------------------------------------------------------------------*/
    
    /*---------------------------------------------------------------------------*/
    void adcStartRead(void)
    {
        ADC12IFG = 0x00;
    
        ADC12IE = BIT1;
        ADC12CTL0 |= ADC12ENC | ADC12SC;   
        // Enable conversion and Start conversion
    }
    
    void accelerometerReadWithOffset(int16_t *x)
    {
      *x = SavedADC12MEM1;
    
    }
    /**********************************************************************************/
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                     // Stop WDT
                                                    // initialize Timer_A module
       //TA1CCTL0 = CCIE;                            // CCR0 interrupt enabled
       //TA1CCR0 =32768;
    
       //TA1CTL = TASSEL__ACLK   + MC__UP + TACLR;    // ACLK, up mode, clear TAR
       // float voltages;
        
         while(1) 
     {
          accelerometerInit();
          adcStartRead();
          //accelerometerReadWithOffset(&x_new);      // ADC output (digital data
         
         // voltages=x_new*factor;
          
          //TA1CCTL0 = CCIE;                           // CCR0 interrupt enabled
          //TA1CCR0 = 32768;
    
         // TA1CTL = TASSEL__ACLK  + MC__UP + TACLR;   // SMCLK, up mode, clear TAR
      // initialize USCI module
          P5SEL |= BIT6 + BIT7;                      // P5.6,7 = USCI_A1 TXD/RXD
          UCA1CTL1 |= UCSWRST;                       // **Put state machine in reset**
          UCA1CTL1 |= UCSSEL__ACLK  ;
          UCA1BR0 = 3;                              //  
          UCA1BR1 = 0;                              // 
      
         UCA1MCTL = UCBRS_3;
    
          UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
     
         int k=0;
          
      sprintf(buffer,"%d", SavedADC12MEM1);
      
                  while(buffer[k])
                      {
                         while(!(UCA1IFG&UCTXIFG)); // USART0 TX buffer ready?
                         UCA1TXBUF = buffer[k++];
                      }
     
      __bis_SR_register(LPM0_bits+GIE);             // Enter LPM0, enable interrupts
       
    }
    
     }
       
    
    3666.time domain.txt
    import sys
    import serial
    import numpy as np
    import matplotlib.pyplot as plt
    from collections import deque
    
    port = "COM17"
    baud = 9600
    timeout=1
    
    ser = serial.Serial()
    ser.port = port
    ser.baudrate = baud
    ser.timeout = timeout
    
    
    a1 = deque([0.0]*100)
    #ax = plt.axes(xlim=(0, 100), ylim=(0, 1000))
    
    
    
    line, = plt.plot(a1)
    plt.ion()
    plt.ylim([-150,150])
    
    try:
      ser.open()
    except:
      sys.stderr.write("Error opening serial port %s\n" % (ser.portstr) )
      sys.exit(1)
    
    #ser.setRtsCts(0)
    
    while 1:
         # Read from serial port, blocking
         data = ser.read(1)
    
         # If there is more than 1 byte, read the rest
         n = ser.inWaiting()
         data = data + ser.read(n)
         #sys.stdout.write(data)
         #print(a1)
         data1=int(data)-128
    
         a1.appendleft((data1))
         datatoplot = a1.pop()
         line.set_ydata(a1)
         plt.hold(False)
         plt.draw()
         
    

    I am using MSP430F5438A controller, I want to know that if it is possible to test ADC values on receiver side using DAC12_A. Please tell us a method how to test sine signal from generator.

    Thanks