I have an Arduino Nano hooked up to a FCR684205T TOSLINK transmitter and FCR684205R TOSLINK receiver, which are connected together with a 10m long TOSLINK cable.
A simple SoftwareSerial example code is running on the Nano:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Native USB only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
These are the waveforms on the pins 2 and 3 of the Nano when I just press the "Send" button on the serial monitor, without typing anything (yellow is TX, going into a MOSFET, which ties the TOSLINK transmitter's Vin to ground, blue is the TOSLINK receiver's output):
Everytime I send something I get three '␦' characters, then as much '␦' characters as long the string I sent is.
I heard that these TOSLINK components works over 100kHz, but if I have such a nice signal at 9600bps then why can't I read the characters I just sent? I tried higher baudrates with the same results...
Ah, sorry, I should have payed more attention. As far as I know, software serial cannot transmit and receive at the same time. You cannot use the hardware serial on Uno because it is also connected to the usb-serial adaptor chip and you can't connect to outputs together without risk of damage.
A better idea would be an Arduino with extra hardware serial ports, such as Mega, Leonardo or Pro Micro.
Thank you! I tried sending from a FT232 module to a Mega and replaced the MOSFET with a level shifter IC. Under 57600 bps now works! I'm surprised because I thought they only work over 100kHz.
I want to increase the speed to at least 500000 bps, but the pulses already gets shorter/longer at the receiver around 57600 bps, so I rarely read the same character I sent.
This issue is no longer related to Arduino I think, but I would be really thankful for any tips to improve the communication speed!
SmileXS4:
I tried sending from a FT232 module to a Mega and replaced the MOSFET with a level shifter IC. Under 57600 bps now works! I'm surprised because I thought they only work over 100kHz.
You didn't post a schematic, so we can't give any feedback on your MOSFET circuit or this mystery "level shifter IC". What was it you thought only worked over 100KHz?
SmileXS4:
the pulses already gets shorter/longer at the receiver around 57600 bps
Randomly? What gets longer and what gets shorter?
SmileXS4:
I would be really thankful for any tips to improve the communication speed!
Well, it looks like these TOSLINK components are really designed for over 100kHz! I don't know why they worked at 9600 bps with the 74HC14 IC, however they work now without it even at 2M bps!