Assembled board with routing error, RS485 A/B swapped - Page 1
Forum section: electronics / projects

author: invzim
author_rank: Contributor
timestamp: September 09, 2012, 09:23:40 am
content: I guess everyone does thisonce.I've had a 100 of these made, but unfortunately I made a mistake swapping two signals, as the SOIC-8 Eagle part in schematics was numbered 1,2,3,4,5,7,6,8 which I didn't catch before I got the boards back. This is the A/B rs485 lines.After facepalming for an hour, I googled this and it seems swapping A/B is a pretty common error, with a possible software fix. RS485 is differential, so in theory just flipping the bits with an xor should do the trick.This is how it looks:Working board:Board with A/B swapped:It indeed looks promising, but flipping the data didn't fix the leading edge, which was still in the wrong direction messing everyting up:Bummer..So my list of options is down to:Cut the traces and solder on kynarDitch the boards, facepalm and pay up for new onesOR, get new boards assembled but without the MCU and manually move these overI'm crossing my fingers option 3 is cheapish, they should be able to use the same stencil and the MCU is by far the most expensive component.What do you guys think, am I too fuzzed about the cutting traces and doing wire rework?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 09, 2012, 09:38:15 am
content: What baudrate are you using ? If not too high you could use a soft UART so you can invert in software.A few UARTS have polarity control, but I don't think PIC18 is one of them.

author: invzim
author_rank: Contributor
timestamp: September 09, 2012, 09:46:27 am
content: I was actually not connecting the startbit with the waveform, or thinking about it at all - maybe this is fixable after allThe baud is 115200 (and has to be) - I haven't done bit banging like this before, but will get on the startbit polarity asap.thanks!

author: invzim
author_rank: Contributor
timestamp: September 09, 2012, 10:55:58 am
content: Quote from: mikeselectricstuff on September 09, 2012, 09:38:15 amThe 18f is INDEED one of them.Code:REGISTER 20-3: BAUDCON: BAUD RATE CONTROL REGISTERbit 5 RXDTP: Received Data Polarity Select bitAsynchronous mode:1 = RX data is inverted0 = RX data received is not invertedbit 4 TXCKP: Clock and Data Polarity Select bitAsynchronous mode:1 = TX data is inverted0 = TX data is not invertedEven had the registers defined in the C18 header files making this a 2 minute fix, what a relief!!BAUDCONbits.RXDTP = POLARITY;BAUDCONbits.TXCKP = POLARITY;If you like beer, PM me your address and I will see to it that some is delivered to you!

author: David_AVD
author_rank: Super Contributor
timestamp: September 09, 2012, 11:41:05 am
content: Ah, don't we all like a good result!

author: Short Circuit
author_rank: Frequent Contributor
timestamp: September 09, 2012, 12:53:46 pm
content: Lucky man! Not often that you can cancel a hardware error this easily.

author: AndyC_772
author_rank: Super Contributor
timestamp: September 09, 2012, 01:09:37 pm
content: I've done it too, and on a commercial product - but fortunately the UART was implemented in an FPGA, so the fix was just as trivial.The moral of the story is: not every device / vendor has the same relationship between A, B, +ve and -ve. Just because 'A' is the +ve half of the pair on one chip doesn't mean it'll be the same on some other chip.