Pages

Monday, 28 January 2013

I've been working on the railway ... and the arm ... and the Pies

 ... because the locomotive kept derailing. I thought, maybe its wheels aren't properly aligned, so I went to Ebay, and discovered that Hornby OO locomotives tend to be a bit expensive! But I found a nice 0-4-0 for £20, and I thought, hey with only four wheels, it's less likely to derail, so I ordered it.

It arrived swiftly, and I tried it out. Right gauge, right voltage. But the loco was too light, and not really strong enough to pull the two passenger cars. I think it's meant to be more of a shunting engine. When I coupled it up, the wheels would spin, and sometimes it was able to get the train going, but sometimes it wasn't. And that's not good for a fully automated railway.

Then I had a flash of inspiratipn - double-header! I coupled the new loco to the passenger cars, then put the original (much larger and heavier) engine in front. It's too soon to say, but this might have done the trick. The load is now being shared between the two engines, and I think that's made them less likely to derail.

On to the Robotic Arm Two. I've got all the software working now, and the cams, and the arm. You can move the arm around, and reach out and type on the keyboard, and I can detect which key you typed. I have a red LED that comes on when you hit the right key, and that's visible in the webcam. So then you swivel the cam around, using servos, to look at the monitor (I've worked out how to squirt a display to the three inch PAL monitor), and up comes the next part of the coords for the cache. That stays displayed for a minute, then you get the clue to tell you what to type next. Swivel back to look at the arm and keyboard, and you can operate the arm to type the next letter. And so on.

The problem is, it's flaky, in two ways. The small way, is that I'm relying on timing to position the arm, which is not a fine control. The big way, is that the USB-to-serial converter, which I'd thought was stable (at least it doesn't crash every time you use it), still occasionally hangs the computer, and when that happens, the last command that went to the arm, stays in place, which means that the electric motors try to drive the arm into an impossible position, and the clutches go "CLACK CLACK CLACK" as they try to break themselves. I've ordered another USB relay box, and I'll use that instead. On the railway, it's been working like a champion.

On the other Pies I'm using, I'm getting the occasional Pi crashing. I don't know how to make that happen less often. I'd estimate that it's happening maybe once per week, over the total of several Pies, so that's about once every couple of Pi-months, not too bad, but it means it can't be trusted to run unattended.

Here's my proposed solution. I'll have a computer that watches all the Pies, and if one of them stops responding, the watchdog computer will cycle power to that Pi. I'll use a relay box to do that. So the power setup will be this:

PC power supply, giving a couple of hundred watts. The 12 volt line of that feeds to a one of the devices that translates 12 volts to five. They can handle 2 to 3 amps, so I'll use two of them.

Each of those will feed a USB hub. A cable will run from each port of the USB hub, to the micro-USB connector of the Pi. So that'll give them all power.

These USB cables have four conductors inside; black, red, green and white. Green and white are data, and are irrelevant for powering the Pi. I've cut the red conductor, and soldered wires to each side of the cut. Those two wires will go to the relay box, connected to the NC (normally closed) terminals. So when everything is started up, power goes to the Pies.

If the watchdog timer finds that it cant get a response from the Pi, and a minute goes by with that problem persisting, then it will cut power to that Pi, wait a few seconds, then restore power. It'll wait a couple of minutes before resuming checking the Pi, to give it time to boot up. And it will email me to tell me about the problem.

It's nice that I'm only switching five volts. I could, in theory, do the same thing with my big computers, but then I'd be switching 250 volts and at least a few amps, and that's do-able, but, well I've never actually even felt a five volt shock, but I've hit myself with 240 volts a few times, and it's not pleasant. And, potentially, lethal. Whereas five volts will never even tickle.


No comments:

Post a comment