Is it possible to have a connection between 3 modules like this:
PC -----usb ------ Master Arduino -----RS485----- ATTINY816
From PC, I want to send commands to Master Arduino via USB connection. then based on the command, Master Arduino could send a command to the ATTINY816 to get some data via RS485.
I don't have much experience in Arduino so I don't know how to differentiate the signal in master Arduino which one is from PC and which one is from ATTINY816 in case both PC and ATTINY816 send data at the same time. Also how to send data to the correct communication channel in the master Arduino.
I know that you know that there are boards with free UARTs that are not used for communication with the PC.
@haisonvh So it depends on which Arduino you use as a "master". 328P based boards only have one UART and it's used for communication with the PC so you need SoftwareSerial; most other boards have at least one free UART that you can use.
I have figured out the way
To communicate with PC, I still use the USB connection and use Serial class for coding.
To communicate with ATITINY microcontroller, I use SPI with MAX485 module to convert SPI signal to RS485 signal. To do that I will use the SPI class
With this setup, I can differentiate the signal of PC and ATITINY in my "master Arduino"
Are you referencing someone else's implementation here, or imagineering? SPI has bidirectional data chip selection, AND a clock signal to contend with. I don't believe I've seen that done on an RS485 bus structure.
Because the ATITINY works as a slaver so I will enable SS pin (set to HIGH) in Arduino when I want to get data from the ATITINY. In addition, it uses a different class (SPI) to transmit data so I guess the Arduino could differentiate this signal from the serial signal sent from PC.
Read that article from end to end, no mention of RS485. Just plain, simple, SPI implementation. Since you don't appear to know the difference, I'll step away now. Have fun!