Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

SW UART and a nightmare problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Inventor-George

Bascom Member



Joined: 28 Mar 2006
Posts: 74

usa.gif
PostPosted: Fri May 11, 2012 2:25 am    Post subject: SW UART and a nightmare problem Reply with quote

I have two processors [on seperate boards] that need to communicate via a SW UART. I am using
Code:
Open "comd.2:1200,8,N,1" For Input As #2
for one processor, and
Code:
Open "comc.1:1200,8,N,1" For Output As #1
with the other processor [not that it matters, but one is a Tiny88, and the other M169.
Here is my problem.
On the Tiny88 side I have two power supplies - 3.3V and 5V. This is necessary. For the RS485 transmission, I am using a MAX488, which requires 5V. But the uP runs on 3.3V. I am using a MAX3375 to do the level translation between the RS485 [5V] and the Tiny88 [3.3V].
The data sheet for the MAX3375 shows a non-inverting level translation. HOWEVER, after days of pulling hair out because the thing will not work, I read the data sheet again. Buried deep in one paragraph of the data sheet it says that a high level on the Vhigh side [the RS485 side], presents as a LOW level on the Vlow side [the processor.]

Of course it can't work, I am getting inverted signals at the incoming processor!!!
1) I will be ... Maxim - they deserve it. [Kidding, but I sure would like to]
2) But for now, is there any way to invert the SW UART signals?

These boards are full made and populated and I am now three weeks late in delivering this. The consequences of my having to remake the boards are very significant.

Any thoughts wil be very gratefully appreciated!
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Fri May 11, 2012 3:20 am    Post subject: Reply with quote

hello mr. inventor,

from the BASCOM Help:
Quote:
The format for the software UART is: COMpin:speed,8,N,stopbits[,INVERTED]

Where pin is the name of the PORT-pin.

Speed must be specified and stop bits can be 1 or 2.

7 bit data or 8 bit data may be used.

For parity N, O or E can be used.



An optional parameter ,INVERTED can be specified to use inverted RS-232.

Open "COMD.1:9600,8,N,1,INVERTED" For Output As #1 , will use pin PORTD.1 for output with 9600 baud, 1 stop bit and with inverted RS-232.


I have not tried it.

Let us know if it works.

Ennio
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Fri May 11, 2012 3:30 am    Post subject: Reply with quote

Lucky for you that Mark provided the Inverted function on a SW UART. And that is probably easiest for you. But of course you can easily invert an RS485 signal in hardware too, just swap the A and B wires somewhere on the transmission link.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
W4GNS

Bascom Member



Joined: 03 Dec 2009
Posts: 11
Location: (Virginia)

usa.gif
PostPosted: Fri May 11, 2012 3:30 am    Post subject: Re: SW UART and a nightmare problem Reply with quote

Inventor-George wrote:


Any thoughts wil be very gratefully appreciated!


The optional parameter ,INVERTED did not work for you ? Bottom line see the Bascom manual and read the remarks for the open command

PS: Opps !posted at the same time as Adrian Embarassed

_________________
Bascom-AVR 2.0.7.6

Programmer USBASP (China Version)
Back to top
View user's profile
Inventor-George

Bascom Member



Joined: 28 Mar 2006
Posts: 74

usa.gif
PostPosted: Fri May 11, 2012 4:00 am    Post subject: Reply with quote

It isn't that the inverted didn't work.
Truth time:
I have used a SW UART many times in the past. I never needed to invcert the signal. So I had no reason to go to help for a function I was quite familiar with.

When I realized the problem, I poured over the device data sheets , but didn't look up help.
I am guilty of hitting the panic button before checking out all options. I considered it a one-in-a-million shot to put the problem up here.

Thank you guys!!!

AND THANK YOU MARK!!!!!!!! for thinking ahead.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Fri May 11, 2012 4:47 am    Post subject: Reply with quote

I know this is probably academic, since you already have hardware in production, and a way to solve the problem, but I wonder how you got into this situation in the first place.

The standard method of doing RS485 has a RS485 driver/receiver at each end of a transmission line. Those drivers do the level conversion between processor voltage levels and RS485 levels, and both 3 and 5 volt versions are available, depending on your processor levels. So you should not need yet another level conversion ( and its inversion !!??!! ) at either end.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Fri May 11, 2012 8:06 am    Post subject: Reply with quote

Take for example the LTC1480 as rs485 driver. It runs at 3.3V so you don't need a level convertor.
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri May 11, 2012 9:25 am    Post subject: Re: SW UART and a nightmare problem Reply with quote

Inventor-George wrote:
Buried deep in one paragraph of the data sheet it says that a high level on the Vhigh side [the RS485 side], presents as a LOW level on the Vlow side [the processor.]

I think you screwed up by wrong wiring the MAX3375, and inverting of the signal seems to be a side effect.
Looking at the data sheet of the MAX3375 this circuit is nowhere described as to invert signals, neither in words nor in the drawing, an inverter would have a dot at the output. It makes little sense to have an inverting level shifter.

Also it looks like your paragraph isn't buried anywhere, instead it's on the first page and you did misinterpret, it says:
Quote:
A low-voltage logic signal present on the VL side of the device appears as a high-voltage logic signal on the VCC side of the device, and vice-versa.

Take special note it does not say: low logic signal, it says: low-voltage logic signal, and of course that's right, that's what a level shifter does, translate a low-voltage signal (3.3V) into a high-voltage signal (5V).
Maybe you like to show how you've wired the MAX3375.
Quote:
Of course it can't work, I am getting inverted signals at the incoming processor!!!

Show Maxim how you did it, and you'll get a bonus for extending the application range Wink
Quote:
1) I will be ... Maxim - they deserve it.

Think this outcome would be like with "... the dead terrorist" Very Happy

MOD by ADMIN : yes, outcome is the same.
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Fri May 11, 2012 11:07 am    Post subject: Reply with quote

Please keep politics and religion out of this forum.
The Mod has remove one word form 1) I will be ... Maxim - they deserve it.

For us in Holland it's no problem to say or read words like that, but in other parts of the world you can have a serious problem.

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri May 11, 2012 11:30 am    Post subject: Reply with quote

Evert Smile wrote:
Please keep politics and religion out of this forum.

It's not me who started it.
Quote:
For us in Holland it's no problem to say or read words like that, but in other parts of the world you can have a serious problem.

Where, what other parts of the world ?
Name an example.

Without going too much into the politics-issue: you can keep a whole bunch of people busy to make forum-content compatible with every little piss-ant dictatorship around the world. But for what use ?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri May 11, 2012 11:37 am    Post subject: Reply with quote

ADMIN, that is Mark in this case. I do not want this forum spoiled with off topic discussions that can be held somewhere else. So i either edit or remove a topic. A joke for one, can be offensive to others. Please let this rest or write me at admin@mcselec.com
_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri May 11, 2012 1:24 pm    Post subject: Reply with quote

albertsm wrote:
ADMIN, that is Mark in this case.

Did not make the difference between mod and admin. Wink
Promise to remember it next time.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sat May 12, 2012 5:02 am    Post subject: Reply with quote

Now with my work here with MAX3232s they are inverters I had a problem with a magazine project that inverted the serial output as it fed another micro directly so when I added a MAX3232 the output was inverted so I was getting rubbish on my PC trying to look at the output then after some logic probing I saw that it was inverted thankfully the software writer sent me a hex file with it not inverted so I did not have to change the hardware.

Regards Paul
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sat May 12, 2012 5:35 am    Post subject: Reply with quote

AFAIK all RS232 type drivers invert the logic state. That is intentional, and users who try to drive or receive raw RS232 signals on processor ports should be well aware of it. IMHO its very bad practice to do this, since the RS232 spec allows for at least +/- 12 volt signals on the lines. Not many processors would like that on their port lines. Of course if you choose to do this because your device will never ever be connected to a real RS232 line, then it does not matter.

In the case of RS485 signals, as the OP was discussing, the situation is entirely different. The transmission is on nominally +5 volt signal lines, but in differential pairs, so its trivial to swap the polarity, just swap the differential pair at one end. Matching each processor supply voltage with its driver at its own end of the line is totally irrelevant to the RS485 transmission line signals.

Personally I really like RS485, its so easy to debug in the field. Just hang an IR LED across the line pair, and point it at a receiver in a laptop or PDA running a terminal program, and you can see the traffic, fully isolated from the transmission lines. If you get garbage, just reverse the LED connection ( or get the baud rate and settings right ).

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat May 12, 2012 11:11 am    Post subject: Reply with quote

AdrianJ wrote:
so its trivial to swap the polarity, just swap the differential pair at one end

Would be funny if the problem simply results out of a twisted connection cord. Very Happy
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum