Dear Community,
I am trying to read the analog inputs of a BegaleBoneBlack. So, I have
taken the obvious route: to use BoneScript (as it gives me a read function
straight away). My code is:
var b = require('bonescript');
var myReadTask;
var myStoreBuffer = [];
function readVoltage(){
b.analogRead("P9_36", saveValue)
}
function saveValue(reading){
var vv = reading.value*1.8;
myStoreBuffer[myStoreBuffer.length] = vv;
}
function startMyTasks(){
myReadTask = setInterval(readVoltage,1);
}
function stopMyTasks(){
clearInterval(myReadTask);
}
function finalStage(){
console.log("Number of elements logged = " + myStoreBuffer.length);
}
setTimeout(startMyTasks, 1000);
setTimeout(stopMyTasks, 1100);
setTimeout(finalStage, 1200);
------------------------------
Now this does work, but it obviously reads very slowly, because instead of
the expected 100 values ( reading should be called every 1 ms, for 100ms
total running time), I only get 6 or 7. Thus the reading speed is hell of a
lot slower than the expected 125ns per read.
My question is: is there a way to improve this via BoneScript --- or is
there some easy alternative?
I have seen quite a few posts on the topic on the forum, but most are
quite advanced -- and I am lacking some detailed descriptions/explanations.
Is there some easier way for someone who does know
C++/C#/Java/JavaScript/LabView/Matlab ... but is quite new into hardware
close issues like this?
My final goal is to have something like a producer-consumer system: the
BBB should read analog data as fast as possible (but at defined rate) ---
while my PC would run some code to get the data back from the bone (over
USB/Ethernet/whatever is best..)
Any ideas?
Thanks a lot!
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.