Xathrya Sabertooth |
Posted: 11 Apr 2014 12:13 AM PDT In this article, I use:
What is WiringPi?WiringPi is a GPIO access library written in C for BCM2835 used in Raspberry Pi. It is designed to be familiar to people who have used the Arduino “wiring” system. Raspberry Pi has a 26-pin General Purpose Input/Output (GPIO) connector and this carries a set of signals and buses. There are 8 general purpose digital I/O pins – these can be programmed as either digital outputs or inputs. Besides input/output capability, one of these pins can be designated for PWM output too. Additionally there is a 2-wire I2C interface and a 4-wire SPI interface (with a 2nd select line, making it 5 pins in total) and the serial UART with a further 2 pins. The Revision2 Raspberry Pi has an additional 4 GPIO lines on a separate connector which you have to solder on the board. The I2C, SPI and UART interfaces can also be used as general purpose I/O pins when not being used in their bus modes, giving a grand total of 8 + 2 + 5 + 2 = 17 I/O pins on the P1 connector (plus 4 more on the P5 connector on a Revision 2 Pi). WiringPi includes a command-line utility gpio which can be used to program and setup the GPIO pins. You can use this to read and write the pins and even use it to control them from shell scripts. WiringPi is extendable and modules are provided to extend wiringPi to use analog interface devices on the Gertboard, and to use the popular MCP23x17/MCP23x08 (I2C 7 SPI) GPIO expansion chips, as well as module that will allow blocks of up to 4 74×595 shift registers to be daisy-chained together for an additional 32-bits worth of output as a single unit. (You can have several blocks of 4 74x595s if needed) One of the extension modules allows you to use an ATmega (e.g. Arduino, or the Gertboard) as more GPIO expansion too – via the Pi's serial port. Additionally, you can easily write your own expansion modules to integrate your own peripheral devices with wiringPi as required. WiringPi supports analog reading and writing, and while there is no native analog hardware on a Pi by default, modules are provided to support the Gertboards analog chips and other A/D and D/A devices can be implemented relatively easily. WiringPi InstallationBefore you can use WiringPi, of course you have to install it inside your Raspberry Pi. The installation is fairly simple. There are two way to get WiringPi installed to Pi: clone from git, download the source tar ball. Before we go, it is recommended to check whether our distribution is up to date or not. sudo apt-get update sudo apt-get upgrade Remember, this is optional. Plan AInstalling using git, involving clone the source code tree from git repository. Make sure you have GIT installed. If you do not have one, you can install it by: sudo apt-get install git-core Then, clone the WiringPi source code tree by: git clone git://git.drogon.net/wiringPi To build WiringPi, do this command: cd wiringPi git pull origin ./build The second command will fetch an updated version of WiringPi source code (if any) and the third script will start building the library. The script will compile and install the library automatically. Remember to use root privilege to do this. Plan BIf you can’t or don’t want to use git, use following step for manual download and installation: Click on following URL: https://git.drogon.net/?p=wiringPi;a=summary Look for the link marked as “snapshot”. Click on the top one which is the latest source code. You will download a tar.gz file with a name like “wiringPi-f18c8f7.tar.gz”. Note that the numbers and letter after “wiringPi” (f18c8f7 in this case) might be different. They are unique identifier for each release. Extract and then build the package: tar xfz wiringPi-f18c8f7.tar.gz cd wiringPi-f18c8f7 ./build Testing WiringPiAfter success installation, we should check our WiringPi. WiringPi has a utility called “gpio” which is used for GPIO access. Here how we check: gpio -v gpio readall Pin NumberingPin numbering of the BCM2835 GPIO port(s) on the Raspberry Pi has been a source of great confusion since the designs for the Pi were first published. In the early days (even beofre hardware was avalable) the default usable GPIO pins were simply referred to by number as GPIO0 through GPIO7. Additionally there were pins for other purposes, SPI, I2C and serial. This was highlighted on the original image on the Raspberry Pi Wiki site too. Reference: Raspberry Pi GPIO Reference wiringPi supports its own pin numbering scheme as well as the BCM_GPIO pin numbering scheme, and as of Version 2, it also supports the physical hardware pin numbers (for the P1 connector only). However, simplified wiringPi numbering is really recommended. In this way, our programs will be portable over different hardware revisions without needing any changes. The following tables give the mapping of the Raspberry Pi GPIO Pins to the (P1) GPIO connector in relation to the pin numbers and the physical location on the connector. This is a representation of the GPIO connector as viewed looking at the board from above. The GPIO connector is to the top-right of the board with the Ethernet and USB sockets to the bottom. P1 HeaderP5 Header (Rev. 2 Pi only)Further Read | ||||
Installing Adafruit’s Occidentalis on Raspberry Pi Posted: 10 Apr 2014 07:18 AM PDT Raspberry Pi, a small computer powered by ARM architecture is a very interesting board for learning embedded system. In this article we will discuss about how to install how to install Occidentalis v0.2 Rubus occidentalis. For this article I use following:
You can use either Linux (in this article, Slackware) or Windows (in this article Windows 8.1). Just pick one and follow the rest of article for your choice. About OccidentalisOccidentalis is a embedded Linux distribution derived from Raspbian Wheezy. This distro is created and maintained by Adafruit Industries. The latest version is Occidentalis v0.2 which is derived from Raspbian Wheezy August 16 2012. What differs occidentalis and other distro? Occidentalis is tweaked in purpose to make DIY electronics more fun using Raspberry Pi. Yes, we have kernel modules for DS1307, AD525x, I2C digipots, HMC6352, BMP085, ADS1015, easy PWM/Servo control, and many more. It’s not very surprising as this distro is officially created for learning purpose in some Adafruit materials. However, Adafruit is not full time linux distro maintainers, which means you can’t expect too much. Adafruit state that this distro is not for beginners or people who are new to linux. Obtain the MaterialsThe Operating System images I used is Occidentalis v0.2 which can be downloaded from here. The size is about 900MB, per August 31, 2012. Prepare the Disk (SD Card)To boot the Raspberry Pi, an installation media and storage media is needed. All we need is a single SD card. On this article I use my 4GB SD card. The image we download on previous section will be stored on this card and later installed. Make sure you have a way to write on SD card. Windows-based InstructionFor Windows user, you can follow this section to “burn” the image. For this purpose you need additional software for writing to SD card, such as Win32DiskImager utility.
Beside Win32DiskImager, you can also use other tool such as Flashnul.
At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage. Linux-based InstructionWriting image on Linux is easier, in my opinion. The utility we use is “dd” which is already bundled on most distro. Make sure you know the correct device file for your SD card. In my machine I use a built in card reader and detect my SD card as /dev/sdb. It might be different on your system so better check it. For this article I use /dev/sdb to refer to SD card.
If you hesitate to use terminal and prefer to use GUI method, here is the tutorial. Note that we
At this point, you have successfully written image to your SD card. And I assume you are. You can proceed to next stage. Running the PiYou have write image and at this point your raspberry pi is ready. Now set up raspberry pi to boot: insert your SD card back to raspberry pi, put on power, plug video output (either HDMI or RCA). To resize the SD card after installation, you can follow this article. Another way, you can use “raspi-config” utility to do it. To log in on your Raspberry pi you can use the default login, which is:
Side NotesI2C SupportI2C support is on SDA and SCL pins. To test, connect any I2C device to power, ground, SDA, and SCL. Run this command as root to detect which addresses are on the bus: i2cdetect -y 0 SPI SupportSPI support is on the CLK/MOSI/MISO/CS0/CS1 pins. To test, connect your logic analyzer / scope to the pins and run following command to send some dummy data to the SPI port. echo "xathrya test" > /dev/spidev0.0 You can simply read/write the /dev/spidev files to read/write from SPI. One Wire SupportMost commonly used for DS18B20 temperature sensors. The Pi does not have ‘hardware’ 1-wire support but it can bit bang it with some success. Connect a DS18B20 with VCC to 2V, ground to ground, and Data to GPIO #4. Then connect a 4.7K resistor from Data to VCC. Run following commands as root. Both command will be used to attach the temperature sub module. modprobe w1-gpio modprobe w1-therm You can then run following command to read the temperature data from the bus: cat /sys/bus/w1/devices/28-*/w1_slave WiFi SupportThe kernel has been patched with RTL8192cu-based patches. Adafruit Kernel Source CodeYou can get the kernel source code here. Have fun |
You are subscribed to email updates from Xathrya Sabertooth To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Tidak ada komentar:
Posting Komentar