GPIO Pins for output (PB V3)

I’m intending to use 2 GPIO pins to switch power (via a relay) and perform a chip select. The GPIO pins would be in OUTPUT mode.

looking at the schematics, I see the GPIO pins on the underside of the PB, but I also see two IO pins on the expansion header - IO25 and IO26.

I cannot, however figure out what pin these are in PB.

I have tried pin 25, 26, 14 and 15, and none of these work.

Can anyone tell me how the mapping from IO pin to PB pin (for use in pinMode(pin,OUTPUT) works?

Thanks.

I’m sure @wizard will correct me, but I believe I read that V3 didn’t have pin access yet. One of many things v3 will get, but I suspect tracking down v3 bugs (like wireless issues) is (correctly) eating into available time to add missing rarely used bits like this back.

@Nick_W,
Those pins should work. Try something like this pattern, which will toggle them on off alternating between 25 and 26:

pinMode(25, OUTPUT)
pinMode(26, OUTPUT)

export function beforeRender(delta) {
  t1 = time(.05)
  digitalWrite(25, t1 > .5)
  digitalWrite(26, t1 < .5)
}
 
export function render(index) {
}

Pin 26 is on the top, then pin 25. There are small labels (IO26, IO25), but the fine printing is sometimes a bit too smudged to read easily.

I think you know this already, but for the benefit of others finding this page:

Keep in mind that for driving a relay a fairly large current is required, much more than a GPIO can output or sink. The inductance in the coils also tend to kick back, so feedback protection is needed. Usually this is done with a transistor or MOSFET and a diode. You can also get relay modules that have these drivers included and are intended to work with digital signals from a microcontroller.

2 Likes

Ah, I misremembered this:
https://forum.electromage.com/t/status-led-control-on-v3-nano/981/4

Thanks for the reply, I tried your test pattern, and it works.

Weirdly, my test pattern doesn’t, but I swear I was doing the same thing. Here is my test pattern which doesn’t work:

var power24v = 26
export var test
pinMode(power24v,OUTPUT)

export function sliderPower(x) {
  test = (x > 0.5) // Assumes pin goes high to enable 24V supply
  digitalWrite(power24v, test) 
}

I’m just testing with a DMM right now, but the relay I’m using is an opto-isolated relay module. It doesn’t switch the 24V directly, but is the input to a 20A relay.

But - step 1. get the GPIO ports to work…

Update, OK it was me being an idiot. I still had the render function in there (scrolled off the bottom) and at some point in my testing, I put digitalWrite(power24v, HIGH) in there - doh!

Delete that, and it works as expect.

Thanks!

2 Likes