I game, I code, I break things
Technical, constructive, fun.
Menu

Arduino IDE on Windows with Minimus32 Profile June 5, 2013

Some time ago I typed up an explanation and presented a download of a compressed file for the Arduino IDE on Windows which included libraries for the Minimus32.

The zip file was/is unnecessarily bulky and has folders in places where they don’t need to be. So I decided to create a script.

The script downloads the Arduino IDE, of a version which you specify from the Arduino Website along with PBrook’s Minimus32 and OneWire components from his GitHub page and also the pre-compiled version 4.7.0 of AVR-GCC for windows (if you want a different version then feel free to update and compile from the source code yourself but for now it’s supplied by yours truly).

It then puts it all in a folder called ‘ide’ and it should copy/rename/move everything in its correct place within a sub-folder. The drivers still have to be manually installed.

There are some thoughts on what I’ve done:

1. Alter the script so that it scrapes the Arduino site for the latest stable revision number.
2. Have the drivers self-signed so that the don’t prompt with an error message. This can’t be done as self signing only works for the system it is signed upon.
3. Use a command line tool to inject the drivers into Windows / auto install them.
4. Perform error checking in the script. I have since done this to at least check that the files exist, but nothing more.

The over-all benefit of this, I feel, is that it’s not waiting for me to do a ‘snapshot’ and anyone can now check the latest version (if they modify the script a bit), type it into the script and when it’s finished downloading it should just work nicely without having to do anything (much) extra.

So once you’ve downloaded it. Extract it to wherever you have write access to, then just double-click or run install.cmd from a command prompt.

You shouldn’t need to, but run it as Administrator if you really get into trouble.

I mainly wrote this for myself, because I’m lazy. So if it does help anyone else, great. I am also aware it could be implemented a lot better, so go ahead.

Download: Arduino IDE Download Script for Windows with AVR-GCC 4.7.0 + Paul’s Minimus32 Profile & Internal PullUp OneWire Library (2.98mB)

Comments Off on Arduino IDE on Windows with Minimus32 Profile

Arduino IDE on Windows June 3, 2013

If I have learnt anything from software development over the years, it’s that programming on Windows is a mixed bag. Even more so when it comes to the development of hardware, as I have learnt more recently since joining the Leeds Hackspace.

The Arduino, a rather nice prototyping board, does have an Integrated Development Environment (IDE) for windows, but when you try to do that little bit more with it, such as code for an unorthodox piece of hardware it can get a bit trickier. Namely, when certain chips aren’t supported.

The Arduino IDE (AIDE) is actually a mixture of smaller components. A Java GUI, the AVR-GCC compiler, source code in C++ and profiles for the various Arduino hardware. A problem mainly arises when you want to use a new device, that is perhaps acting like an Arduino but is using a newer chip on the board than is supported by the archaic AVR-GCC compiler that is bundled with the AIDE.

I’ve been working on a script which pulls down the latest AIDE and incorporates support for, in particular, the minimus32 (using the ATMega32u) but it isn’t exactly user friendly (yet). Until that appears (though if you want to try it out, get in touch), I have happened across a rebuild of the Arduino IDE which is a bit nicer and, perhaps with suggestions for including decent updates such as a recompiled AVR-GCC, it could potentially be a better solution.

Comments Off on Arduino IDE on Windows

Self Calibrating Potentiometer December 31, 2012

Update: Code edited for clarity and make sure you read pbrook‘s comment

So I have a dial connected to an Arduino, a potentiometer (pot), it’s the typical item you might use for volume or brightness control, turning it all the way up to 11. Here’s the problem though, you’re reading in the analogue values of the potentiometer and you think it goes from 0 to 1023, possibly higher if it glitches a bit (though this is dependent on how it is handled in your code).

However, what you’re controlling, only goes from 0 to 10, maybe. What do you do?

Well one idea, is that you convert it to a percentage before making the comparison, I think this is effectively ‘normalising‘ the values – statistically speaking. This is really useful. So in this code I’m doing two things, one is that I am normalising the values but the other is that I am calibrating the values that I am reading.

Why should I be calibrating? Well, this code is then portable (the mathematics could apply to anything similar, as I see it), not only that but if the ‘pot’ needs replacing, then if it is placed in the ‘maximum’ value position for a while, then it’ll be accurate (well enough so).

#include "math.h"

int sensorPin = A0;
int maxVal = 0;
float sensorValue = 0.0f;
float percentile = 0.0f;
float temp = 0.0f;

void setup() {
 Serial.begin(9600);
}

void loop() {
 sensorValue = analogRead(sensorPin);
 percentile = (sensorValue / maxVal) * 100;
 temp = fmod(percentile,10.0);
 if (temp > 0.5)
 {
     percentile += 0.5;
 }
 if (percentile > 100.4)
 {
     maxVal++;
 }
 else
 {
     Serial.println((int)percentile);
 }
}

The code utilises the C++ Math library, and rounds the value from the pot up (I think, I should probably double check it) using the function ‘fmod‘. If the pot is set at the maximum it is capable of being at, it will increase the ‘maxVal’ variable to work out the correct 100% value to calculate with.

If anyone has feedback or corrections on this, please comment!

Comments Off on Self Calibrating Potentiometer
Categories: arduino code

SD Card Writing with the Minimus32 November 20, 2012

Part of a project that I am working on to measure the temperature and log it, involves writing to an SD Card (reading from it is not so important). So as part of this I purchased some items from the Proto-Pic website, one of which was an SD Card breakout board which came with, as a new person to this, I felt, next to no direct guidelines or instructions on how to wire it up. Sure, there’s schematics and the SanDisk pin-outs. However, nothing particularly clear as to what, connects, to what.

Paul Brook has on his wiki, the pin-outs for the Minimus32 which clearly shows the SPI (that’s effectively how to communicate over serial) but translating this to the break-out board was troublesome. However, after trial and error and running out of memory, I discovered the following works:

SCK /10 -> CLK

SS  /9  -> D3

MOSI/12 -> CMD

MISO/13 -> D0

The first problem I had to overcome was the fact that the Minimus32 has 1k of RAM to work with, some of which is used up by variables, ,code running, etc. This was exasperated by the fact that the library I was using to talk to the SD Card, attempting to use FAT32, was quite bulky.

Thankfully, there is an alternative, FAT16 based library that claims to take up much less memory. The difference? This means that really, I can’t write gigabytes of data to an SD Card. When all I’m doing is logging temperatures, I don’t need that much data.

This FAT16 library requires a bit of hacking to get to work with the Minimus32, it requires a profile for the AVR_AtMega32u2 else it cannot identify the chipset, this is so that it can set the aforementioned PINs properly (I think it’s in SDCard.h in the library, which you put in the sketchbook/libraries/Fat16 folder) and be able to communicate with the SD Card.

In fact, it was this library, which because it was smaller and wrote out to the Serial (monitor-able using the Arduino IDE or HyperTerm or equivalent) gave me an error code which let me work out which cable I had connected incorrectly. (I had the CMD and CD connections crossed on the break-out board).

Damn I was joyous.

Comments Off on SD Card Writing with the Minimus32

Electronics at Leeds Hackspace with Arduino and Minimus32 November 16, 2012

Update: While this version of the Arduino IDE will work, I have attempted a way of getting the latest version.

Within the past few months I picked up a new hobby, my friend Kai mentioned this place to me once before and I’ve always had an interest in electronics so off I went to the Leeds Hackspace.

To prototype electrical, let’s say, gadgets there is a device called the Arduino which with a little bit of C++ programming, some wires, LEDs, buzzers, chips, etc. You can get up and running into a large or small system to do almost whatever you want.

Typical applications involve constructing an autonomous robot to controlling laser cutters. Lasers are fun.

So along came this device, called the Minimus32 which, I’m told, was originally intended for circumventing the copy protection on the Sony Playstation 3. Turns out, however, that this little device uses the same chipset as an Arduino and can run the same code and behave in the same way, especially when it has been flashed with a new DFU Bootloader. The best part about this, is that the Minimus32 is typically about a fifth the price of the equivalent Arduino (possibly Leonardo model).

To get this to work under Linux is quite straight forward (at least within Debian and Ubuntu). You use the Arduino IDE 1.0.1 and you grab the profile information for the board from Paul Brook‘s github repositories which allow you to upload the code and monitor the serial port. It also interprets some of the default pin-outs and Paul also has a slightly re-worked OneWire library to use the internal pull-up resistor on the board.

When it comes to Windows, however, it gets a little bit tricky.

As it turns out, the latest Integrated Development Environment (IDE) for Arduino comes with an ‘avr-gcc’ compiler, which handles the compilation of the C++ code. However, in the windows bundle from the Arduino site this is grossly out of date. When this is combined with Paul’s hardware profile for the Minimus32 and a flashed Minimus, the compiler doesn’t know what to do with it.

Fortunately, I have scoured about, packaged together the IDE, a ‘sketchbook’ folder (where the hardware profiles/libraries are stored), an updated WinAVR compiler along with a recently compiled avr-gcc compiler (c/o Andy Brown). If you do not change your Arduino IDE preferences to use this sketchbook folder, you will not be able to select the minimus32 as your board (which is required).

I’m happy to say, that using the drivers supplied with the latest Arduino IDE for windows (1.0.2) along with the updated compiler and Paul’s hardware profile I’m quite happily compiling and working with the Minimus32 on windows (version 7, 64bit). Oh, and Paul’s hardware profile also include the DFU Bootloader to turn the Minimus32 into an Arduino.

Download: Arduino IDE 1.0.2 for Windows with Compiler + Paul’s Profile / Library (98mb)

Comments Off on Electronics at Leeds Hackspace with Arduino and Minimus32