peppe,

i think that you're missing something here. please read the code carefully: if the current buffer is 0, then where was the most recent data written?

another thing to consider is that you want to do as little as possible in interrupt context (e.g. async events). adding a memcpy there is not advisable unless it's absolutely necessary (it's not).

you'll also have to change the code that "prepares" the radio packet. i should point out that accelecg goes to a lot of trouble to build up a packet with data that you don't really need; you might want to consider using SimpleAccel as the basis for your development instead. it will be much easier to modify correctly, it transmits only sampled data, and it will be much more power-efficient than accelecg as it buffers 20 samples together in one transmission rather than sending a packet for each sample.

-steve

On 10/06/2011 04:46 AM, Peppe Scabellone wrote:
Thank you both for answering.

So, if I need to capture the datas from the two ecg channels I only need
to call

call shimmerAnalogSetup.addECGInputs();
call shimmerAnalogSetup.finishADCSetup(sbuf0);

in the Init() and then:


async event void DMA0.transferDone(error_t success) {
         if(current_buffer == 0){
             call DMA0.repeatTransfer((void*)ADC12MEM0_, (void*)&sbuf1,
NBR_ADC_CHANS);
             memcpy(ecgData, &sbuf1, sizeof(*sbuf1)*NBR_ADC_CHANS);
             current_buffer = 1;
         }
         else {
             call DMA0.repeatTransfer((void*)ADC12MEM0_, (void*)&sbuf0,
NBR_ADC_CHANS);
             memcpy(ecgData, &sbuf0, sizeof(*sbuf1)*NBR_ADC_CHANS);
             current_buffer = 0;
         }
without making the
call shimmerAnalogSetup.addAccelInputs();

in this way in the array ecgData I will have the datas from the two
channels?

2011/10/5 steve ayer <[email protected] <mailto:[email protected]>>

    hi peppe,

    for the record, i did not write this application, adrian burns did.
      i made a few latter-day mods to clean it up after creating a
    component for all of the analog-digital setup and conversion
    functionality.

    p_packet is a local variable used to walk the buffer that the
    bluetooth radio will send; it was not meant to be visible elsewhere.
      the buffer that it references is.

    as for "calling" transferDone, you don't call events; they are
    signaled from modules that are performing an operation to notify the
    receiving code that something related to an interface that it uses
    has happened (tinyos is an event-driven operating environment).

    finally, this application works splendidly and has been in use --
    deployed clinically -- for a number of years.  to get the data from
    the ECG, all you have to do is receive it over bluetooth on a host
    computer.

    if you're looking for the two ECG channels, by reading the comments
    at the top of the file, you'll see a detailed description of the
    radio packet's contents, which includes the size and location of all
    of the data produced by this application, in order to make it very
    simple to parse the incoming data on the host side.

    -steve



    On 10/05/2011 06:55 AM, Peppe Scabellone wrote:

        Hi , I was looking Steve Ayer's AccelECGC.nc file.
        I need to get datas from ECG and as I can see in that file the real
        datas are stored in p_packet array as you can see below:

        /* copy all the data samples into the outgoing packet */
                 *p_packet++ = *p_ADCsamples++; //tx_packet[8]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[10]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[12]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[14]
                 *p_packet = *p_ADCsamples; //tx_packet[16]

        but this p_packet is never used in other part of the code.

        I need the two channels of ECG stored in one array
          uint16_t ecgData[2]

        so if I call

        async event void DMA0.transferDone(error_t success) {
                 if(current_buffer == 0){
                     call DMA0.repeatTransfer((void*)__ADC12MEM0_,
        (void*)&sbuf1,
        NBR_ADC_CHANS);
                     memcpy(ecgData, &sbuf1, sizeof(*sbuf1)*NBR_ADC_CHANS);
                     current_buffer = 1;
                 }
                 else {
                     call DMA0.repeatTransfer((void*)__ADC12MEM0_,
        (void*)&sbuf0,
        NBR_ADC_CHANS);
                     memcpy(ecgData, &sbuf0, sizeof(*sbuf1)*NBR_ADC_CHANS);
                     current_buffer = 0;
                 }

                 post preparePacket();

             }

        and the method

        void preparePacket() {
                 uint16_t *p_packet, *p_ADCsamples, crc;

             p_packet = (uint16_t *)&tx_packet[8];

                 if(current_buffer == 1) {
                     p_ADCsamples = &sbuf0[0];

                 }
                 else {
                     p_ADCsamples = &sbuf1[0];
                }

                 /* copy all the data samples into the outgoing packet */
                 *p_packet++ = *p_ADCsamples++; //tx_packet[8]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[10]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[12]
                 *p_packet++ = *p_ADCsamples++; //tx_packet[14]
                 *p_packet = *p_ADCsamples; //tx_packet[16]

                    }

        The Question is using these two methods I'll have the datas in
        ecgData
        array? or I have to intercept p_packet?

        Thank you.



        _________________________________________________
        Shimmer-users mailing list
        [email protected]
        <mailto:[email protected]>
        https://lists.eecs.harvard.__edu/mailman/listinfo/shimmer-__users 
<https://lists.eecs.harvard.edu/mailman/listinfo/shimmer-users>


_______________________________________________
Shimmer-users mailing list
[email protected]
https://lists.eecs.harvard.edu/mailman/listinfo/shimmer-users

Reply via email to