can some one tell me what will be the best way, to make a max485 network with one master and 5 slaves, duplex
There are dozens of good tutorials on the web. Some give more engineering background than others. Some require that you already know a lot, while others are very technical. What is your background, experience level, etc. in both software and hardware?
in fact, my experience in software and hardware, is almost 0,0, so i need alot of help.
i have see a lot of sketches all over the internet, but not a sketch, where a slave sends his status back to the master, and not a sketch, where a master can set a port HIGH on the slave.
the most sketches are to read a sensor and set the value to the serial monitor
Half duplex is fairly easy. Have a read of Nick Gammons RS485 page for a nice simple setup. He even has sample code.
What sort of distance are you planning to put the slaves at? Is it ft, 10's of ft or 100's of ft?
A master/slave command/response setup is quite easy to achieve. Again have a look at Nicks web page.
The largest distance will be about 120 ft.
the plan was, to use push buttons for each slave, to set a port on the slave HIGH.
the slave must send a signal back to the master, so i can see on the master IF the port on the slave is realy HIGH
If events, like pushing buttons, are going to occur infrequently, then there is likely little chance of a message collision if 2 slaves were to transmit at the same time. The master can simply wait for messages to arrive. That would be an ad-hoc RS485 network where slaves are free to transmit whenever they like.
How quickly would you need to know that a button had been pressed? The master could query each slave once every 5 seconds to check (for example). Each slave could only respond when it got the message from the master. That's a more organised master/slave network. It also allows the master to detect if a slave has failed for whatever reason.
How come you picked a serial protocol for the task, if I may ask?
A usful tool when working on RS485 networks is a USB-RS485 dongle, e.g. FTDI USB-RS485-WE-1800-BT - look on EBAY for alternatives
you can then use a PC to monitor the RS485 traffic and send/receive packets
i thought, it will be the best for this project with RS485
If you have the gear why not.
i have look at http://www.gammon.com.au/Arduino/RS485_protocol.zip
but i cant get that RS485_protocol in my libary
i got it now
For $34 and from FTDI -- that's hard to turn down.
(PE - $50+ w/ shipping)
i have 8 max485 modules
+1 for a USB-RS485 dongle that @horace mentioned. Having one of these will save you huge amounts of time when your various slave devices are misbehaving during your project development.
I have a couple of these ones that provide GND, +5V, A & B:
And they are very cheap to buy - around 6GBP on ebay uk.
but my ide, cant still not find it
What do you expect your IDE to do with it? The SerialMonitor has no RS485 half/full duplex capability, it's a (very) dumb terminal.
i need the RS485_protocol.h in that sketch, but i get always the error
H:\ARDUINO\libraries\sketch_oct15a\sketch_oct15a.ino:1:10: fatal error: RS485_protocol.h: No such file or directory
#include "RS485_protocol.h"
^~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: RS485_protocol.h: No such file or directory
Oh, you mean the compiler (called by the IDE) can't find the file. That's very different. Please learn to be clear, and specific; posting exact, complete error messages helps a lot.
Did you install that library yet? How did you install it - through the library manager, third-party download-and-install, file copy, ????
Can you see the file with file manager, somewhere on your PC? If it can't find it, I doubt the IDE's compiler will.
that here above, is the complete error message, here under again
H:\ARDUINO\libraries\sketch_oct15a\sketch_oct15a.ino:1:10: fatal error: RS485_protocol.h: No such file or directory
#include "RS485_protocol.h"
^~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: RS485_protocol.h: No such file or directory