GPIO.setup Question >>> SOLVRED <<<

OK, what did I do wrong?

The following line of code is throwing a channel error(what ever that is)

GPIO.setup(IntensitySelect_Pins,GPIO.OUT)

The Toy_Sel_Pins set up works great!!!

import RPi.GPIO as GPIO
from time import sleep

Busy_Pin = 32
Run_Pin = 16
Toy_Sel_Pins = {10,8}
Abort_Pin = 12
Dir_Pin = 18
IntensitySelect_Pins = {22,24,26,28}

GPIO.setmode(GPIO.BOARD)
GPIO.setup(Run_Pin, GPIO.OUT)
GPIO.setup(Busy_Pin, GPIO.IN)
GPIO.setup(Toy_Sel_Pins, GPIO.OUT)
GPIO.setup(Abort_Pin,GPIO.OUT)
GPIO.setup(Dir_Pin,GPIO.OUT)
GPIO.setup(IntensitySelect_Pins,GPIO.OUT)

I’m guessing that GPIO.setup expects a pin number, not a set of pin numbers.

Hi,

the issue is that you have the pins listed in curly braces. The pins must be listed in either brackets or parenthesis (i.e., “list” or in a “tuple”).

OK, I did what you suggested without success.
I commented out the line of code and the script works!!!

import RPi.GPIO as GPIO
from time import sleep

Busy_Pin = 32
Run_Pin = 16
Toy_Sel_Pins = (10, 8)
Abort_Pin = 12
Dir_Pin = 18
IntensitySelect_Pins = (22,24,26,28)

GPIO.setmode(GPIO.BOARD)
GPIO.setup(Run_Pin, GPIO.OUT)
GPIO.setup(Busy_Pin, GPIO.IN)
GPIO.setup(Toy_Sel_Pins, GPIO.OUT)
GPIO.setup(Abort_Pin,GPIO.OUT)
GPIO.setup(Dir_Pin,GPIO.OUT)
GPIO.setup(IntensitySelect_Pins,GPIO.OUT) # <<< Bad code

Are the pins that you provided in the listing all valid GPIO pins? Make sure that they are and not assigned to another peripheral or a GND or POWER pin.

You can also start by first including one pin at a time to the list to see which pin is causing the issue. For example, start with this:

IntensitySelect_Pins = (22)

then:

IntensitySelect_Pins = (22,24) # and so on until you have all of the pins

You might have to start with a different order to zoom in on the pin that is the source of the error.

Which numbering system are you using? BOARD or BCM?

To find out which one:

mode = GPIO.getmode()
print(mode)

This works without errors.

IntensitySelect_Pins = (22,24,26)

This bombs.

IntensitySelect_Pins = (22,24,26,28)

So I tried this and it bombs

IntensitySelect_Pins = (24,26,28)

Which is telling me pin 28 is causing the problem. Yes, I triple-checked the board numbers.

I am using BOARD numbers.

GPIO.setmode(GPIO.BOARD)

Can you try testing this pin by itself like this to see if you experience something different:

GPIO.setup(28,GPIO.OUT)

If that still doesn’t work:

Is there another GPIO pin that is free and available that you may use as a substitute?

If not, you may have to look at the board “errata” to see if this is a known issue with this particular pin.

`GPIO.setup(28,GPIO.OUT)`

Bombs

I changed pin 28 to pin 36, which works.

Dir_Pin = 18
IntensitySelect_Pins = (22,24,26,36)

GPIO.setmode(GPIO.BOARD)
GPIO.setup(Run_Pin, GPIO.OUT)
GPIO.setup(Busy_Pin, GPIO.IN)
GPIO.setup(Toy_Sel_Pins, GPIO.OUT)
GPIO.setup(Abort_Pin,GPIO.OUT)
GPIO.setup(Dir_Pin,GPIO.OUT)
GPIO.setup(IntensitySelect_Pins,GPIO.OUT)

This means a major rewiring chore.

What is “**errata**”?

Awesome! At least you have found a workaround.

errata” refers to known issues with products (in this case your board) that were not caught and fixed during the development and verification phase and end up showing up in production units (units that make it to the market for consumers). Once an issue is made aware to the manufacturer, they’re added to a published list of known “erratas”. Which is another way of saying known errors with the product.

This pin might be a known issue to the manufacturer. If it is, they might be able to provide a workaround. You will have to check with whoever manufacturers this board for additional information.

I am using a Raspberry Pi 3B. How can I check that it is not a knockoff or original PI?

Do you have a link to the errata` for this board?

Again thank you for sharing your wisdom. :sweat_smile: :sweat_smile: :sweat_smile:

You will have to check with whomever you purchased it from and start from there.

Pins 27 and 28 are reserved for talking to the EEPROM.

Matthew:
So pin 28 can not be used for general valid GPIO use?

Is there a list of valid GPIOs?

Pins 27 and 28 are intended for use with a HAT.

This page:

raspberrypi/hats

says “The ID_SC and ID_SD pins must only be used for attaching a compatible ID EEPROM. Do not use ID_SC and ID_SD pins for anything except connecting an ID EEPROM, if unused these pins must be left unconnected”.

If you did try to use them, don’t be surprised if the RaspberryPi tried to use them to check for a HAT at boot time.

Have a look here:

The Pi4J Project – Pin Numbering - Raspberry Pi 3 Model B

You can see that pin 22 is labelled GPIO 6, pin 24 is labelled GPIO 10/CE0 (SPI) and pin 26 is labelled GPIO 11/CE1 (SPI), but pin 28 is labelled SCL0 (I2C IS EEPROM) without any GPIO number.

1 Like

If I understand you properly I can use all valid GPIO board pin number except pin 28.
Am I correct?

Well, pin 28 isn’t a valid GPIO pin.