-
• #2
Ahh, that's frustrating. It's because you're using an analog input while the Waveform is also trying to use it. I'll file a bug for that and will try and fix it.
Right now your best solution would be to just forget about the analogVRef and hard-code the voltage:
var vOut = 3.3 * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao
Either that or work it out beforehand:
var vref = E.getAnalogVRef(); w.on("buffer", function(myarr) { // ... var vOut = vref * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao
Or... you could not use the double-buffer but instead just use a single buffer that stops reading when it is full:
var w = new Waveform(128/* your buffer size */,{doubleBuffer:false, bits:16}); setInterval(function() { var myarr = w.buffer; myarr.sort(); // cut off first and last 2 elements var view = new Uint16Array(myarr.buffer, 2/*sizeof(uint16)*/*2, n-4); var vOut = E.getAnalogVRef() * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao var vZero = 0.4; var tCoeff = 19.5 / 1000; var tempinc = (vOut - vZero) / tCoeff; var tempinf = tempinc * (9 / 5) + 32; console.log("Temp in C: " + tempinc); console.log("Temp in F: " + tempinf); //console.log(E.sum(view)/(view.length*65536)); // start it again w.startInput(A0,2000 /* Samples per second */); }, 1000*150/2000 /* so slightly over the 128/2000 sec required for the waveform*/);
-
• #3
...where is the n in line 6 come from / defined? - I assumed this is the buffer size... (see example in post).
-
• #5
Yes, looks like n needs to change, but that's not the issue here.
It's not that waveform has a lower limit, it's that it is using the adc in the background. If you use it and then access the adc with analogRead, occasionally they may try and use it at the same time, and you'll have problems
-
• #7
I think there are only 2 ADCs? But yes, only one ADC is available. While switching to ADC2 for Waveform would be a simple fix, unfortunately the F401 in the Pico only has 1 ADC, so I need to come up with a fix that works for both.
-
• #9
No problem! Glad it helped :)
I am receiving this error and don't know why or how to fix this:
Code:
Console output: