I will have several devices with atmel microcontrollers which I'm going to connect to PC using RS-232. Is there any way to connect several devices into one RS-232 port? (Let's assume RS-232 can handle amounts of data I need to transmit). Maybe there is some other good way for me that is not based on RS-232?
Electrical – Connect several RS-232 ports into one
atmelmicrocontrollerrs232
Related Solutions
CAN sounds the most applicable in this case. The distances inside a house can be handled by CAN at 500 kbits/s, which sounds like plenty of bandwidth for your needs. The last node can be a off the shelf USB to CAN interface. That allows software in the computer to send CAN messages and see all the messages on the bus. The rest is software if you want to present this to the outside world as a TCP server or something.
CAN is the only communications means you mentioned that is actually a bus, except for rolling your own with I/O lines. All the others are point to point, including ethernet. Ethernet can be made to logically look like a bus with switches, but individual connections are still point to point and getting the logical bus topology will be expensive. The firmware overhead on each processor is also considerably more than CAN.
The nice part about CAN is that the lowest few protocol layers are handled in the hardware. For example, multiple nodes can try to transmit at the same time, but the hardware takes care of detecting and dealing with collisions. The hardware takes care of sending and receiving whole packets, including CRC checksum generation and validation.
Your reasons for avoiding PICs don't make any sense. There are many designs for programmers out there for building your own. One is my LProg, with the schematic available from the bottom of that page. However, building your own won't be cost effective unless you value your time at pennies/hour. It's also about more than just the programmer. You'll need something that aids with debugging. The Microchip PicKit 2 or 3 are very low cost programmers and debuggers. Although I have no personal experience with them, I hear of others using them routinely.
Added:
I see some recommendations for RS-485, but that is not a good idea compared to CAN. RS-485 is a electrical-only standard. It is a differential bus, so does allow for multiple nodes and has good noise immunity. However, CAN has all that too, plus a lot more. CAN is also usually implemented as a differential bus. Some argue that RS-485 is simple to interface to electrically. This is true, but so is CAN. Either way a single chip does it. In the case of CAN, the MCP2551 is a good example.
So CAN and RS-485 have pretty much the same advantages electrically. The big advantage of CAN is above that layer. With RS-485 there is nothing above that layer. You are on your own. It is possible to design a protocol that deals with bus arbitration, packet verification, timeouts, retries, etc, but to actually get this right is a lot more tricky than most people realize.
The CAN protocol defines packets, checksums, collision handling, retries, etc. Not only is it already there and thought out and tested, but the really big advantage is that it is implemented directly in silicon on many microcontrollers. The firmware interfaces to the CAN peripheral at the level of sending and receiving packets. For sending, the hardware does the colllision detection, backoff, retry, and CRC checksum generation. For receiving, it does the packet detection, clock skew adjusting, and CRC checksum validation. Yes the CAN peripheral will take more firmware to drive than a UART such as is often used with RS-485, but it takes a lot less code overall since the silicon handles so much of the low level protocol details.
In short, RS-485 is from a bygone era and makes little sense for new systems today. The main issue seems to be people who used RS-485 in the past clinging to it and thinking CAN is "complicated" somehow. The low levels of CAN are complicated, but so is any competent RS-485 implementation. Note that several well known protocols based on RS-485 have been replaced by newer versions based on CAN. NMEA2000 is one example of such a newer CAN-based standard. There is another automotive standard J-J1708 (based on RS-485) that is pretty much obsolete now with the CAN-based OBD-II and J-1939.
Based on your intent to use AVR Studio, I will assume you are wanting to develop in a Windows environment. Most of my recommendations below are portable to unix-y systems as well.
You should do the following:
- Download / Install WinAVR
- Download Eclipse IDE for C/C++ Developers
- Follow instructions to install the AVR-Eclipse plugin.
- Make a new project targetting your desired chip and get a blinking light working. Proceed to more advanced things from there.
- You can use AVR Studio to target your chip with a hex file, or you can use avrdude to do it from the command line (the programmeres you suggested should both be viable in either case)
The concept of using a bootloader with an ATtiny is not a great idea, imho. You'll need additional support circuitry to do that (a USB to Serial converter and associated reset circuitry at least), and there is certainly some software complexity involved, as the ATtiny's don't generally have bootloader support built-in (no BOOTRST fuse for example). And you are typically already very space limited as it is.
Best Answer
Such a scheme exists but it is not RS232, it would be an RS485 system. Each device connects to a common wire pair and communication is controlled by each device having a unique address. The main PC system would send a request to an address and only one device would respond at a time. There are RS232 to RS485 converters available.
There are also RS232 multiplexers available that use address schemes, though these are often very bulky.
These days there would be more modern options, such as using addressed (wireless) WiFi modules for communication.