Adaboard Anyone?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

sellensr wrote:I actually have a Due that I've been programming. It is exactly as accessible as the extremely approachable UNO. Reading ADCs and DIO is the simple analogRead(pin) format you want, without messing with registers. The board and IDE exist and there's a lot of experience with the Arduino IDE out there already.
Yes, I agree with that. As stated in this thread, I think it'd be even better with Octave or Python.
sellensr wrote:Even with GHz PC processors and FPUs we usually wind up with C code for the speed. I expect a matlab like platform would be painfully slow on anything less than a current desktop, because that determines our tolerance for delay.
My guess is that the clear majority of Arduino projects don't require the full speed of the processor, so an interpreted implementation may not be that bad. Even in the most advanced X-plane demonstrators, the flight control system sample rate does not exceed 200hz (0.005sec per loop).

Another possibility (however unlikely), would be to implement Octave as a compiled language. In other words, the IDE converts the Octave code into C code. This approach works very well for the Zbasic mcu - this system is programmable in Visual Basic, and behind the scene generates C followed my object native code. If it can be done with visual basic, it can be done with Octave. If Octave for an Arduino-Due-like board ever happens, it'll likely be the interpreted version first, because, well, it's ready to go and it's a matter of integration.

http://www.zbasic.net
sellensr wrote:Write your matrix algebra in the high level language of your choice and use automatic code generation to translate to C code you can take to any platform.
That is a very good approach, but cost prohibitive for those who don't have access to Matlab ($7,000 USD) and the compiler ($$$ USD).

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Adaboard Anyone?

Post by westfw »

I want to make stuff, without having to worry about registers, makefiles, etc.
This is whay Arduino attempts to do. Relatively successfully, by most accounts. Have you actually used Arduino? It doesn't have makefiles, and doesn't often use "registers."
I think an Octave-based platform fits that bill [is easier to much better than C-based platforms. Python is okay too if Octave can not be had.
You see, I don't quite get this. If you're a rank beginner, I tend to believe that most computer languages have a similar sized "hump" to get over, and you're not really going to make things easier by using python, or matlab. rather than C++. Oh, you can attract a few people that have already been exposed to python pr matlab, and alienate some people who have heard of it in a manner that frightens them ("OMG octave has vectors and linear algebra stuff! I've never even heard of a vector expression of a Kalman filter!") But I don't think it's going to really make a big difference. (then, there was the guy on the Arduino forums who said he really couldn't wrap his mind around that C stuff, and wanted help getting Forth running on his hardware. I guess a lot of people really DO "think differently.")

randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

westfw wrote:Have you actually used Arduino? It doesn't have makefiles, and doesn't often use "registers."
I'm using the Arduino-Due now. Of course it "fits the bill". Have you used Matlab or Octave?

I understand it's difficult to understand the power and simplicity of these vector-based languages if you haven't used them. We can agree to disagree here, but the trend in academia and industry is clear: Matlab usage is growing, and so is Python, in a very very big way. Python has a small learning "hump", but you should know Octave is virtually humpless.

For those interested in Octave, I was able to install it in the Raspberry Pi and it functions beautifully. Even the plotting functions work! To install, make sure your RPi is connected to the ethernet, then open a linux terminal, and enter:

Code: Select all

sudo aptitude install liboctave-dev
I'm currently trying to add a C++ library (bcm2835) needed to communicate with the RPi input/output pins. In Octave, you can include C++ libraries - unfortunately I'm weak in this area. Maybe some of you will have better luck.

http://www.open.com.au/mikem/bcm2835/

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Adaboard Anyone?

Post by westfw »

Have you used Matlab or Octave?
I understand it's difficult to understand the power and simplicity of these vector-based languages if you haven't used them.
No, I've never used Matlab or Octave. I thought they were more symbolic calculation environments with some sort of programming capability thrown on the side, sort of like (showing my age) Macsyma.

I guess I have a hard time understanding how someone versed in vectors and linear algebra (which I view as "hard") would have any problems wrapping their brain around C (which I regard as "easy.") And I'm having trouble figuring out what sort of arduino-sized problems would require that sort of math, too (since in my experience, relatively few problems even involve floating point...) Ah well, minds work differently. (I'm also having a hard time understanding how python (which I've only used slightly) is so much different from C.)
sudo aptitude install liboctave-dev
How long did THAT take? My first search for Octave on my Mac suggested a source-based install, an that's still going 3 hours later (8core, 10GB mac...)
octave-3.4.0:4> e^(i*pi)
ans = -1.0000e+00 + 1.2246e-16i
That's not very comforting!

randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

The Octave installation on the RaspberryPi over DSL took roughly 45 to 60 minutes.
westfw wrote:... Matlab or Octave. I thought they were more symbolic calculation environments with some sort of programming capability thrown on the side
It's a programming language as simple as Basic, but with powerful math and vector programming capabilities, and visualization functions. Linear algebra is very "hard" in C/C++, but very easy like arithmetic in Octave and Matlab. Here's a complete example program demonstrating some matrix math. You can create a file and run it, or type each line one at a time for an interactive experience. Try both.

Code: Select all

% Crude example: (works equally in Octave or Matlab)
Pp = rand(12,12);                      % random 12x12 matrix       
H  = rand(12,12);                      % another random 12x12 matrix
R  = rand(12,12);                      % etc.
K  = Pp * H' * inv(H * Pp * H' + R);   % lots of matrix math
plot(K(:,1), K(:,2));                  % plot the 1st column of K vs. 2nd column just to demo plot
The C/C++ equivalent would not be pretty, especially with the graphics.
westfw wrote:I'm having trouble figuring out what sort of arduino-sized problems would require that sort of math, too (since in my experience, relatively few problems even involve floating point...)
I'm interested in using the Arduino-Due for robotics with feedback control systems. Floating point and matrix math are essential. I made an IMU using a Zbasic device ( http://www.zbasic.net ), but for me, the program got too messy, so I had to recode the device to serially stream accel and rate gyro signals to my PC. From there, I did the Kalman filter in Matlab. It literally took a couple of hours at most, and the code is maybe 2 pages long (without using the "kalman" function), and maybe took 2 hours to put together!

Vector programming saves time! And it enables clean, concise, simple, and legible code. Wouldn't that benefit an open source community?

Let's face it, the adaboard is a pipe dream. Maybe when an R-Pi variant comes with more speed and native ADCs, Octave will make more sense. In the meantime, for those interested in vector programming, I started a thread in arduino.cc to at least get something like Eigen going in the Arudino Due.

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

User avatar
brucef
 
Posts: 215
Joined: Tue May 03, 2011 4:51 pm

Re: Adaboard Anyone?

Post by brucef »

I still like the idea, at least as I imagine it: an inexpensive, power-efficient system for more advanced robotics (e.g. inverse kinematics, sensor fusion, maybe a bit of audio / video input) with Arduino's ease of use. Such a product might open up new possibilities for hobbyists and makers.

Thinking about it more and reading some of the comments here, I don't think Octave is likely to work out. You'd need a hardware platform like a Raspberry Pi or a BeagleBone, which provide good computing power but suffer from higher electrical power consumption.

I think the sweet spot might be C++/Eigen (or a similar library - there must be hundreds of options) running on a Cortex M4 with hardware FPU; something like the STM32F405RG - 1MB flash, 192kB RAM, up to 168MHz, 16 x 12 bit ADC, quadrature encoder support, 5V tolerant I/O, USB host/device/OTG, Ethernet MAC, etc etc... more features than you can shake a stick at. And all with a max current draw of 150 mA and a quantity one price of around $12.

The real challenge would be the Arduino part: making useful projects accessible. I expect that would take a huge amount of time and skill. And even if you built it, would it sell well? Might it be too niche? I don't know.

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Adaboard Anyone?

Post by westfw »

something like the STM32F405RG ... and a quantity one price of around $12.
You understand that the low price of the STM32F405RG is a marketing tool, right? The chip itself costs about $10 in moderate quantities, and there's no way you can actually build an equiv of the STM kit for the price that they're selling it for...

User avatar
brucef
 
Posts: 215
Joined: Tue May 03, 2011 4:51 pm

Re: Adaboard Anyone?

Post by brucef »

westfw wrote:
something like the STM32F405RG ... and a quantity one price of around $12.
You understand that the low price of the STM32F405RG is a marketing tool, right? The chip itself costs about $10 in moderate quantities, and there's no way you can actually build an equiv of the STM kit for the price that they're selling it for...
STM32F405RG is the chip, not one of ST's dev boards. I'd see a cheap board built around that chip maybe hitting a price point of $35 or $40, if you were careful with your cost control.

User avatar
sellensr
 
Posts: 47
Joined: Tue Nov 06, 2012 9:41 pm

Re: Adaboard Anyone?

Post by sellensr »

randomvibe wrote: Another possibility (however unlikely), would be to implement Octave as a compiled language. In other words, the IDE converts the Octave code into C code. This approach works very well for the Zbasic mcu - this system is programmable in Visual Basic, and behind the scene generates C followed my object native code. If it can be done with visual basic, it can be done with Octave. If Octave for an Arduino-Due-like board ever happens, it'll likely be the interpreted version first, because, well, it's ready to go and it's a matter of integration.

http://www.zbasic.net
sellensr wrote:Write your matrix algebra in the high level language of your choice and use automatic code generation to translate to C code you can take to any platform.
That is a very good approach, but cost prohibitive for those who don't have access to Matlab ($7,000 USD) and the compiler ($$$ USD).
A little googling suggests that compiled octave is out there: http://strategoxt.org/Octave/OctaveToC

randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

BruceF wrote:Thinking about it more and reading some of the comments here, I don't think Octave is likely to work out. You'd need a hardware platform like a Raspberry Pi or a BeagleBone, which provide good computing power but suffer from higher electrical power consumption.
Well, Octave definitely works on the RPi. Once the Model-A is available, power requirements will drop, as does the price ($25USD). That's roughly two RPi Model-A's for one Arduino-Due. Hopefully RPi will make a Model-C with native ADCs (12 or more) - I'd pay $50 USD for that.
BruceF wrote:I think the sweet spot might be C++/Eigen (or a similar library - there must be hundreds of options) running on a Cortex M4 with hardware FPU; something like the...
Last night I linked the Eigen3 library to the Arduino IDE and I was able to do matrix math on the Due!

Eigen3 takes 29KB of flash - that still leaves 483K of flash. plenty for most applications. I tried matrix +, -, * and inversion, and it all works. For now, this is my go forward path. Link below on this... (stay away from Eigen2, it takes 166KB of flash)

http://arduino.cc/forum/index.php?PHPSE ... c=143602.0
BruceF wrote:The real challenge would be the Arduino part: making useful projects accessible. I expect that would take a huge amount of time and skill. And even if you built it, would it sell well? Might it be too niche? I don't know.
At this point, I probably wouldn't create a new board from scratch. I'd take an existing low cost board like the R-Pi and sell a ready-to-run 8GB SD card complete with linux, Octave, Octave libraries to communicate with the GPIO pins, and clear documentation. If such a thing existed, I'd be willing to pay $15USD (8GB SD card + software load) rather than go through the pain of making my R-Pi function. adacard anyone?

User avatar
brucef
 
Posts: 215
Joined: Tue May 03, 2011 4:51 pm

Re: Adaboard Anyone?

Post by brucef »

randomvibe wrote: Last night I linked the Eigen3 library to the Arduino IDE and I was able to do matrix math on the Due!
Good work! Keep us posted with how it all works out for you.

randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

Important development regarding Eigen. The Arduino/Eigen setup on Windows 7 seems to produce internal compiler errors when using matrices larger than 4x4. After struggling late at night with this, I have a solution.

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 20th century nonsense. To add to the Arduino-Due IDE (1.5.1r2), follow these instructions: (applies to Windows 7)

Step-1:
-> As of 1/25/2013, latest stable release is Eigen 3.1.2
-> Download ZIP from: http://eigen.tuxfamily.org

Step-2:
-> Unzip in temporary location
-> Unzip will create folder containing several files and subfolders.
-> The subfolder "Eigen" is all that is needed.

Step-3:
-> Copy "Eigen" subfolder to this precise location in the Arduino IDE directory tree:
...\arduino-1.5.1r2\hardware\arduino\sam\libraries

Step-4:
-> Eigen is written in C++, so header files do not include the *.h extension.
-> The Arduino IDE expects a *.h extension for it to appear in Sketch/Import Library pull-down menu.
-> So download "Eigen312.h" from this thread and copy to this precise location:
...\arduino-1.5.1r2\hardware\arduino\sam\libraries\Eigen
-> Notice "Eigen312.h" goes in the Eigen subdirectory
-> Normally, all that is needed in "Eigen312.h" is a call to the main Eigen Core header as follows: #include <Core>
However, the Arduino and AVR libraries interfere with Eigen for matrices larger than 4x4; this results in internal compiler errors. So @rpavlik came up with a bunch of #define statements that prevents this, and are conveniently included in "Eigen312.h".

Step-5:
-> Again, make sure you download "Eigen312.h" and copy to the Eigen subdirectory!

Step-6:
-> Run example code below demonstrating the Kalman gain equation using 6x6 matrices. Not as clean as Matlab or Octave, but not too shabby.
-> I wrote a function called "print_mtxf" that serially prints matrices; its included in the example.

Good luck.

Code: Select all

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

#include <Eigen312.h>     // Calls main Eigen3.1.2 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)
//-----------------------------
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();
}
Attachments
Eigen312.h
See Step-4 in thread
(1.09 KiB) Downloaded 312 times

Metaphysicist
 
Posts: 6
Joined: Sat Feb 02, 2013 12:29 pm

Re: Adaboard Anyone?

Post by Metaphysicist »

(I'm also having a hard time understanding how python (which I've only used slightly) is so much different from C.)
As someone who plays with both languages, Python is 'higher level' in the sense that it is more readable like pseudo-code to those uninitiated. It allows (for beginners) a more objective approach to understanding the processes in the code conceptually than following the logic flow in C. This is from my personal experience, YMMV.

randomvibe
 
Posts: 57
Joined: Tue Jan 24, 2012 7:26 am

Re: Adaboard Anyone?

Post by randomvibe »

Sparkfun just released their own mcu board called the "RedBoard". They essentially reinvented another Arduino-esque wheel.

https://www.sparkfun.com/products/11575

I wonder if Adafruit has something in the works. The community can sure use something like an Adaboard, the nonexistent dream board with the power of a Raspberry Pi, but with the peripherals of an Arduino Due (lots of GPIO, 12-bit ADCs, PWM, USART, SPI, I2C, etc.). We certainly don't need another "Redboard".

Is Adafruit going to let Sparkfun dominate the electronic maker world?

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Adaboard Anyone?

Post by westfw »

So what's wrong with BeagleBone?

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”