I have searched BeagleBoard forums for this answer but only found single
A/D responses. Since I already have a single A/D channel working this was
no help.
I am trying to read two analog pins but I get the following error message:
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EAGAIN, resource temporarily unavailable
at Object.fs.readSync (fs.js:481:19)
at Object.fs.readFileSync (fs.js:315:28)
at Object.exports.readAIN
(/usr/local/lib/node_modules/bonescript/hw_capemgr.js:214:30)
at Object.f.analogRead
(/usr/local/lib/node_modules/bonescript/index.js:229:15)
The code below is from the 'fade' demo example. I can read either one at a
time but when both are in the loop the error occurs after a while. Is the
first ADC still busy when the second analogRead occurs?
Linux beaglebone 3.8.13-bone47 #1 SMP Fri Apr 11 01:36:09 UTC 2014 armv7l
GNU/Linux
BeagleBone Black rev 00C0 running BoneScript 0.2.4
var b = require('bonescript');
// setup starting conditions
var awValue = 0.01;
var awDirection = 1;
var awPin = "P9_14";
var AnaloginputPin = "P9_38";
var MyTargetVoltage = 0;
var PWMAnalogVoltage = "P9_36";
var PWMAnalogVoltVal = 0;
var Analogvalue = 0;
// configure pin
b.pinMode(awPin, b.ANALOG_OUTPUT);
// call function to update brightness every 10ms
setInterval(fade, 100);
// function to update brightness
function fade() {
b.analogWrite(awPin, awValue);
awValue = awValue + (awDirection*0.01);
Analogvalue = b.analogRead(AnaloginputPin);
MyTargetVoltage = Analogvalue * 1.803;
console.log(MyTargetVoltage);
PWMAnalogVoltVal = b.analogRead(PWMAnalogVoltage) * 1.803;
console.log(PWMAnalogVoltVal);
if(awValue > 1.0) { awValue = 1.0; awDirection = -1; }
else if(awValue <= 0.01) { awValue = 0.01; awDirection = 1;
}
}
output is
0.20333833333333334
0.44273666666666667
0.18530833333333332
0.44273666666666667
0.19632666666666665
0.441735
0.18130166666666664
0.44273666666666667
0.23338833333333334
0.441735
0.22136833333333333
0.44273666666666667
0.19332166666666664 … until error message
Thanks
--
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.