Teaching has started again, which has pushed this release back a bit. Finally I've got a quiet few days to push out the latest fixes and features!
The first thing you'll notice if you use SniffPad is that syntax highlighting has improved a bit... variable names are now blue, which is handy as it means there's a visual indicator that you've spelt a variable name wrong when you type it, rather than getting a weird error message some time later. You might have noticed this already if you've tried live.sniff.org.uk.
The headline feature is of course MQTT support. There'll be more posts on that over the next few days, but if you want to place Arduino's to measure and control things using a network, then you should be very excited. Combining Sniff and MQTT makes building network sensor about 8 lines of code, and it will integrate with whatever control system you want to run on your central servers.
There's also the usual round of bug fixes and tweaks that are really important, but too small to mention.
Head over to the downloads page to grab a copy.
Wednesday, 12 October 2016
Wednesday, 28 September 2016
Lego IR "train" controller
Just a quick update on the previous post where we used the Lego IR remote to control and Arduino. I've not got my hands on a Lego "train" controller which has two dials and two buttons. Pointing one of those at an Arduino with the IR receiver attached, produces a fairly simple set of codes.
The Left dial generates 100 and 101 as its turned in each direction, while right dial generates 116/117. When used with the regular IR receiver these mean speed up/slow down on the red and blue channels but you can use them in your code to mean anything you like. Each turn will generate a burst of codes, so you're likely to receive several at a time. This is intended to make sure that the code actually gets through. You might need to ignore repeats of a code if they arrive very close together, as its not multiple turns, but just multiple signals.
The left button generates 72, while the right button generates 88. Somewhat surprisingly pressing both butts at the same time generates 31, which to the Lego decoder means brake both motors. The numbers don't appear to make sense as 31 is a code to control both motors, while 72/88 are codes to control individual motors so are sent in a very different way.
Unlike the regular Lego remote, the codes are never combined (except for 72+88=31), so if you press and hold a button, then turn a dual, you can no longer detect if the button is pressed. Turning both dials at once, results in both sets of messages being sent, rather than just a combined signal as per the regular remote.
Channels (1-4) work report in the irProtocal variable, so you can use up to four remotes at a time!
Friday, 23 September 2016
Receiving Lego IR
In the previous post, we used an IR LED to control Lego Power Functions motors, which was pretty useful, but what about going the other way - using a Lego PF remote to control an Arduino?
That standard Lego remote is really nice for controlling Robots as it has two levers, giving you forward/back tank style steering. There's a handy "reverse" switch for each lever, and best of all there's a channel selector, so you can operate up to four remotes at the same time. This is always a problem in workshops where everyone gets the same kit of parts, and everyones remote controls everyone else robots!
At about £7.50 from the Lego store, they're pretty reasonably priced if you're buying them for yourself, or even a classroom, though unfortunatly our workshop budget won't stretch to giving them away, as we do with the regular £1 remotes.
Lego uses a unique (but well documented) protocol, so which we've added to the regular receiveIR device, so if you have build a robot with an IR receiver you don't need to change anything, other than detect the new keypress codes.
Working with IR is cheap and easy - just get a tsop-4828 receiver for about 50p, and wire it to a data pin on an Arduino (note that the transmit code should work on any micro controller, but the receive as some Arduino specific bits):
The code to read from an device, works exactly the same as it always did:
make remote receiveIR device D2
make irProtocol number
make keyPressed number
when start
.forever
..tell remote to "read"
..if not keyPressed = 0
...say join "Protocol:" [ irProtocol ]
...say join "KeyVal :" [ keyPressed ]
...say ""
Now, if you point a lego transmitter at it you'll start getting key codes. The channel is returned in the variable irProtocal, so you can easily run multiple controllers at once. If you're really interested in making sense of keyPressed value then there's documentation available from lego. The value returned is the middle 2 nibbles of the data packet, with the escape bit tagged on the beginning.
While its possible to decode the packet based on the documentation, its probably easier to just look at the values that are being sent when each button/lever is pressed, and actual accordingly.
If we look at the codes sent by the regular remote, a value of 16 is sent when nothing is pressed. In fact you can subtract 16 from every received code and things start to make sense: Left stick generates 0 in the centre, 1 when forwards and 2 when backwards. Add these to the 16, that this remote always sends and you're in business. The right stick works the same except we multiple by four, so the value sent is 16+4*rightStick+leftStick.
Of course you can still use most other regular remotes to, but the Lego ones are a bit nicer. The code is now on live.sniff.org.uk along with an example and will by in the next desktop release.
Wednesday, 21 September 2016
Power Functions IR
Lego WEDO is great - you can control power functions motors, but its a bit expensive, and you need a computer. An alternative and cheaper way to control power functions is with the IR control, which you costs £11.50 (important hint: NEVER buy Lego on Ebay or Amazon without checking the lego site first. It's usually much cheaper. The logo consumer store is also much cheaper than the edu store, even though you're buying the same component from the same company). Of course you'll still need some motors and lights and the remote control, but you probably have some of those anyway. Either way you're in business for about £40 rather than £135 (though of course if you buy a few more bits you'll get free shipping, so a few extra parts is saving money in the long run).
It turns out that while the lego IR system is a bit quirky, its well documented, and pretty easy to control from an Arduino or similar. All you need is an IR LED, which cost a few pennies - wire it to one of the pins with a 500ohm(ish) resistor in series so you don't break anything, and you'r good to go.
To code for it in Sniff, just make a device:
make remote transmitLegoIR device D13
make blueValue number
make redValue number
make channel number
I've called it "remote" and attached it to pin 13. Then I powered up the receiver as normal, and connected a motor to the red output. You'll notice that there's an orange slider on the side of the receiver, which sets the channel. If you've only got one then you can just keep it set to 1, otherwise match the channel in the code to the receiver you want to control.
All I want to do is run a motor back and forth, so here's the code:
when start
.set channel to 1
.set blueValue to 0
.forever
..set redValue to sin of (timer*100)
..tell remote to "send"
..wait 0.1 secs
All the code does is set the blue output to 0 (Stop), then goes into a loop. The red value is set to range from -1 to +1: full reverse to full forwards, changing with time. Once you've set the red and blue values as you want them, just tell the remote to "send" and it fires of a few IR pulses and the Power functions should do whatever you command!
Normally at this point I'd tell you that the code would be in the next update of Sniff (and it will be!), but if you go to live.sniff.org.uk now you'll find the example code already there, and you can compile it for Arduino online!
Friday, 16 September 2016
Sniff Live For Arduino
Our initial implementations of Sniff Live were aimed at getting regular programs compiling and running in the browser, so it would be easier for new users to write a few simple Sniff programs without having to install the system. On Windows in particular installation is a bit of work (it's MUCH easier if you're running Linux or Mac).
However the most fun projects we do with Sniff involve external hardware - usually the Arduino Uno, so getting that working with Sniff Live was something we always had as part of the plan, and now its ready for you to try out.
If you head over to live.sniff.org.uk you'll see that on the front page there's a suggestion to download the Loader app. Download and unzip it somewhere. The Loader app is the easiest way to upload intel hex files to an Uno, though if you have any other method you prefer that will work too.
Then log in as usual, and take a copy of the blink example using the "copy examples" pop up in the top left. Once you've got that, press the Arduino button in the editor to compile your code for arduino. If you were running Sniff on your own computer, this would also do the flashing for you, but unfortunately it can't because now the code is being compiled on our server, while the arduino is connected to your PC!
Once the code is compiled, press the "run" button, either in the editor, or in the sidebar (the run link might not appear straight away). This should download the hex file to your computer. The exact details of what this looks like will depend on your browser and its settings, but you should save the file, and open it.
Your PC probably doesn't know what to do with a "hex" file, so set up the file association so that it opens in the "UnoLoader.exe" that you downloaded earlier. From then on when you double click a hex file, or tell your browser to "Open" it, then it should upload the code straight to your arduino without any further intervention from you.
If UnoLoader doesn't work, then check that you have an Uno connected, and that it is appearing as a COM port. If UnoLoader does fail, then its window will stay open and it will tell you whats going wrong. Check out what it says the problem is, and if you can't figure it out, let us know.
Monday, 12 September 2016
Sniff Live!
We've been fairly quiet recently, as we've been working on a big project. It's not exactly a secret (as we've mentioned it in a previous post), but we're just about ready to make a bit more of an announcement about it...
You can now program Sniff entirely in a browser!
After a few year of trying to make the install as easy and as portable as possible, we now have a solution which requires nothing installed on your machine. Just go to http://live.sniff.org.uk, and enter your name to create an account. From there you'll be taken to the online IDE, which is basically the regular Sniffpad IDE but now everything is online.
This isn't intended as a replacement of the regular Sniff implementation - more as a way for you to get started, so it's slightly more limited, but hopefully being able to try stuff out and online will make it an easy way to get started.
To run a program, just press the compile button, and then the run button. Run requires you to enable pop-ups as it runs the program in a new window. Alternatively if a program has been compiled previously a run link will appear in the left sidebar, which doesn't require pop-up permissions.
On the left sidebar you can copy some demo's which are preloaded onto the system, or edit programs you've previously worked on. You can also upload/download code or images. Images can be edited using the paint package, though it is limited to quite small images. Any code you write can load and save files to your account on the server - either text files or image files.
The system can technically compile code for Arduino Uno too, but currently it there's no way to actually execute that code on a board. We're working on that but its a bit tricky!!!
The system is still in its development phase, so expect things to change/break, but hopefully it should make it a lot easier to use Sniff on a wider range of computers.
Check it out at: http://live.sniff.org.uk
Labels:
Release
Tuesday, 9 August 2016
ScratchMIT2016
We just got back from Boston, where we attended out third Scratch conference. It was lots of fun to be back at MIT, and meet up with everyone, including lots of people we met in Amsterdam last year.
Officially we had a poster, and were talking about Banana Physics which I've written about here already. Here's an updated PDF with our slides. Thanks to Andy for his help on the stand, and spreading the word.
We also showed off our online editor: live.sniff.org.uk. This is very experimental, but is working well - its the fastest, and easiest way to get started with Sniff, as there are installs required - It all runs in the browser (and compiles on our server), so you can just make an account, and start programming. In the future we hope to be able to support local hardware with a small browser plugin. We'll have a dedicated post on this very soon, and making bigger announcement, as it is a big thing.
We also met lots of new people - too numerous to mention, so I'll just call out some specific work that was on show:
The Colour Divide: https://scratch.mit.edu/projects/71447764/ is a great animation done in Scratch by bubble103 (who was an invited speaker at the conference as a result - aged 16!). As someone who works full time in the computer animation field, I generally don't get that excited by Scratch animations, but this is a great piece of work that deserves all the recognition its getting.
There were a lot of students from Warwick techvolenteers who are doing a lot of great schools outreach doing science projects much like we've been building in Sniff, though they were showing off work aimed at slightly younger kids. They've just transitioned from Picoboard to a custom Arduino shield, which we hope to get a good look at soon.
We finally got hands on with the wedo2, and it was as much a let down as we expected. Driver compatabilities, HW limitations on about 50% of the laptops, binding problems and battery requirements all make it a pretty unconvincing upgrade. While we didn't do any serious testing it seemed like the motor was lacking in torque, and struggled to handle gearing well. Maybe in the future things will get better, but right now we'll hang on to Wedo V1.0 (or better yet Control Centre B).
There were a couple of companies showing of their robot buggies. Dexter Industries had a session on their GoPiGo, which is a lot like our SniffBotJr that we use for workshops. However unfortunately its based around a Pi, which means it costs $210 for their starter kit.
The robot kit from ROBBO costs about the same at 250Euros and is Arduino based, which is a lot of money for an Arduino based robot, but it is beautifully made. The sensors attach magnetically providing both physical and electrical connections to both digital and analog pins, which is incredibly clever. The sensors just clip on, so you can reconfigure in seconds and they're physically polarised by the shape cut in the acrylic housing, so its impossible to connect them incorrectly. We spend a chunk of time on Friday night, and Saturday afternoon playing with both their robot, and their "lab kit" (an arduino powered pico board style device), and they are sweet if your budget can handle them. Both work out of the box with Sniff (once we figured the pins being used) - program them using the nano-sniff command, and they work great.
If I can make it to the conference next year I think we'll run a workshop on building a real low cost robot - we spend about £25 per robot to cover hardware costs on our workshops, which means every student gets to build a robot, and take it home with them! Check the "Robot" posts here on the blog to see what we've built, and information on how to build your own, or just get in touch if you need help.
Finally Derek Breen (no fixed abode - coming to a sofa near you soon) has a couple of "new" books - well not really... he's quite open that they're cut down rehashes of is original Scratch for Kids book, but they're smaller, and focus on specific things: one on animation and on one games, which means they're much more approachable for a kid with a specific interest.
And then it was over - a quick stop at the MIT Museum and we were back on a plane to the UK - missing the Delta datacenter outage but a few hours!
Subscribe to:
Posts (Atom)