The printing on the Gertboard indicated the port and pin numbers internal to the Atmega microcontroller… However this is normally hidden from the user by the Arduino’s “wiring” library and rather than refer to (e.g.) Port B, bit 5, you’d normally refer to “pin 15”.
The mapping is fairly straightforward, but to help you connect wires to pins on the Gertboard, here is a handy table to let you see what the connections are:
Gertboard ATmega Port/Pin |
Ardino Wiring Pin |
Notes |
---|---|---|
PB5 | 13 | (LED) |
PB4 | 12 | |
PB3 | 11 | PWM |
PB2 | 10 | PWM |
PB1 | 9 | PWM |
PB0 | 8 | |
PD7 | 7 | |
PD6 | 6 | PWM |
PD5 | 5 | PWM |
PD4 | 4 | |
PD3 | 3 | PWM |
PD2 | 2 | |
PD1 | 1 | TxD |
PD0 | 0 | RxD |
PC5 | Analog In 5 | SCL |
PC4 | Analog In 4 | SDA |
PC3 | Analog In 3 | |
PC2 | Analog In 2 | |
PC1 | Analog in 1 | |
PC0 | Analog In 0 |
Note that Pin 13 is hardwired to a small LED on Arduino Duemilanove and newer boards – it’s not connected to anything on the Gertboard.
Pins missing that you may expect to find on an Arduino are the positive and ground power connections and the analog reference voltage. This is tied to 3.3v in the ATmega on the Gertboard, so you must make sure that you take this into account when using the analog inputs. ie. you must call:
analogReference (DEFAULT) ;
when using analog inputs. Also, remember that to read a voltage, the calculation is
volts = analogReading * 3.3 / 1023.0
as the reference voltage is 3.3v.
Hi,
I picked up a dangerous new hobby: Raspberry Pi + Arduino … Now, what’s the advantage of having Gertboard? It seems that Aruduino RPi can read all the inputs from Arduino.
Is the Gertboard for people who doesn’t want to use Arduino to connect their servo and stuff?
thanks
ap
Hi,
The Gertboard is intended to be used primarily as a buffer board to help you not blow-up the pins on the Pi itself (blow up cheaper chips instead). It also has a set of additional features – the motor controller and open-collector drivers (aimed at powering relays, etc.) There is also a 2-channel A/D and 2-channel D/A convertors on-board connected to the Pi’s SPI interface. There are 12 LEDs to monitor the outputs and 3 buttons for digital inputs.
Additionally, it has an ATmega processor.
So it’s just a general purpose IO interface board for the Pi – you can use it to buffer the Pi’s own IO pins, or it can also buffer the ATmegas IO pins too.
Everything still runs at 3.3v.
I guess a lot will depend on exactly what you’re after and what your experience is – if you’ve used Arduinos in the past, then maybe just connecting one up to the Pi’s USB will suffice for you. If you want a board with some additional peripherals on, ready to wire into the Pi, then the Gerboard might be for you…
-Gordon
Hi Gordon,
I am seriously tempted by the Xino basic arduino to use with my Pi since it seems a low-cost alternative to both a Gertboard and a ‘real’ Arduino.
http://nathan.chantrell.net/20110910/xino-basic-arduino-clone/
I asked a question in the forum:
http://openmicros.org/index.php/component/kunena/10-ciseco-support/2892-xino-basic-board?Itemid=0
The answer seems to imply I should be able to connect the Pi serial port to the board directly (both at 3.3V). However, from reading your site it would seems that it would be better to connect the same GPIO pins that you are using to program the Gertboard version, but that I will only need three wires, ie RX TX and RTS/Reset.
Do you have a suggestion?
Dave
If you run the board at 3.3v then you can connect it directly to the Pi’s serial port. However you’re quite out of spec. at 3.3v to run the ATmega at 16MHz, but I’ve seen reports that it will “just work”.
(that’s why the Gertboard ATmega is running at 12MHz – that’s the fastest the specification is for 3.3v)
the other issue is board reset – you’ll need to manually reset the board immediately before uploading the program into the ATmega (there are no control lines with the Pi’s serial port) – might be tricky with the IDE, but easy if you use avrdude by hand… Type command, push reset, press enter… (thats how it used to be in the early days before they had USB serial on-board that could reset the Atmega)
If you want to program using the SPI method, (same as Gertboard) then again, you’ll need to run it at 3.3v. You’ll need 5 wires – the 4 for the SPI interface plus ground.
Have to say, I bought a (usb) programmer years ago and haven’t looked back. I’ve even used it with the Pi to program the ATmega on the Gertboard (which is how I programmed it up originally when I was experimenting with ways to program the things)
Finally… If you’re really on a budget, then since you’ve got to buy the ATmega, the crystal, the capacitors, etc. for that board, then why not just stick them on a breadboard to experiment with. Start here: http://arduino.cc/en/Main/Standalone
-Gordon
Thank you for the nice tutorial Gordon.
I want to communicate to the Atmega MCU from the RPI over MCTX and MCRX. I uploaded the AnalogReadSerial Arduino example to the Atmrga and was able to read the voltage values with minicom at 9600 7E1. Now I want to write a program on the rpi to read those values. Can you please give me an advise how to do that?
Thank you very much Gordon – Elias
sorry for that n00b question therefore you have written the serial API 🙂 and there is even an example “serialTest.c”. Thanks a lot!
how many PWMs can run simultaneously
when used 3, 5, 6, 9 for 4 motors it worked fine
as soon as I attach a servo on 10 and 11, pin 9 stopped being a PWM and it became normal digital pin.
then i tried 13 to replace 9, no signal at all.
timer interrupt problem? ways around it please?
I’m guessing you mean the ATmega here and not the Pi? The ATmega should have PWM on pins 3, 5, 6, 9, 10 and 11, although I do not use the Arduino IDE myself, but those pins ought to work OK.
-Gordon
The Arduino servo library uses Timer1 which is required for PWM on pins 9 and 10.
So as soon as you use the Servo library, you lose PWM on those two pins.
The only way around it is to avoid the Servo library, and write your own that plays nicely with Timer1.
Hi Gordon,
I meant the Gertboard ATmega. I used 3, 5, 6, 9 they are ok, but when the servo is attached I only have 3,5,6 working. 9-11 are just dead or lost their PWM function. Have you tried testing all PWM simultaneously and run servo with Arduino Servo.h library? I just want to know what other people get, because I only get 3 pins functioning when servo is attached.
I’ve not used the Arduino servo library.
-Gordon.