Go Down

Topic: YunServer + SoftwareSerial = periodic hangs (Read 8190 times) previous topic - next topic

Piero76

Hi all

I want to use AltSoftSerial for my project. but i experience some latency problem...
what i want to do it's to send a request to a rs485 device and receive the response.
the device responds immediately but i don't receive anything (i see the response from a usb-rs485 interface between arduino and the device)
the baudrate it's 9600
I've tried to send manually the response (via hyperterminal). If i send the data before 5 or 6 seconds it doesn't receive anything... if i send after this time it works correctly and goes on.
I think there's some latency time before arduino is ready to receive something... it's only my opinion because i didn't find anything online about this....

some idea?

Piero76

#16
Apr 01, 2014, 07:19 pm Last Edit: Apr 01, 2014, 07:21 pm by Piero76 Reason: 1
Hi all

Some news,

this is the code tha I used for testing:

Code: [Select]
#include <AltSoftSerial.h>

#define rxPin 13
#define txPin 5

int EN = 2;
int val = 0;
int i=0;

String risposta="";
AltSoftSerial mySerial;

void setup() {
        const int baudrate = 9600;
       
       Serial.begin(baudrate);
       
        pinMode(rxPin, INPUT);
        pinMode(txPin, OUTPUT);
        mySerial.begin(baudrate);
       
        delay(5000);
        Serial.println("START!!!!");

}

void loop() {
   i=0;
   risposta ="";
   //Serial.println("X");
   //String stringa = "01 03 00 00 00 0A C5 CD";
   int stringa[8]={0x01,0x03,0x00,0x00,0x00,0x0A,0xC5,0xCD};
   char c;
   //String stringa = "01" ;
   val = digitalRead(EN);
   Serial.print("Stato A: ");
   Serial.println(val);
   //Serial.print("val 1 = ");
   //Serial.println(val);
   digitalWrite(EN, HIGH);
   for (int j=0; j < 8; j++){
       mySerial.write(stringa[j]);  //era write
       Serial.print(stringa[j],HEX);
       stringa[j]= 9;}
   Serial.println("");
   digitalWrite(EN, LOW);
   val = digitalRead(EN);
   Serial.print("Stato B: ");
   Serial.println(val);
delay(5000); // Time that I have to wait to see the pin EN to change status !!!!!!!
   val = digitalRead(EN);
   Serial.print("Stato C: ");
   Serial.println(val);
     
   
    while ((mySerial.available()==0)&&(i<1000)) {
    i++;
    delay(1);
    //Serial.println(".");
    }
   
    while(mySerial.available()) {
    //Serial.print("RICEVUTO!!!!  ");
    c = mySerial.read();
   // Serial.print(c,HEX);
    risposta=risposta+c;
    delay(1);
    }
    delay(1);
   
   Serial.println("");
   Serial.println(risposta);
   Serial.println("");
}


The problem I found is that there is a delay between when the EN pin (enable pin of the RS485 shield - I/O expansion V5 shield) goes high and when it goes low.
I verified that pass at least 5 seconds.
I thought there was some problem with the DigitalWrite and DigitalRead commands and so I've controlled the pins directly (via pin manipulation), but the problem remains the same.....
The slave responds to the master, but the master, not being enabled in reading, does not receive packets.
Have any of you encountered the same problem?
some idea?

sanne1234

Hi,

I also have a problem with the Arduino Yún and an XBEE.

I use the Arduino Yun, a ArduinoXBee v1.1 shield and a Series 1 XBEE. I tried the setup with 13 and 5 for RX and TX. That didn't work. Now I use the setup with 8 and 9 for RX and TX. I also bent the two pins as the pictures show in a different post.

I tried it with the code above but it does not work for me. I actually do not need all these functions. I only need it to send an (empty) message to other XBees. From there I am going to use the RSSI to determine distance. 

I can send between two XBees if they are both in explorers connected to the computer and the Yun seems to work fine.

Anybody with an idea what can be wrong or what I should try next?

ShapeShifter

The problem I found is that there is a delay between when the EN pin (enable pin of the RS485 shield - I/O expansion V5 shield) goes high and when it goes low.
I verified that pass at least 5 seconds.
I see where you are setting the EN pin high or low, but nowhere do you make it an output.

The power-on state for a pin is an input, and when a pin is an input, using digitalWrite() on the pin does not control the output state: all it does is enable or disable a weak pull-up resistor. I think what is happening is that this weak pullup resistor is slowly charging the stray capacitance on the line, resulting in slow transition times.

In setup, try adding pinMode(EN, OUTPUT); and see if that makes a difference.


I also have a problem with the Arduino Yún and an XBEE.
Please do not cross-post the same problem in multiple threads. It wastes the time of people trying to help, and it spreads the possible solutions across several threads, making it harder to find the solution for people who come along later with the same problem.

I do not believe your issues have anything to do with the problem in this thread. You are both using SoftwareSerial, but other than that there is no correlation between your issues.

I have already responded to your other post on this matter, please continue the discussion there and do not reply to this thread.

Go Up