About Xethru X2M200 Connecting with Arduino Uno

Discussion in 'Respiration Sensor' started by marcoyip, Dec 18, 2016.

  1. Ole-Johan

    Ole-Johan New Member

    Hi Vikas.

    The message "7D 30 11 0 0 0 5C 7E" is a system status message saying that the module is ready.

    The message "7D 10 6D 7E" is ACK reply from the target, which you get as a confirmation that the module has received your command.

    vikas mehra and admin like this.
  2. vikas mehra

    vikas mehra New Member

    Hi OJ
    Thanks for reply.
    1. I understand "7D 30 11" for start>SPR system>SPRS ready and "7E" as Stop but why "0 0 0 5C" is for??
    similarly in Ack bytes what is "6D" ??

    2. And most important. You can see in Picture that "Detection at 0.1" then Why at 0.1 mtr irrespective of target distance at farther distance and if you see the example code then you can see Detection zone is 0.4 - 2.0 mtr.

    As per line of code given below which are same as Distance tracking using Atmel Xplained board C example code
    // Detection
    if ((ampMax > triggerThreshold) && (ampMax < 1000))
    { last_detection = basebandHeader->frameCtr;
    distance = basebandHeader->rangeOffset + index * basebandHeader->binLength;
    distanceFiltered = distanceFiltered*(1-distanceFilterWeight) + distance*distanceFilterWeight;
    Serial.print("Detection at ");

    Serial.println((int)( (distanceFiltered - (int)distanceFiltered)*10));

    Looking forward to hear your answer soon.

  3. Ole-Johan

    Ole-Johan New Member

    Hi Vikas.

    1. The system status message has the following format:
    Start flag (1 byte, 7D) + System message code byte (1 byte, 30) + System message value int (4 bytes little endian, 11 00 00 00 = 0x00000011) + CRC (1 byte, 5C) + End flag (1 byte, 7E).

    In the ACK message, the 6D is CRC.

    2. That looks strange. Check the value of basebandHeader->rangeOffset. This float should always be close to 0.4 in your example, the detection zone start.

    vikas mehra likes this.
  4. Øyvind Nydal Dahl

    Øyvind Nydal Dahl New Member

    Hey Vikas,

    There are some limitiations with the UNO that makes it hard to use for processing baseband data. That's why I switched to using Arduino Zero.

    For example the UART receive buffer is very small. And as I remember it, you needed the baudrate of 921600 to make it work. (Maybe Olav can verify if this is correct or not?)

    Also, the UNO works with 5V and the module 3.3V, which means you need a level converter for the UART. My level converter garbled the data on high speeds. The zero works on 3.3V so you don't have to worry about that.

    Anyway, if you still want to pursue trying to make it work on the UNO, you need to dive a bit deeper and print out the data you are receiving to understand what is happening. I'm guessing you're receiving garbled data from a level converter or only pieces of data packets because of buffer limitations. My code only works if the data is correct. With erroneous data, the result is unpredictable.

    As a start you can try replacing (from inside the loop() )
    int len = receive_data();
    int len = receive_data(true);

    Last edited: Feb 7, 2017
    vikas mehra and Ole-Johan like this.
  5. vikas mehra

    vikas mehra New Member


    To : Mr Oyvind

    Thanks for your reply and suggestions.

    1. I have tried replacing in code using Uno

    int len = receive_data();

    int len = receive_data(true);

    But results are baseband data keep on coming. Please see attached (Picture1.jpg)

    2. As of now at my place and nearby area there is no availability of Arudino Zero. Therefore now I have started working with Mega which is of similar specs with Zero (both having 256 kB Flash) (Technical Specs comparison Picture2.jpg attached). Also, someone in forum has connected successfully Mega with X2 using your example code. But I think again baud rate compatibility issues. Results similar.

    To : Mr OJ (Xethru Team)

    1. What is default baud rate @ which X2M200 start sending data serially? As per datasheet it is given 115200 baud rate. But with this data rate, no correct data receiving in Arudino Mega board. As per Mr. Oyvind comment, needed the baud rate of 921600 to make it work. Please comment.

    Attached Files:

  6. Øyvind Nydal Dahl

    Øyvind Nydal Dahl New Member

    Hey Vikas,

    Yes, when you set that to true, the result is that baseband data is showing. That's is correct behaviour. It's not the solution to your problem, just a tool to help you debug your problem.

  7. vikas mehra

    vikas mehra New Member

    To: Xethru Team & Øyvind Nydal Dahl

    Thanks for support always. My Questions are:

    1. As per Serial Protocol Document Ver F:
    Baseband Amplitude/Phase output Outputs the baseband amplitude and phase data of the application.

    Example: <Start> + <XTS_SPR_APPDATA> + [XTS_ID_BASEBAND_AMPLITUDE_PHASE(i)] + [Counter(i)] + [NumOfBins(i)]+ [BinLength(f)] + [SamplingFrequency(f)] + [CarrierFrequency(f)] + [RangeOffset(f)] + [Amplitude(f)]+ ... + [Phase(f)] + ... + <CRC> + <End>

    As per above, eight features can be retrieved from baseband output (Counter,…Phase). However, I have doubt in attached Output (basebanddata.txt). Please see attached (baseband_output.jpg ,DataExcel.jpg) for Questions.

    2. How “Receive_Buffer” data received in standard order (serial protocol document) comes to know which byte is binlength, rangeOffset, frameCtr and others…

    These are being called in code (Distance Tracker)





    What value they will fetch and how??

    3. How to calculate RPM respiration per minute from baseband data received serially?
    Please tell method or any code for same.

    4. What is Carrier frequency here in baseband o/p? Is it not carrier less UWB Signal?

    Vikas Mehra

    Attached Files:

  8. Michael Casselli

    Michael Casselli New Member

    with the newest sensor-theX2M200, do I still need the level shifter or can I run straight from the arduino to the sensor? Also, I am using a mega, is there anything I need to do to the code to accommodate using a mega instead of an uno? I have tried compiling, it seems fine, but when the LED's come on its all three at full intensity,the system doesn't seem to be responding to the code.