Hello guys, I'm trying to collect temperature reading from a Pyrometer connected via RS232 to RS485 converter which in turn connected to MAX485 (This method is used to increase the number of the sensors in future). This MAX485 module is connected to MEGA. I have the sample code but I'm getting junk output. Thank you.
It appears you are missing a lot of hardware. Post an annotated schematic showing exactly how YOU have wired this. Show all connections, power, ground, power sources etc. Post links to the technical information on the hardware items.
A brief read of that user manual suggests that the sensor (or one specific variant of the sensor) outputs TTL serial data - they call it serial digital - see page 10. Page 11 has note #3 which says:
inverted RS232, TTL, 9,6 kBaud
If that is correct, and it looks like it is based on other images in the document that show a USB (serial?) adapter with bare wires, then you will need a TTL-RS232 adapter board as well.
That will convert your TTL serial data into RS232 voltage levels which you can then connect to your RS232-RS485 adapter.
Going back to my previous question:
What product are you going to use for this conversion?
As I previously mentioned, does that RS232-RS485 converter understand the concept of some form of addressing so that individual converters respond to unique addresses.
I suspect the converter may simply convert between RS232 and RS485 signals. In which case how will you configure your setup so that only 1 sensor responds when you have several connected to the RS485 bus?
The user manual suggested that it is TTL serial - see my post #7. That's why they mention a USB adapter that would take TTL serial and convert to a USB serial port so your PC can communicate with it.
If it is TTL serial, then you should be able to connect the sensor Tx and Rx wires directly to your Mega on, say, Serial1 and communicate with it.
No, it's not correct since your sensor doesn't support the Modbus protocol.
It looks like you send a single byte to the sensor and it responds with 1 or 2 bytes depending on the command byte sent.
Looking at your overall goal of having several of these sensors in the future, it might be worth considering using some Arduino Pro Minis - 1 per sensor.
A possible scenario: your Mega serial port #1 would connect to one of the standard RS485 modules. That module would then connect to standard RS485 module connected to the hardware serial port of a Pro Mini. Your Pro Mini would then have use a software serial port implementation to connect direct to one sensor. Each sensor would need its own Pro Mini and RS485 module.
You could then query each sensor individually using any protocol you like, even Modbus. But, as what you are trying to do is so simple, you could simply send out an address byte from the Mega and each Pro Mini would check if that was its address and if its a match, simply respond with the latest temperature reading.
That's where the manufacturer wants to sell you a USB-Serial adapter.
In theory, you don't need that as your Mega could do the same job with a very simple sketch that simply copied any data received over its USB-Serial port to its Serial1 and similarly any data received on Serial1 is copied over to the USB-Serial port. Your PC would then interact with the sensor as if it were directly connected to the PC.
Thank you for this information. So if I want to collect data from one sensor, I can directly connect it to the Rx and Tx of MEGA. I'll work on this on Monday. Do you have any suggestion for a piece of code or any references from this forum?
Could you also please explain a little bit more command signal and how to access the data for one sensor at the moment?
If the datasheet is correct in that the serial is TTL, then you can connect to either Serial1, Serial2 or Serial3 on your MEGA2560. I'm assuming that as you only refer to your board as "MEGA" that you have an Arduino MEGA2560 board with 4 serial ports?
If you were to connect to Serial1 (pins TX1 and RX1) and configure Serial1 for 9600 baud, the a simple piece of code like this should suffice:
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
char c;
if (Serial.available()) {
c = Serial.read();
Serial1.print(c);
}
if (Serial1.available()) {
c = Serial1.read();
Serial.print(c);
}
}
Are you referring to how you would go about addressing a single device on an RS485 bus?
Have a read of:
It's worth reading from the start to get an idea of what RS485 is. The sections that Nick titles Master and Slave show an example sketch of the master addressing a slave device and the slave device checking the address in the message.
Sorry for the miscommunication, it was a question that "Will TTL to RS232 conver ter works?". Currently I have a sensor->RS232 to RS485 converter->MAX485->Arduino MEGA.