Hi GolamMostafa,
Thank you for the comments and ideas.
There is no specific reason for using '2' or '1'. I was experimenting with sending binary, hex, chars, integers. I was sending b'00000001' for on, and if anything else was received that was preceived as off. The thought behind this was a simple read the serial port, and write that value to the port register. The reason I stopped was I thought it might have been problematic if some random bit of interferance was received it could mess with my intentions. So I changed it over to sending 0x01 in hex, and to avoid the same problem I send 0x02 to at least give it some protection against random bits jumping in.
That gave me a little trouble so I started to send the bytes as chars and I just didnt change it to 0x30 and 0x31.
I wanted to run the same code on both Uno's and just select the master v slave with a jumper pin that is only read on startup and it sets the sequence for the rest of the code.
I have simulated the circuit and it is working well.
Thank you Koepel for the ideas, comments and code.
Are you referring to the hardware or the firmware side of the protocol (232 v 485 v 422)?
If you are referring to serial protocol for the firmware:
The data is sent is packets of 8 bytes with no line carriage.
[0x53] [Pin1Byte]...[Pin6Byte] [0x45] example "S101010E" = 53 31 30 31 30 31 30 45.
From a hardware perspective:
Each Uno will be connected to an USR232-E2 (TTL to TCP) adapter. I have used these in the past for retro fitting older 485 devices to get them online.
My understanding is when you use Serial.read() that current byte is removed from the rx buffer. What happens to the rx buffer if data is not read and the buffer is filled up? Can this happen or is there some kind of overflow error or does it just go back to the beginning and any data not read is written over?
Thanks,
Josh
JP1 is the "MasterSelect".
