Show Posts
Pages: [1] 2
1  Topics / Device Hacking / Re: Problem caused by previous data flowing in on: June 18, 2013, 02:14:47 am
Hello thanks for replying. All i was doing was to follow the tutorial given here: http://playground.arduino.cc/Interfacing/Java
2  Topics / Device Hacking / Re: Problem caused by previous data flowing in on: June 18, 2013, 02:05:51 am
yes it had the two Arduinos talking. and the code i pasted is of the receiver where i am printing the received values. Sorry... will modify the post.
3  Topics / Device Hacking / Re: Problem caused by previous data flowing in on: June 18, 2013, 01:59:16 am

Code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.util.Enumeration;


public class SerialTest implements SerialPortEventListener {
SerialPort serialPort;
static PrintWriter print;

        /** The port we're normally going to use. */
private static final String PORT_NAMES[] = {
"/dev/tty.usbserial-A9007UX1", // Mac OS X
"/dev/ttyUSB0", // Linux
"COM15", // Windows
};
/**
* A BufferedReader which will be fed by a InputStreamReader
* converting the bytes into characters
* making the displayed results codepage independent
*/
private BufferedReader input;
/** The output stream to the port */
private OutputStream output;
/** Milliseconds to block while waiting for port open */
private static final int TIME_OUT = 2000;
/** Default bits per second for COM port. */
private static final int DATA_RATE = 9600;

public void initialize() {
CommPortIdentifier portId = null;
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

//First, Find an instance of serial port as set in PORT_NAMES.
while (portEnum.hasMoreElements()) {
CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
for (String portName : PORT_NAMES) {
if (currPortId.getName().equals(portName)) {
portId = currPortId;
break;
}
}
}
if (portId == null) {
System.out.println("Could not find COM port.");
return;
}

try {
// open serial port, and use class name for the appName.
serialPort = (SerialPort) portId.open(this.getClass().getName(),
TIME_OUT);

// set port parameters
serialPort.setSerialPortParams(DATA_RATE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);

// open the streams
input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
//output = serialPort.getOutputStream();

// add event listeners
serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
} catch (Exception e) {
System.err.println(e.toString());
}
}

/**
* This should be called when you stop using the port.
* This will prevent port locking on platforms like Linux.
*/
public synchronized void close() {
if (serialPort != null) {
serialPort.removeEventListener();
serialPort.close();
}
}

/**
* Handle an event on the serial port. Read the data and print it.
*/
public synchronized void serialEvent(SerialPortEvent oEvent) {
if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
//input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
String inputLine=input.readLine();
System.out.println(inputLine);


} catch (Exception e) {
System.err.println(e.toString());
}
}
// Ignore all the other eventTypes, but you should consider the other ones.
}

public static void main(String[] args) throws Exception {
SerialTest main = new SerialTest();
main.initialize();
Thread t=new Thread() {
public void run() {
//the following line will keep this app alive for 1000 seconds,
//waiting for events to occur and responding to them (printing incoming messages to console).
try {Thread.sleep(1000000);} catch (InterruptedException ie) {}
}
};
t.start();
System.out.println("Started");


}


}
4  Topics / Device Hacking / Problem caused by previous data flowing in on: June 18, 2013, 01:51:56 am
hi folks,

i was trying to send  data from an arduino to another using xbee modules. But what i observe on the receiver end is that i continuously keep getting '1's from the previous code which was burnt into the sender mote. Flushing does not help and the 1s just don't stop coming in from the serial COM port. What do i do? Please help.

Thanks in advance.

--
Priyankar
5  Topics / Device Hacking / Why do we need to set Tools > Programmers in Arduino IDE? on: April 27, 2013, 05:24:01 pm
Can anyone explain the role of Tools > Programmer and why/ when we should select one of the various options given such as: AVR ISP, AVR ISP mkii, USB asp etc. And say if i were using the Virtual COM port 6 to burn a sketch into the arduino board, which one of the options should be set by me?

Thanks in advance.

--
Priyankar
6  Topics / Science and Measurement / Re: How to connect a finger probe sensor (SPO2 sensor)to an arduino board? on: March 18, 2013, 10:49:41 am
I have been researching on this and found out that most of the fingerprobe sensors have a RS232 DB9 male interface
and the best way to connect it to any device/ instrument is to buy an RS232-->X converter (X meaning TTL, USB or
whatever). In my case an RS232 DB9 - TTL converter (female) would suffice.

[Note: Guys be careful with what you buy. There are male/ female converters available. Most probably you would require a female
converter]
7  Topics / Home Automation and Networked Objects / How to connect a finger probe sensor (SPO2 sensor)to an arduino board? on: March 14, 2013, 06:06:03 pm
Hi,

I am trying to connect a finger probe sensor to the arduino uno r3 board. The sensor i am looking at and have researched for in the last couple of days is a nellcor ds-100 which has an RS 232 interface (DB9 connector). Now there are two problems i face.

(Problem 1) How can i connect it to the board?

Explanation: I came across http://www.beepbee.com/rs232-serial-port-to-ttl-converter-communication-module-for-arduino-p-32150.html#.UUIVZzeyLbd
and this seems like a possible solution.

But do how do i connect the 6 pins to the board. According to my understanding VCC, GND and SIGNAL pin should be enough for a sensor to give the output.

(Problem 2) Am i supposed to process the output?

Explanation: Do i feed the output from the ttl module directly into my board or do some processing before that? I am thinking about feeding the output to a software oscilloscope like Xocillio <Link http://code.google.com/p/xoscillo/>

Please help (Alternate solutions would be appreciated too).
--
Priyankar
8  Topics / Science and Measurement / How to connect a finger probe sensor (SPO2 sensor)to an arduino board? on: March 14, 2013, 06:00:52 pm
Hi,

I am trying to connect a finger probe sensor to the arduino uno r3 board. The sensor i am looking at and have researched for in the last couple of days is a nellcor ds-100 which has an RS 232 interface (DB9 connector). Now there are two problems i face.

(Problem 1) How can i connect it to the board?

Explanation: I came across http://www.beepbee.com/rs232-serial-port-to-ttl-converter-communication-module-for-arduino-p-32150.html#.UUIVZzeyLbd
and this seems like a possible solution.

But do how do i connect the 6 pins to the board. According to my understanding VCC, GND and SIGNAL pin should be enough for a sensor to give the output.

(Problem 2) Am i supposed to process the output?

Explanation: Do i feed the output from the ttl module directly into my board or do some processing before that? I am thinking about feeding the output to a software oscilloscope like Xocillio <Link http://code.google.com/p/xoscillo/>

Please help (Alternate solutions would be appreciated too).
--
Priyankar
9  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 07:47:33 pm
Are you talking about programming the xbee modules? Actually what i meant was whether or not there exists a way that you can burn "sketches" on to an arduino board while it has a shield or two mounted over it? Or do i have to take the shield off before i burn the code?
[I apologize for not being able to put the question straight enough...Hope this makes it easier to understand]
10  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 01:57:25 pm
Will remember to format the code the next time around. Also i have one more doubt: do i need to take the xbee shield (with the module mounted on it) off the arduino board every time before programming/ reprogramming it ?
11  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 12:04:14 am
But i am not being able to achieve the result...The led on the sender blinks fine which indicates data is being transmitted as desired. But the led on the receiver bears a constant HIGH. (which is what i do not understand). Please help.
12  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 12:02:50 am
Receiver:

int ledPin = 13;


void setup(){
         Serial.begin(9600);
         pinMode(ledPin, OUTPUT);
 
}

void loop(){
 
  //while(Serial.available() == 0);
 
  if(Serial.read() - '0'){
   digitalWrite(ledPin, HIGH);
   delay(1000);   
  } 
 
 
  else{
   digitalWrite(ledPin, LOW);
   delay(1000);
  } 
 
 Serial.flush();
 
   

 

13  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 12:02:16 am
Sender:

int data = 0;
int ledPin = 13;

void setup(){
         Serial.begin(9600);
         pinMode(ledPin, OUTPUT); 
 
}

void loop(){
 
  if(data == 0){
    Serial.write(0);
    digitalWrite(ledPin, LOW);
    data = 1;
  } 
 
  delay(1000);
 
  if(data == 1){
   
   Serial.write(0);
   digitalWrite(ledPin, HIGH);
   data = 0;
   
  }
 
 delay(1000);
 
14  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 12, 2013, 12:01:21 am
Sure. Maybe over a period of time, will overcome the fear  smiley-grin

Also now that i am setting up one arduino to be the sender and the other to be the receiver.

What i am trying to achieve is to blink an led on and off on the receiver based on inputs (1's and 0's) from sender.

Steps for sender:

1)Write the code for the sender.
2)Compile it.
3)Burn the code into the arduino uno.
4)Load the xbee shield with xbee module

Steps for receiver:

1)Write the code for receiver.
2)Compile it.
3)Burn the code into the arduino uno.
4)Load the xbee shield with xbee module.

Then plug them onto diferent computers. (Just for power supply i am assuming)

But it does not seem to work. I am copy pasting the code below.
15  Topics / Home Automation and Networked Objects / Re: How to connect sensors, xbee modules and xbee shield to an Arduino board? on: February 11, 2013, 07:50:25 pm
Now i have everything set up...Just a bit apprehensive about whether or not i should put the x-bee module all the way down into the shield...Because it takes quite a lot of effort to pull that thing up and plug into the spark fun explorer to program it...I am scared that it might damage the module if i went doing it for a couple of times.
Pages: [1] 2