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 & HelpElectronics,  Serial Library › Serial In from Basic Stamp inconsistent
Page Index Toggle Pages: 1
Serial In from Basic Stamp inconsistent (Read 1553 times)
Serial In from Basic Stamp inconsistent
May 31st, 2006, 9:15pm
 
Hello,

I'm looking to get my Stamp to send data to Processing via Serial. Having seen the other topics on the boards my basic test is to first get the DEBUG working.

What I have on the stamp as a test is:
--------------------------------------------
' {$STAMP BS2}

Main:
 DEBUG "ah"
 'SEROUT 16, 16572, ["ah"] 'should work like DEBUG
 PAUSE 10
GOTO main
--------------------------------------------

Now in reality I'd want to send Serial info on a button press, but to send so rapidly was the only way to get any response out of processing at all.

With the following code I get the first few characters and then nothing. Then if I close and reopen the port I get the same thing: a few characters and then nothing.

When I open a new debug window in the Basic Stamp editor all the debugging appears with no problem at all.

Any advice most welcome.

I'm on XP running p0115 and going straight into COM1, no USB (although it did do the same thing going through a FTDI interface to a USB COM port).

Thanks,

andy



Here's my processing code:
Quote:


import processing.serial.*;

PFont f;
Serial port;
int last;

void setup() {
 size(500, 500);
 f = loadFont("Alba-48.vlw");
 textFont(f, 32);
 // Print a list in case COM1 doesn't work out
 println("Available serial ports:");
 println(Serial.list());
 fill(255);
 println("selecting: "+ Serial.list()[0]);
 port = new Serial(this, Serial.list()[0], 9600);
 port.clear();
}

void draw(){
 fill(0,0,0,10);
 rect(0,0,width, height);
 fill(255);
 text(""+port, 0, 100);
 text(""+port.available(), 0, 150);
 text("rate: "+port.rate, 0, 200);
 text("parity: "+port.parity, 0, 220);
 text("stopbits: "+port.stopbits, 0, 240);
 while (port.available() > 0) {
   int value = port.read();
   serialEvent(value);
 }
}

void serialEvent(int v) {
 println("serial input: "+v);
 fill(255);
 last = v;
 text(last, 0, 130);
}

void keyPressed(){
 if (key=='s') {
   println("closing port");
   port.stop();
 }
 else if (key=='o') {
   println("opening port");
   port = new Serial(this, Serial.list()[0], 9600);
   port.clear();
 }
 else if (key=='c'){
   println("clearing port");
   port.clear();
 }
}



Re: Serial In from Basic Stamp inconsistent
Reply #1 - Jun 21st, 2006, 9:55am
 
I'm having issues too on reading data (numeric) from a serial port with wiring, any tutorial about it?

Thanks, chr
Page Index Toggle Pages: 1