rhian
YaBB Newbies
Offline
Posts: 20
bluesense library post 0127
Feb 5th , 2008, 3:51am
I'm working with the boards from bluesense to control some stepper motors and they've been working really well in release 0127 but in any later releases the applet crashes after about two minutes with no error in the processing window. If it was a problem with the bluesense library then it should cause a problem in release 0127 ?? shouldn't it?? My code is import org.bluemelon.bluesense.*; Master master; OCOutputDevice oco; int i = 0; int id; int stepcount = 0; int location; boolean setupOCOutput() { System.out.println("Detecting device "+id+" \n"); // try to find our device within the next 5 seconds Device dev = master.detectDevice(id, 5 * 1000 * 1000); // device not found? if(dev==null) { System.err.println("Device "+id+" not found!\n"); return false; } else{ println("Device found"); } oco = (OCOutputDevice)dev; return true; } void setup() { oco = null; master = new Master(); // type your switchInputDevice id id =1574; if (setupOCOutput()) { // call yield every 1 ms. master.start(1); } size(200,200); frameRate(25); } void draw() { stepcount = mouseX; stepcount = stepcount*4; // test if initialized if (oco!=null) { while (i!=stepcount){ int location =( i % 4)+1 ; //scroll through terminals 1-4 if (location == 1){ oco.requestSetOutput(oco.OCOUTPUT_PB_1,true); oco.requestSetOutput(oco.OCOUTPUT_PB_2,true); oco.requestSetOutput(oco.OCOUTPUT_PB_3,false); oco.requestSetOutput(oco.OCOUTPUT_PB_4,false); } else if (location == 2){ oco.requestSetOutput(oco.OCOUTPUT_PB_1,false); oco.requestSetOutput(oco.OCOUTPUT_PB_2,true); oco.requestSetOutput(oco.OCOUTPUT_PB_3,true); oco.requestSetOutput(oco.OCOUTPUT_PB_4,false); } else if (location == 3){ oco.requestSetOutput(oco.OCOUTPUT_PB_1,false); oco.requestSetOutput(oco.OCOUTPUT_PB_2,false); oco.requestSetOutput(oco.OCOUTPUT_PB_3,true); oco.requestSetOutput(oco.OCOUTPUT_PB_4,true); } else if (location == 4){ oco.requestSetOutput(oco.OCOUTPUT_PB_1,true); oco.requestSetOutput(oco.OCOUTPUT_PB_2,false); oco.requestSetOutput(oco.OCOUTPUT_PB_3,false); oco.requestSetOutput(oco.OCOUTPUT_PB_4,true); } delay (4); if(i<stepcount){ i++; } if(i>stepcount){ i--; } } } } public void stop() { System.out.println("stopping..."); master.close(); System.out.println("stopped"); }