1

I am writing a general-purpose stepper motor driver C shared library for the Raspberry Pi using PIGPIO (pigpiod C interface) for 4 to 7 motors using A4988 drivers. I designed an interface board (basically a GPIO breakout board for the driver chips and limit switches) but I have run out of 'normal' GPIO pins to control the ENA pin of one of the motors so I am trying to use GPIO 1 (the ID_SC pin) for this purpose (or GPIO 0). However, I cannot change its state with the gpio_write function or the pigs' command-line utility.

I am using Raspbian on an RPi v3b (not b+).

My research suggests there may be issues with RPi3 and I2C in this regard. So I set "Disable automatic loading of I2C kernel module" in raspi-config 'Interfaces' but that did not help.
In this post about the same/similar issue on the raspberry pi forum:
https://www.raspberrypi.org/forums/viewtopic.php?t=162119

It was suggested that setting the pin "to normal" should fix the issue but I don't know what that means or how to set the pin to "normal".
With pigpiod running I type:

$ pigs mg 0 mg 1

and I get:

0
0

Then I type:

$ pigs w 1 1

and I get:

-41
 ERROR: no permission to update GPIO

The same result occurs with sudo.

Running the pigpio test utility, gpiotest, I get:

Testing...
Skipped non-user gpios: 0 1 28 29 30 31 
Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 
Failed user gpios: None

Again, sudo makes no difference. By searching the net I found no method to change the 'non-user' gpios into user ones (obviously I am not interested in the power and ground pins - it's just 0 and 1 I'm after).

My driver board and interface code work fine as is but I must leave one motor permanently enabled - with some motors this causes significant heating. I would like to use GPIO 1 and GPIO 0 to write pins if possible. (Please note: I am aware that you can increase the number of GPIOs via I2C expansion boards using MCP23017 or similar. I don't want to do that for this project - and my understanding is that pigpio won't work with those anyway).

So my questions are: Is it possible to set the level of GPIO 1 on the RPi3 without additional hardware? If so, how can I achieve this?

Many thanks in advance.

1
  • Pins 27,28 are reserved for HATs and in later models are connected to a bus extender to control on-board chips. If you use these you may interfere with Pi operation. I have tried, and found they change unpredictably.
    – Milliways
    Feb 24, 2020 at 22:50

1 Answer 1

0

The default settings of the pigpio daemon do not allow GPIO 0 or 1 to be written on the Pis with the 40-pin expansion header.

You need to override this setting when the pigpio daemon is started. The -x option is provided for this purpose.

sudo pigpiod -x 0xFFFFFFF

http://abyz.me.uk/rpi/pigpio/pigpiod.html

3
  • Thanks but ... this only allows me to set the values (from 0 to 1) - I can't go back down to 0. Here is the output of my efforts (and sudo makes no difference - sorry can't seem to get newlines in comments):$ sudo pigpiod -x 0xFFFFFFF $ pigs mg 0 mg 1 0 0 $ pigs w 1 1 $ pigs mg 0 mg 1 0 1 $ pigs w 0 1 $ pigs mg 0 mg 1 1 1 $ pigs w 1 0 $ pigs mg 0 mg 1 1 1 $ pigs w 0 0 $ pigs mg 0 mg 1 1 1
    – WildCat
    Feb 25, 2020 at 0:25
  • Those commands show the correct and expected behaviour. You check the mode of 0/1 (mg) and they are both inputs (0). You write to GPIO 1 and it is correctly set to output mode (1).You write to GPIO 0 and it is correctly set to output mode (1). You then write to 1/0 again and they are still correctly in mode output. Are you confusing reading the voltage level at the GPIO with checking to see what mode it is in?
    – joan
    Feb 25, 2020 at 9:18
  • Oops! Yes, of course you are correct. I am not very familiar with the pigs utility but when I tested this with my driver board and software everything works just fine - I can now command my motor ENA on/off at will. I see you are the pigpio author - Many thanks for your help and for this excellent GPIO library.
    – WildCat
    Feb 25, 2020 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.