We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › bluesense library post 0127
Page Index Toggle Pages: 1
bluesense library post 0127 (Read 311 times)
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");
}

Re: bluesense library post 0127
Reply #1 - Feb 13th, 2008, 3:39am
 
Problem solved.

I needed to shift size() to the first line of setup.
Page Index Toggle Pages: 1