Arduino Due libraries (official and 3rd party)

Hi,

if you successfully run a library with the Due board, please post here a link to the library and a brief description.
I'll update this post regularly to get a list of available libraries for the Due.

First release of the RTC Library for the Arduino Due.

2 examples included.

I would call it final for the moment.

And on github: GitHub - MarkusLange/Arduino-Due-RTC-Library: RTC Library for the Arduino Due

I hope the library is self explaining.

Markus

Update new library with unixtime and compilertime support

Update Version 1.2 now support for Date & Time in one operation for BKM.

And some changes all in the changelog

Update Version 1.3 now unixtime with timezone support with Example for it, for tevroc

Update Version 1.4 now support for geman timezone with Summertime.

Update Version 1.5 some changes in the Summertime Sketch, and updates at this point only on git

Update Version 1.6 added rtc_clock.timing to detect when the time was set in summer- or wintertime
(mostly helpfully for the german member)

Update Version 1.7 added rtc_clock.date_already_set() to proof if date is allready set, to prevent setting time again for Paul Stoffregen

Update Version 1.8 added rtc_clock.set_clock() to set Time,Date in one line fixed bug in unixtime() and summertime() thanks to Paul Stoffregen for the hint

change.log (2.82 KB)

Eigen is a C++ library enabling Matlab and Octave-like matrix programming. Eigen works very well with the Arduino Due. As a Matlab user that appreciates minimalism, the Eigen library is written as plain header files. So no makefiles, no binary files, nothing to compile upfront, no headaches.

To make Eigen available for Arduino-IDE-1.5.2 on Windows 7, please follow these instructions and try my example in step-4: (applies to Due board only)

Step-1:
-> As of 4/16/2013, latest stable release is Eigen 3.1.3
-> Download attached ZIP file called "Eigen313.zip"

Step-2:
-> Copy ZIP file to this precise location in the Arduino IDE directory tree:
C:\Programs\arduino-1.5.2\hardware\arduino\sam\libraries

Step-3:
-> Run virus scanner, just in case.
-> Unzip to directory in step-2; when done, you should see the following directory:
C:\Programs\arduino-1.5.2\hardware\arduino\sam\libraries\Eigen313

Step-4:
-> Normally open Arduino-IDE as usual.
-> Run example code below demonstrating the Kalman gain equation using 6x6 matrices. Notice the clean and concise prose enabling programmer to "see" Kalman equations.
-> Also notice the ease in inputting matrices.
-> I wrote a function called print_mtxf to serially print matrices; it's included in the example below.

Good luck.

// Example By: RandomVibe
// Eigen Doc: http://eigen.tuxfamily.org/dox/
// Quick Reference: http://eigen.tuxfamily.org/dox/QuickRefPage.html

#include <Eigen313.h>     // Calls main Eigen matrix class library
#include <LU>             // Calls inverse, determinant, LU decomp., etc.
using namespace Eigen;    // Eigen related statement; simplifies syntax for declaration of matrices

void print_mtxf(const Eigen::MatrixXf& K);


void setup() {

    Serial.begin(9600);
    
    // DECLARE MATRICES 
    //--------------------
    MatrixXf Pp(6,6);   // Produces 6x6 float matrix class
    MatrixXf H(6,6);    // Note: without "using namespace Eigen", declaration would be: Eigen::MatrixXf H(6,6);
    MatrixXf R(6,6);  
    MatrixXf X(6,6);  
    MatrixXf K(6,6);  
    MatrixXf Z(6,6);  

    // INPUT MATRICES (so-called comma-initialize syntax)
    //---------------------------------------------------------
    Pp << 0.3252,  0.3192,  1.0933, -0.0068, -1.0891, -1.4916,
         -0.7549,  0.3129,  1.1093,  1.5326,  0.0326, -0.7423,
          1.3703, -0.8649, -0.8637, -0.7697,  0.5525, -1.0616,
         -1.7115, -0.0301,  0.0774,  0.3714,  1.1006,  2.3505,
         -0.1022, -0.1649, -1.2141, -0.2256,  1.5442, -0.6156,
         -0.2414,  0.6277, -1.1135,  1.1174,  0.0859,  0.7481 ;

    H << 0.8147, 0.2785, 0.9572, 0.7922, 0.6787, 0.7060,
         0.9058, 0.5469, 0.4854, 0.9595, 0.7577, 0.0318,
         0.1270, 0.9575, 0.8003, 0.6557, 0.7431, 0.2769,
         0.9134, 0.9649, 0.1419, 0.0357, 0.3922, 0.0462,
         0.6324, 0.1576, 0.4218, 0.8491, 0.6555, 0.0971,
         0.0975, 0.9706, 0.9157, 0.9340, 0.1712, 0.8235;

    R << 0.3252,  0.3192,  1.0933, -0.0068, -1.0891, -1.4916,
        -0.7549,  0.3129,  1.1093,  1.5326,  0.0326, -0.7423,
         1.3703, -0.8649, -0.8637, -0.7697,  0.5525, -1.0616,
        -1.7115, -0.0301,  0.0774,  0.3714,  1.1006,  2.3505,
        -0.1022, -0.1649, -1.2141, -0.2256,  1.5442, -0.6156,
        -0.2414,  0.6277, -1.1135,  1.1174,  0.0859,  0.7481;


    // Kalman Gain Example; Matlab form:  K = Pp * H' * inv(H * Pp * H' + R)
    //-----------------------------------
    X  = H * Pp * H.transpose() + R;    
    K  = Pp * H.transpose() * X.inverse();   


    // Print Result
    //----------------------------
     print_mtxf(K);      // Print Matrix Result (passed by reference)
    
}




void loop() {
  // put your main code here, to run repeatedly: 
  
}




// PRINT MATRIX (float type)
// By: randomvibe
//-----------------------------
void print_mtxf(const Eigen::MatrixXf& X)  
{
    int i, j, nrow, ncol;
    
    nrow = X.rows();
    ncol = X.cols();

    Serial.print("nrow: "); Serial.println(nrow);
    Serial.print("ncol: "); Serial.println(ncol);       
    Serial.println();
    
    for (i=0; i<nrow; i++)
    {
        for (j=0; j<ncol; j++)
        {
            Serial.print(X(i,j), 6);   // print 6 decimal places
            Serial.print(", ");
        }
        Serial.println();
    }
    Serial.println();
}

Eigen313.zip (672 KB)

the LCDBitmap Library runs flawlessly on the DUE

Located at
http://code.google.com/p/arduino-lcd-bitmap/

ported basic function over for the adafruit stepper shield

the library can be downloaded here

As mentioned in this thread:
http://arduino.cc/forum/index.php/topic,136495.0.html

My gLCD-Library for Nokia 6100 Displays fully supports the arduino due. This means that the Sparkfun Color LCD Sheild is compatible with the Due.

UTFT library thread:

http://arduino.cc/forum/index.php/topic,144198.0.html

SDfat library thread:

http://arduino.cc/forum/index.php/topic,135439.0.html

OneWire library thread:

http://arduino.cc/forum/index.php/topic,141030.0.html

AdaFruit RTC library thread:

http://arduino.cc/forum/index.php/topic,143515.0.html

Due VGA Library: http://arduino.cc/forum/index.php/topic,150517.0.html

The VGA library lets you connect your Due to a monitor with an analog VGA input. Modes supported include 640x480 and 800x600 in monochrome and 320x240 in colour. Simple drawing functions for pixels, lines, triangles, rectangles, circles and ellipses are included. Full support for Arduino-style print and println functions too.

Schematic is extremely simple - just 3 resistors for monochrome and 10 resistors for colour.

I am using the Eigen library and want to run it in the arduino due I have posted some of my codeblocks c++ code for my windows machine.

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.

http://eigen.tuxfamily.org/index.php?title=Main_Page

#include <iostream>
#include <Eigen/Dense>
#include <Eigen/LU>
using Eigen::MatrixXd;
using namespace std;
int main()
{
cout << "Hello Pattern matching Linear Discriminent Analisis!" << endl;
cout << "" << endl;
cout << "x data" << endl;

//data matrix x row col
MatrixXd x(4,2);
//cur
x(0,0) = 2.95;//g0
x(1,0) = 2.53;
x(2,0) = 3.57;
x(3,0) = 3.16;

//dia
x(0,1) = 6.63;//g0
x(1,1) = 7.79;
x(2,1) = 5.65;
x(3,1) = 5.47;

std::cout << x << std::endl;
cout << "End of x data" << endl;
cout << "" << endl;

cout << "x1 data" << endl;

MatrixXd x1(3,2);

x1(0,0) = 2.58;//g1
x1(1,0) = 2.16;
x1(2,0) = 3.27;

x1(0,1) = 4.46;//g1
x1(1,1) = 6.22;
x1(2,1) = 3.52;

std::cout << x1 << std::endl;
cout << "End of x1 data" << endl;
cout << "" << endl;

//group adv
cout << "x data adverage ui" << endl;

MatrixXd ui(1,2);//group/feature
ui(0,0)=(x(0,0) + x(1,0) + x(2,0) + x(3,0))/4;
ui(0,1)=(x(0,1) + x(1,1) + x(2,1) + x(3,1))/4;
std::cout << ui << std::endl;
cout << "" << endl;

cout << "x1 data adverage ui1" << endl;

MatrixXd ui1(1,2);//group/feature

ui1(0,0)=(x1(0,0) + x1(1,0) + x1(2,0))/3.0;
ui1(0,1)=(x1(0,1) + x1(1,1) + x1(2,1))/3.0;
std::cout << ui1 << std::endl;
cout << "" << endl;

cout << "x & x1 data adverage u" << endl;
MatrixXd u(1,2);//all group/feature
u(0,0)=(x(0,0) + x(1,0) + x(2,0) + x(3,0) + x1(0,0) + x1(1,0) + x1(2,0))/7.0;

u(0,1)=(x(0,1) + x(1,1) + x(2,1) + x(3,1) + x1(0,1) + x1(1,1) + x1(2,1))/7.0;

std::cout << u << std::endl;
cout << "" << endl;


cout << "mean corrected data xig - u" << endl;
MatrixXd ximinu(4,2);
//cur
ximinu(0,0) = x(0,0) - u(0,0);//f0
ximinu(1,0) = x(1,0) - u(0,0);
ximinu(2,0) = x(2,0) - u(0,0);
ximinu(3,0) = x(3,0) - u(0,0);
//dia
ximinu(0,1) = x(0,1) - u(0,1);//f1
ximinu(1,1) = x(1,1) - u(0,1);
ximinu(2,1) = x(2,1) - u(0,1);
ximinu(3,1) = x(3,1) - u(0,1);
std::cout << ximinu << std::endl;
cout << "" << endl;

cout << "mean corrected data xi1 - u" << endl;


MatrixXd ximinu1(3,2);
//cur
ximinu1(0,0) = x1(0,0) - u(0,0);
ximinu1(1,0) = x1(1,0) - u(0,0);
ximinu1(2,0) = x1(2,0) - u(0,0);
//dia
ximinu1(0,1) = x1(0,1) - u(0,1);//g1
ximinu1(1,1) = x1(1,1) - u(0,1);
ximinu1(2,1) = x1(2,1) - u(0,1);

std::cout << ximinu1 << std::endl;

cout << " " << endl;

cout << "Transpose matricies" << endl;
cout << "xi - u T" << endl;

MatrixXd ximinut(4,2);
ximinut= ximinu.transpose();
std::cout << ximinut<< std::endl;
cout << " " << endl;

cout << "xi1 - u T" << endl;
MatrixXd ximinu1t(3,2);
ximinu1t= ximinu1.transpose();
std::cout << ximinu1t << std::endl;
cout << " " << endl;

cout << "Covariance matrix of group ci" << endl;
MatrixXd ci(2,2);
ci = ( ximinut * ximinu ) /4.0;
std::cout << ci << std::endl;
cout << "" << endl;

cout << "Covariance matrix of group ci1" << endl;
MatrixXd ci1(2,2);
ci1 = ( ximinu1t * ximinu1 ) /3.0;
std::cout << ci1 << std::endl;
cout << "" << endl;

cout << "Pooled within group Covariance matrix c" << endl;
MatrixXd c(2,2);
c(0,0) = 4.0/7.0 * ci(0,0) + 3.0/7.0 * ci1(0,0);
c(1,0) = 4.0/7.0 * ci(1,0) + 3.0/7.0 * ci1(1,0);
c(0,1) = 4.0/7.0 * ci(0,1) + 3.0/7.0 * ci1(0,1);
c(1,1) = 4.0/7.0 * ci(1,1) + 3.0/7.0 * ci1(1,1);
std::cout << c << std::endl;
cout << "" << endl;

cout << "inverse of Pooled within group Covariance matrix cinverse" << endl;
MatrixXd cinverse(2,2);
 cinverse=c.inverse();
std::cout << cinverse << std::endl;
cout << "" << endl;

cout << "Probability of a group" << endl;
cout << "x = 4/7 x1 = 3/7" << endl;

//create a vector of a probability...
cout << "" << endl;

//formula for calculatin likelyhood of data in a group...
//fi = uig cinverse xkt - 1/2uig cinverse uitg + ln probability

cout << "End of program!" << endl;

    return 0;
}

main.cpp (3.72 KB)

Library for WS2803 LED driver chips.

DS1307 RTC library: Arduino due DS1307 RTC library - #13 by jake1981 - Arduino Due - Arduino Forum

Library for Due and WiFly GSX Breakout from SparkFun

The graphics LCD (ST7565, UC1701, KS0108, ...) and OLED (SSD1306, ...) library "U8glib" includes support for Arduino Due.

http://code.google.com/p/u8glib/

Roving Networks RN-XV library.

Basically this is the one from GitHub - harlequin-tech/WiFlyHQ: WiFly RN-XV Arduino Library but modified to work with Arduino Due is at:

https://bitbucket.org/thiseldo/wiflyhqdue

Changes are to remove PSTR and PROGMEM use and to change to hardware serial instead of softserial.

Examples updated.

There may still be issues with this as not fully tested in all situations, but basic client and server actions seem to work.

Full credit to the original authors, Harlequin-tech for their library.

Thanks

Andy

who knows the link of the IRremote.h for the Due

I created a simple external memory interface/static memory controller. Because of some HW limitations, it's not a full bus interface but can be used for interfacing with parallel LCDs.

More info here:
http://arduino.cc/forum/index.php/topic,152644.0.html

ported Adafruit's sensor framework and TSL2561 (luminosity sensor) lib to the Due:

The AccelStepper library works beautifully with the Due. (Using step/dir based driver board.)

Desc:
High performance Non-Blocking (or blocking if desired).
Stepper library written in C++

Developmental Assets:
Very well documented.

Library: pwm01.h
Description: A clean alternate approach for setting up unique PWM frequencies from within a sketch, for any or all PWM pins. The trick is to utilize the two PWM clocks (CLKA & CLKB) provided by the SAM3X8E chip.

I wrote and enclosed a library (pwm01.h). It includes 4 user functions to: 1) setup PWM resolution, 2) setup PWM pin, frequency & pick clock, 3) write duty cycle, and 4) stop PWM. See example code for usage:

#include "C:\Programs\arduino-1.5.1r2\hardware\arduino\sam\libraries\Pwm01\pwm01.h"

void setup() 
{
    uint32_t  pwm_duty = 32767;
    uint32_t  pwm_freq1 = 2;  
    uint32_t  pwm_freq2 = 5000;

    // Set PWM Resolution
    pwm_set_resolution(16);  

    // Setup PWM Once (Up to two unique frequencies allowed
    //-----------------------------------------------------    
    pwm_setup( 6, pwm_freq1, 1);  // Pin 6 freq set to "pwm_freq1" on clock A
    pwm_setup( 7, pwm_freq2, 2);  // Pin 7 freq set to "pwm_freq2" on clock B
    pwm_setup( 8, pwm_freq2, 2);  // Pin 8 freq set to "pwm_freq2" on clock B
    pwm_setup( 9, pwm_freq2, 2);  // Pin 9 freq set to "pwm_freq2" on clock B
      
    // Write PWM Duty Cycle Anytime After PWM Setup
    //-----------------------------------------------------    
    pwm_write_duty( 6, pwm_duty );  // 50% duty cycle on Pin 6
    pwm_write_duty( 7, pwm_duty );  // 50% duty cycle on Pin 7
    pwm_write_duty( 8, pwm_duty );  // 50% duty cycle on Pin 8
    pwm_write_duty( 9, pwm_duty );  // 50% duty cycle on Pin 9

    delay(30000);  // 30sec Delay; PWM signal will still stream
        
    // Force PWM Stop On All Pins
    //-----------------------------    
    pwm_stop( 6 );
    pwm_stop( 7 );
    pwm_stop( 8 );
    pwm_stop( 9 );
}

void loop() 
{  
}

The pwm01.h library and example code were tested in IDE 1.5.1r2. Additional notes on this library:

  • Applies to Arduino-Due board, PWM pins 6, 7, 8 & 9.
  • Libary Does not operate on the TIO pins.
  • Unique frequencies set via PWM Clock-A ("CLKA") and Clock-B ("CLKB")
    Therefore, up to two unique frequencies allowed.
  • Set max duty cycle counts (pwm_max_duty_Ncount) equal to 255 per Arduino approach.
    This value is best SUITED for low frequency applications (2hz to 40,000hz) such as
    PWM motor drivers, 38khz infrared transmitters, etc.
  • Future library versions will address high frequency applications.
  • Arduino's "wiring_analog.c" function was very helpful in this effort.

pwm01.h (3.96 KB)

1 Like

Encoder has been updated to support Arduino Due.

http://www.pjrc.com/teensy/td_libs_Encoder.html