I am currently running a script on a Beaglebone Black that controls a motor based on input from a thermocouple. Everything was working perfectly until I enclosed everything in a box, and now an error keeps popping up:
4:4:91-ti-r133
/usr/local/lib/node_modules/bonescript/src/index.js:234
if(typeof pin.ain != 'undefined') {
^
TypeError: Cannot read property 'ain' of undefined
at Object.f.digitalRead (/usr/local/lib/node_modules/bonescript/src/index.js:234:18)
at Object.<anonymous> (/var/lib/cloud9/Relays/Relays.js:9:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
I have double-checked all the connections, resistances, and voltages, and they all seem to be properly connected. Understanding this error message would greatly assist me in diagnosing the issue. Here is the code snippet:
var b = require('bonescript');
var c = require('bonescript');
var d = require('bonescript');
var e = require('bonescript');
var f = require('bonescript');
var state1 = b.low;
var state2 = c.low;
var state3 = e.digitalRead('P9.23', e.INPUT)
var state4 = f.digitalRead('P9.25', f.INPUT)
var temp = d.analogRead('P9_37');
d.analogRead('P9_37', printStatus);
function printStatus(x) {
console.log('temp = ' + x.value);
}
b.pinMode("P9_15", b.OUTPUT);
b.digitalWrite("P9_15", b.LOW);
c.pinMode("P9_12", b.OUTPUT);
c.digitalWrite("P9_12", b.LOW);
e.pinMode("P8_7", b.OUTPUT);
e.digitalWrite("P8_7", b.LOW);
setInterval(toggle1, 10000);
setInterval(toggle2, 200);
setInterval(toggle3, 1000);
function toggle3() {
temp = d.analogRead('P9_37');
d.analogRead('P9_37', printStatus);
}
function toggle1() {
if(temp<0.74 && temp>0.01 && state3 == c.HIGH) {
state1 = b.HIGH;
state2 = c.LOW; //If temp is LT 1190 C
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else if(temp>0.76 && state3 == c.HIGH) {//If temp is GT 1210 C
state1 = b.LOW;
state2 = c.HIGH;
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else if(temp<0.74 && temp>0.01 && state4 == c.HIGH) {
state1 = b.LOW;
state2 = c.HIGH; //If temp is LT 1190 C
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else if(temp>0.76 && state4 == c.HIGH) {//If temp is GT 1210 C
state1 = b.HIGH;
state2 = c.LOW;
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else {//Else do nothing
state2 = c.LOW;
b.digitalWrite("P9_15", state2);
}
}
function toggle2() {
if(state1 == b.HIGH) { //If Temp was LT 1190 C
state1 = b.LOW;
state2 = c.LOW;
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else if(state1 == b.LOW) { //If temp was GT 1210 C
state2 = c.LOW;
state1 = b.LOW;
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
else { //Else do nothing
state1 = b.LOW;
state2 = c.LOW;
b.digitalWrite("P9_15", state1);
b.digitalWrite("P9_12", state2);
}
}
return 0;
If anyone has any advice or suggestions, it would be greatly appreciated. I have not been able to find any reference to this specific error elsewhere, and similar errors appear to be unrelated. Thank you for your help!