Author Topic: configure jumpers at a distance?!  (Read 672 times)

0 Members and 1 Guest are viewing this topic.

Offline k8943Topic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: be
configure jumpers at a distance?!
« on: May 16, 2021, 10:22:29 am »
Consider a network  (CAN)  of devices connected in  a  star formation from a main board, with multiple devices on  each  arm of the star. Currently each  device is “told” which  arm it is  on using on-board  jumpers or switches. Everything is cabled up  using 4-core wire to RJ12 (6 pins) board connectors .

Like the idea of being able to configure boards at a distance such  that a device could be swapped from one arm to another - or a new device brought in -  and it would automatically “know” which  arm  it was on and adopt the appropriate behaviours. How about if use 6-core cables in  the RJ12  connectors? In addition  to GND, +24v, CAN_H, CAN_L there will be CONFIG1, CONFIG2.  On  each arm of the  star, CONFIG1 could carry a different voltage (set by  resistor bridges adjacent to connectors on the main board). 6 arms could be  represented  as 0, 1, 2, 3, 4, 5v respectively. Any given device would use it’s microcontroller ADC  to read the voltage  on  CONFIG1,  (comparing with it’s internal voltage reference) and then the  device  would self-configure accordingly. In  order to ensure that there is never a voltage present on the ADC before the microcontroller has  powered up, presumably the config-input should  be separated with a MOSFET that turns on only after  the device has powered up.

QUESTION: is this going to work reliably? Will voltages transmit  reliably over the network and, if so, what level of  granularity (6 levels over 5v, or more, or less)  would be reasonable? Will there be some kind of EMF interference (a device turning on nearby) such that desirable to take  average over time? Or is there just a much better way of doing  this? All feedback appreciated!
« Last Edit: May 16, 2021, 11:53:20 am by k8943 »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8089
  • Country: fi
Re: configure jumpers at a distance?!
« Reply #1 on: May 16, 2021, 11:24:48 am »
Of course this works, a cheap microcontroller ADC has typically some 8 to 11 bits of linear ENOB and the internal reference is typically specified something like +/- 2% or better. For the divider, 1% resistors are cheap and easily available.

From this, we can see you can easily fit like 4-5 bits of information in the analog level, and afford some illegal dead zones between each two adjacent levels, allowing rudimentary error checking. So I wouldn't hesitate doing this up to some 16 addresses.

Being DC, assuming you can allow longish (milliseconds) time for address enumeration step, noise and EMI is non-concern. Just put a 1uF ceramic right between the ADC input and ground, and use some hundreds to thousands of ohms of series resistance and call it a day. Let the signal level stabilize after you are sure whatever is powering the resistor divider, then wait for like 10*R*C before sampling.

Large enough series resistance also limits the current going through the clamp diodes of the ADC input pin to avoid damaging (or inadvertent parasitic power-up of) the MCU rendering extra isolation switch you are discussing unnecessary. Because you only need one sample, even a large resistance (as long as it is orders of magnitude below DC leakages, i.e., don't go over hundreds kOhm) is not a problem for the ADC which can sample from the added capacitor directly.

However, usually this isn't done for the purpose you are discussing. Whenever you have a communication bus - CAN in this case - available, there almost always is some clever way to communicate address enumeration through that bus before starting actual communication, saving extra hardware or wiring. Think about it.
« Last Edit: May 16, 2021, 11:30:19 am by Siwastaja »
 
The following users thanked this post: k8943

Offline k8943Topic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: be
Re: configure jumpers at a distance?!
« Reply #2 on: May 16, 2021, 12:11:55 pm »
Many  thanks.

How to do purely over  the network? Hmm,  if there was some kind of switch at the CAN_H (for example) of each RJ12 on the  main board, could disable  all but one of the  arms of  the  star, then send a message of  the form "if you are receiving this then  you're on arm number 3". Then  proceed to  the  next RJ12/arm  of star.  Each device would require nothing  in hardware and could stick with 4-core wiring. All  components would be on the main board. Would need a way to launch the procedure in  the case a  device is added to or moved on the network (or just restart).
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8951
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: configure jumpers at a distance?!
« Reply #3 on: May 16, 2021, 01:05:59 pm »
Use a voltage divider so the config pins would be set by resistors to 24V.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3669
  • Country: us
Re: configure jumpers at a distance?!
« Reply #4 on: May 16, 2021, 05:00:25 pm »
Lots of ways to skin this cat.

A 4..20 mA current loop would be more noise resistant, but more expensive and power hungry and probably not needed here.

If you have a spare dedicated wire for this, you could also use digital communication over that wire.  Of course then the question is why use a shared bus for the primary communication?

You can also use the aux wire as an address override.  Drive the auxillary wire high to enable programming the address.

If you have control over the cable you could build the jumpers / voltage divider at the remote end of the cable or inside the connector body.  That would avoid long wires, emi, ground shift and loops.

If the microcontroller has a unique ID built in (many do) you should be able to define an in band enumeration protocol to find new devices and assign them a bus local address.

If the root node can be a little more complex give it the ability to switch on and off each spoke.  Then at startup enable each spoke one at a time to program it's address with a broadcast address before enabling the whole bus.
 
The following users thanked this post: k8943

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: configure jumpers at a distance?!
« Reply #5 on: May 16, 2021, 06:00:17 pm »
You can use resistors to ground and a current source referenced to the MCU's internal analog reference with a single CONFIG pin. This means you can cancel the ADC reference out and rely only on the resistor's accuracy and the ADC's ENOB. Building this current reference would require one op amp voltage buffer, one reference resistor and two current mirror matched pair transistors.

On the other hand, you can use a digital protocol. All satellite nodes DHCP, then there would be a message for the satellite nodes to control one of the CONFIG pins for the central node to sense.
 
The following users thanked this post: k8943

Offline k8943Topic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: be
Re: configure jumpers at a distance?!
« Reply #6 on: May 16, 2021, 08:31:55 pm »
Lot's of  possibilities, indeed. This is exciting. Thanks!

Whilst you were replying I was trying to find a way of toggling on/off branches of a CAN network. Still stuck on that.  Probably never done.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf