Knex clockwork

My kids have been watching and watching old “The Secret Life of Machines” videos (Tim Hunkin, you are an inspiration!!!) and they’re really in love with clocks thanks to “The secret life of the quartz watch“.  Their enthusiasm drove me to it!  I had to make a simple escapement, pendulum, and frequency divider er…  gear reduction.  All done with mostly Knex toys and some hot glue and popsicle sticks to stiffen the escapement.

Posted in change | Leave a comment

Breakthrough on sugo-nxt with NXShield

I decided I’d try another configuration for the sensors and ports.  It worked!  Here is the new port usage:

  • Eyes (DROD40) -> BAS2
  • Left line sensor (NXT Light) -> BBS2
  • Right line sensor (NXT Light) -> BBS1

Motor port usage:

  • Left servo -> Bank A – M1
  • Right servo -> Bank B – M1

I’m not sure of the origin of the problem, however, when I had the DROD40 (passive light) sensor on the same bank (bank a) as a stock NXT light sensor my program would hang while initializing the sensors.  Or, in some configurations, I’d get faulty numbers from the DROD40.  I’ll get some input from OpenElectrons.com on the interoperability of the DROD40, NXT light, and NXShield and share what I hear.

Here’s the current code:

#include <Wire.h>
#include <NXShield.h>
#include <NXTLight.h>

NXShield    nxshield;
NXTLight    eyes;
NXTLight    line_left;
NXTLight    line_right;

int inByte = 0;
int debug = 0;

void setup()
{
  char     str[80];

  Serial.begin(115200);       // start serial for output
  delay(500);                // wait, allowing time to
                             // activate the serial monitor
  Serial.println ("Initializing the devices ...");
  nxshield.init( SH_HardwareI2C );
  /*
    Bank A is dedicated to left side controls (except BAS2 which is for the eyes)
    Bank B is dedicated to the right side controls
  */
  Serial.println ("Initilaizing eyes");
  eyes.init( &nxshield, SH_BAS2 );
  Serial.println ("Initializing line sensors");
  line_left.init( &nxshield, SH_BBS2 );
  line_right.init( &nxshield, SH_BBS1 );

  Serial.println ("Initializing motors");
  nxshield.bank_a.motorReset();
  nxshield.bank_b.motorReset();
}

void
loop()
{
  int eyesReading;
  char str[256];

  Serial.println ("Setting eyes passive");
  eyes.setPassive();

  Serial.println ("Activating line sensors");
  line_left.setActive();
  line_right.setActive();
  //line_left.setPassive();
  //line_right.setPassive();

  while (true) {

    if(debug)
    {Serial.println ("Reading eyes");}
    eyesReading = eyes.readRaw();
    if ((eyesReading > 500) && (eyesReading < 601))
    {
        nxshield.bank_a.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 100);
        nxshield.bank_b.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 100);
    if(debug)
        {sprintf (str, "Object dead ahead: %d", eyesReading);}
    }
    else if ((eyesReading > 600) && (eyesReading < 701))    {
        nxshield.bank_a.motorRunUnlimited(SH_Motor_1, SH_Direction_Forward, 50);
        nxshield.bank_b.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 50);
    if(debug)
      {sprintf (str, "Object to the left: %d", eyesReading);}
    }
    else if ((eyesReading > 700) && (eyesReading < 801))
    {
        nxshield.bank_a.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 50);
        nxshield.bank_b.motorRunUnlimited(SH_Motor_1, SH_Direction_Forward, 50);
    if(debug)
      {sprintf (str, "Object to the right: %d", eyesReading);}
    }
    else if (eyesReading > 800)
    {
      nxshield.bank_a.motorStop(SH_Motor_1, SH_Next_Action_Float);
      nxshield.bank_b.motorStop(SH_Motor_1, SH_Next_Action_Float);
    if(debug)
      {sprintf (str, "No Object: %d", eyesReading);}
    }
    else
    {
      nxshield.bank_a.motorStop(SH_Motor_1, SH_Next_Action_Float);
      nxshield.bank_b.motorStop(SH_Motor_1, SH_Next_Action_Float);
    }
 
    if(debug)
    {Serial.println (str);}
    delay (500);
  }
}
Posted in change | Leave a comment

Progress on the SuGo NXShield

The programming is coming along pretty well. What works? The program reads the DROD40 “eyes” and when they see an object in front of them the left and right motors push the bot forward by issuing the “Reverse” direction. This is just because the servos are reversed in the design. The DROD40 is an older left, right, forward IR detector from Mindsensors.com

I hoped to have more progress today, however I ran into some issues today mixing the stock NXT light sensors with the DROD40 light sensor. I tried both Software and Hardware I2C. I double checked the connection options in the NXShield Advanced development guide.  As you’ll see in the video, I resorted to disconnecting the downward pointing line sensors to make progress with they eyes and motor control.  I hope to have that sorted out soon and post some code with opponent detection AND line detection.

Here’s the code to date:

#include <Wire.h>
#include <NXShield.h>
#include <NXTLight.h>

NXShield    nxshield;
NXTLight    eyes;
NXTLight    line_left;
NXTLight    line_right;

int inByte = 0;

void setup()
{
  char     str[80];

  Serial.begin(115200);       // start serial for output
  delay(500);                // wait, allowing time to
                             // activate the serial monitor
  Serial.println ("Initializing the devices ...");
  nxshield.init( SH_HardwareI2C );
  /*
    Bank A is dedicated to left side controls (except BAS2 which is for the eyes)
    Bank B is dedicated to the right side controls
  */
  Serial.println ("Initilaizing eyes");
  eyes.init( &nxshield, SH_BAS1 );
  Serial.println ("Initializing line sensors");
  line_left.init( &nxshield, SH_BAS2 );
  line_right.init( &nxshield, SH_BBS2 );

  //Serial.println ("Initializing motors");
  //nxshield.bank_a.motorReset();
  //nxshield.bank_b.motorReset();
}

void
loop()
{
  int eyesReading;
  char str[256];

  Serial.println ("Setting eyes passive");
  eyes.setPassive();

  Serial.println ("Activating line sensors");
  line_left.setActive();
  line_right.setActive();
  //line_left.setPassive();
  //line_right.setPassive();

  while (true) {

    Serial.println ("Reading eyes");
    eyesReading = eyes.readRaw();
    if ((eyesReading > 500) && (eyesReading < 601))
    {
        nxshield.bank_a.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 100);
        nxshield.bank_b.motorRunUnlimited(SH_Motor_1, SH_Direction_Reverse, 100);
        sprintf (str, "Object dead ahead: %d", eyesReading);
    }
    else if ((eyesReading > 600) && (eyesReading < 701))    {
      sprintf (str, "Object to the left: %d", eyesReading);
    }
    else if ((eyesReading > 700) && (eyesReading < 801))
    {
      sprintf (str, "Object to the right: %d", eyesReading);
    }
    else if (eyesReading > 800)
    {
      nxshield.bank_a.motorStop(SH_Motor_1, SH_Next_Action_Float);
      nxshield.bank_b.motorStop(SH_Motor_1, SH_Next_Action_Float);
      sprintf (str, "No Object: %d", eyesReading);
    }
    else
    {
      nxshield.bank_a.motorStop(SH_Motor_1, SH_Next_Action_Float);
      nxshield.bank_b.motorStop(SH_Motor_1, SH_Next_Action_Float);
    }

    Serial.println (str);
    delay (500);
  }
}
Posted in change | Leave a comment

NXSuGo ALPHA Prototype sneak peak

This is my NXShield/Arduino/NXT alpha prototype that I’m using to develop NXSugo which I hope to be an Open alternative to sugo-nxt which I wrote for NXT in NBC.

Posted in sugo-nxt | Leave a comment

NXShield’s got eyes!

I’m getting good readings from my DROD40 plugged into a NXShield running this test code:

#include <Wire.h>
#include <NXShield.h>
#include <NXTLight.h>

NXShield    nxshield;
NXTLight    light1;

int inByte = 0;

void setup()
{
  char     str[80];

  Serial.begin(115200);       // start serial for output
  delay(500);                // wait, allowing time to
                             // activate the serial monitor
  Serial.println ("Initializing the devices ...");
  nxshield.init( SH_HardwareI2C );
  light1.init( &nxshield, SH_BAS2 );
}

void
loop()
{
  int lightReading;
  char str[256];
  light1.setPassive();

  while (true) {
    lightReading = light1.readRaw();
    if ((lightReading > 500) && (lightReading < 601))
    {
        sprintf (str, "Object dead ahead: %d", lightReading);
    }
    else if ((lightReading > 600) && (lightReading < 701))    {
      sprintf (str, "Object to the left: %d", lightReading);
    }
    else if ((lightReading > 700) && (lightReading < 801))
    {
      sprintf (str, "Object to the right: %d", lightReading);
    }
    else if (lightReading > 800)
    {
      sprintf (str, "No Object: %d", lightReading);
    }

    Serial.println (str);
    delay (500);
  }
}
Posted in change, sugo-nxt | Leave a comment

NXShield arrived

Last week, as promised, the NXShield arrived!  I was sent the shield and a power connector to use 7.2v R/C battery packs for power.  The quality is surprising.  The shield is made of a PCB, the motor controllers and the circuits are protected by a plastic finish plate to enclose the goodies!  I feel like this board is almost as kid ready as the NXT controller itself was.  Of course, the arduino will have its traces and solder connections exposed when installed.

Here is the shield before I installed my dusty old arduino diecimilla:

The documentation on the OpenElectrons.com site has been easy to follow.  I’ve worked through the user manual and the AVR library tutorial — no problems so far.  I’ve gotten the ultrasonic sensor example to work and I proceeded to modify it.  I’ve added in motor control and a couple of analog touch sensors to turn an NXT servo.

I constructed a battery pack with six old NiMh AA batteries (don’t believe your eyes, I whittled it down to six batteries when I measured the voltage out of the 8 AA pack in this picture):

“What do I plan to do with this NXShield?” you may be wondering.  I don’t have the exact answer to that question just yet.  Like any good project it will evolve as I get closer to the end.  However, I was inspired by Will Hamilton’s “Drawing machine” from the Pittsburgh mini Maker Faire event.  His design included a plywood sheet to fasten the motors in acrylic frames, quadrature encoders (kind of like the knobs of an etch-a-sketch, and arduino.  My kids had a lot of fun with it so I’d like to bring that to their skill level by building a similar drawing machine with NXT components and arduino.

Full disclosure: I received this NXShield at no cost to assist with the beta testing process.

Posted in change | Leave a comment

NXShield is on its way!

Yes, I’ve been busy with my consulting recently and not having time to pick at my picaxe recently. Sorry PicAxe lovers. I still love the platform, I’ll revisit it later. That is in part due to my lack of easy to interface parts.

However, I went to the Mini Makerfaire in Pittsburgh, PA last weekend and bumped into the guys from Mindsensors.com. That was great luck because they had on display a new arduino shield to allow it to easily connect with Lego Mindstorms NXT! The benefit here is that our family has two original NXTs! With one of those shields I’ll have a nice development platform with lots of ready to interface servos and sensors.

I’m receiving one a little before they are officially on sale as a beta tester. I can’t wait to write my first sketch for NXT!

Full Disclosure: I’m receiving a NXShield in exchange for my input and review for free.

Posted in change | Leave a comment

MRTG, Today, For Me

The first time I used MRTG was  to monitor the T1 line at the ISP I worked at in 1997, hereintown.net.  I needed to justify the need for a second T1 line to serve our business needs and our dialup customers.  It served the purpose and was complicated compared to the task at hand: Show how the line is being used.

Fast forward a couple years when I was building Pennswoods.net.  I needed a flexible and powerful traffic and host resource monitor.  I had three NOCs with about 6 servers and 6 cisco devices with something like 24 network interfaces.   With this new task in mind MRTG seemed all the more complicated!  I gave in to the urge to write my own.  I would spend every spare hour in the week building, troubleshooting, finding ways to decrease false positives, and of course justifying this time I spent to my business partner.  I called it, so cleverly, “PWNMS”.  Surely you can see where I got it ;)

Anyway, after a few years of fighting with interesting ways to modularize the different kinds of hosts and systems to monitor, and having built so many conflicting false positive detection  algorithms, I threw in the towel (for a while).  I had a fellow working for me who was happy to configure MRTG.

During the last seven or eight years a lot has happened in the world but not much in network monitoring as far as I can see.  However, I now have a different task: monitor the usage of various resources on a small number of web/database/memcache servers.  I also really don’t want the weight of SNMP nor any additional security implications for my hosts.  I want dead simple graphing of historical performance of these systems. I was banging around on google and ‘apt-cache search’ a bit tonight looking for something like MRTG but simpler.  I didn’t exactly find it… BUT I DID! MRTG with the following simple set of commands:

apt-get install statgrab mrtg
statgrab-make-mrtg-config --no-header >> /etc/mrtg.cfg
statgrab-make-mrtg-index /etc/mrtg.cfg > /var/www/mrtg/index.html
crontab -e

and then edit my blank crontab to look like:

# m h  dom mon dow   command
*/5 * * * * env LANG=C mrtg /etc/mrtg.cfg

I’ll setup a copy I can link to eventually.  For now you’ll just have to take this screen shot as proof it can be this simple:

Screenshot of simple MRTG setup in action

Screenshot of simple MRTG setup in action

Posted in change | Leave a comment

1 PicAXE, 3 Alkaline AAs, and 3 Days of Love

It’s like Woodstock.  That’s the only way I can explain it. :)  Maybe I can do a little better.

Here goes:

Sunday February 6, I turned my little PicAXE test cirucuit on.  It’s been running ever since!  I’ve had a busy Monday and Tuesday and I just looked over at this blinking light in my dining room wondering “What’s that?”.  Sure enough, it’s my PicAXE 08M running for three days so far on one set of inexpensive, no-name alkaline AA batteries!

I’m psyched.  One of my hopes with this microcontroller was really low power consumption.  So far, so good.

Posted in Uncategorized | Tagged , | Leave a comment

AxePad for Mac issues

Note: PicAXE and AxePad for Linux are rocking my world in a good way.  I’m sharing this issue with the mac version of AxePad to help others with this issue.

I have an iomega usb-serial adapter (GUC232A).  See it on iomega’s site at http://www.iogear.com/support/dm/driver/GUC232A The driver installs fine and I see it in my /dev directory as:

/dev/tty.PL2303-0000101D

However the AxePad for Mac options expect you to give a port name like:

/dev/tty.usb*

Where * can be anything AFTER the tty.usb  This probably works great for the official usb programming cable for the PicAXE however since my iomega USB-serial adapter has a different device filename I’m SOL; right?  Wrong, or at least sorta wrong.  I couldn’t edit the port prefix so there was no way to specify my iomega’s device file.  Yes, I tried entering the full path starting at the root – the AxePad field has a limit of around 8 characters.  Here’s what I saw in my options > port dialog:

So I figured MAYBE I could override the default file prefix in a config file.  I found it!  I edited ~/Library/Preferences/axepad.ini and changed the “PortNamePrefix=/dev/tty.usb*^M”

to

“PortNamePrefix=/dev/tty.PL2303-0000101D^M”

I left the “^M” there not knowing if it is useful to axepad when reading this ini file.  Wanna see how my options > port looks now?

So, that rocked my world.  Now it works.  Well, almost.  Actually it seems like there is a bug in the driver that makes AxePad crash?  It programs the chip, checks the version of chip but quits working sometimes.  It gives errors after trying to program.  If I pull the usb plug for the usb-serial adapter out and reinsert it, it works again for a little while.  It totally fails in debug mode with the PicAXE running debug commands.

Maybe AxePad doesnt’ work well with the driver and it is no fault of the drivers?  Not sure.  What I do know if the driver SEEMS to work however, it is last updated around 2006 according to iomega’s website.  I’m betting the driver doesn’t work so well with osx 10.5 so well.

Do you know the answer?  Do the AxePad folks KNOW it only works with their own USB programmer and thats why they hard code that device filename prefix?

If it weren’t for my old linux laptop with a hardware rs-232 port I might be a lot less happy with my PicAXE experience this first week.  But it has worked flawlessly with my Ubuntu 10.10 laptop Linux AxePad and my hardware rs-232 port.

Posted in Uncategorized | Tagged , | Leave a comment