Inverted serial signaling with SerialPIO? #1443
-
Hi, I see that the SoftwareSerial wrapper around SerialPIO does not support the inverted-signaling feature of SoftwareSerial. Is there some other way to do inverted signaling with SerialPIO? I just need to do this on the transmit side. It looks like the high-idle signal happens in pio_uart.pio? So maybe that would have to be inverted in that file? There must be some way to write a PIO program to do this, some mirror-world version of pio_uart.pio ... but it's daunting. Or is there some higher-level switch to invert all the signals from a PIO instance, or all the signals on a GPIO? (Why? I'm trying to pass MIDI signals through two audio outputs that have DC-blocking capacitors on them. Because of the MIDI TRS wiring standard, the MIDI signal goes between two output pins rather than between one pin and ground. Without the DC blocking in place, I can use SerialPIO + Arduino MIDI on the tip pin, set the ring pin high, and it works. But the DC blocking cap on the ring pin prevents that pin from supplying a constant +v. If the ring pin was instead sending the exact inverse signal of the tip pin, then I think the current would be AC-enough to pass the blocking cap.) Thanks for any advice! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
Looking at the datasheet, there doesn't seem to be an That said, if you just need to invert output then I think it's almost trivial. Not tested, but you'd invert the data bits before writing to the FIFO here: arduino-pico/cores/rp2040/SerialPIO.cpp Line 367 in 6e52b72 becomes
And then in the PIO program you'd need to set the idle bit to low: arduino-pico/cores/rp2040/pio_uart.pio Line 32 in 6e52b72 becomes
You'd need to |
Beta Was this translation helpful? Give feedback.
-
It's a current loop, driving an LED inside the opto-isolator of the receiving device. One pin, on the transmit / output side is meant to be connected to +5V DC, via a 220R resistor (that pin drives the anode of the LED), the other side should be connected to your output pin via another 220R resistor, but yes, it's active low (that output pin drives the cathode of the LED), so it would be nice to have an inverted output, to save having the open collector inverting buffer, or transistor, that it should have. Since we're just driving an LED, using 3V logic signals with a 3.3V supply instead of 5V is fine, though really the resistor values should be adjusted to keep the LED current in a 5-10mA range. I can see how it can still work with a capacitor on the output, but do you have to have one on both pins? It would simplify it if you could have the anode side pin of the MIDI socket connected directly to 3.3V via a resistor, staying closer to the MIDI spec. Inverting the data may work but the idle state of the UART (PIO) should be inverted too. Since there's a DC blocking capacitor, you might get away with not inverting it but it seems like it could add more problems, especially with seeing the first bit of the transmission... You might have to add some dummy start bits to the data, to get around that. FWIW, a ULN2003A makes a good inverting open collector buffer in chip form, but you get seven of them in one chip. You could use the rest to drive brighter LEDs via resistors, or just ignore them. An NPN transistor with two resistors works too - one to limit the base current, and one to limit the collector current. MIDI will still work without using an open collector output, but that was the intention. |
Beta Was this translation helpful? Give feedback.
Looking at the datasheet, there doesn't seem to be an
invert this pin
bit, so I do believe for inverted output you'd need to hack SerialPIO.That said, if you just need to invert output then I think it's almost trivial. Not tested, but you'd invert the data bits before writing to the FIFO here:
arduino-pico/cores/rp2040/SerialPIO.cpp
Line 367 in 6e52b72
becomes
And then in the PIO program you'd need to set the idle bit to low:
arduino-pico/cores/rp2040/pio_uart.pio
Line 32 in 6e52b72
becomes
You'd n…