Saturday, 6 August 2016

Old friends

So, I was trying to find a microcontroller board with a ton of 5V I/Os and, as usual, finding nothing at a reasonable price. A Pi Zero is $5, so why is a dev board for an 16MHz 8-bit MCU $50? But then I realised, I don't necessarily need 5V I/O - I need 5V tolerant I/O.

I've spent quite some time (as you might know if you've seen other blog posts) working with the TI Stellaris Launchpad - now known as the Tiva-C Launchpad for reasons I never did understand. I thought I've had a look at the datasheet and low and behold - 5V tolerant I/O.

So, a plan is forming:
  • Create a base board for the Launchpad, like I did for the in-car dashboard
  • Drive the L298 inputs from a open-drain GPIO with a pull-up.
  • Read the quadrature encoder inputs directly (the GPIO will deal with it OK).
  • It can interrupt on any GPIO pin, so no problem there.
  • It's fast - A 67MHz Cortex-M4F won't have any problems running four seperate PID loops.
  • The Pi can connect via USB for both power, control (Serial) and flashing/debug.
  • I know I can get the programmer to work.
  • I know I can program it in Rust...

PiWars 2017...?

I may have accidentally submitted a PiWars 2017 application. Ooops.


Key upgrades for the old robot, I think would include:
  • Proper four wheel drive
  • Closed loop motor feedback
  • Ultrasonic ranging on the sides as well as the front
  • Light sensors in place of the camera for line following
I dusted off the 2014 entry myself and some friends built and the LCD and the PS3 interface still work well. But I'd previously stolen most of the motor driver circuitry, so that needs revisiting.

To make the sensors work, I need more interrupt pins than the two that I have available on the AtMega 328 I used last time. I really need two for each wheel speed sensor, plus one for each ultrasonic sensor. I'd use a Cortex M4 like the Stellaris Launchpad, but the wheel speed sensors of course output 5V, as are most ultrasonic sensors and the inputs on the L298 H-Bridges I use.

I feel a custom circuit board coming. Oh dear oh dear.

Sunday, 10 April 2016

Rust

A few weeks ago, some enforced time off gave me time to do some research into a topic that some of my colleagues have been getting quite excited about. Rust.

Rust is a new language from Mozilla. Unlike Java and C#, it compiles down to machine code. Unlike Swift and Go it doesn't require an OS - a subset of the standard library (known as core) can be used on any platform. Unlike C++, it's been designed with good ideas from the start, including strong borrow semantics and pattern matching, and unlike C it contains good ideas, period. No more writing your own linked-list implementation on every platform you develop for. It's the first language I've seen where there's no "I'll just have to do this bit in C". Pure Rust, even on a Cortex M4, is the promise. But is it the reality?

First impressions weren't good. Rust's stable/beta/nightly model means that you can experiment with new features considered unstable. Unfortunately these features can and do change, and many of them are required to do bare metal Rust. So github is littered with projects which probably used to work for some platform or another, but don't any more. Zinc.rs is probably the biggest, but when I checked a change in compiler internals meant that their clever Rust compiler plugin for auto building platform setup code no longer compiled. It was too much to unpick, especially for a newbie. I saw some good projects for bare metal on x86, but I really wanted to use my M4F Stellaris  Launchpad.

Eventually I found https://github.com/mdaffin/teensy-3-rust which did at least compile out of the box on Rust 1.9 nightly. Some time later, I've got https://github.com/thejpster/bare-metal-arm-rust running on the Stellaris.

Top tip - don't leave unimplemented!() in your code as it calls panic!().

Top tip 2 - Don't forget to keep generating a bin from the ELF, otherwise you're running one version of the code while debugging the other, and that's just baffling.

Sunday, 28 February 2016

WILL THE SOLDERING EVER END?!

Raspberry Pi 3 Model B

So, worst kept secret ever - it appears there's a Raspberry Pi 3 coming soon. Probably tomorrow (the fourth anniversary of the original release). I wasn't told in advance, so unlike most of the internet, I'm not under NDA. Here's what we know:

  • There's an FCC submission qualifying it's Wifi and Bluetooth LE performance. From photos it looks like the same 1GiB SDRAM as the Pi 2.
  • There's a half page advert (and front page picture) of a "Raspberry Pi 3" in this month's CPC catalog. D'oh! It talks about a 64-bit 'ARM 7', but that's nonsense as a) they mean ARM v7 as the ARM 7 is ancient at this point, and b) they actually mean ARM v8-A as ARM v7 is a 32-bit only ISA. We don't which of the Cortex A-3x or A-5x series it's packing at the moment, but I'm predicting an A53. According to the advert it's clocked at 1.2GHz, so that's a good speed bump over the Pi 2. It almost certainly continues to pack a VideoCore 4, given all the good work that's gone in to the Linux/Mesa support for that GPU.

Sunday, 24 January 2016

Some progress

Well, I've missed Christmas, obviously. Maybe it'll be done for Christmas 2016...

I did manage to spend a few hours on it last night. I'd been thinking for a while about fixing the LED to small pieces of PCB, but I didn't think standard 2.54mm pitch Veroboard would fit (four holes would be ~7.6mm, and the holes are only 6mm), I considered getting some 2mm pitch board, but it's remarkably difficult to find in small quantities. I also thought about getting PCBs made, but it just seemed too expensive.

In the end, I thought I'd at least try with some scrap 2.54mm pitch board I had lying around and, well it's not to bad. The board stands a little proud of the rear of the letter, but that's OK. I little work with a file to widen the hole at the appropriate place and it should be OK. The upside is that it is so much easier to solder solid-core to Verboard that it is to try and lay-on not just one but two pieces of wire on each individual leg. Plus the legs were getting dangerously close together for something fused at about 2A.

I had one mishap with an LED that went pop (I could have sworn it was in the right way around), and another that didn't solder correctly, but I got five done in the end and I was starting to get the hang of it. And the little shards of Verboard look like Shreddies.

Only another 39 or so to go.



Tuesday, 22 December 2015

Webserver

I've now got a Python webserver up an running (on my Linux server, for now), which offers a list of modes for the user to select from. When a mode is selected, it uses jQuery to push this back to the webserver, which then tells the other thread to change which animation it should play.

It's on Github, obviously - https://github.com/thejpster/xmas-web.

The letters have arrived too, and I had to re-jig the LED layout a bit. It was tricky to get something that lines up in nice neat rows, but I think I got there in the end. After a few goes on the computer using LibreOffice Draw, I decided to just use chads from a hole punch to get the layout right.