View previous topic :: View next topic |
Author |
Message |
edbfmi1
Joined: 18 Jul 2006 Posts: 103
|
SPI to RS485 Converter |
Posted: Wed Aug 31, 2016 1:04 pm |
|
|
Hello all,
I am in the final stages of a design for a customer and at the last minute they threw me a curve. (Like I should be surprised!)
Anyway I was told that in the future they would like to have the current system control a heater and monitor the temperature at a location that is about 10 feet (3 Meters) away.
The current design uses a PIC16F76. I am using SPI to communicate with a display driver and local temperature interface. I only have a couple I/O pins left so I was wanting to utilize the SPI ports and talk to an RS485 transceiver. I can add another PIC at the remote location with another RS485 transceiver to communicate with the original system.
Does anybody know of an SPI to RS485 transceiver? Or does anyone have another idea.
Thanks for any suggestions. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Aug 31, 2016 1:15 pm |
|
|
OK, while the picture is a bit 'fuzzy'... if you have 2 pins, just use RS-232. It will easily communicate 10'/3m. Now IF you already had RS485, then it's simple to add another device. Kinda what RS485 was designed for.
Creating an SPI<>RS485 link seems 'complicated' to me, overkill and this from a guy that uses 46k22s for simple tasks!
Maybe Google will finds an SPI<>RS485 device, I haven't looked..but if you have those 2 extra pins, I'd go RS232....or RS422.
Jay |
|
|
edbfmi1
Joined: 18 Jul 2006 Posts: 103
|
|
Posted: Wed Aug 31, 2016 1:41 pm |
|
|
Oops, I fat fingered the Key. I only have 1 pin left not 2. I did Google and found an IC by MAXIM, the MAX3140, that looks like it would do the job but it is very pricey. This application is for the Agricultural Industry and they are VERY price conscious. I was just hoping someone had a more "Cost Effective" solution. I really don't want to change the PIC because I already have all the development hardware for the PIC16F76. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Aug 31, 2016 2:29 pm |
|
|
At the end of the day, it depends on how fast you actually need the link to be. You can send and receive data on the same pin, if you (as a 'master'), 'poll' data from the other end. So (for instance), you could use a cheap transceiver, and a monostable multivibrator, to turn it to 'transmit', when you send data. Have it sit in receive mode when you are not sending. Then your device can just send data out when it wants, to the unit it has to control, and then send a 'give me your data' command to the other device, which replies along the same link. Since you only have to receive after having sent, software serial will work fine.
For the short distance you are talking about, you can use a single wire link, rather than RS485. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Aug 31, 2016 2:43 pm |
|
|
hmm. 1 pin is still easy...
In the CCS FAQ section of the manual they show one way to do 2 way communications between PICs, it should easily handle 10 feet !
Now if you need to go 10 miles, or more, I've done that for almost 3 decades, on a true single wire system.
Jay |
|
|
edbfmi1
Joined: 18 Jul 2006 Posts: 103
|
|
Posted: Wed Aug 31, 2016 2:47 pm |
|
|
Awesome!!
I will use the single wire communication idea!
Thanks for the quick responses. As always you guys ROCK!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Aug 31, 2016 3:05 pm |
|
|
see...
What is an easy way for two or more PICs to communicate?
In the Q&A section of the manual. It refers to TWO example programs as
well !!
I did use it 20 years ago, no reason why it won't still work !
Jay |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Wed Aug 31, 2016 3:49 pm |
|
|
The PIC16F76 is a very old part. If the project is cost sensative PIC18F26k22 is about 1/2 the cost and has tons more memory and peripherals. If you need to stay in the PIC16F family there are even less expensive parts available like the PIC16F886. |
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Wed Aug 31, 2016 11:53 pm |
|
|
check out the NXP range of I2C / SPI Slave to UART / IrDA / GPIO Bridges
SC16IS752 is a dual serial port, but there is a single one |
|
|
|