How many channels do you need, what voltage range do they need to work over?
RS232 for example can be a +12V/-12V signal. You may want to bring that down to 0V/5V level first with MAX232 or similar chip, and then switch those levels thru 5V multiplexers. https://www.digikey.com/en/products/detail/texas-instruments/MAX232EIN/1511027
FT232RL (for usb to uart)
MAX3232 (for RS232 to uart)
MAX485 (for RS485 to uart)
I want to switch the uart part of the transmitters to the arduino uart
I have the arduino's TX pin connected to all the transmitter pins, so everyone receives the message from the arduino.
But for the opposite, the reception to the arduino I would like to have a switch or other to select the right communicator, only I do not know how to say (if an RS232 cable is connected then we select this one)
I see a lot of problems, it is easy to just use a multiplexer and switch the 5V data to the Arduino and receive it with the appropriate interface chip. Sending the same thing to each unit is no problem but what if you get several responses, that can garbage the works. the 74HC153 would be a nice input multiplexer.
gilshultz:
I see a lot of problems, it is easy to just use a multiplexer and switch the 5V data to the Arduino and receive it with the appropriate interface chip. Sending the same thing to each unit is no problem but what if you get several responses, that can garbage the works. the 74HC153 would be a nice input multiplexer.
I manage everything from A to Z, the responses, the submissions, ... So I know when I'm expecting a response, and when I'm not expecting it
the problem is that I am wondering how to manage the selection precisely.
Let me explain, if I use a multiplexer, I must know from whom I am receiving the data, in order to activate the connection with it accordingly.
Except with a second micro controller, I don't care about anything, I receive everything, I record and I transmit to the micro controller
kealmlj:
I manage everything from A to Z, the responses, the submissions, ... So I know when I'm expecting a response, and when I'm not expecting it
the problem is that I am wondering how to manage the selection precisely.
Let me explain, if I use a multiplexer, I must know from whom I am receiving the data, in order to activate the connection with it accordingly.
Except with a second micro controller, I don't care about anything, I receive everything, I record and I transmit to the micro controller
while you have the right idea, the approach you are trying to take is not quite right IMHO,
consider the following:
you send a message to ALL receivers as you have stated
more than one receiver responds AT THE SAME TIME.
How are you going to multiplex/buffer that??
A better approach IMO would be for example
a. send message to all
b. ping each receiver (define an address for each) in turn after receiving respective reply.
or alternatively
a. send a frame containing message + receiver addr
b. wait for reply then send new frame to next receiver
I would say, and many will scoff and reject because it's not fancy, but some (small) relays could be used to switch in/out the 232 and 485 transceivers with. [Contacts one way and you're 232'ing, contacts the other way and you're 485'ing, and you could arrange it so things are open circuit before placing either "in use".]
Probably a little more circuitry than you're up for though.
Basically I have on a homemade board (PCB made with KICAD) 8 relays, A CAN / CAN FD module, an RS232 module, an RS485 module, a USB module, and a max17841B (SPI) module all connected to a atmega328pb.
The problem is that the USB takes the TX / RX and the can chip and the max17841b chip takes the SPI 1 and SPI 2
So I have to find out how to add the RS232 and the RS485 ... And for that I only found the SC16IS752 chip ... But I don't really like this chip because I am limited to a FIFO of 64 bytes in reception, except my data frame is based on modbus so in CAN FD it will be much larger! (header + data) ...
I'm completely stuck and I don't know how to get out of this! I search for other MCU like atmega2561 or 1284 but i don't find multiple SPI and TX on it
The only way is to connect all rs232 485 and usb on the same RX TX line on atmega328pb, with an CD74HCT125 and all enable is connected to a signal (+5V from rs232 or RS485 or USB) to activate the good line
if you looked into how to use SPI, you will notice the generally MOSI, MISO and SCK are common between the spi peripherals with their repective SS pin connected to a seperate pin on the master unit.
IMO, get yourself a MEGA or even a DUE(this is a 3.3V board!), they got 4 hardware UART ports and probably better suited for your application.
I only use one means of communication at a time so it suits me to have everything on the same tx / rx ... But I don't know how to do automatic selection
For the mega I don't see how to use multiple spi or UART... And the DUE i think it's more complicated...
EDIT : I just saw ! This is excellent, so basically that solves a lot of my problems, the SPI is common only the SS pin & INT pin changes, so in theory I can use the SPI line to program (ICSP), CAN, and my other module (I I just have to manage his SS pin well and for INT ?) ?
Then, for the TX / RX, in all cases I am blocked because on the pinouts of the card, the SPI0 is also the TX1 / RX1, so only the TX0 / RX0 are free, but as I said, that don't mind because only one way of com will work at a time, I just want to be able to select the right one ...
your proposed method is much more complicated to than u think compared to using a MEGA!
since you are communicating with your devices 'one at a time', IMO, its just a matter of selecting Serial, Serial1, Serial2..etc as and when required in your code.
your current idea does the switching via external hardware while with the mega this is just all contained within the micro controller!
in essence both will achieve the same thing except one is less complex
your methold = more hardware + more complex code
with MEGA = less hardware + simpler code
Get your fixation of using a single UART out of the way!