Author Topic: Which way for a remote control panel connection?  (Read 2701 times)

0 Members and 1 Guest are viewing this topic.

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Which way for a remote control panel connection?
« on: April 21, 2017, 02:41:27 pm »
 Panel will be comprised of 2 pushbuttons and 3 LEDs.

Option 1: Pushbuttons active low (on main board these go to inputs on a micro with pullups), LEDs are active high, so total wires to link the boards would be 6 - a common, one for each pushbutton, and 3 for each LED. Can use RJ12 plugs and jacks.

Option 2: Pushbuttons active low, LEDs active low. This requires 7 wires, a common, a +5, the 2 buttons, and 3 LEDs. Can use RJ45 plugs and jacks.


My main concern is potential interference - the environment will be somewhat noisy (model railroad with DCC). With RJ45's I can use common ethernet UTP cable. 3 pair twisted cable is available for RJ12 (ok, RJ11 6p6c) but not common and seems to be expensive. I also suppose I can use the RJ45 connectors for the design that used only 6 wires. There's nothing complex enough that I need to worry about PCB space between the two different jack sizes, and cost may actually be LOWER with the RJ45.

I may have answered my own question. At least, as far as what physical connectors and cabling to use. I guess the real question is, what is best design practices. Since it's merely a difference in software to light the LEDs by setting the output pin low or high, which way is preferred?

 

Offline Gregg

  • Super Contributor
  • ***
  • Posts: 1128
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #1 on: April 21, 2017, 08:45:53 pm »
I did something similar a long time ago by using opto isolators in a separate plastic box powered separately; I used a wall wart to totally isolate my makeshift remote from the control cabinet I was attaching it to. 
It was for temporary control of one panel while setting up another control panel across a mechanical room with lots of motors and overall an electrically and acoustically noisy environment.  I also chose RJ45 plugs and jacks: reliable, cheap, easy and readily available.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Which way for a remote control panel connection?
« Reply #2 on: April 21, 2017, 08:57:58 pm »
Use two twisted pairs for the buttons,  with each button across a pair, not to panel ground to minimise EMI pickup. Use the remaining two pairs as the three LED wires and their return.  In the event of the cable being damaged its better not to have 5V running down it, so I'd make the LEDs active high and the buttons active low.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1275
  • Country: gb
    • bitdynamics
Re: Which way for a remote control panel connection?
« Reply #3 on: April 22, 2017, 12:27:51 pm »
Go RS485, and leave yourself effectively infinite expansion for future flexibility!

Less time wiring everything up as a result too.


Given the tiny cost of modern small micro-controllers and RS485 transceivers that's what i'd do......
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16276
  • Country: za
Re: Which way for a remote control panel connection?
« Reply #4 on: April 22, 2017, 08:34:24 pm »
However you go, use shielded cables and connectors, the shield is effectively free, and should not be used as part of the circuit, but only used to connect the metal parts of the box to ground, and connected only at the controller end to any grounding point. as well if putting a power rail down there use some ferrite beads as power rail filters, some series resistance in the signal lines, and some VDR units as clamps on the data lines. Power line a polyfuse as well, or some other circuit protection to limit current. for low speed data lines ( if you are using switch closures only) some ceramic capacitors to limit noise injection ( value not too critical, use any capacitor in chip ceramic from 100n to 10uF to reduce noise and sharp edges) in them, and some 10-22uF ceramics on the power side, preferably at both ends of the cable if there are any electronics in the remote end.
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #5 on: April 22, 2017, 09:55:27 pm »
 That makes a lot of sense. Just the thing I was missing - make each button its own twisted pair rather than have a common. Thanks.
(and of course I meant to quote Ian M, not just reply - could SWEAR I clicked quote, but obviously not.)
« Last Edit: April 22, 2017, 10:15:06 pm by rrinker »
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #6 on: April 22, 2017, 10:13:52 pm »
Go RS485, and leave yourself effectively infinite expansion for future flexibility!

Less time wiring everything up as a result too.


Given the tiny cost of modern small micro-controllers and RS485 transceivers that's what i'd do......

 That seems to be a bit of overkill for a simple control panel. The devices behind it actually all interconnect via RS485, and then to a computer for centralized control.
 Distances between the device and control panel will be generally be less than 1 meter. The majority under half a meter.

 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #7 on: April 23, 2017, 05:46:49 pm »
 Just when you think you have it all down...
So if each pushbutton gets its own twisted pair (very sensible suggestion to reduce noise pickup_, that leaves 4 wires in an Ethernet cable, 2 more pairs. There are 3 LEDs so this seems pretty straightforward - well, there aren't enough pins on the micro to give each of the pair of LEDs (2 of the 3) its own dedicated pin, so I am going to have to hook them up in series with a single pin driving them (operationally one is always on and the other off anyway)


So this means I need to get +5 and GND to the control panel anyway, plus signal for the paired LEDs and signal for the one individual LED. 4 wires. Should the +5 and GND be paired and the two signals paired on the other pair, or split it? It seems to make the most sense to pair the power. Or maybe no real big deal because this wiring will be perpendicular to any other power carrying wires that could induce interference on the signal lines AND be relatively short (as mentioned, worse case MIGHT be a meter of cable between the panel and the circuit, the majority less than 1/2 that).

 What sort of things should I be looking at to figure this stuff out for myself? This is what I get for never actually working as an EE, so I have zero design experience, but I know enough theory that I know I need to think about things like this and not just throw wires all over the place and hope it works reliably. This is not any sort of life safety requirement, it's only for model trains, but I do want the action assigned to the button to actually happen when I press the button, not have to jam the button 10x before something finally works. Maybe I'm overthinking it? But I'd much rather someone point me at the place to take measurements and what sort of things I should be looking for rather than just a "here, do this". I could just build someone else's circuit if I just wanted to be told how to do it. I'm having fun planning this out and having my memory of things I've learned tweaked.



 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16276
  • Country: za
Re: Which way for a remote control panel connection?
« Reply #8 on: April 23, 2017, 06:26:04 pm »
How about connecting the LED's in inverse parallel, and have them on a single pair of wires. Then at the MCU end you just drive them via a protection resistor ( 22R to 100R) and the other lead is connected to the junction of 2 470R resistors, connected in series from 5V to Gnd. That way you can set the MCU pin high to light onr, or low to light the other, and if you toggle fast enough both light.  One MCU pin to drive 2 leds, and if you want them off set as an input with no pull up, and they will be both off.

Each MCU pin you use will do 2 leds, and you can choose to only have 3 there, or option the 4th if needed using the same code on each pin.
« Last Edit: April 23, 2017, 06:28:01 pm by SeanB »
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #9 on: April 23, 2017, 07:07:08 pm »
 Doh, see I knew there had to be an alternate way to do effectively the same thing. That keeps all the resistors off the control panel - just 2 buttons, 3 LEDs, and the RJ45 jack. And no power pair to the control panel, either.

 Also I could make the third LED another pair and toggle, although at this point I see no need. How it is intended to function is, if the local control is enabled, the third LED will be either on or off (lit to indicate lock, pushbuttons inactive, or lit to indicate unlocked, pushbuttons active, I haven't decided yet). Pushbuttons will select turnout position, either normal or reverse. The paired LEDs light to indicate which way the turnout is lined - thus one is always on and never do both need to be lit). I COULD instead use 4 LEDs, with both pairs wired as you describe, so I have a green for unlock and a red for lock or something. This is more a question for my model railroad message board. Too much information is confusing. I want it to be fairly obvious with a glance that yes, pushing the buttons will do something, or no, the buttons are locked out and only the dispatcher can remotely control the position.



 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Which way for a remote control panel connection?
« Reply #10 on: April 23, 2017, 07:22:37 pm »
SeanB's suggestion wastes power and never lets you have more than 2.5V to the LEDs.  The real cure is to use an ATtiny with more pins as with only two for the LEds you are very limited.  The easiest fix without swapping MCUs would be to use an inverter to drive the extra LED - if you don't mind SMD, theres lots of makes of single gate, 5V VCC,logic inverter out there in SOT-23 size packages.
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #11 on: April 23, 2017, 11:57:27 pm »
 The circuit I posted is not mine, it was the first example I could find of how I WAS wiring 2 LEDs to the same micro pin. The main circuit actually uses an Arduino Nano and I am literally out of pins, and the next largest option is supreme overkill, plus won't easily plug on to a PCB, that going to a Mega.
 I was initially operating under the mistaken impression that extra two analog ports available on the Nano could be used as digital pins just like A0-A5. Considering the Arduino site itself claims 22 digital pins for the Nano. But the devil is in the details, on the ATMegas328P/U those two lines do not go to standard ports, they are direct feeds to the A/D converter. So, really 20 digital pins, and I don't want to connect anything to the serial pins if I don't have to, so I don't have to disconnect things to reprogram the controller.
 What I have as far as pin usage:
   2 pins for 2 servros. 4 pins for 4 pushbuttons, one pair per servo. 4 pins for relays, 2 per servo - one relay disconnects power while the servo moves, the second relay activates to change the power feed polarity, and then the first relay drops to establish he power connection, to prevent a short if the linkage between the servo and track switch is not perfect, 2 inputs from the master controller, active low with pullups, one per servo, 2 additional inputs from the master controller, active low with pullup, to lock out use of the pushbuttons, 2 outputs, one per servo, to drive the indicator LEDs, and 2 outputs, one per servo, to indicate whent he remove lock is enabled.
 If you lost count that's 18 pins. Exactly how many I have available if I leave the serial pins 0 and 1 unconnected. I am open to suggestions, but I'd rather not add multiplexors that will complicate the code. An inverter on the LED line would be fine, but then I'm back to either getting +5 and GND to the control panel to locate the inverter there, or needing more wires to the panel that I have available. The problem with trying to multiplex the LED drives is there is a good bit of unknown timing in the code, as it will be writing the servo position to EEPROM using an incrementing counter and a pointer to spread the writes across the whole memory range for maximum endurance, plus timing can change based on the lockout status. I suppose I COULD use the two extra analog lines as inputs, and just compare a threshold, if below a certain level then the line is being pulled low by the master controller, if above a certain value it is either high or open circuited and being pulled up by an external resistor.

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Which way for a remote control panel connection?
« Reply #12 on: April 24, 2017, 12:11:46 am »
I'd probably put the buttons on the extra analog inputs - you don't need to read them terribly fast, and if you have a timer interrupt driven debounce routine, it can alternate between the two channels, grabbing the high bit of the result and discarding the rest, swapping channel and triggering the next conversion so your code can get on with other stuff while the ADC is converting.  Its only a few extra lines of code,  The well defined threshold will play well with the external RC filtering you should be using anyway on longish wires to remote buttons, and if you really need to add hysteresis, you could, by using offset thresholds depending on the previous state instead of simply taking the high bit.   Compared to kludging in extra hardware to decode the LED outputs or multiplexing them its a no-brainer.
« Last Edit: April 24, 2017, 01:04:37 am by Ian.M »
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #13 on: April 24, 2017, 12:53:54 am »
 The reason I mentioned using the analog lines to read the remote lock signal is that I am already using Bouncer2 to read the buttons on digital lines which gives a very good debounce and also gives me the hysteresis I wand so you have to decidedly push but button not just accidently lightly bump it. I suppose I could switch all 4 buttons to analog - even use just 2 or maybe even 1 analog pin to read all 4 although I would need to account for the fact that someone could push button A from the first set and simultaneously press buttin B from the second set.
 

Offline rrinkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2046
  • Country: us
Re: Which way for a remote control panel connection?
« Reply #14 on: April 24, 2017, 03:37:05 pm »
 I may have a solution. After some discussion with other model railroad people, it is probably overkill for me to even have that 'locked' indicator on the individual servo controller. An input to disable the local buttons, yes, but since there will usually be multiple turnouts locked and unlocked as a group, there's no point in having all those individual indicators. That frees 2 pins on the Nano AND eliminates the extra wire going to the control panel. Thus each panel will have 2 buttons, 2 LEDs. 4 pairs, no worries about using ethernet cable as the interconnect. each element can have its own twisted pair.

 I also may to actually need 2 relays per servo - the idea was to first cut power, then move the servo, then switch polarity via relay 2, then reapply power. However, it would be extremely rare that I would use an sort of track arrangement here I would need to guard against the points making contact before the frog polarity changed, or vice-versa. That simplifies the design down to 2 relays per board instead of 4, and frees up 2 more pins - now I am only using 16 out of the 18 available while switching the position LEDs back to individual pins instead of any form of multiplexing.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf