RS3Finished

Finally have all of the connections wired and (more or less) tested. I’ve added LEDs to the running lights and servos (not shown) to control the couplers. Just need to add about 11oz or so to the fuel tank and put it all back together for final testing. I’ve attached a programming cable to the microcontroller board so I can download new builds or tweak the s/w if required. Phew. This has been quite a bit of development. The control widget itself went through many interations (see controlwidgets.com) as did the power board. I’ve settled on the Pololu 18v7 programmed to only give forward motion with a relay switching between forward and backward. Anyhow, soon we will be doing some real world testing.

arduniowifi

This is a nice board but a little mysterious to get working. Or at least like I want it to. But I’m getting there. The Xbee is just so much easier for what I want to do in terms of a high speed real time network without all the overhead of access points, tcp/ip and all that jazz. BUT, I’m hoping this chip will allow direct control of my widget (and all it’s connected servos and other devices) direct from a smartphone or tablet. It should also provide a gateway from the Xbee network to the 802.11 network without the raspberry Pi. We shall see. Nevertheless, I really enjoy playing with new gadgets like this so I’m having a blast.

terminal

I’ve come up with a very basic uart library for the widget called obviously enough, wiFlyUartLibrary. You can find it on the control widgets files page.

Here is a listing of the Ardunio code that turns the widget (with the help of the serial port on the USB programmer) into a local terminal for the WiFly Module:



#include <WiFlyUart.h>

WiFlyUart wifi;

void setup()
{
  wifi.Initialize();
  wifi.enableRX1IRQ();
  wifi.enableRX0IRQ();
  sei();
}

void loop()
{
  uint8_t data;
  
  data = wifi.getByte1();
  if (data != 0xff)
  {
    wifi.sendByte0(data);
  }
  
  data = wifi.getByte0();
  if (data != 0xff)
  {
    wifi.sendByte1(data);
  }

}


All the schematics and source code for this are on my controlwidgets.com page.


pygame

I also have been exploring a way to make apps for my Android Tablet. I’ve tried all sorts of development things like Eclipse and Android Studio and Xamarin and PhoneGap and all that and I really like, I prefer just because its simple and easy, is Python and PyGame for Android. Here are several links:

Here is the initial download for Pygame, I use Python 2.7 32 bit for this.
PyGame for Python

This is an add-on to allow you to develop android apps using Python and PyGame.
PyGame for Android Subset

There is also a library of widgets (sliders, dropdowns, buttons, etc) for PyGame called PGU that will also work on Android, IF you make a few changes to it:
Phils Game Utilities

And this link has the changes you will need to make to PGU so it works on Android:
PGU Modifications for Android


This is the python code to display one slider and send it via a socket to the Wifly module:



import pygame
from pgu import gui
import socket
from pygame.locals import *

# Import the android module. If we can't import it, set it to None - this
# lets us test it, and check to see if we want android-specific behavior.
try:
    import android
except ImportError:
    android = None

TIMEREVENT = pygame.USEREVENT
FPS = 30
screen = pygame.display.set_mode((800,480),SWSURFACE)

 # Map the back button to the escape key.
if android:
   android.init()
   android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE)

# set the timeout to 1 second, just in case it's not there
socket.setdefaulttimeout(0.25)

# open a connection to the AP in the locomotive
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    s.connect(('10.20.10.1',2000))
    print "connected to 10.20.10.1"
except:
    pass
        
class screenContainer(gui.Table):
    def __init__(self,**params):
        gui.Table.__init__(self,**params)

        fg = (255,255,255)
        self.tr()
        self.td(gui.Label("Speed: ",color=fg),align=1)
        e = gui.HSlider(100, 0, 500, size=20,width=700,height=80,name='speed')
        e.connect(gui.CHANGE, self.adjustSliderA, (0,e))
        self.td(e)
        self.sv = 0

    def adjustSliderA( self, value):
        (num, slider) = value
        self.sv = slider.value

    def SliderValueA( self ):
        return self.sv
        

app = gui.App()
sc = screenContainer()
c = gui.Container(width=200,height=180)
c.add(sc,0,0)
app.init(c)

pygame.time.set_timer(TIMEREVENT, 1000 / FPS)

##$$$
pygame.init()
 
done = False

while not done:

     for ev in pygame.event.get():
    
        if ev.type == TIMEREVENT:
            screen.fill((100,0,0))
            app.paint()
            pygame.display.flip()
            
        elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_ESCAPE:
            done = True
            break
        else:
            app.event(ev)
            v = str(sc.SliderValueA()) + "rn"
            s.send(v)

pygame.quit()


powerboard

Main power board I’m working on for my Aristocraft RS-3. I removed all the old radio R/C gear and the nimh batteries and am replacing it with a new control widget, this board, the pololu motor controller (on the right) and a big 5000mah lipo. Should be interesting.

hhd-A
hhd-B

Here is my latest stand-alone hand-held-throttle design. It’s based on my control widget thing and I (finally) have it all working.

All the circuits and keyboard are mounted on a 3D printed faceplate with a 3D printed back enclosure. It still needs some structural work, screws to hold the face plate on and I need to mount the power switch too, not sure where that should go.

There is some hard-coded stuff in the handheld software but it does work quite well. I also have a slight design gotcha on my USB interface into this thing but I’ll get that solved soon.

pir-widget

I’m really enjoying my widget PCB design. Simple, cheap, easy bake oven for SOIC, program in C, add an Xbee for wireless real-time control, how cool is that? Here I have one hooked up to a parallax IR motion sensor. With a bit of C code it controls the servo based on the input from the motion sensor. Think railroad crossing signals- that crossing arm that comes dowm and blocks the traffic, right?

Anyhow, great fun and a good project to post over to controlwidgets.com

I’m looking at a $9 retail for board and components. Software will be free and open source. Of course :)