Loading...
  Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Serial communication with processing small issue on: May 01, 2013, 07:15:46 pm
Just solved it... was missing that invisible CR...
added a myPort.write(13); and it works great now!!!
2  Using Arduino / Interfacing w/ Software on the Computer / Serial communication with processing [SOLVED] on: May 01, 2013, 05:40:49 pm
Please help...been stumped all day...

 

I am sending data to arduino from processing in the form of "+a123"

where + just tells the arduino that data is behind it the a is a command and 123 is any integer value.

I have a GUI in processing with multiple sliders and each slider has a letter assigned (hence the "a") and the value of the slider is the integer behind the letter.

 

I am sending it out using lines like this using 9600 baud:

 

myPort.write("+a"+value);

 

on the arduino end I receive it using:

 

if (Serial.available() > 0){
   inByte = Serial.read();
    // only input if a letter, number, =,?,+ are typed!
    if ((inByte >= 65 && inByte <= 90) || (inByte >=97 && inByte <=122) || (inByte >= 48 &&     inByte <=57) || inByte == 43 || inByte == 61 || inByte == 63) {
    command.concat(inByte);
}
}// end serial.available
if (inByte == 10 || inByte == 13){
inByte = 0;
if(command.indexOf('+') == 0){

code = command.substring(1,2);
temp2 = command.substring(2);
code.toCharArray(carray,2);
temp2.toCharArray(carray,4);
value = atoi(carray);

if (code=="c"){  DO SOMETHING with value temp1}

 

The code is to control RGB LEDs with a processing GUI console.

 

I'll gladly post the whole code but I thought it would just make it harder to solve this.

 

 

 

Basically if I open up the serial monitor in arduino and type in commands such as +a123 followed by [ENTER]

My leds ramp up the red value to 123.

It works perfectly.

 

When I println the variables in processing..  the display shows good numbers...

When I connect the arduino to processing.... the sliders don't work with the leds

 

 

I am thinking the issue is in how I am sending data to arduino since its mixed letters and integer values but im not sure.  Since I cant open up the serial monitors while the arduino is connected to the com port, I am stuck and completely blind....

 

 

Any ideas?????
3  Using Arduino / Project Guidance / Help choosing best wireless serial package on: April 08, 2013, 09:13:23 pm
After nearly 3 full days trying to get bluetooth connectivity I am ready to throw in the towel.

I got as far as having wireless communication but its very inconsistent.  One minute it works then for the next five hours I cant get it to connect again.

Problem might be windows 8 compatability because Ive tried it on two win8 64bit pcs and no luck on either.


What I need is to have an arduino collect sensor data and then send it wirelesly to a pc 3 feet away.
Since the bluetooth approach seems to be failing is there a better way???

I just need it to work every time no matter which pc is receiving the data.

I thought of maybe using xbee or a bluetooth modem to bluetooth modem setup where the pc end is not a bluetooth dongle but rather a bluetooth modem on a uart to usb interface????

It is short distance and a baud of 9600 would probably be enough...  its the reliability that is killing me...

Hope some one has a good suggestion for this.
I didnt mention but I am trying to keep it as small as possible.

A bluetooth modem is acceptable in size,  xbee...just barely but already getting too big for the enclosure.
4  Using Arduino / Programming Questions / Re: Error message on ProMicro using Serial.write() and wire library on: April 06, 2013, 11:47:30 pm
Whats strange is that if I search and replace all of the Serial. with Serial1. it will compile fine.

The problem is that I am getting serial data from the USB in Processing and Serial1 is not the USB port...

the error is: no matching function for call to 'Serial_::write(byte [2], int)'


Razor_AHRS.pde: In function 'void loop()':
Razor_AHRS:535: error: no matching function for call to 'Serial_::write(byte [2], int)'
C:\Users\fxmech\Documents\Arduino\hardware\proMicro\cores\arduino/USBAPI.h:41: note: candidates are: virtual size_t Serial_::write(uint8_t)
Output.pde: In function 'void output_angles()':
Output:12: error: no matching function for call to 'Serial_::write(byte*, int)'
C:\Users\fxmech\Documents\Arduino\hardware\proMicro\cores\arduino/USBAPI.h:41: note: candidates are: virtual size_t Serial_::write(uint8_t)
Output.pde: In function 'void output_sensors_binary()':
Output:92: error: no matching function for call to 'Serial_::write(byte*, int)'
C:\Users\fxmech\Documents\Arduino\hardware\proMicro\cores\arduino/USBAPI.h:41: note: candidates are: virtual size_t Serial_::write(uint8_t)
Output:93: error: no matching function for call to 'Serial_::write(byte*, int)'
C:\Users\fxmech\Documents\Arduino\hardware\proMicro\cores\arduino/USBAPI.h:41: note: candidates are: virtual size_t Serial_::write(uint8_t)
Output:94: error: no matching function for call to 'Serial_::write(byte*, int)'
C:\Users\fxmech\Documents\Arduino\hardware\proMicro\cores\arduino/USBAPI.h:41: note: candidates are: virtual size_t Serial_::write(uint8_t)
5  Using Arduino / Programming Questions / Error message on ProMicro using Serial.write() and wire library on: April 06, 2013, 10:43:20 pm
Has anyone besides me had issues using Serial.write with the proMicro???
I am getting errors that land specifically on a line of code
Serial.write(id,2);

I am communicating I2C with a 9DOF stick but the error does not appear when I load the same sketch into an UNO so I am assuming that it has to do with how the ProMicro is similar to the leonardo in that it has a Serial and Serial1 outputs.  I am using data collected by the ProMicro sent serial via USB to my pc for use in Processing...

I'll post the exact error message and code as soon as I get back to my PC tonight but thought Id start the thread in case this info is enough for some of you more experienced users to identify the problem...
6  Using Arduino / Installation & Troubleshooting / Re: Digital pins power jolt at bootup issue on: January 16, 2013, 04:56:30 pm
I just realized that the problem is not in the arduino but in the servo itself so it will jump when power is applied even if the signal wire is not connected.
The issue would go away if the arduino was running already when the servo got power because the jump would still be there but the arduino would correct it before it moved too far off course....

Is there any way of disabling the 5Vout pin temporarily during boot up from within the actual arduino software...  I don't know if the 5V pin is wired through the regulator straight to Vin or if it is switchable in some way...  If I could delay it until the arduino was ready to go, it would solve this on other similar issues Ive had in the past

I guess it could work by adding a relay type circuit that will keep the 5v line to the servo cut until it gets a signal from one of the digital pins....
Id rather solve it on the software end since I do a lot of this type of work and the alternative would bean adding the additional circuitry every time I do this...
7  Using Arduino / Motors, Mechanics, and Power / Re: Servo jumps when arduino is powered up on: January 16, 2013, 04:51:48 pm
Unfortunately that is not an option this time around...
I can however do something to cut the power to the servo until the arduino is booted up and sends a signal from another I/O pin...
That is something I am trying to avoid due to space and time limitations
8  Using Arduino / Motors, Mechanics, and Power / Re: Servo jumps when arduino is powered up on: January 16, 2013, 03:24:54 pm
These are pretty high end servos, but you are correct.
I tried plugging it in with the signal wire disconnected and it jumped just the same.
The reason it not normally an issue is that servo cyclers and receivers seem to immediately correct the drift so before it finishes jumping its already getting a signal to go back to where it should be.
On the arduino there is a significant delay between powerup and when the sketch is executed so the servo finishes its jump completely so its about 4 times bigger than on a cycler...

Any solutions to this???  I am powering the servo directly off of the 5V out pin so if there was an internal solution it would be do add some kind of delay in the arduino code to delay the 5v out pin from connecting....if that's even physically possible....
9  Using Arduino / Installation & Troubleshooting / Digital pins power jolt at bootup issue on: January 16, 2013, 03:10:08 pm
I posted this in another section of the forum thinking it was a servo specific issue, but I just discovered it is with the arduino itself.
When the arduino boots up( receives power) it sends some kind of spike out of the digital pins.

I am using the servo library with a servos signal wire attached to digital pin 8.
When I plug in power the servo spins CCW a few degrees even with a completely blank sketch

void setup()
{
}
void loop()
{
}

is there a way to get around this???  My problem is that the servo cant move outside of specific limits without causing damage to the mechanism.
The initial jolt I mentioned above happens even before the setup() function so it can potentially go out of bounds upon powerup...

Any ideas why this happens or how to avoid it???
10  Using Arduino / Motors, Mechanics, and Power / Re: Servo jumps when arduino is powered up on: January 16, 2013, 03:03:43 pm
Just tried it with a completely blank sketch:

void Setup()
{
}
void loop()
{
}

the jump is still there at powerup...  When the arduino gets power it sends a small spike out of the digital pins....
11  Using Arduino / Motors, Mechanics, and Power / Servo jumps when arduino is powered up on: January 16, 2013, 02:59:35 pm
I have a small servo driving sketch using the servo library.  
Its working fine but upon powerup the servo rotates a few degrees  CCW.
Normally its not a big deal but I am using it to drive a fragile mech and its possible it could damage something if the servo jumps out of its assigned min/max limits.


Is there a way to eliminate this little jolt at powerup???  It happens before the sketch reaches the setup() function so I'm assuming its happening as part of the bootup routine and has nothing to do with my sketch...


Code:
#include <Servo.h>

Servo mouthservo;  

const int mouthServoPin = 8;  
const int mouthUpLimit = 1550;
const int mouthDownLimit = 1450;
int mouthServoPos = mouthUpLimit;



void setup()
{
  mouthservo.attach(mouthServoPin,mouthDownLimit,mouthUpLimit);
  mouthservo.writeMicroseconds(mouthUpLimit);  
  delay(15);
}

void loop
{
}
12  Using Arduino / Programming Questions / Re: Simple Serial send receive question on: December 10, 2012, 06:59:32 pm
Ah yes...  I was switching variable types to see if I could blindly land on the solution...
Guess I forgot to switch it back for the post... good eye
13  Using Arduino / Programming Questions / Re: Simple Serial send receive question on: December 10, 2012, 06:26:42 pm
HEHE Sorry about that!!

Its just not working....  if I use the Serial monitor to test it it seems fine.
nothing happening on the monitor
I type an A
it returns a B
I type a C
Sensor data starts to stream....

But when I try to do it through another sketch (in processing)
I see  on the processing monitor area:

Waiting for connection
-1
Waiting for connection 
-1
Waiting for connection
-1
Waiting for connection
-1
Waiting for connection


So its probably not being received the right way
I don't think its a processing issue but I am pretty sure its just my basic understanding of serial communication that's off...

When I send data through a println("A");
am I sending a character
When I receive using ch=(char)Serial.read() do I get a character to compare (if(ch=='A'))

I might be comparing apples to oranges....

I
14  Using Arduino / Programming Questions / Simple Serial send receive question on: December 10, 2012, 06:07:33 pm
Im having a very hard time understanding serial communication... hopefully one of you can help me out.

I need to write a function to check communication between processing and my arduino via serial.

I am sending the a stream of character "A" from processing to arduino
when Arduino sees an 'A' then it sends a character 'B' back to processing
when processing sees that 'B' then it sends the character 'C' back to arduino

this is done for this reason:

stream of A's sent 1/4 sec apart to allow arduino time in case its not yet ready to receive
once the arduino is receiving data it gets that A and replies with a B to let processing know its online and receiving

processing reads that B then sends arduino a C to let it know it can now proceed to the void loop() function and start streaming the actual sensor data

BTW im using an arduino micro so like Leonardo it uses Serial and Serial1....Serial1 is used to receive data from elsewhere but doesn't apply to this section of the sketch.  likewise on the processing end there are two serial connections established but only myport is used to communicate to this arduino  so myport2 is not applicable either...the robot() class is used elsewhere also but since it has a delay feature I dropped it into this part of the sketch to only send data every 1/4 second so it doesn't fill up the buffer too fast waiting for arduino to respond....If besides the solution you have a better approach to achieve this please let me know...  I am making this stuff up as I go ad don't really know the most efficient way to accomplish this....thnkx


My programs look like this:

Arduino:

Code:
char ch;
int R;
int L;
int comFlag=0;  //0=waiting for initial request to connect from PC
//1= request received...sending confirmation to PC
//2=confirmation acknowledged by PC ready to proceed into main loop()

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(19200);
  Serial1.begin(19200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  //ESTABLISH COMMUNICATION LINK WITH PC
  while(comFlag!=2){
    if (Serial.available()) {// wait for data from pc
      ch=(char)Serial.read();      //if data is available read it
      if(ch=='A' && comFlag==0){    
        Serial.println("B");//Send 'A' character back to pc to acknowledge that it received the data
        comFlag=1;//flag to let us know that we are ready for stage two of connection verification process
      }
      if (ch=='C' && comFlag==1){         //check to see if data  in = 'C'
        comFlag=2;
      }

    }
  }
}

void loop() // run over and over
{
.
.
.
}
 




The processing end looks like this:

Code:
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.InputEvent;
import processing.serial.*;
import guicomponents.*;

Serial myPort;
Serial myPort2;
Robot robby;

char message;

void setup() {  
  size(267, 366);
  try
  {
    robby = new Robot();
  }
  catch (AWTException e)
  {
    println("Robot class not supported by your system!");
    exit();
  }  

  println(Serial.list());
  println("  Connecting to -> " + Serial.list()[portIndex]);
  myPort = new Serial(this, Serial.list()[portIndex], 19200);
  String portName = Serial.list()[1];
  myPort2 = new Serial(this, portName, 9600);
  robby.mouseMove(xx, yy);
  String[] files;

  //ESTABLISH SRIAL COMMUNICATION WITH HEADSET

  while (message!='B') {//Write 'A' to serial port until a reply is received
    int message = myPort.read();
    println(message);
    myPort.write('A');
    println("Waiting for connection");
    robby.delay(25);
  }
  myPort.write('C');
  println("CONNECTION ESTABLISHED!!!");
  //robby.delay(1000);
}


void draw(){
.
.
.
}
15  Using Arduino / Networking, Protocols, and Devices / Re: Serial1 IN--> Serial0 OUT why is my data a bit different? on: November 28, 2012, 01:40:58 am
Good point!
I actually started doing it that way but was getting error and did not know what was causing them yet so I tried a few things including changing the text to ascii values...  now I know that wasn't the problem so I do plan on doing it that way in the future...  cause your right, I wont remember...  btw off topic do you plan ahead when you write code???  I have been doing some pretty complicated stuff (within the stuff I understand... not serial communications)  I never plan ahead just start writing and figure it out as I go so yes 1 week later if not for comments in my code I would be completely lost.  I was just curious if most non professional programmers work this way or if they start with a flowchart...
Pages: [1] 2 3 ... 7