Sniff is a "Scratch-like" programming language that's designed to help Scratchers move gently from Scratch to more conventional languages. They can start writing programs, without having to learn a new language because Sniff is based on Scratch. They learn a little more about variables, compiling, syntax errors (!), and they can have fun controlling real hardware while they're doing it.

Monday, 11 August 2014

Studuino

At Scratch@MIT2014 Arduino was a big thing - lots of people controlling Arduino's from Scratch (though of course only Sniff lets you actually program the Arduino!). The most visible of those groups was a large contingent from ArTeC - a Japanese company that make and sell robot contraction kits. They use a strange block mechanism that clicks together, like some strange and alien lego. They have motors and sensors to plug into those blocks. They're pretty cool, and they had some great demo robots made from the things.

To control these robots the have their own custom Arduino clone, which they call the Studuino. They were selling these at the conference for $3 - in other words they were giving them away (regular price is $30), but didn't want the first guy who turned up at their stand to take all of them. As it turns out the first guy at the stand was me, and I grabbed two!


It turns out that these are as strange as they look. The good things about them are that they're about the size of an Uno, and have standard(ish) Arduino socket layout. I say standard-ish, as the ICSP port is moved. This isn't a biggy, but it means some shields that use SPI won't work. For controlling robots, all of the i/o pins (A & D) are broken out on gnd/Vcc/Signal three pin servo headers. We like this a lot, as it makes plugging in things really easy. However the "feature" of the board is that it has two motor drivers built in, and four buttons. ArTeC's robot components will plug straight in, and they make a  really nice box that attaches the board to their block system.

So what are the downsides: The main on is that it uses an ATmega168pa which has only 16K ROM, and 1K RAM - half the specification of an UNO. It runs at 8MHz (half the speed of an UNO), though that's probably a good thing if you're running of battery, as it will save power. The whole thing operates at 3.3V which in theory is better (and again saves power), but in practise the whole 5v/3.3v arduino thing is a bit of a mess. Operating at 3.3V means you need to be a bit more careful. What all this comes down to is its going to suffer from the "not an UNO" effect: They UNO board is so prolific, any differences make it harder to work with, as everyone supports the UNO, and writes tutorials assuming that's what you're using. This isn't ArTeC's fault - Arduino's own Due is the biggest victim of the effect, but its a hassle in a board that's obviously aimed at beginners. There's a 3.3V/5V jumper on the Studuino, but it doesn't switch the whole  board over - its exact operation is unclear.

Another niggle with the board is that it uses a pl2303 USB chip, so you'll need to install drivers. The UNO and other boards which use the 16u2 to provide USB, work out of the box on Mac, but you need to install a driver to use the Studuino. There are links and instructions on the ArTeC site, or you can get the driver direct from the manufacturer.

As with most non-standard boards you need to make a few tweaks to the standard Arduino installation. Again ArTeC include instructions for installation. However you don't need those if you just want to use the Studuino with Sniff (or for that matter with Scratch - they provide a mod'ed version of Scratch too).

Plugging in and running Sniff setup detects the board fine (at least on Mac - let me know how you get on, on other platforms). If it doesn't check that there's a file: /dev/ttyXXX which shows that the driver is working correctly.

Running Sniff requires a few tweaks to the standard uno-sniff, and in the next release there'll be a stud-sniff. However to let you get started there's a zip file you can download which contains all of the extra's you need to add to the current Sniff release. Add stud-sniff to the Sniff/bin folder.

You should now be able to compile and install standard Sniff programs using stud-sniff. Try running blink from the Sniff/examples/Arduino folder:

stud-sniff blink.sniff

and the green light on the board should start blinking.


The Studuino's buttons are a nice touch - when I first got an Arduino, I was frustrated that there were button press examples, but no button on the board. Combined with the standard onboard LED, having a few buttons is a great help for beginners. The buttons are connected to A0-A3, but provided you don't press the buttons you should still be able to use those pins as you normally would.

make studuino studuinoButtons device
make buttonA boolean
make buttonB boolean
make buttonC boolean
make buttonD boolean

make led digital output 13

when start
.forever
..tell studuino to "checkButtons"
..if buttonA
...set led to off
..if buttonB
...set led to on

To use the buttons from Sniff, use the studuinoButtons device (it takes care of pull-ups, which Sniff normally doesn't), and tell the studuino to checkButtons. You can then use the state of bottonA-D to do whatever you like.

The Motor driver uses pins D2,3,4,5,7 & 8. In theory you should be able to use these for other tasks if you don't need the motors, but its probably best to avoid them if possible. It's perfectly possible to drive these directly from Sniff, but to simplify things (and make the code comparable with the standard Motor Shield), theres another device:

make buttons studuinoButtons device
make buttonA boolean
make buttonB boolean
make buttonC boolean
make buttonD boolean

make motors studuinoMotors device
make motor1 number
make motor2 number

when start
.forever
..tell buttons to "checkButtons"
..if buttonA
...set led to off
..if buttonB
...set led to on
..
..set motor1 to 0
..if buttonC
...set motor1 to 1
..if buttonD
...set motor1 to -1
..tell studuinoMotors to "update"
..
..wait 0.1 secs

Originally I set this up as a single device for both buttons and motors, but separating them is more flexible, and makes them more compatable with other Sniff programs.

Overall the Studuino is a nice board, with a couple of handy features, though it suffers from simply not being an Uno. The smaller CPU probably isn't a problem it you're just making simple robots, and if you're working with ArTeC's other products, then its great.

You can download all the bits you need to get started here. We'll add these to the next release. Let us know how you get on...

No comments:

Post a Comment