User avatar
droople
Posts: 13
Joined: Tue Aug 28, 2012 6:07 am
Location: Earth

Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 8:46 am

Hi

I just bought the epud book Meet the Raspberry Pi from B&N, and I'm a little bit confused with chapter 6 GPIO part.(Rest of the book is fine as I'm using Linux everyday)

1) The Figure 6-1 shows the layout of the GPIO port, the bottom raw thaking the odd numbers and the top row the even numbers, but for the definitions, it put "GPIO Pin 18" on number 12, and "GPIO Pin 21" on number 13, I'm totally confused :cry:

2) The Figure 6-4, shows the green line connected to GPIO Pin 11, but the paragraph above it, says connect Pin 12 of the GPIO port. Is this a typo or I confused again?

Cheers
Jas
Spent more money on an HDMI monitor than on Raspberry Pi

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 10:19 am

For question 1:

The RPi GPIO ports are labelled wierdly.... Don't ask me why! An example would be if I wanted to flash an LED on the proper pin 7 I would have to send a signal to GPIO pin 4.

Here is some example Python code using the RPI.GPIO library:

Code: Select all

import RPi.GPIO as gpio
import time

#set up pin 7 as an output
gpio.setmode(gpio.BCM)
gpio.setup(4, gpio.OUT)

#Make an LED flash on and off forever
while True:
    gpio.output(4, gpio.HIGH)
    time.sleep(1)
    gpio.output(4, gpio.LOW)
    time.sleep(1)
Just a beginner sharing his experiences on his way to geek nirvana...

mikerr
Posts: 2825
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 10:34 am

From the excellent guide on
http://www.raspberrypi-spy.co.uk/2012/0 ... -and-pins/

I printed this out:
Image
Android app - Raspi Card Imager - download and image SD cards - No PC required !

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 10:36 am

Only some of the cpu's gpios are brought out to the headers such as P1. See http://elinux.org/Rpi_Low-level_periphe ... .28GPIO.29.

The book is giving the P1 pin number as well as the associated cpu gpio number.

User avatar
Grumpy Mike
Posts: 936
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 7:38 pm

Bigcat123 wrote:The RPi GPIO ports are labelled wierdly....
No they are not. The physical pin a signal is brought out on has no relationship to what that signal is.

This applies not only to the Raspberry Pi but to every single computer ever made.

It just so happens that on the Pi those signals have numbers in their names so on the physical pin that is number 3, is the signal from the Pi that has a name 'GPIO 0'. Should this signal be connected to pin 0? Does a pin 0 physically exist, no to both.

Would you consider it weird if on physical pin number 8 had a signal called Transmit data? Look at a standard 9 pin RS232 connector, that has TX on pin 2, RX on pin 3 and so on. There is no correlation between the signal and the pin number it is on.

The point is that not all the GPIO pins are free, some are used for things in making the Pi work, others are not even brought out from the BGA package.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13092
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 01, 2012 8:25 pm

Yes, the Broadcom SoC chip actually supports many more "GPIO's" than are routed to the "GPIO header".
In fact the SoC supports 53 "GPIO's", but a lot of them are not even used (routed out from the "pins" of the SoC), and many which are routed out support various special functions. For example the "OK LED" is actually connected to GPIO16, and the SD-card is actually interfaced using GPIO's 47 to 53.
As a matter of interest, four GPIO's are brought out from the SoC, but not used! GPIO's 28 to 31 are only connected to some resistors on the board, and not actually used for anything, but they form an I2S interface, and are candidates for a redesign that extends or changes the GPIO header.
Lastly GPIO 40 and GPIO 45 are controlled by audio PWM interfaces in the SoC and are actually used for the analog audio output.

User avatar
droople
Posts: 13
Joined: Tue Aug 28, 2012 6:07 am
Location: Earth

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 7:19 am

Thank you guys

So in the Python, the GPIO number is the physical number of the GPIO headers, not the logical number given by the SoC, am I correct?

and how about my 2nd question?

Cheers
Jas
Spent more money on an HDMI monitor than on Raspberry Pi

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 7:52 am

If you are using the RPi.GPIO library you can switch between using physical pin numbers or the Broadcom GPIO references. So you can choose to use '11' (pin 11) or '17' (GPIO 17). This is set by a single line at the start of your script.

I use proper GPIO numbers in my scripts these days.

So my advice is to refer to either 'Pin X' or 'GPIO Y' never 'GPIO pin Z'.

If you use physical pin numbers you can use 'P1-01' to refer to the first pin on the Pi's GPIO header, P1.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

User avatar
Bigcat123
Posts: 230
Joined: Thu Aug 23, 2012 2:41 pm

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 9:21 am

@Grumpy Mike

Sorry... Just my way of understanding it. Thanks for telling me how they actually work... Good bit of information!Thanks
Just a beginner sharing his experiences on his way to geek nirvana...

User avatar
droople
Posts: 13
Joined: Tue Aug 28, 2012 6:07 am
Location: Earth

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 1:29 pm

MattHawkinsUK wrote:If you are using the RPi.GPIO library you can switch between using physical pin numbers or the Broadcom GPIO references. So you can choose to use '11' (pin 11) or '17' (GPIO 17). This is set by a single line at the start of your script.

I use proper GPIO numbers in my scripts these days.

So my advice is to refer to either 'Pin X' or 'GPIO Y' never 'GPIO pin Z'.

If you use physical pin numbers you can use 'P1-01' to refer to the first pin on the Pi's GPIO header, P1.
Thank you Matt,
Spent more money on an HDMI monitor than on Raspberry Pi

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 1:38 pm

No they are not.
Discuss :)

I think the mistake was calling it a GPIO header - if it had just been called Connector A and the pins were labeled the "correct" GPIO names it would have saved the cognitive dissonance that "most" of us experienced when what we think is GPIO Pin 11 gets called GPIO17 :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 3:10 pm

simplesi wrote:
No they are not.
Discuss :)

I think the mistake was calling it a GPIO header - if it had just been called Connector A and the pins were labeled the "correct" GPIO names it would have saved the cognitive dissonance that "most" of us experienced when what we think is GPIO Pin 11 gets called GPIO17 :)

Simon
There's nothing to discuss. The name of the 26-pin header is "P1". For reference, see also header "P2" (VideoCore JTAG) and "P3" (unpopulated LAN9512 JTAG) on the board. See: http://elinux.org/RPi_Low-level_peripherals

The pins on header P1 have a number (01-26). The way these are numbered makes sense if you look at how an IDC connector works mechanically: http://www.electusdistribution.com.au/i ... CconnE.pdf

The pins on header P1 also have a name. The names are related to the pins on the Broadcom SoC where the individual pins on header P1 are connected to.

For example, Pin number 11 on header P1 ("P1-11") is connected to GPIO number 17 on the SoC. Hence the name "GPIO17". This pin also has alternate functions by the way (ALT3 = UART0_RTS, ALT5 = UART1_RTS).

Both the name and the number of the pin provide useful information. It's how these things work. It's an industry standard. It's what happens when you connect 2 things together. It's not a mistake. It's not weird.

If you think it's confusing: Bite the bullet. It's not going to change.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 3:26 pm

There's nothing to discuss.
Strange - you then posted a lot of information after saying that :)

For us little people, we looked at pictures like this
Image
and the word GPIO pins got into our little heads that the pins were the GPIO.

We are very sorry that we got it wrong :)

And once we got confused, we've been confused ever since :)

I refer to my previous statement but amending it in the light of your comments
"I think the mistake was calling it a GPIO header - if it had just been called Connector P1....." :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 3:56 pm

@simplesi: You seem a bit offended. It wasn't my intention to offend you (or anyone). English is not my native language, so my posts may come across as awkward, or a bit harsh in this case. I was just trying to clear up the confusion.

The infographic you posted is initially a great way to communicate the general functions and connections on the board. But infographics are usually simplified versions of the real thing. Once you start using these connections, you need more (detailed) information. That's where the (more correct) information from the wiki comes in (http://elinux.org/RPi_Low-level_peripherals).

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 4:04 pm

I'm not offended at all :)

Please don't be offended that we are confused :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

hippy
Posts: 7728
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 4:33 pm

Bigcat123 wrote:The RPi GPIO ports are labelled wierdly....
It's more potentially ambiguous and a bit confusing than weird, whether "GPIO pin 7" refers to connector pin 7 which is SoC signal GPIO4 or to the SoC signal GPIO7 which is on connector pin 26. With "pin" in the description I'd assume it referred to connector pin.

Originally connector pin 7 / SoC signal GPIO4 was labelled "GPIO7" but those confusions should have long gone.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sun Sep 02, 2012 6:13 pm

but those confusions should have long gone.
But the internet (google) has a long memory :)
And people will ALWAYS remember the wrong way even when told 20 times the right way :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
droople
Posts: 13
Joined: Tue Aug 28, 2012 6:07 am
Location: Earth

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Tue Sep 04, 2012 7:58 am

So how about the 2nd question, anyone bought that book?
Spent more money on an HDMI monitor than on Raspberry Pi

hippy
Posts: 7728
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Thu Sep 06, 2012 12:53 pm

hippy wrote:Originally connector pin 7 / SoC signal GPIO4 was labelled "GPIO7" but those confusions should have long gone.
But may have snuck back in with Version 2 of the board and the new P5 connector ...

"This carries the four GPIO signals [BCM2835/GPIO28 – BCM2835/GPIO31] named GPIO7 – GPIO10 respectively" - http://www.raspberrypi.org/archives/1929

Would be nice to get those confusions also removed.

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Fri Sep 07, 2012 10:26 pm

The mention of "GPIO7 - GPIO10" made me shiver when I read it.

GPIO28 - GPIO31 is the way to go.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

User avatar
jojopi
Posts: 3268
Joined: Tue Oct 11, 2011 8:38 pm

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Sat Sep 08, 2012 12:45 am

hippy wrote:Originally connector pin 7 / SoC signal GPIO4 was labelled "GPIO7"
It is even worse than that: http://www.raspberrypi.org/archives/384

So only by coincidence is GPIO7 on pin7. GPIO0 (SoC GPIO17) is on pin11. This scheme is based on giving nine of the signals names, numbering another seven of them from zero in what might be either pin or SoC order, and then calling the one that you forgot about GPIO7, although it should have come first.

And it seems that GPIO7 was forgotten about again, if the new I2S/PCM signals are GPIO7..10. Now we have two GPIO7s! The probable reason for this is that in the schematics the previous GPIO7 was denoted GPIO_GCLK, rather than GPIO_GEN7. So it should probably have been named GPCLK0.

I agree with the previous posters, and the wiki: these Pi-specific GPIOn names are useless and misleading. All signals should be named for their BCM2835 GPIO numbers, and their main special functions also indicated.

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: Questions GPIO chapter in the book Meet the Paspberry Pi

Thu Sep 13, 2012 9:26 pm

Now I've got my Rev 2 board I have documented the P5 pin-out :

http://www.raspberrypi-spy.co.uk/2012/0 ... p5-header/

Looking at the top of the board with P1 in the top left corner Pin 1 is the top left pin :

1. +5V
2. +3V3
3. GPIO28
4. GPIO29
5. GPIO30
6. GPIO31
7. Ground
8. Ground

Pin 8 is in the bottom right hand corner.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

Return to “General discussion”