Getting games to work on Raspberry Pi

For a while, I was unable to get any games to play on raspberry pi, and whenever I tried to get to where you actually were playing them, the games and everything would freeze up. I found a simple solution to that issue. Just add this little line of code to the bottom of /boot/config.txt and it should fix it.

gpu_mem=128

I kept having problems with playing descent and quake 3 arena due to this issue, but that little patch was all that it took to fix it.

edit: Alternatively you can use the line below and just paste it onto the command line and press enter, and it does it all for you.

sudo sh -c  “echo ‘gpu_mem=128’ >> /boot/config.txt”

Reading CPU temps using python for Raspberry Pi

earlier, I found this, and thought it was cool so I modified it a bit to work how I needed it to.

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=22180

and here is my modification:

#!/usr/bin/env python
import os

# Return CPU temperature as a character string
def getCPUtemperature():
res = os.popen(‘vcgencmd measure_temp’).readline()
return(res.replace(“temp=”,””).replace(“‘C\n”,””))

temp1=int(float(getCPUtemperature()))
temp2= 9.0/5.0*temp1+32
print temp1,”C”, “\n”,  temp2,”F”

Now I can have an IF statement watch the temperature and if it goes above a certain temp, I can turn on a GPIO pin using RPI.GPIO package, or anything I wanted to do with it. I figured I’d share this little trick with everyone. 😛

ps. if the guy that wrote the original function part ever reads this, thank you so much for that 😛

Raspberry Pi and the Serial Port

By default the Raspberry Pi’s serial port is configured to be used for console input/output. Whilst this is useful if you want to login using the serial port, it means you can’t use the Serial Port in your programs. To be able to use the serial port to connect and talk to other devices (e.g. Arduino), the serial port console login needs to be disabled.

Needless to say you will need some other way to login to the Raspberry Pi, and we suggest doing this over the network using an SSH connection.

Disable Serial Port Login

To enable the serial port for your own use you need to disable login on the port. There are two files that need to be edited

The first and main one is /etc/inittab

This file has the command to enable the login prompt and this needs to be disabled. Edit the file and move to the end of the file. You will see a line similar to

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable it by adding a # character to the beginning. Save the file.

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable Bootup Info

When the Raspberry Pi boots up, all the bootup information is sent to the serial port. Disabling this bootup information is optional and you may want to leave this enabled as it is sometimes useful to see what is happening at bootup. If you have a device connected (i.e. Arduino) at bootup, it will receive this information over the serial port, so it is up to you to decide whether this is a problem or not.

You can disable it by editing the file /boot/cmdline.txt

The contents of the file look like this

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Remove all references to ttyAMA0 (which is the name of the serial port). The file will now look like this

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Reboot

In order you enable the changes you have made, you will need to reboot the Raspberry Pi

sudo shutdown -r now

Test the Serial Port

A great way to test out the serial port is to use the minicom program. If you dont have this installed run

sudo apt-get install minicom

Connect your PC to the Raspberry Pi serial port using an appropriate serial port adapter and wiring, then open Putty or a similar serial terminal program on PC side. Setup a connection using the serial port at 9600 baud.

Now run up minicom on the Raspberry Pi using

minicom -b 9600 -o -D /dev/ttyAMA0

What you type into the minicom terminal screen should appear on the serial PC terminal and vice versa.

This info was mirrored from this site:

http://www.hobbytronics.co.uk/raspberry-pi-serial-port

Best tools that Ive found for electronics

You all knew this was coming eventually, but here is a post about the most useful tools that Ive found for electronics.

1. Large size breadboard, found on ebay for 34 dollars and well worth it.

2. AASaver, takes 2 dead AA batteries and turns them into clean 5v or 3v output. I used to go through 3-4 9v batteries a month, and ever since I started using this, Ive had the same pair of batteries that my digital camera said were dead in it for the last 9 months.

http://rayshobby.net/aasaver

3. Large spool of single strand telephone wire, found this in someone’s trash, but you can cut little pieces of it off and use it in a breadboard or for wiring everything up.

4. XMEGA Xprotolab, it works as an oscilloscope, function generator, logic analyzer, and much more. It’s about the size of a large stamp, but the display is very clear and seems to work really well. Ive had mine for a few months now, and have only had one issue with it, everything Ive seen says it will only handle 3v inputs on logic analyzer function, so I just use a 3v zener diode and a 330 ohm resistor, just like in the raspberry pi GPIO pins post. No biggie 😛 Other than that, the thing works good, it’s fast can can handle up to Mhz speeds, which I just use it to see 38-40Khz for modulated IR, and seeing serial data to diagnose wireless connection issues.

http://www.gabotronics.com/development-boards/xmega-xprotolab.htm

as I think of the other things, Ill add them up to the list.

Cute robots



My top list of favorite cute robots

PS. The first one isnt from batteries not included as much as we wish it was 😛

Raspberry Pi GPIO pins

Here is a list of the GPIO pins on the Raspberry Pi that can be used, the GPIO names, and the ones that are reserved.

Image

Here is a basic regulator circuit that works for me instead of using the level converters/mosfet level shifters. it was found on the raspberry pi site, but figured I’d post it here for reference.

Image

16F628A pinout and basic stuff

Image

here is the pinout of the 16F628A PIC chip, VDD is +5v only, VSS is ground, MCLR is reset pin, just tie that to +5v.

when you open microcode studio, just select the 16f628a from the dropdown box at the top, and write your code.

to use PortA as digital and not the analog comparators, which is what you use for robotics and such, add this to the top of your code.

Just copy/paste it at the top.

@ __config _XT_OSC & _BODEN_OFF & _WDT_OFF & _PWRTE_OFF & _LVP_OFF
CMCON = 7
VRCON = 0

The 7805 regulators, looking at the front of it, the pinout going from left to right is

1. input, 2. ground, 3. +5v regulated out.

You’ll need the mplabs stuff installed to use that stuff, when you go to compile the code, it’ll try to autofind it.

In all, the programs that should be installed are picbasic pro, microcode studio, and mplab, and the programmer software.

here’s the basic layout for the pic chips with the crystal and capacitors, the capacitors for the crystals are labeled 22 for 22pf, and are the smaller ones, the 104 ones are 0.1uf and used for power filtering.

index index2

just dont worry about the diode on the 7805, it’s added to add more current as an output, and the 330n one can be replaced with one of the 1uF caps.

there’s alot of code examples in C:/pbp/samples, or in the microcode studio folder which should show up as soon as you click open in microcode studio

More from MakerFaire 2012

These ones were taken from the digital camera.

Links for PIC based robots

Here’s a few links Ive found that shows basic PIC based robots and how they’re made. There’s also a few PBP example programs to show how to use the language.

http://melabs.com/samples/index.htm

http://www.picbasic.co.uk/forum/forumdisplay.php?f=4

http://www.rentron.com/Micro-Bot/index.htm

http://web.archive.org/web/20041020030528/http://www.geocities.com/SiliconValley/Orchard/6633/robots.html

http://www.cornerstonerobotics.org/picbasic.php

MakerFaire 2012

These were taking from my cell phone.