I am working on a device that requires controlling a large number of switches by RS-232. The designer wants to use a microcontroller. So in that scenario, a code is sent via RS-232 to the microcontroller which then operates each switch individually. Since he wants to have a one-port-to-one-switch setup, the microcontroller needs to have a lot of IO ports which means we have to use an adapter. All in all, if we add in the complexity of programming the microcontroller, it seems unnecessarily complex to me. I am wondering if there is a straightforward way we can do this using discrete logic.
So, for example, suppose we have 10 switching points and each of these switches is 4-way. Then we have 4 possible states for each switch, which requires 2 bits. So, I guess we need 2 latches per switching point, or twenty latches altogether. So, not being expert in digital logic I am not sure how it might be possible to set each latch using RS-232. Can someone point me in the right direction of how to set this up?
RS-232 has 9 pins, so if we treat 1 pin as the pin used to set logic, then we have 8 logical pins. So, if we have 20 different latches, then since 2^5 = 32, we can control these using 5 of the pins. Then the 3 remaining pins can be used to set the state. Or something like that. What is the strategy here?
An additional issue is that it would be desirable, but not necessary, to query the state of the switches. Is that easy to do in some way?