Go Down

Topic: Multiple max 485 communicatio (Read 1 time) previous topic - next topic

AMPS-N

Dear all,

Here i am attaching simple circuit for communicating two device over max485. i found below code seems work fine for some extent. during first time it read data, as soon as it complete read it start reading garbage value. Please let me know what are changes to be made in circuit to make it work.

I NEED TO COMMUNICATE DEVICE AS IN LAYOUT.
CONNECTION DIAGRAM REPRESENT ,PRESENT CONFIGURATION

master program-> Arduino1
Code: [Select]



void setup() {
 // put your setup code here, to run once:
 
 Serial.begin(9600);

}

void loop() {
 Serial.write("Arduino write");
 delay(1000);
 
}



slave program-> arduino 2

Code: [Select]

void setup() {
 
 Serial.begin(9600);

}



void loop() {
 
Serial.write(Serial.read());
 
delay(1000);
 
}

AMPS

AWOL

Quote
as soon as it complete read it start reading garbage value.

-1 is not "garbage"
"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.

AMPS-N

#2
Apr 17, 2013, 03:36 pm Last Edit: Apr 17, 2013, 03:38 pm by AMPS-N Reason: 1
Here i am attaching screen shot of output. Some time it keep reading same thing, how to overcome this problem.
Is there any mistake in connection diagram
AMPS

AWOL

#3
Apr 17, 2013, 03:47 pm Last Edit: Apr 17, 2013, 03:50 pm by AWOL Reason: 1
Yes, that looks like -1 all right.
What do you expect to see printed when you read data that isn't there?

Start here
"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.

AMPS-N

#4
Apr 18, 2013, 06:53 am Last Edit: Apr 18, 2013, 09:02 am by AMPS-N Reason: 1
Here i m attaching out put window . Where i am getting data from Arduino 1 and reading it from Arduino 2
AMPS

AWOL

My PDF reader reports your document is damaged.
"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.

AMPS-N

ya , i made it working . Small changes made in circuit, I have added 120ohm resistor at both data lines

But i am facing another problem.

i have reverse the action , i.e Initially  Arduino1 master and Arduino2 slave. changed to Arduino1 as slave and Arduino2 as master . This time i could able to receive data. Program syntax similar as pasted earlier
AMPS

AWOL

Quote
But i am facing another problem.

...but you're not going to tell us what it is?
Or post any code or output.
"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.

AMPS-N


I am interchanging master to slave and slave to master, Code Working is working fine if i interchange the code.


Code in master
Code: [Select]



void setup() {
  // put your setup code here, to run once:
 
  Serial.begin(9600);

}

void loop() {
 
  Serial.println("I am  master ");


String content = "";
  char character;
  while(Serial.available()) {
      character = Serial.read();
      content.concat(character);
   
  }
 

    Serial.println(content);

delay(1000);
 
}



salve arduino
Code: [Select]




void setup() {
  // put your setup code here, to run once:
 
  Serial.begin(9600);

}



void loop() {

Serial.println("I m slave ");

Serial.write("Msp SENDING DATA");

 
delay(1000);
 
}






Quote
But i am facing another problem.

...but you're not going to tell us what it is?
Or post any code or output.
AMPS

AWOL

I can't open either of the documents attached to reply #4.

Quote
Code Working is working fine

Great!
"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.

AMPS-N

ya its working fine. I have attached output and code above.

SO i am trying these two things which are not working
1)interchanging master to slave and slave to master .and dumping code viceversa
2) communicate single master with two slave devices
here only one salve is receiving data , as soon u connected to 2nd slave start reading garbage value
AMPS

AWOL

Quote
as soon u connected to 2nd slave start reading garbage value

Is this real garbage this time, or still just data that isn't there?
"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.

AMPS-N

I dont value what garbage value meant by. I am reading improper values  like in communcation if ground is not properly connected you observe improper strings
AMPS

AMPS-N

i dont know what is meant by garbage value. According to me if output is reading improper strings i called it as garbage value.
i have attached output file here
AMPS

AWOL

Quote
According to me if output is reading improper strings i called it as garbage value.

According to you earlier in this thread, reading data that wasn't there (which you still appear to be doing from your screenshots) was "garbage", but is, in fact, completely normal and expected behaviour.
Sort that out, then post your code and your output.
"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.

Go Up