RS485 on Veroboard anyone? 20/12/08
A little progress on the bench earlier on today, and I'm feeling very happy. Nothing like the smell of solder on a rainy evening to make you feel like, well, you're sniffing solder fumes.
This is my un-sophisticated RS485 network. The bottom bit of veroboard is the RS232-RS485 converter, and the top one is a PIC16F628 which blinks it's LED when it gets a clean character received from the serial.
I'm using Maxim MAX485 driver IC's at 19.2kbps which in theory should give me up to 1,200m cable length, or about 12,000 times longer than the cable I'm using here. Hmmm.
As a total asside, i was going to use some PIC16F88's I've had lying around for ages. However my picstart plus programmer needs an upgrade to the 'PMU' module to allow a firmware upgrade to support the 16F88's.
So I've ordered a PMU, and some 16F688's which are a dandy little 14pin device with UART and a 8Mhz internal oscilator. Sounds like the perfect device for a very small RS485 connected RTU to me!
I wrote a very quick'n'dirty test program in C under Linux to send some characters out, and very quickly discovered problem #1. The Linux ioctl commands appear not to check the output FIFO on the PC's uart correctly, so that when you send a character out and then query the ioctl function to see if the serial port is finished send it, it lies.
This is a bit of a problem as I'm using the RTS line on the serial port to control the output enable on the MAX485 drivers. If I reset RTS imediately after the ioctl status request indicates that the FIFO is empty I get garbage data at the PIC end of the RS485 link. Some experimentation will be needed to see where the real problem lies, and I may have to put some gaurdtime functionality into the code at both ends.
It'll be interesting to see if I have the same problem on Windows, as I intend to create some example software for Windows as well as the linux PLC. My target platform is Linux, but if anyone decides to follow in my footsteps it's likely that they will be using Windows, statistically speaking, so it would be handy to have at least some low level routines proven for Windows.