Hardware.sampler.configure for multiple input

Hello everyone,
I tried to sample analog signals (ADC) in a project of mine.
here is the code:
`
function DataReady(buffer_1, length)
{
local i;
local m;
local n;
local output = blob(20); //set output to an array
//local signal_1 = blob(20);

if (length > 0) 
{
    for (i=0;i<length;i+=2)
        {
         output[i] = (buffer_1[i]+256*buffer_1[i+1]) *3.3/65536;
         
          //server.log( output);
        }
    for (i=0;i<length;i+=2)
    {
      server.log(output[i] +  output[i+1]);
    }
             
}

}

function StopSampler()
{
hardware.sampler.stop();
}

buffer_1 <- blob(20);
buffer_2 <- blob(20);
imp.configure("Sampler ", [], []);
hardware.sampler.configure([hardware.pin9 , hardware.pin8], 100, [buffer_1 , buffer_2] , DataReady);

hardware.sampler.start();

imp.wakeup(2, StopSampler);

`

the code works when i input 2 analog signal. i used 2 DC for now to get a consistence result at the moment but if this work, i go for some more complex signal. However, when i output the result using server.log, i would like it to have a format like "channel 1 , channel 2 .
I could not get the output format to be like this. what i have is
`

2014-05-08 14:52:39 UTC-6 [Device] 2
2014-05-08 14:52:39 UTC-6 [Device] 1
2014-05-08 14:52:39 UTC-6 [Device] 2
2014-05-08 14:52:39 UTC-6 [Device] 1
2014-05-08 14:52:39 UTC-6 [Device] 2
`
where channel 1 is 1 and channel 2 is 2.

Can anyone help me with this?

thanks

and 1 more extra question if anyone know : is there a way to export the server log file into a txt file automatically ?

The problem here is that your code is actually adding the values together, because it sees they are both numbers :slight_smile:

Change:

server.log(output[i] + output[i+1]);

to

server.log(output[i] + " " + output[i+1]);

…and you’ll see both numbers.

If you want to log the data, you should probably be sending it somewhere eg xively etc.