Avr Serial Port Code Example 12f675 Pinout
I'm trying to communicate with 32 microcontrollers (PIC 12f675). These are used to control 32 DC motors and 2 sensor for each PIC. So only two pins are left to communicate with master device.
I want to send signals (how much rounds to rotate and direction) to these 32 slave PICs in one master device. PIC 12F675 hasn't I2C or SPI hardware. So I want to communicate with some bitbang technique. (PIC 12F675 running at 4 MHz internal clock) What is the best way to do that?
Now open the BASCOM-AVR Terminal and set your connection settings by clicking “Terminal” -> “Settings” Select your computers COM port and select baud 19200, Parity none, Data bits 8, Stop bits 1, Handshake none, emulation none. If you see the Hello World displayed in the BASCOM-AVR Terminal emulator window, your configuration is OK.
(I prefer to use C language (xc8)). If wiring permits, the simplest approach is to have one wire which is an output from the master to all slaves, and the other of which is a return wire shared by all slaves to the master, and give each slave a separate 'hard-coded' address which is also hard-coded into the master.
Using such an approach and having each slave communicate only when spoken to will eliminate the need for arbitration. If you have any sort of periodic interrupt in the master and slave, I'd suggest using normal UART-style communication with the additional proviso that the traansmit line will be idle for at least 12 bit times before any command, but all the bytes of each command will be sent consecutively with at least 1.1 but no more than 5 stop bits between them. Then any slave that decides a command isn't of interest to it can ignore everything that happens unless or until it sees the line idle for at least 10 bit times. The data return wire could be implemented using an open-collector/open-drain approach (use a pull-up resistor, and have slaves pull down the wire when they want to send a '0' and leave it floating when they don't), but that would be slow and sensitive to noise. Speed and noise immunity could be improved by not using open--collector/open-drain approach, but instead having nodes include a circuit like the following on their output wires: – Schematic created using If the PIC drives the output high, the bus will be driven high, and likewise if the PIC drives the output low. If the PIC leaves the output floating without any internal pull-ups enabled, which it should do whenever it has nothing to say, other devices on the bus will be able to pull it high or low without impediment.
As you mention Rx and Tx you want to have bi-directional communication. I would go for the old-fashion UART protocol. No need for a clock thus your code can then concentrate on one pin at a time. There are lots of UART bit-bang example codes out there.
Post edit: For the return channel (Tx on the slaves) you have to make sure that the salves don't interfere with each other. First makes sure only one slave is transmitting at a time.
The simplest method is that slaves only respond after they receiver a 'read' command from the master. All the slaves that do not transmit have their output tri-stated (See comment from @supercat above) Then it is good to have a pull-up resistor on the line so it is in a defined state if none of the slaves is active (All are tri-stated) I have implemented a single UART return protocol just like that on a commercial product. Download michael crichton ebook collection torrent files website. If you do it right it works. The difference is that in my case the output of a slave was set to 0 and I would control the tri-state pin to simulate an open-collector output. That way there is no short circuit if I accidentally make en error in the program. Recently there was a question about tri-state and open collector equivalence on stack exchange but I can't find it anymore.
In my own clumsy way, I quote here from the Serial section of the Language reference. 'The Arduino Due has three additional 3.3V TTL serial ports: Serial1 on pins 19 (RX) and 18 (TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. Additionally, there is a native USB-serial port on the SAM3X chip, SerialUSB'. ' This is all of interest to me but useless if I don't know how to program the several ports. There is no hint that I could see on the associated functions/methods appropriate to these Due ports. There should be some kind of hyperlink here.
I also get the feeling that some of these ports have different names in other places. Are pins 0 and 1 really connected to two different ports? Where is more documentation of the debug port? Is this the Serial Monitor? How is the word SerialUSB related to the native port?
Is it a software keyword? From browsing documentation for other boards I gather that, for example, Serial1.begin() would activate pins 18 and 19. Is that correct? Thank you for any information. Hi grimdon, I think all answers are in these 3 links: But I'm right with you, it's difficult to understand, it's complex schemas.