I have a really niche device called a "BIU" I'd like to communicate with using my Arduino Mega, but I want to get a second opinion before attempt anything as I cannot get another BIU if I was to damage it. Fortunately, the device was made according to a thoroughly written standards document, and from it I can get a understanding of what signals it expects in great detail beforehand. I will quote sections of this standard below just in case I'm misunderstanding, in addition to linking to the entire document.
This BIU is designed to communicate synchronously on a full-duplex RS485 multi-drop bus. In order to achieve synchronous RS485, the device has two sets of transmitters and receivers, the first (Tx Data +/- and Rx Data +/-) is for the actual data and the second set (Tx Clock +/- and Rx Clock +/-) is entirely dedicated to carrying the clock signal of the sending or receiving device.
The standards document then describes characteristics of how data should be transmitted (Page "3-5"):
- Data shall be transmitted by the sending station on the Tx Data + and Tx Data - lines. The receiving station shall consider the data to be a binary 1 when the voltage potential of the Tx Data + line is more positive than the voltage potential of the Tx Data - line. The receiving station shall consider the data to be a binary 0 when the voltage potential of the Tx Data + line is more negative than the voltage potential of the Tx Data - line.
- A clocking signal shall be transmitted by the sending station on the Tx Clock + and Tx Clock - lines. The receiving station shall read the data on the Tx Data + and Tx Data - lines when the voltage potential of the Tx Clock + line makes a positive going transition with respect to the Tx Clock - line, as shown [below].
- The data transfer rate shall be 153,600 bits per second, plus or minus 1 percent. The width of the bit cell on the Data links shall be the reciprocal of the data transfer rate.
- The clocking signal from the sending station shall be a square wave with a frequency of 153,600 hertz, plus or minus 1 percent, and shall be synchronous with the data on the Data links. The clocking signal shall make its positive going transition at the midpoint of the bit cell, plus or minus 10 percent of the bit cell width, as measured at the sending station.
The standards document also defines the protocol and frame format to be sent over the RS485 bus, but I don't think there is a need to describe that here. To summarize, it's SDLC.
I took a brief look at the circuitry on the BIU and the first thing the serial connections go into is a SN75ALS1178 chip (datasheet), if that helps.
My Proposed Solution & Questions
I've ordered a bunch of generic MAX485 breakout boards which consist of the MAX485 chip (datasheet) with only basic passive support components, including a 120ohm resistor across A and B. Here is a link to the MAX485 breakout board modules I ordered and a copy of it's schematic image is below.
From my understanding, RS485 cares only about the comparison of the non-inverting and inverting lines, and the datasheet of the BIU's SN75ALS1178 chip specifies a receiver input voltage range of +/-12v max, so it seems like using a +/-5v differential signal would work just fine, right?
My idea is to connect up four of these modules to the Arduino Mega, two for receiving and two for sending, but here I encounter the second possible issue:
Would it be feasible to generate the required 153,600Hz clock signal in order to send data? If so, what would be the best method to generate such a signal while being able to toggle it in code when not sending? I've tried for days now to configure one of the timers on the Arduino Mega to get as close to that bit rate as possible, but the closest I've gotten is a super inconsistent frequency outputting to a fixed pin, and I don't know of a way to "pause" it when not transmitting as the specifics of AVR timer configuration is still highly confusing to me. As a last resort, I do have a 555 timer on hand, perhaps that could function external clock reference.
Either way, if you have any alternative ideas of how to communicate with such a peculiar device, it'd be much appreciated, as it seems the only option I'm left with is building a entirely custom circuit from scratch or buying some expensive pre-made transceiver. I've looked into alternatively using a Raspberry Pi, but it's not looking great there as well. I hope I'm just overthinking this and there is a simpler solution...
The full standards document (It's lengthy!)