CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pseudo 485 using two pins

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
burnsy



Joined: 18 Oct 2003
Posts: 35
Location: Brisbane, Australia

View user's profile Send private message Send e-mail Visit poster's website

pseudo 485 using two pins
PostPosted: Sat Apr 03, 2004 6:10 am     Reply with quote

I'd like to do connect a few pics (about 5 or so) over a few hundred meters of cable and have them communicate using around 2400baud. No uarts, just bit banging.. but with a sturdy protocol (acking, crc's, etc).

I have most of that under control, but.... I want to do it without using a 485 chip to lower the cost of the device. And I know they don't cost much but it would be nice if the device gets past concept and into production..

Has anyone got any ideas on using two pins to send a 'pseudo' 485 signal (when one is high, the other is low, and visa versa)? Would this work effectively against noise like REAL 485?

To transmit a byte I would transmit on one pin in typical serial fashion. On the other pin I would transmit the complement.

To receive, I thought about monitoring one pin with an 'ext int' to detect a start bit, and with each bit received, compare it to the 'other' pin, expecting the opposite level?


Any thought would be welcome...


Any
_________________
This is the last code change until its ready....
Ttelmah
Guest







Re: pseudo 485 using two pins
PostPosted: Sat Apr 03, 2004 2:55 pm     Reply with quote

burnsy wrote:
I'd like to do connect a few pics (about 5 or so) over a few hundred meters of cable and have them communicate using around 2400baud. No uarts, just bit banging.. but with a sturdy protocol (acking, crc's, etc).

I have most of that under control, but.... I want to do it without using a 485 chip to lower the cost of the device. And I know they don't cost much but it would be nice if the device gets past concept and into production..

Has anyone got any ideas on using two pins to send a 'pseudo' 485 signal (when one is high, the other is low, and visa versa)? Would this work effectively against noise like REAL 485?

To transmit a byte I would transmit on one pin in typical serial fashion. On the other pin I would transmit the complement.

To receive, I thought about monitoring one pin with an 'ext int' to detect a start bit, and with each bit received, compare it to the 'other' pin, expecting the opposite level?


Any thought would be welcome...


Any

Send the data using real RS485 transcievers instead.
You can send differential serial TTL data using two pins, but the edges will not be synchronised, and you would need to simulate differential reception as well.
RS485, is not only 'differential', but also has to implement hysteresis in the receiver, and the signal pair requires termination (if you are using twisted pair cable, you will need this as well to prevent echo in the lines, and unless you use twisted pair, you lose most of the advantages...). A transceiver chip is so cheap (the Texas 8pin transceivers are less than a dollar), and in themselves also provide another level of protection for the processor against ESD.
Don't waste the amount of processor time involved, use the proper chips.

Best Wishes
burnsy



Joined: 18 Oct 2003
Posts: 35
Location: Brisbane, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Apr 03, 2004 6:01 pm     Reply with quote

Yes I agree, so far I have always used the proper chips (over the last 15 years) and had no problems, at least none that couldn't be solved with a few late nights and a few cups of coffee.

Some people I know wanted me to improve on an existing product. It multidrops several Atmel micros over two wires with no 485 chip. If I want to build this for them, it will have to be competitive in price and thats why I wanted to shave off a dollar if possible. Other wise they will take it to china to build it.

I might fire it up the competition unit and see what protocol it uses, and post info about it. It may be useful to some of you out there.

thanks for your reply
_________________
This is the last code change until its ready....
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Sat Apr 03, 2004 6:23 pm     Reply with quote

What you get in a 485 driver chip amounts to a push pull circuit that applies 0 or 5 volts to each of the pins while they are output. Thats just the transmit part of the circuit and you should plan to source/sink ~50mA on each pin. The recieve side can be a simple op amp circuit that places a small load resistor on the bus. It's dificult to do all this for under a dollar. It also takes more board space and that means more board cost. I don't think you can beat using a driver chip on purly cost issues. If you do i would like to hear about it. Maybe you could use something thats not differential, that will cost less.
burnsy



Joined: 18 Oct 2003
Posts: 35
Location: Brisbane, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Apr 03, 2004 10:18 pm     Reply with quote

Yeah, once again I agree. Just one 485 chip and maybe a terminating resistor is not a lot. This 'other' device I have has 2 1n4148s on each of the two wires (tied to gnd and vcc) plus some other device (looks like an inductor) in series with the line in/out. There's a lot of inserting components in that, and as you say, board space and probably cost.

I have several designs working well with just a 485 chip and no problems, so I may stick with the proven technology. All the same this other company have what appears to be a successfull product. I'd like to work out how they do it. I'll keep you posted...
_________________
This is the last code change until its ready....
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Sun Apr 04, 2004 1:07 am     Reply with quote

burnsy wrote:
Yeah, once again I agree. Just one 485 chip and maybe a terminating resistor is not a lot. This 'other' device I have has 2 1n4148s on each of the two wires (tied to gnd and vcc) plus some other device (looks like an inductor) in series with the line in/out. There's a lot of inserting components in that, and as you say, board space and probably cost.

I have several designs working well with just a 485 chip and no problems, so I may stick with the proven technology. All the same this other company have what appears to be a successfull product. I'd like to work out how they do it. I'll keep you posted...


The company I work for sells an RS232 to RS485 converter that is not based on a driver chip and it works very well. We scraped it and went to a design with a driver chip to save cost. Even with all the protection circuits it cut the board space in half. I highly recomend using transient protection if any of the bus is in a location where the static charge of a near lighting strike could get on the bus. I have heard of our competition having to replace every device on a network. I have seen on occation a board of ours that was returned for service that had burns on the transient circuit from a near lighting strike. I have never heard of more than one node knocked off a bus. The thing about a lighting strike is that it can create voltage from one ground point to another ground point. That is difficult to plan for. Lighting is just hard to get away from.


This has some ideas I wanted to note for later use. I have not actually used all of it but it might help you with your design.
http://home.houston.rr.com/neutone/Assorted%20circuits.pdf
ritchie



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

PostPosted: Sun Apr 04, 2004 4:12 am     Reply with quote

Hi,

I've us RS485 in my project with no problems... I use a transceiver from Sipex with a built-in transceint voltage suppressor in less than a dollar and it reduce my PCB of the same size of a credit card..

This already included protection circuits and optical isolation.
burnsy



Joined: 18 Oct 2003
Posts: 35
Location: Brisbane, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Apr 04, 2004 8:39 pm     Reply with quote

I use some Sipex 232 chips. I'll contact my local distributor and see which 485 version they carry. Hopefully the one with built in protection...

One further thought I had would be to use the onboard comparator of the 16f627 to take care of the comms. That would provide me with a differential input, an interrupt for the detection of a start bit and 20ma drive capability when sending data, and a balanced line as I'm manually sending bits (along with the compliments on the other pin). Correct me if i'm wrong..

I'm not sure if I want to use it now in my original project where the distances are up to 100metres, but I have another use as a bus in a ticket machine and free up the uarts for driving peripherals such as note and coin acceptors / printers ets..

This idea of course would limit me to those micros that have a comparator onboard, and I can't say I have used any other that the 16f627/628/648..

food for thought..
_________________
This is the last code change until its ready....


Last edited by burnsy on Mon Apr 05, 2004 7:51 am; edited 1 time in total
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Apr 05, 2004 7:38 am     Reply with quote

The real value of RS485 is in the differential receiver. That is where the noise rejection comes from. If you can bit bang the transmitter and use a cheap op amp for a receiver you may have something.
On the other hand you may be able to use something simpler if your noise environment is not bad. I had an application where a cheap coax cable ran 300 meters across a dock and under a ship, crossing AC power mains, telephone lines, welding lines, and who knows what else. I communicated bi-directionally between two PICs at 1200 baud with nothing but a series terminating resistor, series blocking cap (in case we hit a nick in one of those AC power mains!) and a pull down resistor. There were occasional errors but the checksum caught them.
Try something cheap and simple and see if it works well enough!
_________________
The search for better is endless. Instead simply find very good and get the job done.
AllanL5



Joined: 05 Apr 2004
Posts: 6

View user's profile Send private message

PostPosted: Mon Apr 05, 2004 8:02 am     Reply with quote

At first glance, this looks like a bad idea. You will be tying the world interface directly to your chip -- with problems of transients, static discharge, antenna effects, etc. It looks like 'false economy' -- saving $1 now, but making a solution which is much less reliable.

BUT, if you're going to do it, things you need to do:

1. RS485 is a 'multi-drop' network -- so you have to allow for 2 drivers on the line at a time. 485 itself is 'protected' so two drivers don't burn each other out. Typically this is implemented as open-collector driving -- ie using the TRIS register to put a 0 on the line, or let it float. I don't know if you'll get the speed you want that way -- you probably should drive both low and high, and put a 220 ohm series resistor in the line to protect the drivers.

2. You'll want to 'clip' any negative signal -- thus the use of the 1n4148 diodes.

3. Maintain a 'standard' RS485 implementation. This addresses termination resistors at the ends of the 'bus', a pull-up resistor on the 'A' line and pull-down on the 'B' line to insure a default 'zero', etc.

4. Having said all that, with the current drive output of the PIC, this actually looks feasable. I'm still not sure it's a good idea, but it does look feasable.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group