Friday, 25 August 2017

Getting Started with Kitronik MOVE Mini - Part 2

There's not much to say in part 2! Follow the Kitronik instructions in their booklet, avoid snapping any of the panels like I did but have a tube of Gorilla Glue available, just in case you do!


Finish the build and then fire up Bitty Controller from the wonderful Bitty Software and let the fun begin!


video

Getting Started with Kitronik MOVE Mini - Part 1

Those lovely people at Kitronik sent me one of their cool MOVE Mini kits to play with.

This morning I went through the initial steps to partially build the kit and test it. The kit is not fully assembled yet, but I do have the micro:bit connected to the PCB and the servos connected, with their wheels attached.



The Kitronik web site provides details of the code you need on your micro:bit if you want to control it from a smartphone using Bitty Controller. There's also a ready made hex file available from the Kitronik web site which you can download, if you just can't wait to get started.

Initially I had no success at all. I got no response from Bitty Controller and so had to back-track and troubleshoot.

The most important thing to do in this situation is to eliminate Bluetooth completely and check that the electrical connections between the kit's PCB, the micro:bit and the servos are all properly in place. In the Kitronik booklet, they provide guidance on testing the servos in Step 4. I implemented this code in MakeCode  but made one change, which was very useful. The code lets you start the servos running in either direction, by pressing micro:bit buttons A or B or make them stop by pressing A+B together. If these tests do not work, then you have a problem with the construction or electrical connections of your Kitronik kit. There's no point trying to control it over Bluetooth if this is the case and you need to track down the problem and fix it, perhaps disassembling and reassembling carefully, before trying the servo test again.

Watch this video to see the servo test in action:

video


The change I made to the servo test code was simply to display something on the micro:bit LED panel. The presence of the expected LED pattern confirmed that the micro:bit was receiving power from the batteries connected to the MOVE mini PCB. I'd definitely had problems with electrical connectivity earlier on, so this was a very useful change. Here's my code, from the JavaScript view of MakeCode, by the way.

basic.forever(() => {

})
input.onButtonPressed(Button.A, () => {
    pins.servoWritePin(AnalogPin.P1, 180)
    pins.servoWritePin(AnalogPin.P2, 180)
})
input.onButtonPressed(Button.B, () => {
    pins.servoWritePin(AnalogPin.P1, 0)
    pins.servoWritePin(AnalogPin.P2, 0)
})
input.onButtonPressed(Button.AB, () => {
    pins.servoWritePin(AnalogPin.P1, 90)
    pins.servoWritePin(AnalogPin.P2, 90)
})
basic.showIcon(IconNames.SmallDiamond)

There's a hex file compiled from this code available for download from the Bitty Software web site. Install it if you're having problems and check that micro:bit buttons A, B and A+B have the expected effect.

Once I'd sorted out connectivity glitches, I installed the ready made hex file for Bluetooth control which I'd downloaded from the Kitronik web site.

It didn't work.

It dawned on me that perhaps the hex file required me to pair my phone. Pairing is optional and whether you need to do it or not depends on the code from which your hex file was created. By default, MakeCode projects require you to pair.

Sure enough, this turned out to be the problem. Pairing requires a slight change to the usual procedure though, since you cannot access the reset button on the micro:bit when it's mounted on the kit PCB. Instead, switch off the kit PCB using its OFF/ON switch at the top,  hold down micro:bitbuttons A and B and then power the kit ON, keeping buttons A and B held down all the time until you see "PAIRING MODE!" scroll across the micro:bit display. Then use your phone's Settings/Bluetooth screen to select and pair (Android) or the nRF Connect application on iOS. See Bitty Software for videos demonstrating the basic procedure. Note though that you will not need to enter a 6 digit PIN. MakeCode specifies a simpler approach to Bluetooth pairing called "Just Works".

Here's a video showing me pairing with the micro:bit in my MOVE mini.

video

And here's my final test, involving Bluetooth and Bitty Controller!

video


Monday, 14 August 2017

Bitty Blue on Chromebook

A new version of free application Bitty Blue was made available for Chromebook yesterday. It's now available on iOS, Android and Chromebook.

Bitty Blue lets you play with the primary Bluetooth features of a BBC micro:bit and hopefully could form part of lessons and coding club activities, prompting the question "how does that work?" at every turn.

Chromebook seems a great platform and I understand that in some parts of the world it's the standard kit to be found in classrooms.

Teachers and STEM leaders.... hope you find this useful and fun.


Friday, 4 August 2017

Bitty Data Logger 2.4.0

Bitty Data Logger 2.4.0 was just released for both iOS and Android. It adds one new feature, namely the ability to trigger calibration of the digital compass in a connected BBC micro:bit, on demand.

Capturing and charting magnetometer data is just one of the great things you can do with Bitty Data Logger. Magnetometers need constant love and attention though, if you like your magnetometer data to be accurate. Accurate data can only be obtained if you calibrate the compass in the environment you intend to use it in. On the micro:bit, the calibration procedure involves you responding to a "DRAW A CIRCLE" prompt which appears on the LED display by rotation the micro:bit in space, causing an LED light to be lit all the way around the edge of the display. Once you've lit all the edge LEDs, a smiley face appears, indicating that the calibration procedure has completed.

You can now trigger the magnetometer calibration procedure over Bluetooth from within the Bitty Data Logger settings screen. You need to be running a suitable hex file on your micro:bit of course, but luckily there's just what you need available for download from http://www.bittysoftware.com

Oh and Bitty Data Logger is no longer free of charge. Sorry about that. See the previous blog post on Bitty Controller for the reasons behind this.


Monday, 24 July 2017

Hello Bitty Controller. Goodbye Bitty Game Controller!

Bitty Game Controller is an application from my friends at Bitty Software that lets you remote control something like a Kitronik buggy from your smartphone. In fact you could use it to control anything connected to a micro:bit, provided the micro:bit is running the right code.

However, Bitty Game Controller has been withdrawn from the Google Play store and will soon also be withdrawn from the Apple App store.

Don't despair though! A rather similar application called Bitty Controller has taken its place. Bitty Controller offers a choice of the old dual d-pad game controller user interface or a new, analog touchpad controller and in the future, other UIs will be added to the application too. The point is, some types of micro:bit connected machine, are best controlled by one type of UI like the game controller, whilst others are better suited to something else. So Bitty Controller will offer a collection of controller user interfaces so that it is suitable for use with a wide range of micro:bit projects.

Bitty Game Controller was free of charge. Bitty Controller is not. It now costs GBP 1.99 in the UK, or something equivalent in other parts of the world. Why is Bitty Controller not free of charge?

Bitty Software has various costs associated with it, from web hosting and domain names, to developer accounts with Google and Apple and test equipment. Various companies are also selling commercial products, with Bitty Controller bundled with them. It's no longer possible to offer this application free of charge, therefore and so a small, fee is now payable. Bitty Software hope people understand and continue to find their applications useful and fun. On that basis, Bitty Software will be able to continue to offer smartphone applications for lovers of the BBC micro:bit.

Dual D-Pad controller interface

Analog touchpad interface - push the ball to set direction of movement

See http://www.bittysoftware.com for further details.


Tuesday, 27 June 2017

Bluetooth 5 and PHY Flexibility

Bluetooth 5 introduced two new PHYs. PHY? That's the PHYsical layer in the Bluetooth protocol stack, the bit which deals with the world of radio and the encoding of digital data in an analogue form.

In Bluetooth 4, there was only one PHY. It encoded digital data using Guassian Frequency Shift Keying (GFSK) and transmitted it at a rate of 1 mega symbol per second (ms/s).

Bluetooth 5 continues to support the Bluetooth 4 PHY and calls it LE1M. But it also added a 2 ms/s PHY called LE2M, which doubles the transmission rate at the physical layer and a long range capability, achieved when using the LE Coded PHY which uses Forward Error Correction (FEC) to allow receivers to be more sensitive, extract data from signals at a lower Signal to Noise Ration (SNR) and therefore at a greater distance from the transmitter. Cool.

But ......

1. How flexible is this?
2. Can application developers choose the PHY to be used?
3. And in an environment like a smartphone, with multiple applications running, would one application setting the PHY change it for all other applications?

Luckily the answers to these questions are:

1. Very
2. Yes if their platform provides APIs (because yes, the Bluetooth stack allows this)
3. No it would not.

To elaborate on (3):

You can set a default PHYs to be used in all subsequent connections or connectionless communication events for each of received packets (RX), transmitted packets (TX) or both.

However you can also use a different PHY for each and every packet if you really want to. That's pretty flexible!

When in a connection with another device, the Bluetooth stack lets you use the Host Controller Interface (HCI) Set PHY Command to set the PHY for your connection and you may specify a different PHY for TX and RX use on this connection.

Bluetooth 5 lets you define distinct "advertising sets" which are separate sets of advertising parameters for different applications. So in connectionless scenarios (i.e. advertising and scanning), you can specify the PHY as part of the definition of a particular advertising set. You use the HCI LE Set Extended Advertising Parameters Command to select the PHY to use when advertising and use LE Set Extended Scan Parameters Command to control scanning and the PHY or PHYs to use when handling received advertising packets.

Of course this doesn’t necessarily mean that operating systems like Android give you complete access to all of this. But we're in luck....it seems that Android O does in fact does give you pretty much everything. In summary, here's my interpretation of the revised Android O APIs which give access to Bluetooth 5 capabilities:

1. Android lets you determine which PHYs the local Bluetooth adapter supports.

2. A GATT server application can specify preferred PHYs for each of TX and RX (class: BluetoothGattServer)

3. A GATT client application can specify preferred PHYs for each of TX and RX (class: BluetoothGatt)

4. When scanning you can specify the PHY(s) to use, including “all supported PHYs” (class ScanSettings.Builder)

5. When advertising you can build advertising parameter sets, each with its own primary and secondary PHY (AdvertisingSetParameters.Builder)

Bluetooth 5 offers enormous, packet by packet flexibility and control over PHY selection and it looks like Android APIs put this power right into the hands of the developer.

Enjoy!

Sunday, 23 April 2017

Bitty Data Logger 2.3

A new release of Bitty Data Logger from Bitty Software is now available for both Android and iOS. Check Google Play and the Apple App Store for the update.

This release aims to streamline the process of using the app for Bloodhound Race for the Line competition participants (see http://www.racefortheline.com/). Key data may now be uploaded direct to the Bloodhound leader board after data has been collected.

Changes in this release are:

1. Data logging projects may now be designated as type 'Bloodhound Race for the Line' or 'Other'

2. Results from Bloodhound projects (rocket car races) may be uploaded directly to the Bloodhound Leader Board

3. Minimum and maximum acceleration in X, Y and Z directions are now recorded in results

4. Certain types of data in results may now be edited to correct mistakes prior to upload or posting to the Bloodhound Leader Board

It is recommended that you uninstall Bitty Data Logger and then install the new release from the application store.

That's it

Enjoy