Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termination and bias resistors #9

Open
llamad911 opened this issue Aug 27, 2019 · 11 comments
Open

Termination and bias resistors #9

llamad911 opened this issue Aug 27, 2019 · 11 comments

Comments

@llamad911
Copy link

Hello, good job for the code!
In your code, you specify:
To prevent most noise between messages, add a 120ohm "termination" resistor in parallel to the D+ and D- lines. Also add a 680ohm "bias" resistor between the D+ line and +5V and a second 680ohm "bias" resistor between the D- line and # ground.
But the way I see the installation between the Rapbberry Pi and the TWC, we only need two wires from the RS485; the D+ and the D-.

What do I do with the RS485 5V and Ground wires ? Do I just simply cut them or they have to be connected somewhere in the TWC?
If I only keep the D+ and the D-, do I need the 120ohm "termination" resistor in parallel to the D+ and D- lines?
Thanks for your precisions.
Best regards,

@rhernaus
Copy link

rhernaus commented Sep 2, 2019

Put a 120 Ohm resistor between D+ and D-. Put a 680 Ohm (pull-up) resistor between 5v and D+. Put a 680 Ohm (pull-down) resistor between Ground and D-.
Connect D+ and D- to your TWC.

@laur3ns
Copy link

laur3ns commented Sep 2, 2019

Does it matter if you connect the resistors on the Pi end or the TWC end?

And should you first try without or always do this? I have a USB-RS485-WE-1800-BT.

@rhernaus
Copy link

rhernaus commented Sep 3, 2019

Daisy chain if you have more than two devices (eg. 2+ TWCs) and terminate at both ends of the wire.
Some RS485 adapters already have a termination resistor built in. And some even have the pull-up/down resistors built in.
Check this first before adding resistors.

I didn't add resistors at first and my RS485 adapters died after 1-3 weeks of operation.

@simotronic
Copy link

simotronic commented Sep 3, 2019 via email

@laur3ns
Copy link

laur3ns commented Sep 24, 2019

I didn't terminate mine, one Pi, two TWCs. I did however need to ground the Pi side of the USB-RS485 cable before communication was smooth on the 2nd TWC. Logical, since Pi normally has no ground connection through the power supply.

I might add resistors later. The USB-RS485 has two wires that have the 120Ohm built in that I could connect to the D+/D- for this. On the TWC I could add it ont he D+/D- out port of the last TWC (currently that connection is open).

Cable length is probably 25m (CAT6 no shield) Pi-TWC1 and another 7 (SFTP CAT6) from TWC1-TWC2.

@laur3ns
Copy link

laur3ns commented Sep 24, 2019

I didn't add resistors at first and my RS485 adapters died after 1-3 weeks of operation.

How could you kill it by not adding the 120Ohm? I mean, it would read more noise/not see a clear signal, but it's not like it would overcurrent and blow things up, or will it?

@robot256
Copy link

It's possible to damage parts with unterminated lines because reflections cause voltage spikes (overshoot). This is more likely on long wires, and also depends on how sensitive the devices are. I can't say without putting a scope at the TWC terminals whether that's happening, or how long it will be before said spikes actually cause a failure--it could be weeks, years, or it could be never if the device has robust protection diodes. I'll check mine for overshoot when I get it installed, I was testing without terminations this weekend.

@twoway
Copy link

twoway commented Nov 2, 2019

Hi
I have an brand new WC (European version) with communication problems. When TWCManager starts up connection is activated and ok for a minute or so. Then i get this:

Traceback (most recent call last):
  File "TWC/TWCManager.py", line 2857, in <module>
    if(msgLen == 0 and data[0] != 0xc0):
IndexError: index out of range

And after a while more this;:
07:38:09: WARNING: We haven't heard from slave 1839 for over 26 seconds. Stop sending them heartbeat messages.

Then 4 red blinks on WC... Then after a while (30s to a minute) comms is OK again and so it continues.
Installation:

Tested with and without 120Ohm termination i both ends (D- and D+ IN-terminals in WC). Same problem.

When charging the charging is interrupted and starts again when comms is OK and so it continues.

Any tips...

@twoway
Copy link

twoway commented Nov 2, 2019

This is debug level 11 startup until connection is lost..

TWC Manager starting as fake Master with id 7777 and sign 77
07:53:28: Send master linkready1
Tx@07:53:28: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0
Rx@07:53:28: () FD E2 18 39 52 0C 80 00 00 00 00 00 00 00 00 11 FF
07:53:28: ERROR: Ignoring message of unexpected length 17: FD E2 18 39 52 0C 80 00 00 00 00 00 00 00 00 11 FF
07:53:28: Send master linkready1
Tx@07:53:28: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0
07:53:28: Send master linkready1
Tx@07:53:28: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0
07:53:28: Send master linkready1
Tx@07:53:28: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0
07:53:28: Send master linkready1
Tx@07:53:28: C0 FC E1 77 77 77 00 00 00 00 00 00 00 00 46 C0
07:53:29: Send master linkready2
Tx@07:53:29: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0
07:53:29: Send master linkready2
Tx@07:53:29: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0
07:53:29: Send master linkready2
Tx@07:53:29: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0
07:53:29: Send master linkready2
Tx@07:53:29: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0
07:53:29: Send master linkready2
Tx@07:53:29: C0 FB E2 77 77 77 00 00 00 00 00 00 00 00 47 C0
Rx@07:53:37: () FD E2 18 39 52 0C 80 00 00 00 00 00 00 00 00 11
07:53:37: 32.00 amp slave TWC 1839 is ready to link. Sign: 52
07:53:37: Set slave TWC 1839 protocolVersion to 2, minAmpsTWCSupports to 6.
Tx@07:53:37: C0 FB E0 77 77 18 39 00 00 00 00 00 00 00 00 00 1F C0
Tx@07:53:38: C0 FB E0 77 77 18 39 00 00 00 00 00 00 00 00 00 1F C0
Tx@07:53:39: C0 FB E0 77 77 18 39 00 00 00 00 00 00 00 00 00 1F C0
Rx@07:53:39: () FD E0 18 39 77 77 00 00 00 00 00 00 00 00 00 1F
desiredAmpsOffered reduced from 6 to 6 with 1 cars charging.
Don't start charging yet because: self.lastAmpsOffered 0.0 == 0 and time - self.timeLastAmpsOfferedChanged 11 < 60
set_last_amps_offered(TWCID=18 39, desiredAmpsOffered=0.0)
07:53:39: SHB 1839: 00 00.00/00.00A 0000 0000 M: 09 00.00/00.00A 0000 0000
Ignoring byte FC between messages.
Rx@07:53:39: (FC) FD E0 18 39 77 77 00 00 00 00 00 00 00 00 00 1F
desiredAmpsOffered reduced from 6 to 6 with 1 cars charging.
Don't start charging yet because: self.lastAmpsOffered 0.0 == 0 and time - self.timeLastAmpsOfferedChanged 11 < 60
set_last_amps_offered(TWCID=18 39, desiredAmpsOffered=0.0)
07:53:39: SHB 1839: 00 00.00/00.00A 0000 0000 M: 09 00.00/00.00A 0000 0000
Ignoring byte FC between messages.
Tx@07:53:40: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:41: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:42: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:43: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Ignoring byte 00 between messages.
Ignoring byte 00 between messages.
Ignoring byte 1F between messages.
Tx@07:53:44: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:45: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:46: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:47: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:48: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Rx@07:53:49: (FC 00 00 1F) FD E0 18 39 77 77 00 00 00 00 00 00 00 00 00 1F
desiredAmpsOffered reduced from 6 to 6 with 1 cars charging.
Don't start charging yet because: self.lastAmpsOffered 0.0 == 0 and time - self.timeLastAmpsOfferedChanged 20 < 60
set_last_amps_offered(TWCID=18 39, desiredAmpsOffered=0.0)
07:53:49: SHB 1839: 00 00.00/00.00A 0000 0000 M: 09 00.00/00.00A 0000 0000
Ignoring byte FC between messages.
Tx@07:53:49: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:50: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:51: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:52: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:53: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:54: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:55: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:56: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Rx@07:53:57: (FC) FD E0 18 39 77 77 00 00 00 00 00 00 00 00 00 1F
desiredAmpsOffered reduced from 6 to 6 with 1 cars charging.
Don't start charging yet because: self.lastAmpsOffered 0.0 == 0 and time - self.timeLastAmpsOfferedChanged 28 < 60
set_last_amps_offered(TWCID=18 39, desiredAmpsOffered=0.0)
07:53:57: SHB 1839: 00 00.00/00.00A 0000 0000 M: 09 00.00/00.00A 0000 0000
Ignoring byte FC between messages.
Rx@07:53:57: (FC) FD E0 18 39 77 77 00 00 00 00 00 00 00 00 00 1F
desiredAmpsOffered reduced from 6 to 6 with 1 cars charging.
Don't start charging yet because: self.lastAmpsOffered 0.0 == 0 and time - self.timeLastAmpsOfferedChanged 28 < 60
set_last_amps_offered(TWCID=18 39, desiredAmpsOffered=0.0)
07:53:57: SHB 1839: 00 00.00/00.00A 0000 0000 M: 09 00.00/00.00A 0000 0000
Ignoring byte FC between messages.
Tx@07:53:57: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:53:58: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Ignoring byte 77 between messages.
Ignoring byte 77 between messages.
Tx@07:53:59: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Ignoring byte 1F between messages.
07:54:02: Msg timeout (FC 77 77 1F) C0 FC
Tx@07:54:02: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:03: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:04: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:05: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:06: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Ignoring byte 77 between messages.
Ignoring byte 00 between messages.
Ignoring byte 00 between messages.
Ignoring byte 00 between messages.
Traceback (most recent call last):
File "TWC/TWCManager.py", line 2857, in
if(msgLen == 0 and data[0] != 0xc0):
IndexError: index out of range
Tx@07:54:11: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:12: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:13: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:14: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:15: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:16: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:17: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
07:54:20: Msg timeout (77 00 00 00) C0
Tx@07:54:20: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:21: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
Tx@07:54:22: C0 FB E0 77 77 18 39 09 00 00 00 00 00 00 00 00 28 C0
07:54:24: Msg timeout () C0 FD E0
07:54:24: WARNING: We haven't heard from slave 1839 for over 26 seconds. Stop sending them heartbeat messages.

@laur3ns
Copy link

laur3ns commented Nov 2, 2019 via email

@twoway
Copy link

twoway commented Nov 4, 2019

Problem solved.
After investigation, I had another parallel application communicating on the same USB->485 device.
After shutting that app down everything seems to work out fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants