The product is currently Out-of-Stock. Enter your email address below and we will notify you as soon as the product is available.







Expansion Shield, compatible with various Arduino boards and with our Fishino UNO that without virtually committing hardware resources, allows you to have as many as 16 outputs PWM and 16 additional digital inputs / outputs. Not only that, the sheets are overlapped up to a maximum of 8, allowing to manage with Arduino up to 128 digital and 128 outputs PWM additional I / O; all it made completely transparent to the user via a user-created library ad-hoc.

N.B. Arduino / Fishino and RC servos are not included (see related products).

Why it was made

As practical and capable of achieving countless applications, the Arduino boards compatible and have two limitations: the relatively reduced program memory and the reduced amount of available outputs, kind of I / O which may be assigned a PWM signal. For example, an Arduino / Fishino ONE has only six PWM outputs and, unless generate the related signals via software (with considerable commitment of the processor), allows the piloting of a driver, and then only a single LED RGBW power, or alternatively six monochromatic LEDs.

The boundary itself emerges when you want to fly more than 6 servo motors with the same tabs; the realization of a type robots "hexapod", which requires well servos 12, is problematic, if not impossible. the inputs and outputs are also limited; always talking about Arduino boards, we have a total of 13 digital and 6 analog inputs I / O, also used in digital; It seems too abundant, except that many of these are used for devices on board or by the expansion shield. In practice, creating a project with a shield Ethernet / WiFi, an SD memory and requires serial output and some analog input, only six digital I / O are available that are often insufficient to medium complexity projects.

Libraries

As already mentioned, for this card we have specifically designed a software library, called Octopus, equipped with some special features that make it easy to use. The first interesting feature of the library you can see from dell'include file lines (Octopus.h):

#define Octopus __octopus()
OctopusClass &__octopus();

and from the source file lines (Octopus.cpp):

OctopusClass &__octopus()
{
static OctopusClass octo;
return octo;
}


This seemingly strange ways of the Octopus variable use can overcome one of the C ++ problems, or initialization of global variables which does not happen in a predetermined order, but is random, and is carried out to load the sketch. In our case, having to initialize the I²C interface using the instructions:

Wire.begin();
Wire.setClock(400000);

before the use of the library, it is impossible to create the static variable Octopus when loading the program, since the Wire interface that moment has not yet been initialized.
The chosen solution allows to obtain against the creation of the variable to the first use of the same, and then after initializing properly the I²C-bus interface; This has allowed us to create a code, with no additional program line, is able to count and initialize correctly all the shield Octopus connected and automatically numerarne outputs in order of I²C address. For example, if we apply to our Arduino shield two, we will have 32 digital I / O, numbered from 0 to 31, and 32 PWM, also numbered from 0 to 31.
The library provides two functions that allow you to know the number of connected boards and the number of I / O and PWM available:

// return number of boards founduint8_t getNumBoards(void) const;
// return number of available I/Ouint8_t getNumIO(void) const;

As mentioned earlier, the PWM frequency is unique for each card, then for each group of 16 PWM outputs; can be set using the following two functions, the first tab to tab and the second for all the connected cards in one command:

// set pwm frequency for a single connected board
// valid values 24 Hz...1526 Hzvoid setPWMFreq(uint8_t board, uint16_t freq);
// set pwm frequency for ALL connected boardsvoid setPWMFreq(uint16_t freq);

In the first you should indicate the card number (ranging from 0 to Octopus.getNumBoards ()) and the PWM frequency, from 24 Hz to 1,526 Hz; the second is sufficient to indicate the frequency and all tabs will be set on that. At power up, the preset frequency is 200 Hz, suitable for servo control but also to LEDs. The PWM output value can be set, similarly to the Arduino libraries, using the following function:

// pwm output
void analogWrite(uint8_t port, uint16_t val, bool invert = false);

For example, to set the exit 30 (the third last of the second board connected) to 50% of the maximum value, you must write Octopus.analogWrite (30, 2048); The optional third parameter, invert, is useful if you connect the LEDs outgoing exploiting the open collector outputs mode and by connecting the anodes to the positive; in this case it needs to reverse an output (more time remains high, less current flows in the LED) and it is therefore necessary to set the parameter
to true to get a growing light with the value val. As you may have noticed, the PWM value unlike the Arduino outputs is 16 bits, of which they are used 12, thus allowing a variation of intensity at 4096 levels instead of 256 Arduino; This allows, for example, a much more gradual emitted from LED light intensity control connected to the card. On the other hand it is necessary to remember this when you set the value, considering that a number of 255, which corresponds to the maximum intensity of Arduino, here corresponds to a rather low value (255 / 4,096 of the maximum). For the management of the digital I / O, the library provides the following functions, virtually identical to those
the standard libraries, if not for the fact of being able to also use a very large number of target:
// digital I/Ovoid pinMode(uint8_t port, uint8_t mode);bool digitalRead(uint8_t port);void digitalWrite(uint8_t port, bool value);
// read/write all digital pins of given board at onceuint16_t digitalReadAll(uint8_t board);void digitalWriteAll(uint8_t board, uint16_t val);


The last two functions allow you to read and write all digital ports for a card in one go, using a 16-bit variable; This is very handy in case you need to change or read quickly the doors digitali.Al time of publication of this article library (downloadable from our website www.elettronicain.it together with the project file) is nearing completion, and functions of the interrupt and change the output mode PWM (open drain / totem pole) must be completed.

Sketch 

Finally, we present a simple sketch that displays a "tail" light using 16 LEDs connected to the PWM outputs (Listing 1).
The code initializes the serial interface, prints a message, initializes the I²C, press the number of detected cards and, using the first of them (PWM outputs from 0 to 15) creates a kind of 'snake' Bright using 16 LEDs.
The brightness values ​​of the 'snake' are previously calculated in the setup and entered in a table containing 16 values; depending on the table base (variable 'i' in the loop) the 'head of the snake' is located in a different place, thus creating the visual effect desired.
As you can see, apart from having to enter 'Octopus.' Before analogWrite () commands use is virtually identical to the Arduino native library. The only thing of note is the calculation of the brightness values, performed here with a polynomial of the second order so as to create a wave effect; other methods are possible with trigonometric functions or simply with a linear variation of which you'll experience; eg:

for(int k = 0; k < 16; k++)
sinTable[k] = 4096 * sin(M_PI / 16 * k);

for a sinusoidal shape, or

for(int k = 0; k < 16; k++)
if(k <= 8)
sinTable[k] = 4096 * (double)k / 8;
else
sinTable[k] = 4096 * (double)(15 - k)
/ 8;

for a bilinear trend.

We conclude here the description of our Octopus card; you can now experience the different lighting effects using eg Hummingbird drivers presented in the last issue of Electronics In.

Documentation and useful links

Write a review

Please login or register to review

Octopus - Shield 16 I/O for Fishino and Arduino -kit

  • Price: 21.00€


Tags: Octopus, Shield, 16 I/O, Fishino, Arduino, kit, servo

The product is currently Out-of-Stock. Enter your email address below and we will notify you as soon as the product is available.