data transmission from a bluetooth module to computer, need C code help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mimi nazary
    New Member
    • Dec 2010
    • 2

    #1

    data transmission from a bluetooth module to computer, need C code help.

    hello,

    i am trying to write a code in C to transfer my signals from bluetooth to the compuer. I have four signals coming from a sensor unit. 2 AC and 2 DC. In my code I have already read those signals and sampled with AD converter , now when i am sending the data I do not know what should i define in the code. like how to assign values to bytes and pack the data, since im not a prgrammer :( this is my code, i would begrateful if you could give me some hints:
    Code:
    */
    
    //#include <macros.h>
    #include <iom32v.h>
    #include <mymacros.h>
    #include <AdcADS8341Layout.h>
    #include <AdcADS8341.h>
    #include <Delay.h>
    //#include <Uart.h>
    
    int main(void)
    {
            unsigned int PPG_IR_AC;
            unsigned int PPG_IR_DC;
            unsigned int PPG_R_AC;
            unsigned int PPG_R_DC;
    
        // Insert code
    
        do
        {
    
        // init the port
        // Ex
        DDRD = OUT7 | OUT6 | IN5 | IN4 | IN3 | IN2 | IN1 | IN0;
        SetBitMask(PORTD, BIT6);
    
        //Power On
        SetBit(PORTD,7);
    
    
        while(TRUE)
        {
            PPG_IR_AC = GetAdcADS8341(ADS8344_CH5);
            PPG_IR_DC = GetAdcADS8341(ADS8344_CH6);
            PPG_R_AC = GetAdcADS8341(ADS8344_CH7);
            PPG_R_DC = GetAdcADS8341(ADS8344_CH2);
    
           UartSendByteUB(PPG_IR_AC>>8); // How to send measured data to bluetooth transmitter
           UartSendByteUB(PPG_IR_AC); // How to send measured data to bluetooth transmitter
    
           UartSendByteUB(PPG_IR_DC>>8);
           UartSendByteUB(PPG_IR_DC);
    
           UartSendByteUB(PPG_R_AC>>8);
           UartSendByteUB(PPG_R_AC);
    
           UartSendByteUB(PPG_R_DC>>8);
           UartSendByteUB(PPG_R_DC);
    
    
       Delay(1024, 0.013); // delay
    
    
        }
    
        }while(0);
    
        return 0;
    }
    Last edited by Niheel; Dec 21 '10, 06:07 PM.
  • mac11
    Contributor
    • Apr 2007
    • 256

    #2
    There's a device discovery procedure that must be done to get the communication channel established. So, your PC needs to have a bluetooth dongle. Is your PC able to see your device? Are you past that initialization part already?

    If the PC isn't seeing your embedded device yet you'll have to go to your datasheet/userguide and figure out how to set up bluetooth and make sure both sides work.

    #include <iom32v.h> says you've got some AVR chip, does it have bluetooth support embedded in it? (I'm unfamiliar with AVR details).

    Once you get bluetooth communication going and the PC can see the embedded device just throw any data at it and make sure you can see it on the PC side. Simple text works well.

    Then you're at the point where you need to format your data to be useable on the PC side. Maybe you're there already. You have to decide if you want to send binary data or text based data. There's a good FAQ on the subject at http://www.parashift.com/c++-faq-lit....html#faq-36.2 It's focused on C++, but the basic concept is all you need.

    What's the device you're programming and how does the PC side use data it's receiving?

    I guess I'm a bit scrambled in my response because I can't tell if you have any communications established already or not.

    Comment

    • mimi nazary
      New Member
      • Dec 2010
      • 2

      #3
      the pc recognize the bluetooth, and we use labview to recieve the data, but the thing is that i dont know how to send the data , so when it gets into the labview , it will be clear which signal is it. like how to distinguish the signals over there. since its asynchronous data, and 4 signals go in a line of 64 bits (16 each). so i wanna know how can i use a flag or something in my c code for bluetooth while sampling, so when it gets to the computer we can easily speerate them.

      Comment

      • mac11
        Contributor
        • Apr 2007
        • 256

        #4
        Well, as the FAQ states, you have to decide if you want to send data in binary format (as your code does currently), or text format.

        I've never used lab view so I can't tell you how to make it recognize your numbers. Is there a certain format that it expects that you need to have your input conform to?

        Comment

        Working...