A couple of sitting figures I’m working on…
Archives
All posts by admin
I’ve started some development for a new throttle controller, this one is based on an Android tablet for the user interface. My approach is a bit different than what is out there for tablets and smartphones though. I don’t like ‘sliders’ on a touch screen for controlling vehicles, so the idea here is to interface a small analog joystick (the parallax unit) and a potentiometer to do the actual control. The tablet will be used to pull up user interface screens for the locomotives and also have screens for controlling other things.
Basically, I’ve connected a generic bluetooth interface (about $10) to my Xbee Widget controller. The Widget can be configured to have up to 8 analog inputs, I’m using 3 of them here. I have the bluetooth interface on the spare serial port. On the other serial port is the Xbee which actually sends the commands to the locomotive.
I’m using PyGame to build Android apps with because I love Python!
Right now, the only thing on the screen that actually works is the speedometer. This is a screen shot of a Positive Train Control screen I dug up on the internet. I’m not sure what most of the other things on there are so this is just for playing around for now. But hey, it looks neat!
So anyhow, since I looked high and low and found ONE reference on how to scan the BT devices with Python, I decided to post up some python source to help out anyone looking to do this. As with most Python things, it’s really quite easy once you get the particulars ironed out.
To use this, just pass in the name of your bt device after you instantiate it. This is the same name you see when you pair your device with your tablet. In my case, it’s ‘HC-06’.
bluetooth = Bluetooth()
bluetooth.prepare("HC-06")
bluetooth.write("--testmessage--")
Here is the method. Note that the UUID in the device create is the same for all BT devices (as far as I know).
Jnius is a nice package that lets you call Java from Python so this could be used for other things besides Bluetooth I guess, but that’s another project. I really detest Java so anything I can do to write Android apps in python is great.
#
# Bluetooth interface class for PyGame- Python Android Games and Graphics development
# you will need the jnius python library to use this
#
import pygame
import sqlite3
import math
try:
import android
from jnius import autoclass
except:
android = None
class Bluetooth:
def __init__(self):
self.BluetoothAdapter = autoclass('android.bluetooth.BluetoothAdapter')
self.BluetoothDevice = autoclass('android.bluetooth.BluetoothDevice')
self.BluetoothSocket = autoclass('android.bluetooth.BluetoothSocket')
self.UUID = autoclass('java.util.UUID')
self.deviceValid = False
def prepare(self, name):
paired_devices = self.BluetoothAdapter.getDefaultAdapter().getBondedDevices().toArray()
for device in paired_devices:
if device.getName() == name:
self.socket = device.createRfcommSocketToServiceRecord(self.UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"))
self.recv_stream = self.socket.getInputStream()
self.send_stream = self.socket.getOutputStream()
self.socket.connect()
self.deviceValid = True
def write(self, sendString):
if self.deviceValid:
self.send_stream.write([ord(b) if ord(b) <= 127 else ord(b)-256 for b in sendString])
def read(self):
datastring = ""
if self.deviceValid:
c = self.recv_stream.available()
if c > 0:
for i in range(c):
datastring = datastring + chr(self.recv_stream.read())
return datastring
def close(self):
if self.deviceValid:
self.socket.close()
Finally got my control system tested out in the woods. Very happy with the range. The Xbee will do 300ft and I can’t even see the RS3 if I go that far away. This is my controlwidgets.com design. All the wireless communications are handled by the Xbee. I can send any sort of data to or from anything with this system in real time. Those are 16 byte data packets that are controlling the throttle and coupler servos.
The RS3 has the throttle, front and rear couplers and single channel sound all hooked up and working. All of it is powered by a 5000mah hour LiPoly battery driving a Pololu 18v7 motor controller. The control widget drives the servos directly. There is also an RFID reader under the fuel tank which works quite well too.
The results of my latest attempt at mold making and resin casting. 3D print original and his clones. These guys are about 2.5 inches tall or 6 ft in 1:29 G Scale.
I’m trying to get these to a point where I can make consistent resin casts from 3D figure models.
Anyhow, this is the sixth or seventh? iteration of mold making and so far the best. I do think I need to explore some of the finer points of this process but for now I’m finally getting decent results.
Buy my 3D Printed Peoples from Shapeways
More 3D People here
I guess this counts as engineering so I’ll post a quick update here. I’ve finally started to lay a bit of track on my Gilbert Virginia ‘Layout Design Element’. You can find a few more pictures and some info by following this link – Laying Track in Gilbert.
3D Printed Foreman looks over the latest oven fresh widget, complete with 1634R-SU and the Xbee Series 1 with wire antenna. Programmed and tested. The figure is 2.4 inches tall for perspective.
Well, I got tired of Makerbots at the library that were always busy or broken, and the UPrints in the Engineering Lab were basically junk for printing 1:29 size figures.
So, I uploaded my Fab Four 3D peoples to Shapeways this time and man, I am glad I did. Much better resolution, really nice. Need a bit more facial detail for the two on the left but that’s not something I could even see on the other prints!