Hondo's Cabin
http://www.hondosackett.com/yabb/YaBB.pl The Cabin >> Raspberry and Other Pies >> Raspberry Pi and the Serial Port http://www.hondosackett.com/yabb/YaBB.pl?num=1496118771 Message started by Fernando on May 30th, 2017, 12:32am |
Title: Raspberry Pi and the Serial Port Post by Fernando on May 30th, 2017, 12:32am I was looking over the pcDuino Nano4 forum when I ran into a webpage on the forum about the serial I/O Port on the GPIO on the pcDuino. One of my biggest problems is wanting to use the serial port on the R-Pi and use it to talk to a network of Arduinoes over the serial port. I’ve done this with 8bit hardware in reverse - connecting a bunch of Atari 800’s together to talk to a single printer. Likewise I did the same with Macs to talk to a single printer later on but Macs have AppleTalk Network so it was simple to set up. In having a bunch of Arduinoes talking to a single computer (an R-Pi) through the serial port, one can save space and wiring and not need to use the USB or Ethernet Port and special adapters for using it. It also saves on coding as drivers are not needed to be added to the Raspberry Pi and the Arduino. But the problem is how to access the Serial Port on the Raspberry Pi. The same is true with the Arduino but there are many examples using the serial port on the Arduino; and in some cases, the Arduinio has 2, 3, 4, as many as 8 serial ports! Writing a program that uses the serial port on the Arduino is easier than on the Raspberry Pi. In such a network - one Raspberry Pi can blindly throw text (of commands) out the serial port where the Arduinoes are listening to the serial port. Code:
Each Arduino is looking for a string which calls it and then its command and ending tag: Coded String: [Arduino X] [command] [end] (Where X is a number) All the Aduinoes will receive the code but the Arduino with the correct ID Tag will act on it, and then send back text saying the command was received and then the code executed as per its program, returning a “Done” string. In this, one can have parallel processes going on as one Arduino does one thing while another Arduino does another. You can have one Arduino with a sensor network to check out its environment while another Arduino runs the motors to make it move. The Raspberry Pi Computer can decide what to do based on what the sensors are picking up and what the motors are doing. In this an Arduino can send an “All Stop” command request if it senses something it should not be nearby, which the Raspberry Pi receives and then sends an “All Stop” command to the motors on Arduino controlling the motors. Though the Serial Port is not the fastest of options, it is one that is the least hackable. USB, Ethernet, Bluetooth, and Wifi can be hacked into, as these ports are accessible from the outside. The Serial Port is internal, making it harder to get into. All this requires a lot of programming, especially depending on what the program will be for each of the Arduinos. But the sending and the receiving the command requests now becomes the easy part. Of course, in Linux and UNIX, the serial port is used as a diagnostic port to see what is going on with the system. Systems like the Beagle Bone Black, Orange Pi, Nano Pi and Banana Pi has a separate Serial Port to “talk” to the unit if there is no monitor or console on it, as they have 2 or more serial ports on their boards. The Raspberry Pi only has 1 serial port on the GPIO. And until now, it has been difficult to get access too. This requires a lot of reading, so here are some links I found. Links: eLinux’s R-Pi Technical Information Page on the Serial Port (shows R-Pi Model B but includes information for all R-Pies): http://elinux.org/RPi_Serial_Connection Indestructable’s Webpage on how to access the Serial Port (Need to get some sort of 3.5v to 5v TTL converter): http://www.instructables.com/id/Read-and-write-from-serial-port-with-Raspberry-Pi/ David Hunt’s webpage (shows what to get, not to build it, shows a Model B but good for all R-Pi’s): http://www.davidhunt.ie/add-a-9-pin-serial-port-to-your-raspberry-pi-in-10-minutes/ R-Pi’s Web Forum (not much information there...): https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=41055 R-Pi Exchange Tech Page (lots of good info there, though it is for the R-Pi 3, it should be good for all of them): https://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3 AB Electronics UK (sells adapters and shows code to turn it on, setting up the serial port on the R-Pi and then talk to its board. For the board is R-Pi 3 and R-Pi 0 but the code works for all the others.): https://www.abelectronics.co.uk/kb/article/1035/raspberry-pi-3-serial-port-usage HobbyTronics (how to set up the serial port and explains why it is there, good for all R-Pies): http://www.hobbytronics.co.uk/raspberry-pi-serial-port |
Title: Re: Raspberry Pi and the Serial Port Post by Hondo I. Sackett on May 30th, 2017, 8:14pm Cool! Great info again! Thanks |
Hondo's Cabin » Powered by YaBB 2.1! YaBB © 2000-2005. All Rights Reserved. |