shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 7:40 am

This may be stupid question, but I do not know the details how Arduino works....I just use it.

I have been using Arduino and coded it like this:

Code: Select all

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT); 
  Serial.begin(9600);
  Serial.println("\nhello there!");
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  Serial.println("LED on");
  delay(2000);              // wait for a second

  digitalWrite(13, LOW);    // set the LED off
  Serial.println("LED off");
  delay(2000);              // wait for a second

}
Now looking the code examples in the GertDuino docs, it looks very different. Like bare metal approach, where everything needs to be done yourself.
Can I not use the "normal" Arduino sketches with GertDuino?

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 9:17 am

Again, I don't know a lot about using Arduino's but I'll try to answer it how I understand it (who knows I might not be wrong...).
I think this comes down to the bootloader. The Arduino uses a bootloader which will automatically run the important parts of your script. All you need to do is program the bootloader onto the chips and you'll be able to use it like that.

I think we need to produce some more Arduino articles for the MagPi.
Here is a list of what we have so far (sorry if I've missed any):
http://issuu.com/themagpi/docs/issue_8_final/12
http://issuu.com/themagpi/docs/issue15final/4
http://issuu.com/themagpi/docs/issue16final/28

It would be really helpful to start with how the whole Arduino thing works, explaining shields, sketches, bootloaders, the debugging terminal etc.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 10:00 am

You can program an Arduino (including the Gertduino) using either the Arduino IDE or write C or C++ code yourself. The Arduino sketches are in reality just C++ programs. In a C++ program execution starts in the main function. The Arduino IDE adds a main function to your sketch that looks like this (slightly simplified):-

Code: Select all

int main(void)
{
    init();
    setup();
    
    for (;;)
    {
        loop();
    }
        
    return 0;
}
The functions just calls your setup function once and calls your loop function in an infinite loop.

So to answer your question. Yes, you can still use the Arduino IDE to write programs for the Gertduino. The instructions in the use manual are basically the same instructions that Gordon Henderson wrote for the Gertboard (classic). So I am reasonably sure that Gordon's instructions for using the Arduino IDE with the Gertboard will work for the Gertduino.

User avatar
Mortimer
Posts: 923
Joined: Sun Jun 10, 2012 3:57 pm

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 10:10 am

You are programming using example of Arduino code, whereas Gert's examples are written using C.

I think the name Gertduino is slightly misleading, I think it should have been something like "GertAVR" or "GertMel".

An Arduino is an Atmel AVR microcontroller with some preloaded code that allows it to run Arduino code, and a open source board design for the controller to live on. Gert's manual describes using AVRDude which can be used with Arduino boards, but you are not using the full Arduino environment.

I don't believe the board can accurately be described as an Arduino or Arduino compatible unless:
  • The board comes with the Arduino bootloader preinstalled, like an Arduino does. (Maybe it does, I don't know, but the manual suggests that it probably doesn't)
  • Full instructions are included in the Gertduino Instructions on how to install the Arduino GUI and get it working. (If the Gertboard instructions for the Arduino GUI are anything to go by, this may be non-trivial for some less experienced users.)
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 12:16 pm

If you download the tarball with all the relevant code you will find that the 'blink' example is available in two formats:
The RAW C format as in the manual, but you also find a 'Arduino' format which you can
load and use straight from the Arduino GUI.
The motor shield demo you see in the Video is written in 'Arduino' style code using a whopping 55 lines of code!
IMHO the fact that the Gertduino does NOT require a boot program is an advantage as you have more space and simpler programs.
Also, I am told, it uploads and programs the device about 100x faster :-)

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 12:18 pm

Full instructions are included in the Gertduino Instructions on how to install the Arduino GUI and get it working. (If the Gertboard instructions for the Arduino GUI are anything to go by, this may be non-trivial for some less experienced users.)
TRUE! I REALLY would like the Raspberry-Pi added as default to the Arduino GUI (avrdude etc.) when you download and install it. At the moment I have no idea how to accomplish that!!

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 12:22 pm

ok, seems like I am not the only one, who really does not get how it works. :)
Anyway, it also seems like it should be possible to port my Arduino code without changes to Gertboard.

Currently I am discussing between Rpi and Arduino using the simple USB connection. I guess that should work also.

Need to buy one of these and try it in practise. Probably the only way to really understand what works and how. :?

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: GertDuino compatibility with Arduino sketches

Mon Nov 25, 2013 10:12 pm

Keep an eye on Matt's site:
http://www.raspberrypi-spy.co.uk/2013/1 ... pberry-pi/

It looks like he will be exploring what can and can't be done with the board.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

Dutch_Master
Posts: 362
Joined: Sat Jul 27, 2013 11:36 am

Re: GertDuino compatibility with Arduino sketches

Tue Nov 26, 2013 3:44 am

Gert van Loo wrote:I REALLY would like the Raspberry-Pi added as default to the Arduino GUI (avrdude etc.) when you download and install it. At the moment I have no idea how to accomplish that!!
Given your obvious coding skills, write a patch for the GUI tools you'd like people to use for your GertDuino (like avrdude, etc) and submit that to the project/developers for inclusion. They may or may not accept it, but some background info on your board may help them to decide in your favour ;) For tools that reject your patch, make the patch itself available to those who want to include it themselves (or fork the tool to include your patch, a .deb package would be very convenient for Raspbian).

Return to “HATs and other add-ons”