Pages: [1] 2   Go Down
Author Topic: Multiple max 485 communicatio  (Read 1367 times)
0 Members and 1 Guest are viewing this topic.
DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:


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:
void setup() {
  
  Serial.begin(9600);

}



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


* CONNECTION DIAGRAM.pdf (6.1 KB - downloaded 31 times.)
* LAYOUT.pdf (4.5 KB - downloaded 23 times.)
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
as soon as it complete read it start reading garbage value.
-1 is not "garbage"
Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* output.pdf (175.36 KB - downloaded 24 times.)
« Last Edit: April 17, 2013, 08:38:57 am by AMPS-N » Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that looks like -1 all right.
What do you expect to see printed when you read data that isn't there?

Start here
« Last Edit: April 17, 2013, 08:50:11 am by AWOL » Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here i m attaching out put window . Where i am getting data from Arduino 1 and reading it from Arduino 2

* output-with result.pdf (144.68 KB - downloaded 25 times.)
* out2.pdf (143.38 KB - downloaded 19 times.)
« Last Edit: April 18, 2013, 02:02:50 am by AMPS-N » Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My PDF reader reports your document is damaged.
Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But i am facing another problem.
...but you're not going to tell us what it is?
Or post any code or output.
Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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


Code in master
Code:


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:



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.

* Schematic.pdf (17.04 KB - downloaded 30 times.)
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
Code Working is working fine
Great!
Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* output-with result.pdf (144.68 KB - downloaded 18 times.)
Logged

AMPS

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 836
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* output-with result.pdf (144.68 KB - downloaded 17 times.)
Logged

AMPS

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26348
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Pages: [1] 2   Go Up
Jump to: