Wina512MB Raspberry Pi & interfacing goodies
|
|
|
- William Glenn
- 10 years ago
- Views:
Transcription
1 IISSUE14-JUL2013 Get printed copies at themagpi.com The camera module A Magazine for Raspberry Pi Users I/O and logic expansion Robotic arm control Parallel processing Bootcamp report LED matrix Charm JAVA Wina512MB Raspberry Pi & interfacing goodies Raspberry Pi is a trademark of The Raspberry Pi Foundation. This magazine was created using a Raspberry Pi computer. hht tt tpp: :/ // / thheemaaggppi i..ccoom
2 14 Welcome to the 1 4th issue of The MagPi - another fully loaded guide to all things Raspberry Pi! This month we begin our journey in introducing the newest module in the Raspberry Pi world, the camera, with a great guide written by James Hughes on setup and basic operation. The conclusion of this article will be found in next month's edition where James builds on these foundations with hints and tips on advanced usage. We reload the Matrix with part two of the interesting Pi Matrix article, take a look at the Guzunty board and review the ever popular South West Raspberry Pi Boot Camps. We bring you more on the programming languages Charm, Scratch and Python plus bring you the first MagPi article on the popular language, Java. I am pleased to report that all pre-order Volume 1 MagPi bundles ordered via Kickstarter or themagpi.com have now shipped. We will soon have individual issues coming to print. We hope you enjoy the printed editions and thank you again for your support and patience in helping make the dream a reality. Ash Stone Chief Editor of The MagPi The MagPi Team 2 Ash Stone - Chief Editor / Administration / Proof Reading W.H. Bell - Issue Editor / Layout / Graphics / Administration Bryan Butler - Page Design / Graphics Ian McAlpine - Layout / Tester / Proof Reading Chris 'tzj' Stagg - Tester Colin Deady - Layout / Proof Reading Matt Judge - Website / Administration Aaron Shaw - Layout Shelton Caruthers - Proof Reading Meltwater - Proof Reading Sai Yamanoor - Tester James Nelson - Proof Reading Adrian Harper - Layout Paul Carpenter - Tester Dave Allan - Tester Claire Price - Proof Reading Phil Tesseyman - Tester Steve Drew - Layout
3 Contents RASPBERRY PI CAMERA MODULE Part 1 : Getting to grips with the camera module PYTHON CONTROL: ROBOTIC ARM Controlling the Maplin robotic arm with Python MUNTS I/O EXPANSION BOARD Using an ARM Cortex-M0 microcontroller BUILD A GUZUNTY PI Make a low cost hardware expander PI MATRIX PART 2 Control individual LEDs and give the Pi Matrix a workout THIS MONTH'S EVENTS GUIDE Barnsley, Lima, Singapore, Liverpool 22 RASPBERRY PI BOOT CAMPS What are the ingredients for a fun filled family Pi day? CHARM PART 3 Charm syntax and semantics FRESHLY ROASTED A beginners guide to Java THE PYTHON PIT 32 Using a simple client-server model for parallel calculations - part 3 COMPETITION 35 Win a 51 2MB Model B Raspberry Pi and interfacing goodies! 36 FEEDBACK Have your say about The MagPi Boot Camp photographs on pages 3, 22 and 23 by Alex Sheppard Prototype camera mount on the front cover is courtesy of Grasping Hand 3
4 BASIC OPERATION Getting to grips with the camera module The Raspberry Pi camera - part 1 DIFFICULTY : BEGINNER James Hughes Guest Writer A few weeks ago, the Raspberry Pi Foundation launched their first peripheral, a 5MP camera. Priced at $25, the same price as the model A, it s a very small PCB on which is an Omnivision OV5647 camera module. It connects to either the Model A or Model B Raspberry Pi using a 1 5cm 1 5 way ribbon connector. Over the course of this series I will take you through initial connection of the camera to your Raspberry Pi and will show you some of the basic commands used to take both still and video imagery. At the end, some of the more sophisticated features will also be explained. Not every option will be covered (new options are being added all the time so it s difficult to keep up) but hopefully this article will give enough information for you to be able to cover most image taking tasks. Firstly though, a description of how the camera module came to be... History From its first launch the Raspberry Pi has had a connector on it to attach a camera to the GPU (the VideoCore 4 Graphics Processing Unit on the Raspberry Pi). This connection uses the CSI- 2 electrical protocol and is a standard used in most mobile phones. It is an extremely fast connection, which on the Raspberry Pi is capable of sending 1 080p sized images (1 920x1 080 x1 0bpp) at 30 frames per second, or lower resolution at even higher frame rates. It had always been intended at some point to release a camera module that could use this connection, as the ability to stream high speed video data through the GPU without any interaction with the ARM processor would always make the camera much more efficient than any USB attached webcam. It would also enable the use of the GPU s ability to encode H264 video, or JPEG images in hardware. It turns out that productising a tiny PCB like the camera board is not a quick task! The prototype was re-designed to remove some unnecessary components, but more importantly, to move the camera crystal, used for timing, to the PCB itself. 4
5 Electromagnetic compatibility (EMC) testing had shown that the 25Mhz clock provided by the GPU caused too much interference as it passed up the ribbon cable to the PCB. Adding a crystal to the PCB itself stopped this interference. A couple more board designs later, to help with production line manufacture and testing, and eventually, about a year after the first prototypes, the production board was ready. Meanwhile, work had been ongoing to write a couple of applications to make use of the camera, to update the GPU firmware to support the camera, and to improve the camera tuning as the basic tuning already in place had a number of obvious defects. Camera tuning is a complex task, which has been covered on the Raspberry Pi website, so I won t repeat it here. Suffice it to say, the end results are well worth the extra effort put in by David Plowman while at Broadcom. Thanks David. each end of the connector. It should slide up easily, and be able to pivot around slightly. Fully insert the ribbon cable into the slot, ensuring it is straight, then gently press down the tabs to clip it into place. The camera PCB itself also requires you to pull the tabs away from the board, gently insert the cable, then push the tabs back. So, with the history out of the way, let s take a look at getting your camera going. Setting up Firstly, it s important to start with a warning. Cameras like these are static sensitive. You should earth yourself prior to handling the PCB (a sink tap/faucet or similar should suffice if you don t have an earthing strap). There are only two connections to make, the ribbon cable needs to be attached to the camera PCB and the Raspberry Pi itself. You need to get it the right way round or the camera will not work. On the camera PCB, the blue backing on the cable should be away from the PCB, and on the Raspberry Pi it should be towards the ethernet connection (or where the ethernet connector would be if you are using a model A). Although the connectors on the PCB and the Pi are different, they work in a similar way. On the Raspberry Pi, you need to pull up the tabs on The PCB connector is a little more awkward than the one on the Pi itself. There is a video at which shows the connections being made. So, we now have the hardware all attached, we now need to make sure we have the correct software installed. As explained above, there are some command line apps to install, and a firmware upgrade with the camera driver and tuning to install. This process may not be necessary in future as newer distro s are 5
6 released which already contain the required files. To update the firmware, libraries and applications, execute the following instructions on the command line. sudo apt-get update sudo apt-get upgrade Now you need to enable camera support using the raspi-config program you will have used when you first set up your Raspberry Pi. sudo raspi-config Use the cursor keys to move to the camera option and select enable. When you exit raspiconfig it will ask to reboot. The enable option will ensure that on reboot the correct GPU firmware will be running (with the camera driver and tuning), and the GPU memory split is sufficient to allow the camera to acquire enough memory to run correctly. Running a camera and associated encoder does take up a big chunk of memory, as the images are large, and there needs to be at least two of them in memory at any time in order to provide a double (in some cases triple) buffer which prevents 'tearing' of images during display. Checking it works OK, we have connected the hardware, and installed the software. Now we need to see if it is all working correctly! The quickest way is just to type in raspistill -t 5000 This runs the stills capture program for 5 seconds (or 5000 milliseconds. Note that all times used are in milliseconds). You should see the whole display replaced with a moving image of whatever the camera is looking at. If you don t see the preview appear, or there are error messages displayed, go straight to the Troubleshooting section at the end of the article! So, what can it do? As with any camera, it can work in two ways. We can capture still images, just like a camera, or we can capture video, like a camcorder. The two demo applications provided handle these tasks separately. Although it would be quite possible to combine them into one application, that makes the code more complicated, and as demo code a lot of effort was put in to make it as easy to understand as possible. As an aside, the C language source code for the applications is publicly available from the Foundation's github repository. Anyone is welcome to play around with it and alter it for their particular purposes. The code is well commented and uses the Doxygen commenting scheme so you can produce HTML documentation directly from the source code. So, on to the apps themselves. They are command line applications, and do not need to be run from a desktop environment since the preview output from the apps is superimposed over the top of any desktop or console being used. Typing just the name of the application, or adding --help or -? to the command line will produce a list of all the available options. The list is quite long, so you may want to pipe the output into less so you can scroll up and down to read it. raspistill less raspivid less 6
7 Basic options Both applications use the -t option to specify the length of time in milliseconds they should continue running. So raspistill -t 3000 will run the camera for 3 seconds. In the stills case, and if a filename is specified, the capture of the still will take place at the end of the time period. In the video case, and again if a filename is specified, the capture starts straight away and will be as long as the time period. To specify the filename of the output file, you use the -o option. The following command runs the camera for 2 seconds and at the end of the period will take a still image, saving it to the file image.jpg. raspistill -o image.jpg -t 2000 This command will do the same but will save a 2 second H264 video file called video.h264 raspivid -o video.h264 -t 2000 You don t need to specify a filename for the output - if you don t then no capture is done, but the preview will still be run for the specified time. If you don t specify a time, then 5 seconds is used as a default. The following will take a picture after 5 seconds. raspistill -o image.jpg So we have made some files, but how do we see what they look like? Well, to view JPG images, the FBI program is quite useful. You can install it quickly using: sudo apt-get install fbi Then you can easily display your JPG images, zoom in and out (use - and +) etc. fbi image.jpg To view video, you can use the already installed omxplayer. omxplayer video.h264 Preview options You can specify whether you want the preview disabled (-n), or whether it is to appear full screen (-f) or in a window (-p). You can also specify what opacity (-op) the preview window is to have (so you can see the desktop underneath if necessary). To display the preview in a window at position 1 00,1 00, width 500, height 400 and at 50% opacity (0-transparent to 255 -opaque), enter: raspistill -p 100,100,500,400 -op 128 -o image.jpg To disable preview completely, enter: raspistill -n -o image.jpg Join us in issue 1 5 of The MagPi where some of the more advanced features will be discussed! Troubleshooting If your camera is not working, there are a number of things to check to ensure it is set up correctly. 1 ) Are the ribbon connectors all firmly seated and the right way round? 2) Is the camera module connector firmly attached to the camera PCB? 3) Have you run sudo apt-get update, sudo aptget upgrade? 4) Have you run raspi-config and enabled the camera? So, if things are still not working, try the following: Error : raspistill/raspivid not found. This probably means your update/upgrade failed in some way. Try it again. Error : ENOMEM displayed. Camera is not starting up. Check all connections again. Error : ENOSPC displayed. Camera is probably running out of GPU memory. Check config.txt in the /boot/ folder. The gpu_mem option should be at least
8 PYTHON CONTROL Control using a Python script Controlling the Maplin/OWIrobot robotic arm DIFFICULTY : BEGINNER Peter Lavelle Guest Writer Introduction This article expands on the work by Jamie Scott, et al in the Wikihow article at Arm-with-a-Raspberry-Pi-(Maplin) and allows you to control the movement of the arm using a sequence of instructions read from a CSV (Comma Separated Variables) formatted file by a Python script. This article assumes you are using the Raspbian distribution but you should also be able to get this working using the Occidentalis distribution from Adafruit. (More information about this distribution can be found at Configuring your Raspberry Pi Before you can start using the script, there are a few things you will have to do to get your Raspberry Pi ready. The first thing you will need to do is add the user account you are using on the Raspberry Pi to the 'plugdev' group. Assuming you are using the default 'pi' user account, the command to do this will be: sudo usermod -ag plugdev pi The next step is to add a udev rule to allow the 'pi' user to send commands to the arm. To do this, create a file called /etc/udev/rules.d/85- robotarm.rules, using the command: sudo nano /etc/udev/rules.d/85-robotarm.rules with the contents below: SUBSYSTEM=="usb", ATTRS{idVendor}=="1267", ATTRS{idProduct}=="0000", ACTION=="add", GROUP="plugdev", MODE="0666" To save the file, press ctrl-x and then press Y followed by Enter. You ll then need to install the Python USB libraries. I found that the one from the Apt repository was slightly out of date, so I had to install the Apt version first and then upgrade it using the pip command. The command below will do this: sudo apt-get install python-pip -y sudo pip install pyusb --upgrade When the Python USB libraries have been installed, reboot your Raspberry Pi so that the changes to udev and the 'pi' user account take effect with the command: 8
9 sudo shutdown -r now Connect the arm When the Raspberry Pi has been rebooted, connect the arm to a free USB port and turn it on. A USB hub should not be needed here. To check that the Pi has successfully detected the arm, execute the command: dmesg grep usb grep 1267 If the arm has been detected successfully you should see output similar to the line below: [ ] usb 1-1.3: New USB device found, idvendor=1267, idproduct=0000 cd maplinarm/ ls commander.py commands.csv maplinrobot.py README.md Making the scripts executable Now we need to make the scripts executable by the Raspberry Pi. To do this, change into the directory you cloned the repository down to using the cd command and run the command chmod 755 *.py This will give all files ending in.py executable permissions. You can double-check this with the command ls -la *.py and looking for the x in the left-hand column of the output on each line. See example listing below: If you don t see the result above, turn off the arm using the power switch, unplug from the USB port, plug the arm back in and turn the power back on. Getting the code drwxrwxr-x 3 pete pete 4096 May 19 14:11. drwx pete pete 4096 May 19 14:11.. -rwxrwxr-x 1 pete pete 1726 May 19 14:11 commander.py -rwxrwxr-x 1 pete pete 2388 May 19 14:11 maplinrobot.py Programming the arm The scripts can be found on Github at You can clone the repository directly on to your Pi if you have the Git client installed. Installing the Git client on Raspbian is as simple as running the command: sudo apt-get install git-core When you have the Git client installed, run the command: git clone to pull down a copy of the Python code. This command will clone the repository into a subdirectory called maplinarm and should pull down the files listed below: Ok, now on to the good part. The script commander.py will read in commands from a CSV file passed to it as an argument. There is an example file called commands.csv in the Git repository to help you get started. So lets open this file up and take a look with the command: nano commands.csv Contents are included below for reference: shoulder-up,1.00,1.00 elbow-down,1.00,2.00 base-clockwise,4.00,1.00 shoulder-down,1.00,1.00 grip-close,1.00,1.00 base-anti-clockwise,4.00,2.00 grip-open,1.00,1.00 elbow-up,1.00,2.00 git clone Cloning into 'maplinarm'... remote: Counting objects: 35, done. remote: Compressing objects: 100% (23/23), done. remote: Total 35 (delta 8), reused 12 (delta 2) Unpacking objects: 100% (35/35), done. 9
10 As you can see here, the basic format for each command is: command,duration,pause command - any valid command found in the maplinrobot.py script duration - the time in seconds to execute the command for. Make sure all values are entered to two decimal places. e.g, for 1 second specify a value of 1.00 here. pause - the time in seconds to wait before executing the next command in the sequence. Make sure all values are entered to two decimal places. e.g, for 1 second specify a value of 1.00 here. The commander.py script will execute each line in the CSV file as a separate command for the duration you set and will wait for the number of seconds set in the pause value before moving on to the next command in the sequence. Valid commands and a description for each can be found below: base-anti-clockwise - Rotates the base anticlockwise base-clockwise - Rotates the base clockwise shoulder-up - Raises the shoulder shoulder-down - Lowers the shoulder elbow-up - Raises the elbow elbow-down - Lowers the elbow wrist-up - Raises the wrist wrist-down - Lowers the wrist grip-open - Opens the grip grip-close - Closes the grip light-on - Turns on the LED in the grip light-off - Turns the LED in the grip off stop - Stops all movement of the arm Try this out yourself by editing the commands.csv file in the repository and replacing the contents with your own instructions to the arm. Running your program Running your program is as simple as running the command./commander.py commands.csv from the command line on your Raspberry Pi. The script will output each step of your program as it runs it. You can find a example output of my terminal below as an example run using the commands.csv file in the repository:./commander.py commands.csv Running command 'shoulder-up' for a duration of second(s) with a pause of second(s) Sending command shoulder-up The series of commands will then finish with: Done. All commands executed. Stopping the arm That s it. If you have any ideas on how this could be improved or expanded (maybe by adding some sort of control logic to the commands file, for example) then feel free to contact me via the contact form on my blog at Where to buy? In the UK the robot arm is available from Maplin ( - code A37JN) or elsewhere from Robotikits ( - codes OWI-535 and 535-USB). 1 0
11
12 I/O, A/D & TIMING Using an ARM Cortex-M0 microcontroller Input/Output Processor DIFFICULTY : ADVANCED Philip Munts Guest Writer As an embedded system developer, I awaited the release of the Raspberry Pi with great interest and anticipation. I ordered one early on and, like many others, waited for it to arrive. There are many, many embedded system possibilities for a $35 Linux computer. Linux brings a great deal of capability to the party, especially with regards to networking and USB support. But one thing Linux systems, including the Raspberry Pi, lack: microsecond I/O (input/output) signal timing resolution. The multiuser, multitasking, virtual memory foundation of Linux simply prevents it from responding to or timing external events with predictable microsecond resolution. Some interesting projects that would require microsecond timing resolution include: IR (Infrared) remote control protocols, such as the LEGO Power Functions RC protocol; DCC (Digital Command Control) for model railroads; Ultrasonic ranging with a device like the Parallax ultrasonic distance sensor. The other capabilities of Linux are so compelling that attempts have been made from time to time to graft in real time support. None of these have been particularly successful, at least in terms of mind share. But fortunately there is another way: the I/O processor (Figure 1 ). Figure 1 - I/O Processor I/O Processor An I/O Processor is simply a separate computer dedicated to I/O operations, usually acting as a slave to the main or real processor. The I/O processor runs its own software, separate from the main processor. Depending on the implementation, the I/O processor software may or may not be alterable from the main processor. The I/O processor idea is not new. The IBM 7094 mainframe computer of could use a 7044 computer for all I/O. Processing was performed on the 7094 and I/O done on the Even the original IBM PC, released in 1 981, had an bit microcontroller in the keyboard to handle key press timing. Today, the I/O processor idea has been pushed all the way down to single chip systems: The NXP LPC4300, itself a single chip ARM Cortex-M4 microcontroller, includes a separate ARM Cortex-M0 microcontroller, for real time processing, on the same chip. 1 2
13 The Raspberry Pi Model B offers several different I/O interfaces, for example: ethernet, USB, and the P1 expansion header. A case can be made for attaching an I/O processor to any of the three interfaces. Ethernet and USB offer good bandwidth and standard interfaces. An I/O processor board built to attach to either Ethernet or USB would also be able to connect to any other Linux, Windows, or Mac computer. But both Ethernet and USB impose significant cost and complexity penalties upon the I/O processor board. It would be difficult (though not impossible) to design an I/O processor board, with USB or Ethernet, costing less than the Raspberry Pi itself. The P1 expansion header provides several different I/O interconnect: I2C, SPI, UART, and basic GPIO. Any or all of these may be used to communicate with a microcontroller. LPC I/O processor I have designed and built an I/O processor board for the Raspberry Pi using the NXP LPC , an ARM Cortex-M0 single chip microcontroller. I selected this device for several reasons: Low cost - I paid USD $1.26 each for the LPC FN28 from Avnet Express. The LPC1 1 xx family is essentially NXP's 32-bit attack on the 8-bit microcontroller market. They are priced less than almost any PIC or AVR of similar capability. The LPC internal oscillator is also stable enough that no crystal or external oscillator is required, saving even more money. DIP package - I can do surface mount soldering, given proper equipment, but I can't say I enjoy it. As far as I know, the LPC FN28 and some PIC32MX devices (more expensive) are the only 32- bit microcontrollers available in a easily handsolderable DIP package. ISP (In System Programming) - without additional hardware. NXP ARM Cortex microcontrollers have a built-in serial port boot loader that allows them to be reprogrammed without any additional hardware. Good support by free development tools. ARM microcontrollers, including the LPC , are very well supported by binutils/gcc/newlib/gdb compiler toolchain. Figure 2 - Assembled I/O Processor board Some other Raspberry Pi expansion boards contain a microcontroller (usually an AVR) as an addition or afterthought. The LPC microcontroller is central to this board's design. Even though it only contains one integrated circuit, an LED, and 8 resistors and capacitors, this board offers: 8 GPIO (General Purpose Input/Output) signals brought out to screw terminals. 5 terminals can be configured as A/D (Analog to Digital) inputs for measuring analog signals. 3 terminals can be configured as timer inputs, for counting or measuring incoming pulses. 5 terminals can be configured as timer outputs, such as PWM (Pulse Width Modulation) outputs for controlling motors. Not all input/output functions are available at the same time; for example, P1.0 can be configured for any of digital input, digital output, analog input, timer/counter input, but only one function at a time. For more information about the LPC I/O Processor, including how to purchase one, visit: i/expansion/lpc / Next time In future articles I will describe in more detail how to use the LPC I/O processor to build some interesting control projects with the Raspberry Pi. 1 3
14 Build a Guzunty An Open Source, Open Hardware Addon Make a low cost GPIO expander DIFFICULTY : ADVANCED Derek Campbell Guest Writer Do you want to connect electronics to your Raspberry Pi but are worried about overloading or damaging the GPIO (General Purpose Input Output) pins? Say "Hello! " to the GuzuntyPI-SB. Guzunty, so it is almost impossible to feed damaging voltages into your Raspberry Pi. Instead, all signals pass though the chip at the heart of this design, a Xilinx XC9572XL. The XC9572XL is a Complex Programmable Logic Device or CPLD for short. Don t worry about the word Complex in the name, the Guzunty makes it easy. The CPLD is tolerant of 5 volt signals which would damage your Raspberry Pi, so you can interface with more kinds of external devices, including Arduino. Guzunty is an Open Source, Open Hardware addon you can easily build yourself. This tiny little board will protect your Raspberry Pi while you learn, but it can do so much more. The Guzunty is programmable using cores. These files can handle repetitive tasks that slow down the Raspberry Pi's CPU and they can provide access to 25 more input/output pins than on the GPIO alone. Take it to the next level and learn to program a core to do new tasks yourself. Protecting your Raspberry Pi As standard, no Raspberry Pi signals are directly brought out to the pins on the top side of the NOTE: The CPLD will be damaged by voltages greater than 5.5 volts. You should be especially aware that mains voltages are dangerous and need special isolation circuitry. However, if you should make a mistake and fry the CPLD, a replacement chip can be purchased inexpensively and swapped into the socket. Input / Output expansion The CPLD is programmable, but unlike a computer program, a CPLD program defines hardware logic. To provide I/O (Input / Output) expansion, we program the CPLD to provide a Serial Peripheral Interface (SPI) on four of its general purpose I/O pins. The System On Chip (SOC) of the Raspberry Pi has SPI, on GPIOs 8, 9, 1 0 and 1 1. We can thus easily make the Raspberry Pi send data to the 1 4
15 CPLD in any programming language that can open the SPI device. The CPLD then uses the data we send it to turn its output pins on or off. The SPI interface works in both directions, so we can also read from the CPLD whether its input pins are in a high or low state. The standard Guzunty board has a total of 25 free I/O pins. We need 4 Raspberry Pi GPIO pins talking to the CPLD and, if we need them, there are another 1 3 unused pins on the Raspberry Pi. Guzunty takes your Raspberry Pi from 1 7 GPIO signals to 40 I/O's (25 plus 1 3). Not bad! plugged into your Raspberry Pi. However, you don t have to stop there. You can create your own cores using a free tool chain downloadable from the Xilinx website. You program cores using either schematics or a Hardware Description Language. How you do that is beyond the scope of this article, but in the meantime check out the cores already available at: Doing repetitive tasks These tasks will be simple jobs where we need to turn logic signals on and off quickly and repetitively as with Pulse Width Modulation (PWM) for example. With PWM, we can control the brightness of a LED or the position of a servo by controlling the length of time a logic output is held high. Another example is driving a LED or LCD display. The display looks clear and stable to the human eye, but in reality, the different display elements are being switched on and off hundreds of times a second. These tasks can put a considerable load on the CPU of the Raspberry Pi, but a CPLD can easily handle them leaving your Raspberry Pi to get on with the real work. NOTE: Handling an independent task like this does require one extra pin on both the CPLD and on the Raspberry Pi to provide a clock signal so that the CPLD can keep track of time. Design your own core To make it as easy as possible to get started, the Guzunty website already contains a suite of cores to do a variety of useful tasks when Can Guzunty power my projects? Yes, the Guzunty provides ground, 3.3v and 5v outputs. These are taken from the power pins on the Raspberry Pi GPIO header. You must adhere to the Raspberry Pi's overall power drain limits. For more details, see: That's all Folks! I do hope you decide to build your next project with a Guzunty. I m sure you will be glad you did. Please visit to find example cores and the code to drive them. 1 5
16 PI MATRIX Control an 8x8 matrix of 64 LEDs Part 2: Control individual LEDs & give the Pi Matrix a workout DIFFICULTY : MODERATE Bruce E. Hall W8BH Guest Writer Introduction In Part 1 of this series we looked at how to build the Pi Matrix kit and how to configure I 2 C on the Raspberry Pi to communicate with it. The result was a simple Python script to turn all the LEDs on and off. In this month's tutorial we will follow on from Part 1 and do something more interesting. First we will look at how the Pi Matrix works, then we will write code for something more YouTube friendly! That s where the matrix comes in. Take a look at a typical wiring diagram for these devices: How does it work? The heart of the Pi Matrix is the MCP chip from Microchip. This is a wonderful device for creating hardware interfaces because: It 'speaks' I 2 C and only needs two communication lines from the Raspberry Pi It buffers and protects your Pi from the outside world It gives you 1 6 I/O data lines to work with It is dirt cheap! Less than US$1.50 at unit quantities If you do something bad with your connection to the outside world and fry the , you ve lost less than US$1.50 and still have a working Raspberry Pi. It just so happens that the LED matrix requires 1 6 data lines - a perfect match. But how can you control 64 LEDs with only 1 6 lines? Don t you need 64 lines? The LEDs are wired in an 8x8 matrix with 8 rows (labeled Dig ) and 8 columns (labeled Seg ). These 8 rows and 8 columns make up our 1 6 connections to the outside world. To turn on an LED, apply power and ground to the corresponding column and row connections. For example, to turn on the highlighted LED at position (0, 0) apply power to the anode on left-most column SegDP and ground to the cathode on the top-most row Dig0. Notice that each LED shares a row connection with 7 other LEDs and a column connection with 7 other LEDs. 1 6
17 Let s see how our program from part 1 works. To light up all of the LEDs we send the hexadecimal value 0xFF to Port A of the , which goes to the column pins of the matrix. Hexadecimal 0xFF is the same as binary Each bit and therefore each column input will be at logic 1 (+3.3V). We also must send the value of 0x00 to Port B, which goes to the row pins. Hexadecimal 0x00 is the same as binary value Each bit and therefore each row input will be at logic 0 (ground). Because all the columns (anodes) are high and all the rows (cathodes) are low, all the LEDs turn on. Coding for columns We can make more interesting displays by changing the row and column inputs. For instance, instead of making all of the column inputs high, if we only make one column high then only the LEDs in that column will turn on. The others will stay off. To try this we will use the Python interactive mode. From the command line, enter: python The Python prompt is a tripple chevron '>>>'. From here we enter our Python code and the interpreter works as we go. Enter the 1 1 commands from the two code blocks on page 1 2 issue 1 3: >>> import smbus... >>> bus = smbus.smbus(1) #0 for Rev.1 Pi... >>> bus.write_byte_data(addr,porta,0xff) All LEDs should now be on. Now let s turn on a single column. To turn on the first column we just need to turn on the lowest bit. This is easy, just write the value of (0x01 ) to Port A. Enter: >>> bus.write_byte_data(addr,porta,0x01) If we want to turn on the third column we write the binary value (0x04) to Port A: >>> bus.write_byte_data(addr,porta,0x04) If we start numbering our columns at zero we can determine the value mathematically as 2^n, where n is the column number. So column 0 is 1, column 1 is 2, column 2 is 4, column 3 is 8 and so on. To code this value we use a neat trick, the left-shift operator <<. Enter the following and replace 'col' with any number between 0 and 7: >>> bus.write_byte_data(addr,porta, 0x01<<col) Did what you expect happen? Depending on your orientation the result might have been the opposite of what you expected. This is because the column pins for the LED matrix are wired in the opposite direction to the Port A pins (see the table on page 1 3 in issue 1 3). To correct for this we ll use the right-shift operator instead of the left-shift operator: >>> bus.write_byte_data(addr,porta, 0x80>>col) When you are ready to move on, turn on all the column LEDs with the following command: >>> bus.write_byte_data(addr,porta,0xff) Coding for rows Now let s do the same thing for rows. We can use the same technique but electrically we need to selectively bring the row to logic 0, not logic 1. For example, to turn on row 3 we ll need to send the binary value to Port B. The third bit from the right is logic 0 and everything else is logic 1. Notice that all of the bits are flipped, or inverted, compared to what we used in the column method. We can write the binary value as the inverse of In Python the inverse (or bit wise NOT) operator is the tilde '~'. Enter the following and replace 'row' with any number between 0 and 7: >>> bus.write_byte_data(addr,portb, ~(0x01<<row)) Coding for individual LEDs It s easier than you think. All we have to do is 1 7
18 combine the code for selecting the row and selecting the column! >>> bus.write_byte_data(addr,porta, 0x80>>col) >>> bus.write_byte_data(addr,portb, ~(0x01<<row)) We now have enough material to create a demo program. Each type of demo has been grouped into its own routine. Try typing this code using your favorite editor and save it as matrix-part2.py. Alternatively you can copy it from You can run it from the command line with the following: Finally, to turn off all LEDs enter: >>> bus.write_byte_data(addr,porta, 0x00) Demo code chmod +x matrix-part2.py./matrix-part2.py In Part 3 of this series we will create some matrix displays. Have fun! intricate #!/usr/bin/python # matrix-part2.py # Selectively turn on and off each row, column, and pixel import smbus import time #gives us a connection to the I2C bus #for timing delays #Definitions for the MCP23017 chip ADDR = 0x20 #The I2C address of our chip DIRA = 0x00 #PortA I/O direction, by pin. 0=output, 1=input DIRB = 0x01 #PortB I/O direction, by pin. 0=output, 1=input PORTA = 0x12 #Register address for PortA PORTB = 0x13 #Register address for PortB OUTPUT = 0 INPUT = 1 # Lower Level LED Display routines def Init23017 (): #Set up the for 16 output pins bus.write_byte_data(addr,dira,0x00); #all zeros = all outputs on PortA bus.write_byte_data(addr,dirb,0x00); #all zeros = all outputs on PortB def TurnOffLEDS (): bus.write_byte_data(addr,porta,0x00) #set all columns low bus.write_byte_data(addr,portb,0x00) #set all rows low def TurnOnLEDS (): bus.write_byte_data(addr,porta,0xff) #set all columns low bus.write_byte_data(addr,portb,0x00) #set all rows low def SetLED (row,col): #Turn on an individual LED at (row,col). All other LEDS off. bus.write_byte_data(addr,porta,0x80>>col) bus.write_byte_data(addr,portb,~(1<<row)) def SetColumn (col): #Turn on all LEDs in the specified column. Expects input of 0-7 bus.write_byte_data(addr,portb,0x00) bus.write_byte_data(addr,porta,0x80>>col) def SetRow (row): #Turn on all LEDs in the specified row. Expects input of 0-7 bus.write_byte_data(addr,porta,0xff) bus.write_byte_data(addr,portb,~(1<<row)) def Pause(): #Turn off LEDS and wait a while between cases TurnOffLEDS(); time.sleep(0.5); 1 8
19 def FlashLEDS (delay): #Flash all of the LEDS on/off for the specified time TurnOnLEDS() time.sleep(delay) TurnOffLEDS() time.sleep(delay) def LEDtest (delay): #Turn on all 64 LEDS for the specified time delay, in seconds print "\nlighting all LEDS for %d seconds" % delay TurnOnLEDS() #turn them all on time.sleep(delay) #wait a while Pause() #then turn them off def FlashTest (numcycles,delay): print "\nflash all of the LEDS" for count in range(0,numcycles): FlashLEDS(delay) Pause() def ColumnTest (numcycles): #Turn on each Column. #Keep PortB (rows) low & set each bit in PortA (columns) high #This will actually light LEDS in reverse order, col 7 to col0, #because PortA bit 0 is wired to Col7, A1 to Col6,..., A7 to Col0 print "\nturn on Columns 0 to 7" for count in range(0,numcycles): print "...cycle",count+1 for col in range(0,8): SetColumn(col) time.sleep(0.5) time.sleep(1) Pause() def RowTest (numcycles): #Turn on each row, from row 0 to row 7 #Keep PortA (columns) high & selectively turn a bit in PortB (rows) low print "\nturn on Rows 0 to 7" for count in range(0,numcycles): print "...cycle",count+1 for row in range(0,8): SetRow(row) time.sleep(0.5) time.sleep(1) Pause() def PixelTest (numcycles): #Flash each LED according to its (row,col) coordinate print "\nflash each LED in (row,col) order" for count in range(0,numcycles): for row in range(0,8): for col in range(0,8): SetLED(row,col) time.sleep(0.1) Pause() # Here is the program body: call each of the text routines in turn. print "\npi Matrix test program starting" bus = smbus.smbus(1); #Use '1' for newer Pi boards; 0 for oldies Init23017() #Set all 16 I/O pins as output LEDtest(5) #Turn on all LEDS to verify connectivity FlashTest(25,0.1) #Flash them all for a little fun ColumnTest(3) #Sequentially turn on Columns 0 to 7 RowTest(3) #Sequentially turn on Rows 0 to 7 PixelTest(1) #Flash each pixel in row,col order FlashLEDS(0.1) #Visual end of test print "\ndone." 1 9
20
21 Want to keep up to date with all things Raspberry Pi in your area? Then this section of The MagPi is for you! We aim to list Raspberry Jam events in your area, providing you with a Raspberry Pi calendar for the month ahead. Are you in charge of running a Raspberry Pi event? Want to publicise it? us at: [email protected] Barnsley Hack-a-thon When: Saturday 6th July am Where: Digital Media Center, Bansley This event will run from 9.00am until 9.00pm. The event is free. Further information is available at Liverpool Raspberry Jam When: Saturday 6th July am Where: North Liverpool Academy, 1 20 Heyworth St, Liverpool, L5 0SQ The event will run from 9.30am until 4.00pm. Further information and free tickets are available at 3/ Lima Raspberry Pi Meet-up When: Saturday 1 3th July am Where: Lima Public Library, 650 W Market St, Lima, OH Attendees will receive an LRITA.org flash drive and a pizza lunch. Register at 3, raspberry-pi-meet-up.aspx Singapore Raspberry Pi Training When: Saturday 1 3th 2.00pm Where: Singapore Science Centre, Digital Design Studio, Singapore Runs from pm. Free for Science Centre members, S$1 0 for others. Further information: 21
22 RASPBERRY PI Boot Camps What are the ingredients for a fun filled family Pi day? Dr Mike Bartley & Caroline Higgins Guest Writers Raspberry Pi Boot Camp events are now being held on a regular basis in the south west of the UK. The MagPi asked Mike Bartley, one of the organisers of the Bristol event, to tell us all about the events and how they came about, hopefully to inspire similar events elsewhere. In December the Bristol branch of BCS The Chartered Institute for IT held its annual talk to encourage children into computing. The venue was At-Bristol and the theme was the Raspberry Pi. With an inspirational talk from Rob Bishop of the Raspberry Pi Foundation, the event attracted over 450 attendees with at least 300 being children. Since the UK government proposed the planned updates to the IT curriculum last year there has been a growing interest in the subject from children, parents and teachers. It was clear we had hit a topic of high interest and we needed to understand how best to take it forward. Both the University of Bristol and At-Bristol have outreach programs to encourage children into computing and engineering. A collaboration between the three organisations seemed like a perfect way to collectively achieve our goals; to create a series of events which support the learning of the next generation of innovators and engineers, whilst providing a fun day out for the family. At-Bristol provides the facilities and logistics; the University of Bristol s students run a drop in clinic and workshops as well as loaning equipment. The BCS put a call out to their members to find volunteers who run workshops and demonstrations. All three made financial contributions of some sort. The voluntary "let's do this" attitude pervaded the organisation and the event and enabled the three organisations to work together to pull off the first two events, which proved to be hugely successful. 22
23 Over 400 children and 200 adults attended the first two Raspberry Pi Boot Camps to learn what they can do with the Pi. From controlling remote control cars and LEDs to setting up a home media server the children got to grips with how they can use the Raspberry Pi to make things! Marcus aged 1 2 commented "This was fantastic. My Pi has been at home in its box for a while but I ve now learned loads of cool things to do with it. Me and my mates are looking forward to the next one already! " The events will now become a regular feature at At- Bristol on a Saturday in September, November, January, March and May. The workshops ranged from beginner to advance level, and also included a show-and-tell section that gave visitors the opportunity to learn more about expert level projects. Pi-Cars proved to be very popular workshop; children had the opportunity to build remote control handset for a car using their Raspberry Pi. Other workshops included the Pi as a home media server, led traffic lights and how to log data to the internet. The Magpi team were on hand to answer questions. The show-and-tell section included a number of robots controlled by a Raspberry Pi and a drawing robot. Obviously organising a large scale event of this nature throws up many challenges, finding enough equipment has been the main issue. We asked people to bring their own monitors, keyboards and power cables, which of course isn t always possible. We encouraged visitors bring their laptops and there were volunteers on hand to show them how to set up their laptop to control their Pi. Future Boot Camps will continue the theme of workshops and demonstrations on the Pi and other platforms like Arduino. However, other aspects of computing will also be covered. For example, the second Boot Camp on June 1 5th featured a 'Rails Girls' workshop, hosted by local web agency Simpleweb. Female programmers were invited to spend the day learning Ruby on Rails. In addition to this we ran three 90 minute workshops which aimed to introduce children to application writing using the language Processing. The basics of variables, conditionals, loops and functions with the aim of developing a game by the end of the workshop. This will help the children prepare for a free one week programming course to be held at the University of Bristol as part of a national competition organised by the Young Rewired State. Going forward the three organisations will continue to work together as all objectives remain completely aligned. It is clear that collaboration like this has been extremely beneficial in enabling us to achieve our goals. Events will be held over five Saturdays each year and there will be themes (such as Wireless, Robotics, and smart homes) to keep the events fresh. The first two events relied heavily on the goodwill of volunteers. Now that we have organised two successful boot camps we need to ensure the event is sustainable by asking for donations and sponsorship. We would like to buy dedicated equipment and cover the costs incurred by volunteers. If you would like to contribute to future events by providing a workshop, being part of the show-and-tell section or by making a donation, please contact [email protected] Dr. Mike Bartley is Chair of BCS The Chartered Institute for IT in Bristol and of the High Tech Sector Group of the West of England Local Enterprise Partnerships. Caroline Higgins is Outreach & Student Liaison Manager, Faculty of Engineering, University of Bristol. 23
24 Programming in Charm part 3 DIFFICULTY : ADVANCED Peter Nowosad Guest Writer Having covered RISCOS on the Raspberry Pi and Charm data types in the first two articles, it's my pleasure to welcome you to the third article in the series on the Charm programming language. If you've been following the series, you may well have already installed Charm under RISCOS and tried out the printed exercises. If not it's not too late to go back and do so! In this article I am going to cover some of the syntax and semantics of Charm illustrated by simple examples which I hope will whet your appetite and arm you (no pun intended! ) with enough knowledge to start writing your own Charm programs. Charm is an object oriented structured programming language. The structured program theorem, which provides the theoretical basis of structured programming, states that three ways of combining programs namely sequencing, selection, and iteration are sufficient to express any computable function. execute a line at a time from top to bottom e.g. int x := 1; int y := 2; int z := x + y; do_this (); do_that (); however even in this simple example do_this and do_that cause call outs to named procedures that contain their own code (not shown here). Although white space is ignored, usually each line contains a single statement which ends with a semicolon, with one common statement type being the assignment statement in which the left hand side is assigned the value of the expression on the right hand side with the two being separated by the assignment operation :=. Selection Sequence In the absence of flow of control statements related to selection and iteration, Charm programs 24
25 Often programs want to take different courses of action under different conditions and this is handled by selection, which in Charm is provided by theif and case keywords. if checks whether the following conditional expression evaluates to true in which case the next statement, or block of statements enclosed in curly brackets is executed, or false in which case it is not. The if keyword has an optional associated else keyword that if present introduces the statement or statements that should be executed if the boolean expression is nottrue e.g. if x = 1 y := 0; else y := 1; and for keywords. while checks whether the following conditional expression evaluates to true in which case the next statement, or block of statements enclosed in curly brackets are executed until the expression evaluates to false e.g. while true loop (); repeat is similar to while but the conditional expression is at the end of the loop and must evaluate to false for the loop to be repeated e.g. repeat loop (); false; for allows a control variable to be initialised, incremented and tested all in one statement e.g. Note the use of indentation to help highlight the flow of control logic. The case keyword introduces a series of clauses that match the value of an integer variable against a number of possible constant values and chooses a block of code to execute e.g. case x { 1: handle_1 (); 2: handle_2 (); otherwise: handle_other (x); } Note the use of the otherwise clause to catch any values that do not match. Iteration Sometimes the same code needs to be executed many times within a loop, often to process each member of an array. This is handled by iteration using the while, repeat for (int i := 0 step i := i + 1 while i < 10) a[i] := 0; initialises the contents of an integer array of size 1 0 to 0. Boolean expressions Boolean expression appear as part of many flow of control statements in Charm and can be composed of the following comparison operators: = - equal # - not equal :=: - equal (pointer comparison) :#: - not equal (pointer comparison) > - greater than < - less than >= - greater than or equal to <= - less than or equal to If A and B are boolean expressions, they can be combined using the logical operators: A and B - both A and B must be true A or B - either A or B must be true not A - A must be false 25
26 nil The nil keyword occupies a special place in the Charm language and can be used to initialise and test pointers (ref variables). It indicates that the pointer is not currently setup to point anywhere, and an attempt to use it will result in an exception that stops program execution. Tree recursion The following program uses tree recursion and the language constructs to draw a tree on the screen import import lib.maths; lib.vdu; module Tree { const MODE = 31, display mode OFFSET = 30, display offset LEVELS = 7, branch levels VARS = 1000; variations int xmax, ymax, xshift, yshift; screen parameters proc variation (real value, real deviation) real { return value * (1 + deviation * ( * (Maths.random () mod (VARS + 1)) / VARS)); } proc branch (int level, real length, real angle, int xs, int ys) { int xe := xs + length * Maths.fn.cos(angle); int ye := ys + length * Maths.fn.sin(angle); Vdu.plot (Vdu.P_POINT + Vdu.P_PLOT_F_ABS, xs l_sl xshift, ys l_sl yshift); Vdu.plot (Vdu.P_PLOT_F_ABS, xe l_sl xshift, ye l_sl yshift); if level > 1 + Maths.random () mod 2 { real scale := variation (0.65, 0.25); int branches := level - Maths.random () mod 3; if branches <= 0 return; real range := variation (1.5, 0.2); for int i := 0 step inc (i) while i <= branches { real factor := variation (0.5, 0.8); if i = branches factor := 0; branch (level - 1, variation (length * scale, 0.2), variation (angle, 0.3) + i * range / branches - range / 2, xe - (xe - xs) * factor, ye - (ye - ys) * factor); } } } 26
27 } export proc ~start () { Vdu.mode (MODE); xshift := Vdu.mode_var (MODE, Vdu.MV_X_EIG_FACTOR); yshift := Vdu.mode_var (MODE, Vdu.MV_Y_EIG_FACTOR); xmax := Vdu.mode_var (MODE, Vdu.MV_X_WINDOW_LIMIT) + 1; ymax := Vdu.mode_var (MODE, Vdu.MV_Y_WINDOW_LIMIT) + 1; Vdu.g_colour (0, 7); Vdu.plot (Vdu.P_POINT + Vdu.P_PLOT_F_ABS, OFFSET l_sl xshift, OFFSET l_sl yshift); Vdu.plot (Vdu.P_RECTANGLE_FILL + Vdu.P_PLOT_F_ABS, (xmax - OFFSET - 1) l_sl xshift, (ymax - OFFSET - 1) l_sl yshift); Vdu.g_colour (0, 0); branch (LEVELS, (ymax - OFFSET) / 3, Maths.fn.asn(1), (xmax - OFFSET) / 2, OFFSET); } To make the tree look more realistic some branch parameters have been randomised, for example their length and the angle between them. To compile this program, Charm version or newer is needed. For this month's exercise add some fruit (hint randomly draw some coloured circles at or near branch ends). Next Time Next time I intend to talk about writing containers in Charm, namely sets, lists and maps. 4 4
28 FRESHLY ROASTED A beginners guide to Java A Pi and a cup of Java, please! DIFFICULTY : MEDIUM Vladimir Alarcón & Nathaniel Monson Guest Writers You will need: - A Raspberry Pi with Raspbian MB of free space in your SD card. - Basic knowledge of programming. - Basic command-line usage. Introduction In this article I'll show you how to write and run Java programs on your Raspberry Pi. Java is an object-oriented language designed to run on many operating systems without requiring recompilation of the source code. Java also includes a vast amount of libraries, which offer solutions to more advanced problems like running complex web sites or high-end mission-critical algorithms. In this article I will focus on the very basics of the language. Once you master the language there are plenty of web sites on the Internet with lots of details of libraries and many examples. I'll first show you the steps to install the Java compiler and virtual machine on the Raspberry Pi. Then, we'll create a couple of basic Java programs... and we'll run them! This article shows you the running examples first, and delves into concepts later. The idea behind this approach is that it will be easier for you to look at real Java programs and try to identify the new elements and their functions by yourself. Once you have written the program and run it, I will explain the novelties. 1. Installation To write, compile and run your program, you'll need two things: a text editor, and a Java development kit (JDK). You can use any text editor to write a Java program. I prefer Geany because of its syntax colouring, but Leafpad or GEdit will work too. While there are several JDKs, I suggest OpenJDK 7. A JDK includes (mainly) a compiler and a Java virtual machine (JVM). The compiler generates platform independent bytecode and the JVM is able to run this bytecode. To install Geany and OpenJDK 7 open a terminal window and type: sudo apt-get install -y openjdk-7-jdk geany It will probably take at least nine minutes to download and install everything, but it can take longer depending on the speed of your internet connection. Once the installation has finished, check both packages are installed correctly. You should be able to open Geany from the main menu, under "Programming". To test OpenJDK7, open a terminal window and type: 28
29 java -version It should display a few lines starting with: java version " OpenJDK... the same directory called HiThere.class. the compiled program that will be run. To run the program type: java HiThere This is 2. Running our first program Create a directory to store our programs. For example, open a terminal and type: mkdir cupofjava Now it is time to write our first program (a class) called "HiThere". Java is an object oriented programming langauge, where every program contains at least one class which in turn can use other classes. Open the text editor (Geany in my case) and create a file called HiThere.java. Type in, public class HiThere { } public static void main(string[] args) { System.out.println("A Java Pi!"); } and save the file. Using the terminal, change to the directory "cupofjava" (where you created the program) using: cd cupofjava and then type: javac HiThere.java The javac command compiles the.java file into a.class file. The compiler analyses the source code in the HiThere.java file and generates the bitecode form. After 1 5 seconds or so, this command should silently finish. If you misspelled something it will show an error message that will display where the problem is. If this is the case, go back to the text editor, check your code and fix the misspelling, save the file, and then run javac again. Once the file has been successfully compiled, you'll find a new file in You don't need to specify the.class extension. The command javac compiles programs, and the command java executes them. The program will run and will display: A Java Pi! Well... Congratulations! You have written and run your first Java program on the Raspberry Pi. You probably noticed the program took a few seconds to write that message. Why so slow? Actually, Java is quite fast. The whole program took only a couple of milliseconds to run, but Java needs a few seconds at the beginning to load the JVM. The good news is that once the JVM is loaded, the program runs very fast. Well, let's now look at the program in more detail. There's only one line in it that is actually executed. This line is: System.out.println("A Java Pi!"); The other lines specify the name of the class "HiThere" (at line 1 ), and the name of the method main (at line 3). This class, similar to any other Java class, can have many methods but we are using only a single one in this example. Challenge #1 : Your turn now. Using the text editor, change the message in between double quotes in the source file from "A Java Pi! " to "My name is Name." (use your name) and save it. With the terminal, compile the program again and run it using the two commands (javac and java) shown before. If you do it right, the program will display your name now. Do it! A note: The syntax of Java (the words and punctuation of the language) is very similar to the syntax of the C language. Any programmer with 29
30 knowledge of C will find the basics of Java very easy to understand. 3. Java variables and Control flow The next example illustrates the use of variables and control flow statements. In the same directory where we stored the first program, create a new file called DiceRoller.java. Then append, import java.util.random; public class DiceRoller { } public static void main(string[] args) { Random generator = new Random(); int d = 0; } while (d < 4) { System.out.print("Rolling... "); int face = 1 + generator.nextint(6); System.out.print("I got a "+ face + ". "); if (face == 1) { System.out.print("Wow! An ACE!"); } System.out.println(); d = d + 1; } to the file and save it. program. javac DiceRoller.java java DiceRoller You'll see something similar to: Compile and then run the Rolling... I got a 2. Rolling... I got a 1. Wow! An ACE! Rolling... I got a 4. Rolling... I got a 5. The program will roll four dice and will identify which ones are aces (the number 1 ). Do you see how it works? There are quite a few things of interest in this example. This program uses two integer variables, named d and face. The variable d is used to make sure we roll four times, not three times or not five times. The face variable stores the die face after each run. The program also receives an array of strings in the variable named args. The args variable contains the command-line parameters present when the program is run. Finally, the program also uses an object called generator. Remember I told you a Java class can use other classes? This is an example. This program uses an existing class (called Random) that specializes in generating random numbers. A class can be used by calling its methods, either directly or by creating an object. In this case we only use one of its methods, the one called nextint(), to get a random number. Additionally, Java uses the brackets{ and } to define groups of instructions, called blocks. Each block can be empty, or have one or more instructions. You can define sub-blocks inside existing blocks as needed. This is commonly used in control-flow statements. Talking about this,... this example shows the use of two control-flow statements: if and while. An if statement executes a block only if the condition specified in parenthesis is true; a while, on the other hand, will execute the nested block multiple times as long as the condition is true. Other control blocks are for, do-while, switch and if-else. In the example, the if statement checks the value of face. That's why the extra message appears only when an ace is rolled. The while statement, on the other hand, executes the included block four times. The while loop continues while the value of the variable d is less than 4. Notice that the variable is set to zero before the loop. Inside the loop it increases by one at the end of the block. Therefore, the first four times (0, 1, 2, 3) the while succeeds, but on the fifth one (when it has the value 4) it fails. Challenge #2: Change the program to roll 7 dice, where each dice has 1 0 faces. Once you have saved your changes, go to the compile the program again and run it using the two commands (javac and java) shown before. If you do it right, the program will now display all seven dice. Go for it! 30
31
32 CLIENT SERVER Model for using many computers Parallel calculations - part 3 DIFFICULTY : ADVANCED W. H. Bell MagPi Writer Completing BatchCalculator Welcome back to the Python Pit. This article is a continuation of the tutorial presented in Issues 1 0 and 1 3. If you have not already done so, it would be a good idea to read the previous parallel calculations articles in these Issues before proceeding. The FunctionCalculator.py file was originally written to run a genetic algorithm, using several computers at once. The calculations for each point in the genetic algorithm were evaluated using C++ and ran for around eight minutes on high specification CPU cores. In this case, the time overhead of server and client processes written in Python was negligable. Since the cluster used was often used for other tasks, the implementation of FunctionCalculator.py provided a way of using as many cores as possible without requiring a rigid addressing structure. There remain two steps left in this series of articles: (i) the completion of the BatchCalculator class and (ii) the use of FunctionCalculator.py to run some more serious calculations. Open the file FunctionCalculator.py from Issue 1 3. Then go down to function shutdown in the class BashCalculator. After shutdown, add the member function evaluate: def evaluate(self, cmds): # Wait until at least one client thread is available while len(self.client_threads) == 0: print "Waiting for a client to connect" time.sleep(5) ncmds = len(cmds) # Create a buffer to collect the results results = [0.]*ncmds # If no commands were given return empty list of results if ncmds == 0: return results # Create a buffer to collect the status of the results and the results # 0 => not calculated, 1 => being calculated, 2 => done status_results = [] icmd = 0 while icmd < ncmds: status_results.append(statusresult(0,0.)) icmd = icmd
33 # Loop until all of the calculations have finished. finished = False ithread = 0 icmd = 0 while not finished: print "Looping" print "Status and results = %s" % status_results time.sleep(1) # Check if all status flags are 2 and copy the results into the # results list at the same time jobsleft = False for i in xrange(ncmds): sr = status_results[i] if sr.cmd_status!= 2: jobsleft = True break results[i] = sr.result if not jobsleft: finished = True continue print "Have jobs to do" # Check the number of threads inside the loop in case more # threads are created during the loop nthreads = len(self.client_threads) print "Currently have %d threads to work with" % nthreads # If the index points at the last thread go back to the # first thread. if ithread == nthreads: ithread = 0 print "Using thread index %d" % ithread # If the index points at the last cmd go back to the first cmd. if icmd == ncmds: icmd = 0 print "Checking cmd index %d" % icmd # Check if this cmd has been submitted or not. If the # command has already been submitted skip to the next # command. if status_results[icmd].cmd_status!= 0: print "Command %d has status %d" % (icmd, status_results[icmd].cmd_status) icmd = icmd + 1 continue print "Searching for an idle thread" # Find an idle thread foundthread = False while not foundthread: # Check the number of threads inside the loop in case more # threads are created during the loop nthreads = len(self.client_threads) # Keep looping round and round. if ithread == nthreads: ithread = 0 33
34 self.client_threads[ithread].processingcmd().wait(1) # wait until finished or 1 sec. if not self.client_threads[ithread].processingcmd().isset(): foundthread = True else: ithread = ithread + 1 time.sleep(1) # If there are no available threads if not foundthread: print "All threads are busy processing commands." time.sleep(2) continue # Submit the command and the target list element print "icmd %d" % icmd sr = status_results[icmd] self.client_threads[ithread].evaluate(cmds[icmd], sr) # Go to the next command icmd = icmd + 1 # For debugging print "results = %s" % results return results The evaluate function takes a list of commands and returns a list of floating point numbers which correspond to each command. The function performs the calculations by passing each command to a client process. The evaluate function waits until a least one client thread has connected. Once one client has connected a while loop is used to evaluate each of the commands. The commands are given an associated status code of zero, which is set to one if the command is being evaluated or two if the command has been evaluated. To prevent a tight loop and an associated high use of CPU on the computer running the BatchCalculator, a sleep statement is used within several of the loops. There are a lot ofprint statements to show how the function works. If a client process connects to the server while some commands are being evaluated, then it will be added to the pool of available clients. Therefore, the speed of calculation will increase as more clients connect. The evaluate function waits for one of the associated threads to become available and passes it a command. When a command has been evaluated the result is stored in the status_results list and then copied into the results list. The status_results list is of type StatusResult, which is mutable. Therefore, the client_threads function is passed a pointer to the element of the list, can write the results into it, and set the command status. Testing the BatchCalculator While the launchbatchclient.py program from the last tutorial in Issue 1 3 can be used to start the clients, the server program launchbatchcalculator.py needs to be updated to pass a list of commands to the evaluate function of the BatchCalculator. Look back at the first article in this series and see how the commands were passed to the FunctionCalculator.py. Then try to numerically solve, y = 4*x**4 - (x - 4)**3/(6-x)**2 + x for the value of x when y is 1 0. Choose 1 00 values of x at random between and Pass these equations to the BatchCalculator. Pick the best two points and select another 1 00 values for x within the second range. Repeat the procedure until a solution is found. While this calculation will run slower than using a single Raspberry Pi, the problem will demonstrate how to use the BatchCalculator. The solution to the problem will be given next time. 34
35 JULYCOMPETITION Once again The MagPi and PC Supplies Limited are proud to announce yet another chance to win some fantastic Raspberry Pi goodies! This month there is one MASSIVE prize! The winner will receive a new Raspberry Pi 51 2MB Model B, an exclusive Whiteberry PCSL case, 1 A PSU, HDMI cable, 1 6GB NOOBS memory card, GPIO Cobbler kit, breadboard and jumper wires! For a chance to take part in this month's competition visit: Closing date is 20th July Winners will be notified in next month's magazine and by . Good luck! To see the large range of PCSL brand Raspberry Pi accessories visit June'sWinners! The winner of a new 51 2MB Raspberry Pi Model B plus PCSL PiAngle case and GPIO Cobbler kit is Surajpal Singh (Bristol, UK). The 2nd and 3rd prize winners of a PCSL PiAngle case are James Duffell (Preston, UK) and Kobitharun Kunasekaran (Scarborough, UK). Congratulations. We will be ing you soon with details of how to claim your prizes! 35
36 Feedback & Question Time Friday June 1 4, Escondido, California, USA. I got my magazines today! Hooray Hooray Hooray! Homer Hazel Wow! what an incredibly professional production! I have downloaded the 1 3 issues and have ploughed through the first two. As a retired IT teacher, this is just what we need and it is presented in such a way that anyone can get something out of it young and old. My Pi takes me back to my Acorn Atom days and a soldering iron, and it is good to see young students taking this up again. I am currently working with a Year 7 young lady doing some programming and simple control circuits, and she is loving it well, we both are, really! I spend my life writing a complex engineering program in PowerBASIC if only this was available for Linux (and it is not for the want of asking) and getting to grips with the syntax of Python has been an interesting challenge. My only feeble complaint is that setting up a printer is a nightmare! I can get it to print from LibreOffice, but not the command prompt, though I am sure that the answer will be in the issues I have not looked at yet. It is good to see Britain leading the world again in the field of microcomputers well done Pi. Iain Johnstone [Ed: See issue 12 for command line printing] 288 pages of goodness just arrived. The mags look awesome, love the binder and stickers! Its been a bit of a wait but its definitely been worth it! The whole bundle is fantastic and the magazine quality is perfect. They look and feel like a premium magazine you would buy from a newsagents. You can see right away the hard work that has gone into these and it is very much appreciated. THANK YOU!! to the whole MagPi team!! Time to crack on and start reading! Nial Pearce First of all. GREAT magazine! Thanks for taking the risks to get it out there in the first instance. I bought the issues as soon as I saw I could and they turned up today (YAY!! ) Chris Burgess Just received my binder and mags - they look great! Thanks for all the effort you have put into this. And you just know that we all want Volume 2 now don't you :-) Mark Pearson [Ed: All Volume 2 issues to date will be available soon] Just received my magazines and binder today. Wow! They are beautiful. This whole project has been great. I had selected the Signature Kit and am I ever glad. The hardware kit came some time ago and the whole thing was top quality. It meant a lot to have those books signed by Liz and Eben. Congratulations for a well executed project. Tony Guerich The MagPi is a trademark of The MagPi Ltd. Raspberry Pi is a trademark of the Raspberry Pi Foundation. The MagPi magazine is collaboratively produced by an independent group of Raspberry Pi owners, and is not affiliated in any way with the Raspberry Pi Foundation. It is prohibited to commercially produce this magazine without authorization from The MagPi Ltd. Printing for non commercial purposes is agreeable under the Creative Commons license below. The MagPi does not accept ownership or responsibility for the content or opinions expressed in any of the articles included in this issue. All articles are checked and tested before the release deadline is met but some faults may remain. The reader is responsible for all consequences, both to software and hardware, following the implementation of any of the advice or code printed. The MagPi does not claim to own any copyright licenses and all content of the articles are submitted with the responsibility lying with that of the article writer. This work is licensed under the Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License. To view a copy of this license, visit: Alternatively, send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
An Introduction to MPLAB Integrated Development Environment
An Introduction to MPLAB Integrated Development Environment 2004 Microchip Technology Incorporated An introduction to MPLAB Integrated Development Environment Slide 1 This seminar is an introduction to
Bob Rathbone Computer Consultancy
Raspberry PI Robot Arm Constructors Manual Bob Rathbone Computer Consultancy www.bobrathbone.com 2 nd of November 2013 Bob Rathbone Raspberry PI Robotic Arm / 1 Contents Introduction... 3 Raspberry PI
MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence : 0660-3
MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence : 0660-3 CMPS03 Magnetic Compass. Voltage : 5v only required Current : 20mA Typ. Resolution : 0.1 Degree Accuracy : 3-4 degrees approx. after calibration Output
Beginner s Guide to the PI MATRIX. by Bruce E. Hall, W8BH 1) INTRODUCTION
Beginner s Guide to the PI MATRIX - Part 1- by Bruce E. Hall, W8BH 1) INTRODUCTION The Pi Matrix is a fantastic tool for learning GPIO programming on the raspberry pi. Sure, you could hook up a few LEDs
Bob Rathbone Computer Consultancy
Raspberry PI Stepper Motor Constructors Manual Bob Rathbone Computer Consultancy www.bobrathbone.com 20 th of December 2013 Bob Rathbone Raspberry PI Robotic Arm 1 Contents Introduction... 3 Raspberry
Chapter 1 Hardware and Software Introductions of pcduino
Chapter 1 Hardware and Software Introductions of pcduino pcduino is a high performance, cost effective mini PC platform that runs PC like OS such as Ubuntu Linux. It outputs its screen to HDMI enabled
SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.
SKP16C62P Tutorial 1 Software Development Process using HEW Renesas Technology America Inc. 1 Overview The following tutorial is a brief introduction on how to develop and debug programs using HEW (Highperformance
PiFace Control & Display
PiFace Control & Display A Plug and Play Device to control Raspberry Pi Exclusively From Quick Start Guide Version 1.0 Dated: 30 th Oct 2013 Table Of Contents Page No 1. Overview 2 2. Fitting the PiFace
ROBOTC Software Inspection Guide with Additional Help Documentation
VEX ROBOTICS COMPETITION ROBOTC Software Inspection Guide with Additional Help Documentation VEX Cortex Software Inspection Steps: 1. Cortex Firmware Inspection using ROBOTC 2. Testing Cortex Robots using
FlowKit in-circuit debug system
FlowKit in-circuit debug system www.matrixmultimedia.com HP299 Contents About this document 3 Board layout 3 General information 4 Detailed operation 4 Circuit diagram 7 2 Copyright About this document
INTRODUCTION TO SERIAL ARM
INTRODUCTION TO SERIAL ARM A robot manipulator consists of links connected by joints. The links of the manipulator can be considered to form a kinematic chain. The business end of the kinematic chain of
CPSC 226 Lab Nine Fall 2015
CPSC 226 Lab Nine Fall 2015 Directions. Our overall lab goal is to learn how to use BBB/Debian as a typical Linux/ARM embedded environment, program in a traditional Linux C programming environment, and
Adafruit's Raspberry Pi Lesson 5. Using a Console Cable
Adafruit's Raspberry Pi Lesson 5. Using a Console Cable Created by Simon Monk Last updated on 2014-09-15 12:00:13 PM EDT Guide Contents Guide Contents Overview You Will Need Part Software Installation
STB- 2. Installation and Operation Manual
STB- 2 Installation and Operation Manual Index 1 Unpacking your STB- 2 2 Installation 3 WIFI connectivity 4 Remote Control 5 Selecting Video Mode 6 Start Page 7 Watching TV / TV Guide 8 Recording & Playing
Raspberry Pi Setup Tutorial
Raspberry Pi Setup Tutorial The Raspberry Pi is basically a miniature linux- based computer. It has an ARM processor on it, specifically the ARM1176JZF- S 700 MHz processor. This is the main reason why
MANUAL FOR RX700 LR and NR
MANUAL FOR RX700 LR and NR 2013, November 11 Revision/ updates Date, updates, and person Revision 1.2 03-12-2013, By Patrick M Affected pages, ETC ALL Content Revision/ updates... 1 Preface... 2 Technical
Computer Automation Techniques. Arthur Carroll
Computer Automation Techniques Arthur Carroll 1 Three Types of Computers Micro-Controller Single Board Computer Desktop Computer 2 The Micro-Controller Small inexpensive DIP or surface mount chips Roughly
Adafruit's Raspberry Pi Lesson 1. Preparing an SD Card for your Raspberry Pi
Adafruit's Raspberry Pi Lesson 1. Preparing an SD Card for your Raspberry Pi Created by Simon Monk Last updated on 2015-11-25 11:50:13 PM EST Guide Contents Guide Contents Overview You Will Need Downloading
Fondamenti su strumenti di sviluppo per microcontrollori PIC
Fondamenti su strumenti di sviluppo per microcontrollori PIC MPSIM ICE 2000 ICD 2 REAL ICE PICSTART Ad uso interno del corso Elettronica e Telecomunicazioni 1 2 MPLAB SIM /1 MPLAB SIM is a discrete-event
Accurate Measurement of the Mains Electricity Frequency
Accurate Measurement of the Mains Electricity Frequency Dogan Ibrahim Near East University, Faculty of Engineering, Lefkosa, TRNC [email protected] Abstract The frequency of the mains electricity supply
UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation
UPS PIco Uninterruptible Power Supply with Peripherals and I 2 C control Interface to be used with Raspberry Pi B+, A+, B, and A HAT Compliant Raspberry Pi is a trademark of the Raspberry Pi Foundation
Camera Sensor Driver Development And Integration
Camera Sensor Driver Development And Integration Introduction Camera enables multimedia on phones. It is going to be an important human machine interface, adding to augmented reality possibilities on embedded
An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform)
An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform) I'm late I'm late For a very important date. No time to say "Hello, Goodbye". I'm late, I'm late, I'm late. (White Rabbit in
Lab Experiment 1: The LPC 2148 Education Board
Lab Experiment 1: The LPC 2148 Education Board 1 Introduction The aim of this course ECE 425L is to help you understand and utilize the functionalities of ARM7TDMI LPC2148 microcontroller. To do that,
DKWF121 WF121-A 802.11 B/G/N MODULE EVALUATION BOARD
DKWF121 WF121-A 802.11 B/G/N MODULE EVALUATION BOARD PRELIMINARY DATA SHEET Wednesday, 16 May 2012 Version 0.5 Copyright 2000-2012 Bluegiga Technologies All rights reserved. Bluegiga Technologies assumes
A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware
A+ Guide to Managing and Maintaining Your PC, 7e Chapter 1 Introducing Hardware Objectives Learn that a computer requires both hardware and software to work Learn about the many different hardware components
User Guide Win7Zilla
User Guide Win7Zilla Table of contents Section 1: Installation... 3 1.1 System Requirements... 3 1.2 Software Installation... 3 1.3 Uninstalling Win7Zilla software... 3 Section 2: Navigation... 4 2.1 Main
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
C4DI Arduino tutorial 4 Things beginning with the letter i
C4DI Arduino tutorial 4 Things beginning with the letter i If you haven t completed the first three tutorials, it might be wise to do that before attempting this one. This tutorial assumes you are using
User Guide HUAWEI UML397. Welcome to HUAWEI
User Guide HUAWEI UML397 Welcome to HUAWEI 1 Huawei UML397 4G LTE Wireless Modem User Manual CHAPTER 1 BEFORE USING YOUR UML397 WIRELESS MODEM ABOUT THIS USER MANUAL...4 WHAT S INSIDE THE PRODUCT PACKAGE...4
Designing VM2 Application Boards
Designing VM2 Application Boards This document lists some things to consider when designing a custom application board for the VM2 embedded controller. It is intended to complement the VM2 Datasheet. A
Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester
Leonardo Journal of Sciences ISSN 1583-0233 Issue 20, January-June 2012 p. 31-36 Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester Ganesh Sunil NHIVEKAR *, and Ravidra Ramchandra MUDHOLKAR
MeshBee Open Source ZigBee RF Module CookBook
MeshBee Open Source ZigBee RF Module CookBook 2014 Seeed Technology Inc. www.seeedstudio.com 1 Doc Version Date Author Remark v0.1 2014/05/07 Created 2 Table of contents Table of contents Chapter 1: Getting
Qt on Raspberry Pi. Jeff Tranter Integrated Computer Solutions (ICS) Qt Developer Days 2012. www.ics.com
Qt on Raspberry Pi Jeff Tranter Integrated Computer Solutions (ICS) Qt Developer Days 2012 Agenda What is the Raspberry Pi? Raspberry Pi Foundation Hardware Software QtonPi Distribution QtonPi Device Program
ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering
ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering Daniel Estrada Taylor, Dev Harrington, Sekou Harris December 2012 Abstract This document is the final report for ENGI E1112,
Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II
Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II Administration: o Prayer PicBasic Pro Programs Used in This Lesson: o General PicBasic Pro Program
Controlling a Dot Matrix LED Display with a Microcontroller
Controlling a Dot Matrix LED Display with a Microcontroller By Matt Stabile and programming will be explained in general terms as well to allow for adaptation to any comparable microcontroller or LED matrix.
Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide
Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide Sensors LCD Real Time Clock/ Calendar DC Motors Buzzer LED dimming Relay control I2C-FLEXEL PS2 Keyboards Servo Motors IR Remote Control
Ocean Controls RC Servo Motor Controller
Ocean Controls RC Servo Motor Controller RC Servo Motors: RC Servo motors are used in radio-controlled model cars and planes, robotics, special effects, test equipment and industrial automation. At the
How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers
USB to router s serial port How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers by Neo at RouterTech.Org Introduction Routers based on the AR7RD/AR7WRD
Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD www.arexx.com.cn. Six-servo Robot Arm
Six-servo Robot Arm 1 1, Introduction 1.1, Function Briefing Servo robot, as the name suggests, is the six servo motor-driven robot arm. Since the arm has a few joints, we can imagine, our human arm, in
M68EVB908QL4 Development Board for Motorola MC68HC908QL4
M68EVB908QL4 Development Board for Motorola MC68HC908QL4! Axiom Manufacturing 2813 Industrial Lane Garland, TX 75041 Email: [email protected] Web: http://www.axman.com! CONTENTS CAUTIONARY NOTES...3 TERMINOLOGY...3
Animated Lighting Software Overview
Animated Lighting Software Revision 1.0 August 29, 2003 Table of Contents SOFTWARE OVERVIEW 1) Dasher Pro and Animation Director overviews 2) Installing the software 3) Help 4) Configuring the software
UniPi technical documentation REV 1.1
technical documentation REV 1.1 Contents Overview... 2 Description... 3 GPIO port map... 4 Power Requirements... 5 Connecting Raspberry Pi to UniPi... 5 Building blocks... 5 Relays... 5 Digital Inputs...
USBSPYDER08 Discovery Kit for Freescale MC9RS08KA, MC9S08QD and MC9S08QG Microcontrollers User s Manual
USBSPYDER08 Discovery Kit for Freescale MC9RS08KA, MC9S08QD and MC9S08QG Microcontrollers User s Manual Copyright 2007 SofTec Microsystems DC01197 We want your feedback! SofTec Microsystems is always on
E-Blocks Easy Internet Bundle
Page 1 Cover Page Page 2 Flowcode Installing Flowcode Instruction for installing Flowcode can be found inside the installation booklet located inside the Flowcode DVD case. Before starting with the course
AXE114S BINARY CLOCK. revolution Revolution Education Ltd. Email: [email protected] Web: www.rev-ed.co.uk Version 1.1 12/09/08 AXE114.PMD.
AXE114S BINARY CLOCK Features: The PICAXE binary clock kit tells the time by lighting up blue LEDs in a binary pattern. This is a useful tool for teaching students binary code or simply just confusing/
The Programming Interface
: In-System Programming Features Program any AVR MCU In-System Reprogram both data Flash and parameter EEPROM memories Eliminate sockets Simple -wire SPI programming interface Introduction In-System programming
E-Blocks Easy RFID Bundle
Page 1 Cover Page Page 2 Flowcode Installing Flowcode Instruction for installing Flowcode can be found inside the installation booklet located inside the Flowcode DVD case. Before starting with the course
EasyC. Programming Tips
EasyC Programming Tips PART 1: EASYC PROGRAMMING ENVIRONMENT The EasyC package is an integrated development environment for creating C Programs and loading them to run on the Vex Control System. Its Opening
Strato Pi Hardware Guide
Strato Pi Hardware Guide October 2015 Revision 001 a professional expansion board for Raspberry Pi 2 Introduction 3 Features 4 Usage and connections 5 Hardware Installation 5 Strato Pi boards 5 Strato
Vehicle data acquisition using CAN By Henning Olsson, OptimumG [email protected]
Vehicle data acquisition using By Henning Olsson, OptimumG [email protected] Introduction: Data acquisition is one of the best tools to increase the understanding of vehicle behavior. One can
V16 Pro - What s New?
V16 Pro - What s New? Welcome to the V16 Pro. If you re an experienced V16+ and WinScript user, the V16 Pro and WinScript Live will seem like old friends. In fact, the new V16 is designed to be plug compatible
Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs
Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs AN033101-0412 Abstract This describes how to interface the Dallas 1-Wire bus with Zilog s Z8F1680 Series of MCUs as master devices. The Z8F0880,
Tutorial for MPLAB Starter Kit for PIC18F
Tutorial for MPLAB Starter Kit for PIC18F 2006 Microchip Technology Incorporated. All Rights Reserved. WebSeminar Title Slide 1 Welcome to the tutorial for the MPLAB Starter Kit for PIC18F. My name is
Embedded Software Development: Spottbillige Hardware + OSS = Zum Spielen zu Schade!
Embedded Software Development: Spottbillige Hardware + OSS = Zum Spielen zu Schade! Gregor Hohpe www.eaipatterns.com OOP 2012 1 Microcontrollers CPU core, memory, and I/O (analog, digital) on one chip
Software User Guide UG-461
Software User Guide UG-461 One Technology Way P.O. Box 9106 Norwood, MA 02062-9106, U.S.A. Tel: 781.329.4700 Fax: 781.461.3113 www.analog.com ezlinx icoupler Isolated Interface Development Environment
Fall 2009. Lecture 1. Operating Systems: Configuration & Use CIS345. Introduction to Operating Systems. Mostafa Z. Ali. [email protected].
Fall 2009 Lecture 1 Operating Systems: Configuration & Use CIS345 Introduction to Operating Systems Mostafa Z. Ali [email protected] 1-1 Chapter 1 Introduction to Operating Systems An Overview of Microcomputers
User manual DinaSys DTC/DTS and DTC/DTZ
PiCommIT has developed the DinaSys DTC/DTS and DinaSys DTC/DTZ turntable controller for the Fleischmann / Marklin Turntables in scale H0, H0m, TT, N and Z. One of the most important starting point was
In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM-.01. www.rovingnetworks.com 1
RN-WIFLYCR-UM-.01 RN-ISP-UM In-System Programmer 2012 Roving Networks. All rights reserved. Version 1.1 1/19/2012 USER MANUAL www.rovingnetworks.com 1 OVERVIEW You use Roving Networks In-System-Programmer
The Bus (PCI and PCI-Express)
4 Jan, 2008 The Bus (PCI and PCI-Express) The CPU, memory, disks, and all the other devices in a computer have to be able to communicate and exchange data. The technology that connects them is called the
This document is intended to make you familiar with the ServersCheck Monitoring Appliance
ServersCheck Monitoring Appliance Quick Overview This document is intended to make you familiar with the ServersCheck Monitoring Appliance Although it is possible, we highly recommend not to install other
Tutorial for Programming the LEGO MINDSTORMS NXT
Tutorial for Programming the LEGO MINDSTORMS NXT Table of contents 1 LEGO MINDSTORMS Overview 2 Hardware 2.1 The NXT Brick 2.2 The Servo Motors 2.3 The Sensors 3 Software 3.1 Starting a Program 3.2 The
Raspberry Pi Webserver
62 Int'l Conf. Embedded Systems and Applications ESA'15 Raspberry Pi Webserver Max Runia 1, Kanwalinderjit Gagneja 1 1 Department of Computer Science, Southern Oregon University, Ashland, OR, USA Abstract
Amcrest 960H DVR Quick Start Guide
Amcrest 960H DVR Quick Start Guide Welcome Thank you for purchasing our Amcrest 960H DVR! This quick start guide will help you become familiar with our DVR in a very short time. Before installation and
User Guide. Your first steps to smart monitoring
User Guide Your first steps to smart monitoring 2 3 Important safety and legal Information We have taken all measures to ensure the BabyPing Video Monitor meets the highest safety standards but it must
Monitor Your Home With the Raspberry Pi B+
Monitor Your Home With the Raspberry Pi B+ Created by Marc-Olivier Schwartz Last updated on 2015-02-12 03:30:13 PM EST Guide Contents Guide Contents Introduction Hardware & Software Requirements Hardware
Capacitive Touch Lab. Renesas Capacitive Touch Lab R8C/36T-A Family
Renesas Capacitive Touch Lab R8C/36T-A Family Description: This lab will cover the Renesas Touch Solution for embedded capacitive touch systems. This lab will demonstrate how to setup and run a simple
DRV8312-C2-KIT How to Run Guide
DRV8312-C2-KIT How to Run Guide Version 1.1 October 2011 C2000 Systems and Applications Team This Guide explains the steps needed to run the DRV8312-C2-KIT with the software supplied through controlsuite.
Installer guide. Release 2.2
Installer guide Release 2.2 Important safety notice h r j n l s The following safety regulations must be observed at all times. Failure to observe precautions could result in severe injury or death. jj
Frequently Asked Questions for TFT Remote Controlled Monitors. First Rev 4/6/2005 SGMc Second Rev 5/7/2005 Third Rev 11/15/2005
Frequently Asked Questions for TFT Remote Controlled Monitors. First Rev 4/6/2005 SGMc Second Rev 5/7/2005 Third Rev 11/15/2005 1. What was the primary spark that started the fire under TFT to make remote
Next Gen Platform: Team & Mentor Guide
Next Gen Platform: Team & Mentor Guide 1 Introduction For the 2015-2016 season, the FIRST Tech Challenge (FTC) will be adopting a new controller for its robot competitions. The new platform, which will
Cart Interface Installation & Control Board Manual for M38 XP and RX Carts and Legacy M39 Carts
Rubbermaid Medical Solutions Cart Interface Installation & Control Board Manual for M38 XP and RX Carts and Legacy M39 Carts REVISED FEBRUARY 25, 2010 Filename: Cart Interface Installation & Control Board
Pmod peripheral modules are powered by the host via the interface s power and ground pins.
Digilent Pmod Interface Specification Revision: November 20, 2011 1300 NE Henley Court, Suite 3 Pullman, WA 99163 (509) 334 6306 Voice (509) 334 6300 Fax Introduction The Digilent Pmod interface is used
Copyright 2012 by Fen Logic Ltd. All rights reserved.
Copyright 2012 by Fen Logic Ltd. All rights reserved. Gertboard Overview... 5 Labels and Diagrams... 7 Power on the Gertboard... 9 GPIO Pins... 10 Schematics... 11 Test Programs Overview... 11 C Code Overview...
Computer Systems Structure Input/Output
Computer Systems Structure Input/Output Peripherals Computer Central Processing Unit Main Memory Computer Systems Interconnection Communication lines Input Output Ward 1 Ward 2 Examples of I/O Devices
Web Site: www.parallax.com Forums: forums.parallax.com Sales: [email protected] Technical: [email protected]
Web Site: www.parallax.com Forums: forums.parallax.com Sales: [email protected] Technical: [email protected] Office: (916) 624-8333 Fax: (916) 624-8003 Sales: (888) 512-1024 Tech Support: (888) 997-8267
C8051F020 Utilization in an Embedded Digital Design Project Course. Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia
C8051F020 Utilization in an Embedded Digital Design Project Course Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia Abstract In this paper, the utilization of the C8051F020 in an
USB 3.0 4-Port PCI Express Card
USB 3.0 4-Port PCI Express Card User Manual Model: UGT-PC341 All brand names and trademarks are properties of their respective owners www.vantecusa.com Contents: Chapter 1: Introduction... 3 1.1 Product
FLYPORT Wi-Fi 802.11G
FLYPORT Wi-Fi 802.11G System on module 802.11g WIFI - Infrastructure mode - softap mode - Ad hoc mode Microchip PIC 24F 16 bit processor Microchip MRF24WG0MA/MB - Native WiFi 802.11g transceiver - PCB
Freescale Semiconductor, I
nc. Application Note 6/2002 8-Bit Software Development Kit By Jiri Ryba Introduction 8-Bit SDK Overview This application note describes the features and advantages of the 8-bit SDK (software development
How To Program An Nxt Mindstorms On A Computer Or Tablet Computer
NXT Generation Robotics Introductory Worksheets School of Computing University of Kent Copyright c 2010 University of Kent NXT Generation Robotics These worksheets are intended to provide an introduction
AVERSIVE STIMULATION WITH VIDEO MONITORING
AVERSIVE STIMULATION WITH VIDEO MONITORING USERS MANUAL SOF-732-4 User s Manual DOC-155 Rev. 1.0 Copyright 2007 All Rights Reserved MED Associates, Inc. P.O. Box 319 St. Albans, Vermont 05478 www.med-associates.com
An Experimental Study on Pixy CMUcam5 Vision Sensor
LTU-ARISE-2015-01 1 Lawrence Technological University / Autonomous Robotics Institute for Supporting Education - Technical Memo ARISE-2015-01 An Experimental Study on Pixy CMUcam5 Vision Sensor Charles
mdm-mp3 minidirector with MP3 Player
minidirector with MP3 Player User Manual December 15, 2014 V1.02 Copyright Light O Rama, Inc. 2007, 2008 Table of Contents Introduction... 4 What s in the Box... 4 Hardware Utility Version... 5 Important
Advanced LED Controller (LED Chaser)
Advanced LED Controller (LED Chaser) Introduction. Advanced LED controller (also known as LED Chaser) is microcontroller based circuit designed to produce various visual LED light effects by controlling
Multi-Touch Control Wheel Software Development Kit User s Guide
Multi-Touch Control Wheel Software Development Kit User s Guide V3.0 Bulletin #1204 561 Hillgrove Avenue LaGrange, IL 60525 Phone: (708) 354-1040 Fax: (708) 354-2820 E-mail: [email protected] www.grayhill.com/instinct
Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview
Technical Note TN-29-06: NAND Flash Controller on Spartan-3 Overview Micron NAND Flash Controller via Xilinx Spartan -3 FPGA Overview As mobile product capabilities continue to expand, so does the demand
BUILDING INSTRUCTIONS
etap2hw 38 mm I2C to LCD Interface BUILDING INSTRUCTIONS October 2013 P. Verbruggen Rev 1.01 15-Oct-13 Page 1 Table of Contents Chapter 1 General Information 1.1 ESD Precautions 1.2 Further Supplies 1.3
Raspberry Pi. Hans- Petter Halvorsen, M.Sc.
Raspberry Pi Hans- Petter Halvorsen, M.Sc. Raspberry Pi 2 https://www.raspberrypi.org https://dev.windows.com/iot Hans- Petter Halvorsen, M.Sc. Raspberry Pi 2 - Overview The Raspberry Pi 2 is a low cost,
Wash Select II to WashPay Integration Field Retrofit Installation Guide
Wash Select II to WashPay Integration Field Retrofit Installation Guide Wash Select II Software Version 6.00 and above POS4000 Software Version 8.25 Unitec www.startwithunitec.com WASH SELECT II TO WASHPAY
Serial Communications
Serial Communications 1 Serial Communication Introduction Serial communication buses Asynchronous and synchronous communication UART block diagram UART clock requirements Programming the UARTs Operation
Model 5511 Filler Controller User s Manual Version 1.1 October 2011
Thompson Scale Company WEIGHING SYSTEMS & PACKAGING MACHINERY CONTROLS 2758 Bingle Road Houston, Texas 77055 Phone: 713/932-9071 Fax: 713/932-9379 www.thompsonscale.com Model 5511 Filler Controller User
Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]
Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205] Users Manual Robokits India [email protected] http://www.robokitsworld.com Page 1 Bluetooth + USB 16 Servo Controller is used to control up to
The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.
The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit. Micro Wizard has been manufacturing Pinewood Derby timers for over 10 years.
Raspberry Pi Adding a Real Time Clock (RTC)
Raspberry Pi Adding a Real Time Clock (RTC) Level of difficulty: Beginner Hardware: Raspberry Pi Model B, RTC Module, wires, optional connectors Tools required: Wire cutters, soldering iron Project cost:
Ways to Use USB in Embedded Systems
Ways to Use USB in Embedded Systems by Yingbo Hu, R&D Embedded Engineer and Ralph Moore, President of Micro Digital Universal Serial Bus (USB) is a connectivity specification that provides ease of use,
Communicating with devices
Introduction to I/O Where does the data for our CPU and memory come from or go to? Computers communicate with the outside world via I/O devices. Input devices supply computers with data to operate on.
Access Control Using Smartcard And Passcode
IOSR Journal of Electrical and Electronics Engineering (IOSR-JEEE) e-issn: 2278-1676 Volume 4, Issue 5 (Jan. - Feb. 2013), PP 29-34 Access Control Using Smartcard And Passcode Omorogiuwa Eseosa 1., Uhunmwangho
Massachusetts Institute of Technology
Objectives Massachusetts Institute of Technology Robotics: Science and Systems I Lab 1: System Overview and Introduction to the µorcboard Distributed: February 4, 2015, 3:30pm Checkoffs due: February 9,
