• Hello,

    I'm studying the waveform below and I'm interested in the corresponding voltages of each point that the waveform returns:

    var w = new Waveform(2000, {bits:16});
    w.on("finish", function(buf) {
    for (var i in buf)
    console.log(buf[i]);
    });
    w.startInput(A0,10000,{repeat:false});

    For example, the first points are

    49168 - corresponds to 2.7v
    49264 - corresponds to 2.6v
    49264 - corresponds to 2.6v
    49408 - corresponds to 2.8v
    49408 - corresponds to 2.8v

    Do you know how can I convert? It would help if I knew the minimum and the maximum of the values of these points, for example: minimum: 20000, maximum: 50000

    The analog to digital converter converts the analog data in points with corresponding voltages between 0 - 3.3v, correct?

  • Yes, so what happens is normally the 0-3.3v voltage is converted to a number between 0 and 1 (eg via analogRead). Actually it's the CPU's voltage, which is supposed to be 3.3v, but may not be if you're powering it externally or drawing lots of power. You can check with E.getAnalogVRef().

    For the waveform, the numbers are integers, so can't be fractional. For 8 bits you have a number that can be between 0 and 255 (2^8 - 1), and for 16 you have one between 0 and 65535 (2^16 - 1). Waveform just multiplies the reading up to that range.

    So for instance if you wanted to work out what 49408 was, you'd do 49408 * 3.3 / 65536 = 2.48. It's not the voltage you had measured, but I think that might be something to do with the way you're measuring (wrong pin?) as the numbers you have posted above don't look quite right.

  • Hello Gordon,

    Yes, the numbers that I have put up there are not correct, it was just an example so you would be able to understand what I meant. But I understood perfectly now, your explanation was awesome. And I have another question, I'm using an accelerometer to measure vibrations with this waveform, however this waveform is only for one axis. If I wanted to measure these values in the three axis (X, Y and Z) with this waveform function, how could I do?

  • You should just be able to start 3 waveforms recording. You can actually make sure they start at the same time as well - search for synchronized waveforms inside the http://www.espruino.com/Waveform page

  • Thanks a lot Gordon!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Converting the results of a waveform in the corresponding voltage

Posted by Avatar for user68392 @user68392

Actions