Uart to RS-232 convension - serial-port

I am working on a project and I use several PIC18F26K83's for this project. For communication between PIC's I use UART. Now I also need to send data with RS232 to the user. As I have understood the main difference between UART and RS-232 is voltage levels. And with PIC I cannot supply proper voltage level that is required for RS232. Because of that UART to RS232 converter's look like a must. (i.e. MAX232) I have two questions.
1) Using UART to RS232 chips is the only option in this case? Are there any alternative ways?
2) I am planning to send UART data directly to the Uart to RS232 converter chip. I do not know how they work, codewise do I need to change anything? Can I directly put UART tx data to the receive pin of these chips? Thanks beforehand.

Using UART to RS232 chips is the only option in this case? Are there
any alternative ways?
For converting from UART to RS-232, using RS-232 level-converter IC like MAX232 is the most economical, reliable and convenient approach. You can build the respective RS-232 line drivers and line receivers using discrete parts but that's not recommended for above mentioned reasons (economical, reliable and convenience).
I am planning to send UART data directly to the Uart to RS232
converter chip. I do not know how they work, codewise do I need to
change anything?
Coding wise nothing will change. Just verify taht the baud rate of your UART is supported by RS-232. Most MAX232 will operates up to 120 kbit/s and MAX3232 operates up to 250 kbit/s.
For typical connection where baud rate is generally 9600 either of IC will suffice.
Can I directly put UART tx data to the receive pin of these chips?
Your UART TX needs to connect to Logic Data Input pin of MAX232 (T1IN (Pin Number - 11) or T2IN (Pin Number - 10)).
Your UART RX needs to connect to Logic Data Output pin of MAX232 (R1OUT (Pin Number - 12) or R2OUT (Pin Number - 9)).
If you connect you UART TX to T1IN (Pin Number - 11) then you will get your RS-232 TX signal on T1OUT (Pin Number - 14) else if you connect you UART TX to T2IN (Pin Number - 10) then you will get your RS-232 TX signal on T2OUT (Pin Number - 7).
Similarly,
If you connect you UART RX to R1OUT (Pin Number - 12) then you have incoming RS-232 data/signal line should be connected to R1IN (Pin Number - 13) RS232 line data input(from remote RS232 system) or if you connect you UART RX to R2OUT (Pin Number - 9) then you have incoming RS-232 data/signal line should be connected to R2IN (Pin Number - 8) RS232 line data input(from remote RS232 system).

Related

HC-05 Module sending data problem (Mater + Slave)

I've been working with a Siemens PLC to send data using RS232. The communication itself is working perfectly, I can monitor it if I connect the PLC to my PC (via a serial comm port).
Now, I wanted to make this communication wireless. I found out about the HC-05 modules and decided to get a few. I set 2 of them up with my arduino (one as master, one as slave, both paired and using the UART 9600,1,0 which is the same that my PLC uses).
I made the following connections:
PC Connection (with a serial comm adapter)
PLC Connection
Let's say I want to send this string:
<SoH>1RZ<CR>
If I check my serial monitor, I get weird stuff. Like:
##NULL©#NUL
The weird thing is that if I just remove the bluetooth modules and connect the PLC's Rx and Tx to the PC's Tx and Rx, respectively, the data is sent flawlessly. So I know that I have everything sorted out on the PLC/PC side.
Has anyone been through this, or does anyone have a suggestion that I can try?
RS232 typically uses ±12V. Negative voltages between -3V and -15V is logic high and positive voltages +3V till +15V is logic low.
Your bluetooth module on the other hand uses TTL logic. With a voltage range of 0-5V.
0-0.8V is low, 2-5V is high.
So
a) you cannot create the necessary voltage levels
b) you risk to destroy your 5V hardware by connecting it to ±12V.
c) you might run into problems as RS232 also has optional mechanisms for flow control. So Rx and Tx might not be enough.
You'll at least need a TTL-> RS232 level shifter for the PLC side and a USB to TTL serial adapter for the PC

I2C on ESP32 or Arduino: what's the max number of slaves using the BMP388 sensor

BMP388: what is the maximum of slave addresses in I2C mode
In I2C mode with one master how many BMP388 as slave can be connect to an Arduino UNO?
From the datasheet I understand that there are only 2 adresses possible in I2C mode (0x76 or 0x77) as designated by bit 7 in the device address and configured via the SDO (pin 5) port to ground or plus.
In SPI mode, as I hope to understand well from the datasheet, it's up to 128 BMP388 addresses.
My questions are:
-Am I understanding well that in I2C mode the maximum number of slaves is two?
-Of course I can connect a lot of BMP388's in series to the Arduino, but how can I address them in I2C mode. Or should I use SPI mode?
-Is there any documentation, except the datasheet, that makes this more clear?
-Is there any example Arduino code for the I2C situation?
You understood the i2c addressing correctly. There can only be 2 addresses for
BMP388 controlled by SDO pin in i2c mode.
If you want to use more than 2 BMP388 units with a single microcontroller, go with SPI. You can use as many BMP388 units as you have GPIO pins on microcontroller to control Slave Select pin.
This is the example from Adafruit BMPxxx library.
Here is permalink to the line where you can pass Slave Select (CS) pin of each unit to each unique object.
Later in the code you can use each object of the Adafruit BMPxxx library to get the readings.

How to send from ESP32 to Arduino?

I am using ESP32 to read a temperature sensor and I wont to send this reading to Arduino to act according to different reading
what should be the connection between the ESP32 and Aruido?
Should is not the appropriate word, I would suggest to use the UART (Serial.print() and Serial.read()).
Because the ESP has an operating voltage of 3.3V and Arduino 5V, you must use a level shifter.

UART Transmit Rs232 to USB

I have A UART transmitter written in VHDL and want to transmit data from FPGA Rs232 to a PC that only has a USB.
My question is, is it fundamentally a correct assumption that USB can receive serial data? I'm basically treating the USB as an Rs232 receiver.
If this is correct, what program can allow me to monitor the USB incoming data?
Thanks in advance
USB port includes 1 differential data line + 2 power line, that makes 4 cable(I mean version <= usb2.0).
RS232 is full duplex data transmission protocol which you can't do it with USB2.0(USB3.0 is full-duplex). And it has additional control lines. It doesn't include power line. It has variable voltage levels(up to +-25V).
Simply, yes you need a converter.
USB
RS232

How do I wire a 9 pin serial connection to an Arduino?

My question is pretty straightforward. I've got a big old machine that has an RS-485 connection on the back and I've got a converter from RS-485 to 9 pin serial.
The device I'm connecting to sends out an ACK signal to see if anything is connected. How do I wire up my Arduino (Uno) to the 9 pin serial connector so that I can read the ACK (and in future write back) and display the ACK signal in the Serial Monitor?
I would first check the voltage of the data lines coming from the RS-485 converter. The arduino ports are expecting 0 to 5 volts. Also, look-up the standard for RS-485 to determine what should be on the lines from the RS-485.
Notice, the arduino does NOT directly implement an RS-232 port. Rather, it has a USB port for connecting to a PC. I know that the RS-232 connection does NOT use TTL or 0 to 5V signals, and would question what signal levels are produced by an RS-485.
If the RS-485 does NOT generate 0 to 5 volts, then you will need to get an arduino RS-485 shield.
Finally, in fact, this is what you need to do. I just searched on "RS-485 Arduino" and found multiple hits.
Now, this is the good news, because once you have installed a RS-485 shield then you connect the shield to pins 1&2 on the Arduino and you have a serial connection!!
In most cases you need to wire only RX, TX and Ground signals (RX of Arduino to TX of RS-232 and vice versa). But it really depends on your RS-485 converter, if you need any additional lines. If this converter is half-duplex, may be you will also need to control it with DTR signal. You can use any digital IO on UNO then, and control it in software. Also you need to know the speed of serial port of this old machine, and configure UNO serial port accordingly.

Resources