Go Down

Topic: Serials... (Read 272 times) previous topic - next topic

Slavka85

Mar 07, 2014, 07:38 pm Last Edit: Mar 07, 2014, 07:41 pm by Slavka85 Reason: 1

   Hi guys.. Im new to arduino world. So pls help...

I got this problem here:

    I try to use 3 serials not really at the same time but .  I got 3 Serials.. UNO serial hookuped with OBD-UART, Blue.serial with bluetooth device... LCD.serial is LSD skreen... All staff from sparkfun.... All bound rates at 9600. Bluetooth UNO LCD OBD_UART
    So what happens is that if i  send chareters from bluetooth to serial or lcd it comes with mistakes or not all word like for example: bluetooth i will get on lcd or serial like: uetooth. And if send just one char it missing each secon or therd time... Like it wont read the first few char on bigining of the word... And it's bidirectional no matter from lcd or serial i send to blue Watever..

This the code:


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

SoftwareSerial lcd(2,3);
SoftwareSerial blue(4,5);\\

void setup()
{
 lcd.begin(9600);
 lcd.print("LCD Start");
 
 
 blue.begin(9600);
 blue.print("Blue Start");

 Serial.begin(9600);
 Serial.print("Serial Start");

}


void loop()
{
 while(blue.available())
  {
    Serial.print((char)blue.read());
  }
 
 if(Serial.available()>0)
 {
   lcd.write((char)Serial.read());  
 }
 else if(Serial.available()>0, Serial.read()=='l')     //This is command char to clear lcd... That's what im all time missing
    {
      clearDisplay();
    }
}
   

void clearDisplay()
{
 lcd.write(0xFE);  // send the special command
 lcd.write(0x01);  // send the clear screen command
}



 




 


AWOL

Code: [Select]
if(Serial.available()>0, Serial.read()=='l') ?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Slavka85

This my cpesial char to obtain the clear lcd function..

It just the beggining of the code. but it is already gives a problem... this char missing evry second or therd time you sending it... like you need send 3 l. then it clean it the lcd.

michinyon

Get yourself an Arduino Mega,  which has four serial interfaces.

Slavka85

#4
Mar 11, 2014, 06:28 am Last Edit: Mar 11, 2014, 06:44 am by Slavka85 Reason: 1
 Ok. I got myself Mega...

And its unbelivable what happens on this serials ... What im trying to do atleast for now is a pathway for data...
on serial1 here is obd_uart.  on serial 2  out in loop section i puting in there or blutoth or lcd... And here happans some kind of debounsing ... on port 2 instade of any data i getting ??????????????????????????? unSTOPable.....  it's stops only if i unplug  tx wire from serial2.... I understand if it happans when all devices has difrent ground... All devicecs Mega OBD_UART bluetooth and lcd all on one ground.... CRAZY DEBOUNS.  i tryed put Tx through resistor on the ground - same shit. I don't know what to do else...

What bord broken??? Could Be?.... But it  prints the "blue poehali" and then when loops starts just unstopable ??????????????????????????? and so on.... AHHHHHH

So to be more clear... On setup The OBD_UART gets right comands and do them and it prints the answer which doesn't wanna go at all through the bord   ( debounsing)

On loop you not putting anything you just getting(?????????????????????????????????????????????????)

Code: [Select]

int vehicleSpeed = 0;
int vehicleRPM = 0;

void setup()
{
 Serial.begin(9600);
 Serial.println("SerialPoehali");
 
 Serial2.begin(9600);
 Serial2.println("BluePoehli");
 
 
 Serial1.begin(9600);  //This serial for OBD-UART
 
 //Wait for a little while before sending the reset command to the OBD-II-UART
 delay(1500);
 //Reset the OBD-II-UART
 Serial1.print("ATZ\r");
 delay(50);
 
 if(Serial1.available()>0){
     // Print answer from ELM on ATz
   Serial2.println(char(Serial1.read()));}
   
 //Wait for a bit before starting to send commands after the reset.
 delay(5000);
 
 Serial1.print("ATE0\r");  //turn echo of
                                                                                     
   if(Serial1.available()){
   char inByte = Serial1.read();   // Print answer from ELM
   Serial.print(inByte);
   }
}

void loop(){
   
    if(Serial2.available()>0)
    {
      Serial1.println(char(Serial2.read()));
    }
    if(Serial1.available()>0)
    {
      Serial2.println(char(Serial.read()));
    }



}
 

Go Up