2017-04-15

Power Logger

The power meter I have in my basement has a LED that blinks once every Wh. With a consuption of 3600W it will blink once every second. By logging the clock time at every blink it is possible to get a good overview of the consuption, both momentarily and over time.

The logger I have built is based on the Raspberry Pi Zero W. The LED sensor consists of a photo resistor and an transistor. It is connected to GPIO on the Raspberry Pi. An optional 16x2 LCD display is used to display the IP address of the logger and the current power consuption. A button is used to turn on the LCD backlight. Blink timestamps are logged to file and the data can be viewed in a Web GUI.

Mechanical Design

There is not much to say about the mechanical design. The LCD is attached to the RPi with a single M4 bolt and nuts. The logger and the sensor is attached with blu-tac to the power meter. The photo resistor have long legs that are bendable and can be used to finetune its position in front of the LED.

Electrical Design

The LED sensor is designed using a GL5528 photoresistor and a BC337 transistor to amplify the signal. The transistor collector and the photoresistor are powered with 3.3V from the RPi. The unpowered side of the photoresistor is connected to the transistor base. Without light on the photoresistor, the transistor will be closed and logical 0 will be measured by RPi GPIO 10 connected to the emitter. With light on the resistor, the transistor will open and logical 1 will be measured on RPi GPIO 10.


The 16x2 LCD is powered by 5V from the RPi and connected to GPIO in the following way.

RS - GPIO 25
EN - GPIO 24
D4 - GPIO 23
D5 - GPIO 17
D6 - GPIO 21
D7 - GPIO 22
BACKLIGHT (K) - GPIO 4

More information about LCD and RPi can be found at [1].

A switch is connected to GPIO 16 and GND to be used to turn on LCD baklight.

Software Design

See the GitHub project [2].

References

[1] https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring
[2] https://github.com/TheOtherMarcus/PowerLogger

2017-04-02

Designing a Turtle

In the seventies, Seymour Papert invented LOGO as a teaching tool for computer programming, encouraging exploration and interactivity. The accompanying Turtle robot could draw sketches on paper, creating a tangible thing from the programming effort. Now, the concept has been recreated on a platform base on Raspberry Pi and Python.

The prototype Turtle

The prototype is more complicated than it has to be, mostly due to the fact that Raspberry Pi model A doesn't have built in Wifi and can't even supply a USB Wifi dongle with enough power on its own. Today the amazing Raspberry Pi Zero W can be used instead.

Development Environment

The Turtle is programmed using a Web IDE running on the robot itself.

The Integrated Development Enviroment

The IDE makes it possible to edit and run code on the Turtle. A history of executed programs are saved to make it easy to go back to an earlier version. It is also possible to save a program using a descriptive name. The console output of the running code is displayed in a separate text area to simplify debugging.

More than one person can program a single Turtle at the same time if they have one computer or tablet each and take turns running programs.

Mechanical Design

Wheels from inline skates are perfect for the Turtle. They are narrow with good friction which makes the robot turn in a tight and controlled way. To attach a wheel to a stepper motor shaft you need a mounting hub [6]. It is unlikely that you will find a hub that matches the holes on the wheels. I used a 1mm thick steel plate to adapt the mounting holes on the hub to the wheel.

Two stepper motors are used to drive the front wheels. The drawing pen needs to be centered between the motors for the Turtle to be able to turn on the spot without moving the pen. The pen should also be possible to lift to be able to move the robot without drawing a line. I found two copper plumbing parts in the local hardware store that fit perfectly together without getting stuck or fall through. I attached the pen to the narrow conical tube and placed six of the larger tubes between the motors. I strapped it all together with cable ties and used some blu-tac between the tubes to increase the friction.

On top of the engine pack I attached a 1mm thick steel plate to hold the electronics. Steel is probably not optimal for the Wifi signal and I would choose wood or plastic today.

As third supporting wheel I used a bearing ball but anything with low friction works fine.

The servo motor that is used to lift the pen is attached to a vertical steel plate that is glued to the base plate. Rubber bands push the pen down. The servo arm pulls a thread to lift the pen.

Electrical Design

The Turtle is powered by a rechargeable racing pack delivering 12V DC. To get the 5V DC that the Raspberry Pi requires, dual 5V/1A regulators [7] are used, one powering the Raspberry Pi and one powering the Wifi dongle through the USB hub.

The stepper motors are 200 steps/revolution, 12V DC. I use Easy Driver [8] to drive the stepper motors, one per motor. The STEP and DIR pins are connected to Raspberry Pi GPIO.

The servo that lifts the pen runs on 5V DC and is connected to the same converter that drives the Raspberry Pi. The signal wire is connected to Raspberry Pi GPIO.

Software Design

Install Raspbian: [1]

Setup headless networking: [2] [9]

Change keyboard layout:
sudo vi /etc/default/keyboard
sudo setupcon
sudo reboot

Install the IDE: [3]

References

[1] https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
[2] https://davidmaitland.me/2015/12/raspberry-pi-zero-headless-setup/
[3] https://github.com/TheOtherMarcus/TurtleIDE
[4] https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
[5] http://abyz.co.uk/rpi/pigpio/
[6] https://www.sparkfun.com/products/10006
[7] https://www.kjell.com/se/sortiment/el-verktyg/elektronik/halvledare/spanningsregulatorer/spanningsregulator-ua7805-p90061
[8] http://www.schmalzhaus.com/EasyDriver/
[9] http://tech.scargill.net/pi-zero-wi-fi-automatic-reconnect/