Category Archives: Raspberry Pi

Ports of The Dalek

I’ve decided on what interfaces the Pi-Dalek will mounted on the rear of the case.

  • USB-B socket to accept power for chrging the internal battery (a mobile phone emergency charger. Internally the socket offers a USB-A socket which is connected to the Pi with a short USB-A-to-microUSB-B cable, then the emergency charger, then another short USB-A-to-microUSB-B cable.
  • USB-A socket for memory sticks etc. Connected to the UTG socket with a short UTG cable.
  • HDMI socket. Connected to the miniHDMI socket on the Pi with a short adapter cable.

These will be mounted on the arse-end of the Dalek.  Two on the 3rd row up of the Dalek-bumps on the rear panel (both USB ports), with the HDMI socket on one of the rear flank quarters (3rd row up).

Ideally I’d like them all on the back, but the bumps on row 1 are blocked by the motor housing, while rows 2 and 4 have far too many structual bits behind it.

This still leaves me with the issue of mounting the camera. While I’d love to have the camera mounted to the eyestalk, this is impractical.  Mainly as the eyestalk is missing, but also because the camera module is a huge square blob that wouldn’t look right.

The best I can hope is to mount the camera on the Glacis, between the Whisk and Plunger, just above the top of the skirt. It will still mean that some cutting will have to be done, but it will probably not look as awful.

I’ve also decided that instead of mounting the Pi and Motozero directly to the base chassis, I’ll mount them upside down hanging from the internal ceiling at the top of the skirt. This shortens the distance to where I want the camera to be, and means only 6 wires need to be run down to the base (motor power +/-, motor left +/- and motor right +/-). Everything else will be skirt mounted. So the 40pin GPIO header connection twixt Pi and Motozero forms the split in the arrangement.

A sort of split between the head and body, if you want to make up some sort of analogy up.

I’m sure there’ll be some photos of it when its done.

 

Installing Raspbian on a Pi-zero W

There is so simple way to do this. I’ve tried several times and failed each time. So here is my idea to make things easy.

    1. Download your prefered Raspbian Jessie version from https://www.raspberrypi.org/downloads/raspbian/ be it Lite or with Pixel.
    2. Get and install Etcher, and use that to burn your image to the microSD card.
    3. Remount the SD card and create a file on it called “ssh”.  Create another file called “wpa_supplicant.conf” with contains:
      update_config=1
      ctrl_interface=/var/run/wpa_supplicant
      
      network={
               scan_ssid=1
               ssid="yournetworkname"
               psk="yourpassword"
      }
      
    4. This should enable you to boot the Zero-W. It should then get an an address for your LAN via DHCP. All you have to do is check you router, or use Fing (or something like it ) to find it.

IT DOESN’T WORK!

Ah. Do you have another Pi with a wired connection somewhere about the place? Good.

Pop your microSD card from your new Pi-zero into an adapter and boot your other Pi (in my case one of my KODI boxes) and boot it.

Find the machine on your network and login (“pi” and “root” have the password “raspberry”).

As root, run

apt-get update
apt-get upgrade

And, while you have a wired connection, install Apache2 and PHP5.

apt-get install apache2
apt-get install php5

Set your new hostname in /etc/hostname now, so you’ll ne able to identify it later.

After thats done, shut it down, pop the card into the Pi-Zero W, and it should come up and appear on your network.

From Fing or your hub you should be able to get the MAC address and add the to your DHCP.

And it should all work.

Additional note concerning #3 above. If you are planning to use it on more that one WiFi network (example: I use my home network, and also the hotspot on my phone if I’m working on it anywhere but at home), your wpa_supplicant.conf file can contain multiple network entries.  Thusly:

update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
         scan_ssid=1
         ssid="yournetworkname"
         psk="yourpassword"
}
network={
         scan_ssid=1
         ssid="yourhotspotnetworkname"
         psk="yourhotspotpassword"
}

Put the entries in order of preference.

Resurrection of the Dalek

At last I can paraphrase a Doctor Who serial title again.

This time I’m going to be using a Raspberry Pi-Zero W with MotoZero control board. Gone are the attempts at bashing by own circuitry (which are already in the Model Railway control system anyway), and this time IT WILL WORK!

So, the ingredients for *this* incarnation of the Dalek are:

For now I’ll forego the distance sensors, as I’ve already bashed them into a sort of thermin idea.

Anyway, the key stages for this project are:

To make things easier to track, the new Category Pi-Dalek has been created.

 

Daleks Never Retreat

I’ve thought again about the problem of not being able to do bi-directional motors on the Dalek Project when using just one Piface Digital.

Why should the motors need to run backwards? Daleks never retreat! The only controls I’m going to need are Forward! Advance Left! and Advance Right! (and Exterminate!)

Looking back (which is something that Daleks can’t do anyway), the whole full movement thing came from my idea to build an Arduino Turtle (which was based on an idea developed from a Spectrum project from about 1985). But a Turtle is not a Dalek. Sure, they both have a hard shell and two driving wheels, but that is where the similarity ends.

So now we just need a web interface to control the Dalek’s movements forward, and to the sides a bit. All the while we need to be able to see what the Dalek sees from the on-board camera

 

Raspberry Pi Camera Module (of the Dalek)

So now I’ve bought the Camera Module for the Raspberry Pi. I got mine from Amazon, mainly as I was putting in a big order and was drunk enough to tag it on to the end.

raspberry-pi-camera

Getting the damn thing set up and streaming video through a web page was a Pain In The Arse (which I know about)!

The only resource I could find that worked was Miguel Grinberg’s guide, but I still had problems with that. I suggest that you read his site, as it contains a lot more information. My version, below, is a quick run through, more for me to refer back to than anything else.

1. Build and Install the software

Run the following as root:

$ apt-get install libjpeg8-dev imagemagick libv4l-dev
$ ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
$ wget http://sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip
$ unzip mjpg-streamer-code-182.zip
$ cd mjpg-streamer-code-182/mjpg-streamer $ make mjpg_streamer input_file.so output_http.so
$ sudo cp mjpg_streamer /usr/local/bin $ sudo cp output_http.so input_file.so /usr/local/lib/ $ sudo cp -R www /usr/local/www

2. Start the Camera and Streamer

Starting “raspistill” as suggested in Miguel’s guide dumped a lot of text to my xterm, making things really annoying, so I installed “screen” and ran the Camera software and the streamer in a different “screen”, which would also keep running after I logged off the machine (follow the oncreen prompts when you see them):

$ apt-get install screen
$ screen
$ mkdir /tmp/stream
$ raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 &
$ LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg"
-o "output_http.so -w /usr/local/www" & 

Dropping out of “screen” ( CRTL-A CTRL-D ) and back to a command prompt, and its all done.

3. Viewing the Stream

Fire up your favourite Browser (which I hope is Firefox) and access the site generate by th Pi. As the eventual goal of this whole thing a Wifi controlled toy Dalek drone, the hostname is “dalek”. Thus, on my network the address is:

http://dalek:8080/

You’ll have to substitute dalek for either the name of the machine on your network, or the IP address, eg:

http://192.168.0.203:8080/

You should be getting a web page with instructions on how it all works.

Short Version:

To grab a single from the camera:

http://dalek:8080/?action=snapshot

To grab streaming video:

http://dalek:8080/?action=stream

There other things you can play with, but those two are the only ones relevant to my little project.

Finally, an example of a still picture from the camera:

192.168.0.203

(Once again, full credit to Miguel Grinberg and his excellent guide.)

The Arduino Dalek Is Dead – Long Live The Raspberry Dalek

Well, it has been nearly two years since I looked at the Dalek project.

Last time I was looking at using a Raspberry Pi to control the Arduino, which would in turn control the motors in the Dalek.

Since then, I build my own Shield to fit the Arduino (and munged up the circuit design, rendering it useless), repurposed the USB camera that I bought to use in a security system, moved house, and generally forgot about the whole thing.

I’ve had a rethink over the last few days about the whole thing, and looking back on past ideas, I’ve come up with some better ones…

I’m replacing the Arduino with a PiFace Digital. This will solve most of the power problems. That, along with a Camera Module designed for the Pi will cut down on the USB sockets needed.

Pi with Piface Digital
Pi with Piface Digital

Next, for connectivity, I’m only having a WiFi dongle on the Pi, and a wired Ethernet socket on the outside case. Anything else is really going to be superfluous.

The question is, though, should it act as a WiFi hub, or should it connect to my existing network?

As the Piface Digital only has two SPDT relays on board, I’m going to use those to control the power on/off for the motors for now, just giving me forward movement for now. Eventually I plan to enable bi-direction operation on both motors, as was the case with the Arduino Dalek project before I made a balls-up of soldering the circuit. This time I won’t be trying to cram it all onto one small board, so it won’t be as hard to mess with.

A problem I have come across is that, unsurprisingly, the Piface Digital does not have any analogue inputs. This is going to make the distance sensors difficult to implement for now. I’m sure I’ll come up with something though.

So, for now the immediate goals are:

  • Get the motors working in one direction.
  • Get the Pi to either connect to my existing wireless network, or act as a WiFi hub

The Arduino Dalek Master Plan – Episode 2

Looking back on my grand ideas, I’ve decided on a bit of a change of plan.

The current scheme will not have ports for video, or extraneous USB holes for keyboards and things of that ilk.

The current list of ports to stick on the Dalek is:

  • Ethernet – as i think I’ll need it in case the wifi fails
  • USB (using the already fitted port) for power while testing

The Raspberry will need USB for these:

  • Connection to the Arduino
  • Connection to the webcam (unless i can get a camera that uses the on-board connection)
  • Some form of microphone

So it still looks like I’ll need an unpowered hub.

It will also need a speaker connection for whatever sound output I decide to use.

Also, at some point i intend to get the ear lights working again.