I have some random stuff connected to an arduino nano, which is connected to an endstop connector on a RAMPS (equivalent). There are three lines from the RAMPS, - +5, ground and "signal" which I believe is +5 that should either be connected to ground or not, sometimes through a simple mechanical switch. There must be current limiting, because the normal thing is that there are unpowered endstops that are simple switches that connect signal to ground or not. Under the RAMPS is an arduino, but I do not think that this is a matter of hooking one Arduino to another - because the RAMPS expects to communicate with powered and unpowered endstops.
I want to make my Arduino Nano look like an endstop to the RAMPS board. I want to be able to change one of my digital pins and make the RAMPS see "low" or "high". As far as I can tell, "low" is "open" and "high" is shorted, or equivalent.
I had decided that the best simulation of a simple switch that I could do with an Arduino Nano was to use a digital output pin in output mode - at "HIGH" it should stop the passing of current because there would be +5V vs. +5V. At "LOW" it should sink enough current to pull the line down. But I was wrong. High didn't stop current from passing. No matter whether my output was "low" or "high" it always seemed as shorted to the RAMPS.
I would expect that in low state, it would sink the 5 volts from the other end. In fact, I see that in low state, I am getting about 0.359 volts (pin to ground) (I presume my meter is not that accurate) and in high state I get a short excursion to 3.5 volts before it settles down to about 1.6 volts.
I became very confused.
Disconnecting the signal line changes the input to "low". But then I noticed that adding a 750k resistor made the input "low" and the junction point always read 5 volts.
So I finally decided that what was happening was that I had too much loss through the Arduino's digital output at all times - it seemed to be shorted "enough" to the other end to be a closed switch. Maybe the impedance was higher than I thought on output.
So I thought, "Maybe there should be some more impedance in the circuit." I found (amazingly) my resistor decade box. I tried various values and finally determined that 3k of resistance worked - that is, when the Arduino is "low" it sinks enough that the thing at the other end registers high, and when it is high, it fails to sink enough current that the sensor reads low.
Is this the right way to do this? If I send this to someone else, are they likely to need a pot (hooked up as a resistor) to adjust this to their system, or is it likely to work in many places if I pick a good central value on my system?
Is there some other way I should do this? I am trying to be cheap - my goal is to hold total parts cost under $12 and I think I am up around $10. But reliability and portability are the most important things.
Sorry about the wall of words, but I wanted to be sure my explanation was complete.