In the previous post I made an LCD based share price ticker. It was always my intention to move the demo to a LoL shield for that authentic look. The code change only took 5 minutes or so, the assembly of the LoL took a quite a bit longer. The modified code listing is below. The main difference is the new procedure, LOL_SLIDER, and the installation of the LoL shield. The remainder of the code remains the same. You may notice that the key words used to display text and graphics on the LCD shield are the same as the keywords used to display text and graphics on the LoL shield.Read More
Hackaday recently posted a blog on how to use an Arduino to indicate whether particular share prices were rising or falling by altering the color of an LED. At about the same time a friend of mine had decided to purchase some shares of his own. The timing of these two matters inspired me to put together a SolderCore script that could fetch data from the stock market and display the results to one or more of the supported graphical shields...Read More
Anyway, progress continues on the Quadshot:
I ordered the Cappuccino variant form the original Kickstarter funding which delivered the airframe, but it means I must add my own flight hardware and software. This is what I want to do because, although I'd like to fly it, what really interests me is the software that is needed to fly it. The hardware is already done, I have a SolderCore and the CoreMPU. For those unfamiliar with the CoreMPU, it's a small unit containing an MPU-6050 and an HMC5883L which is a 9DOF sensor array: accelerometer, gyroscopes, and magnetometer. In addition, I have a CorePressure module that can accurately measure altitude using barometric pressure so, hopefully, a programmed controlled landing on autopilot will be possible!
As part of this task, I thought I'd share how I typically develop a driver for inclusion in CoreBASIC. Today, I'm constructing a driver for the L3G4200D MEMS gyroscope from STMicroelectronics. I've had a couple of breakout boards from SparkFun for a while now, and I ordered two.
First things first...One of the first things that I do is wire up the breakout board to test it out. Historically, I hand-wired the boards to the SolderCore directly, but this is both time consuming and error prone. When I change my software, I want to be able to test that I haven't broken anything by quickly grabbing a module from our extensive library of hardware, plug it in, and go! Finding all the data on the chip, the breakout, and having prototyping wires srouting from boards takes much too much time.
Instead, what I do now is use a CoreProto board and attach the breakout to it. Here's what I'll be snapping together:
I place the module on the CoreProto and wire-wrap it. My soldering and wire-wrapping skills are not the best, and I try to remove the flux with a cleaner, but to be honest, it's not my day job. This is what I end up with:
Once I've constructed that, I plug into into a SenseCore, which is installed on top of a SolderCore. Now I have a great sensor platform! Whenever I want to whip up a demonstration, or make sure that the latest modifications to the software haven't impacted the existing drivers, all I need to do is take a SolderCore, a SenseCore, and plug in the SExI-format module and I'm good!
This is what it looks like:
So now I am ready to try some software.
First connectionI have my hardware set up, so I need to see if the module is responding. To do this, the easiest thing is to use CoreBASIC interactively and poke the sensor. It's much faster to do this than construct a program in C, compile it, fix errors, download it, and debug why the blazes it's not working! As CoreBASIC already has full support for I2C and SPI, you have a great test platform at your fingertips, so why use something more fiddly and less immediate?
Great! The sensor is working. I can communicate with it. From there on, I can play with the registers from the datasheet in CoreBASIC and make sure I understand what I am seeing.
Write it in C...From there, it's a short distance to write the code in C and integrate it into the set of confidence tests. I write the driver in C and use CrossWorks to compile it into the CrossWorks Device Library:
The I write the confidence tests to ensure that I can communicate and demonstrate that it works as I expect:
So, now I have the sensor working in C. What I need to do now is construct the CoreBASIC interface onto this sensor, which is pretty much gruntwork because the hard work is already done:
Drum roll please...And now, of course, it's available in CoreBASIC!
How easy is that to read a gyro? A CoreBASIC user can do it, interactively, in just two lines. No C compiler, no compilation, nothing. Immediate.
StatisticsSo, here are some vital statistics for this task. The whole exercise took about four hours to integrate the sensor: from making the SExI module to firing up CoreBASIC and printing the gyro readings.
The low-level driver code, confidence tests, and CoreBASIC integration is about 500 lines of code, but that does not include all the framework functions such as I2C drivers, gain and bias application, bus selection, and so on, as that is already written.
However, with all that code written, it immediately works on all implementations of CoreBASIC (SolderCore, Freedom Board, Raspberry Pi) and on all C platform targets that we support. Great!
Many Internet-of-Things devices might want to connect securely; and more than that, robust authentication is also necessary. Simple authentication is being discarded and OAuth is starting to become the norm for services such as Twitter and COSM.
In view of that, I constructed an example a little while ago that will sign a Twitter API call using an HMAC-SHA1 signature. Rowley Associates has an established history in all this crypto boffinry as we wrote compilers under contract to Microsoft for their smart card virtual machine, and we also wrote the SmartWorks for MULTOS product which was bought out, rebranded, and now rests with MAOSCO as SmartDeck. This signing code isn't hardcore crypto: it's rather simple, in fact.
So, if you're interested in the signing code, you'll find it here:
This example takes the example from Twitter of constructing an OAuth signature and codes it up in CoreBASIC. When I run the program, I get the correct signature:
So, we're on the way to direct posting to Twitter without using a proxy application! Read More
With those things put to bed, I turned to a question about the PWM output of the SolderCore when a pin is configured as a digital output. I hooked up a scope to the PWM output of the SolderCore and things actually looked good, pretty much as I expected. I need to test some more tomorrow to confirm things.
To put this to good use, I wrote a small CoreBASIC program that uses a Nintendo Classic Controller to control the left and right tracks of a hastily-constructed robot. From the bottom up, the robot is built from a Polulu chassis and motors, a liquidware LiPo battery pack, a SparkFun Ardumoto, a SolderCore, and a SenseCore with a CoreWii adapter fitted:
Here's the CoreBASIC application to exercise this contraption:
' Call up required drivers.
INSTALL "NINTENDO-CLASSIC-CONTROLLER" AS CONTROLLER
INSTALL "SPARKFUN-ARDUMOTO" AS MOTORS
' Run until I die.
' Read vertical positions of both controllers.
THROTTLE = CONTROLLER.V
' Ask left and right motors to follow the joysticks.
MOTORS.LEFT = THROTTLE(0)
MOTORS.RIGHT = THROTTLE(1)
I'll blog a bit more about PWM tomorrow along with controlling the robot with a Nintendo Nunchuk controller, as long as I have some spare time. Read More