espsoftwareserial
espsoftwareserial copied to clipboard
Add Open Collector Mode to TX (OneWire)
is it possible to add another config that open-drain output while sending transmit(TX) data? Your onewire implementation is amazing, i think that float driven TX output give a chance that long distance communication. Simply added a 4k7 (or convinent value) pullup resistor on the bus same as onewire driven sensors.
any idea?
Thank you Bulent
There have been different ways of driving the output signal (output; open collector; toggling input w/ pullup and open collector output) over the course of the last two years; the ways it is now seems to fit most/all users. You see to be asking from a purely theoretic point of view. For driving long distance lines, EIA232 isn't the most appropriate hw protocol selection to begin with. If you could show that, for instance, an EIA 485 line driver requires open collector output, that would a real reason to implement that. Otherwise, you might prepare a PR and we will discuss that.
Dear Kaar @dok-net Thank you for your reply,
I found that all your explanation for pin direction modes such as output; open collector; toggling input w/ pullup and open collector choices available both on ESP32 and ESP8266 Arduino core,
for ESP32 esp32-hal-gpio.h and esp32-hal-gpio.c library
//GPIO FUNCTIONS
#define INPUT 0x01
// Changed OUTPUT from 0x02 to behave the same as Arduino pinMode(pin,OUTPUT)
// where you can read the state of pin even when it is set as OUTPUT
#define OUTPUT 0x03
#define PULLUP 0x04
#define INPUT_PULLUP 0x05
#define PULLDOWN 0x08
#define INPUT_PULLDOWN 0x09
#define OPEN_DRAIN 0x10
#define OUTPUT_OPEN_DRAIN 0x12
#define ANALOG 0xC0
for ESP8266 Arduino.h and core_esp8266_wiring_digital.cpp library
//GPIO FUNCTIONS
#define INPUT 0x00
#define INPUT_PULLUP 0x02
#define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16
#define OUTPUT 0x01
#define OUTPUT_OPEN_DRAIN 0x03
#define WAKEUP_PULLUP 0x05
#define WAKEUP_PULLDOWN 0x07
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
#define FUNCTION_0 0x08
#define FUNCTION_1 0x18
#define FUNCTION_2 0x28
#define FUNCTION_3 0x38
#define FUNCTION_4 0x48
Advantage of open-collector outputs, or open-drain outputs is that the load to be switched or controlled can be connected to a voltage supply which is independant, and/or different from the supply voltage used by the controlling circuit, and that they can “sink” or “source” an externally-supplied voltage depending upon whether its to ground, or source.
Another advantage is that more than one open-collector output can be connected to a single line. If all outputs attached to the line are in the high-impedance state, the pull-up resistor will hold the wire in a high voltage (logic 1) state. If one or more device outputs are in the logic 0 (ground) state, they will sink current and pull the line voltage toward ground.
Thank you, Bulent
@bulentperktas Thanks for your write up, which may be interesting to future readers. With regard to this issue, will there be a PR forthcoming from your side, would you ask for a specific extension of the library, provided that you give assistance testing any changes with actual hardware, or are we done and this issue can be closed? Please advise. Thank you :-)
@bulentperktas Would you like to test and report back on #239 ?
@bulentperktas 1.5 months and still no word. I will close this on short notice.
@bulentperktas Another friendly, final reminder; I would like to merge my PR, but it should be tested. You suggested the change, I was hoping you could try it and give feedback. If not, I am not sure if it will make it anytime soon. Which would be a loss to you as much as anybody else. RSVP.
Fixed by #239