<p>A "port" for the AVR microcontroller is a set of eight IO pins that are controlled together at a hardware level. The underlying machine code can write an entire byte to set the status of all 8 pins at once. So in principle, all the step pins on the RAMBO board can be triggered exactly simultaneously. </p>

<p>The Arduino IDE hides this behavior from firmwares by abstracting the port's byte handling as a function call for each individual pin. That means programmers only have to know the Arduino PIN number, not which port and position on the processor is being used. And then the modern firmwares typically used by RAMBO do a further layer of abstraction to make it easy for the same firmware to be used by different boards, by changing pin assigned names in a config file (usually pins.h) and not assuming any specific port selection was made during board design.</p>

<p>There's no guarantee for open-source firmware that a particular pin selection was made in hardware. Lots of 3D printer controller boards even have pretty dumb pin assignments, like using hardware-PWM-capable pins for stepper signals rather than PWM'd heaters. Marlin and Repetier have chosen flexibility over performance optimization in this regard. They pretty much let the board designer use any pin for anything. When they have to do stuff like run heater PWM control or fire a bunch of step pulses as fast as possible, they emulate that in software rather than taking advantage of specific hardware that isn't always available. </p>

<p>In this specific case, there may not actually be all that much performance gain/loss. Writing to an output pin is pretty fast. The amount of time difference between firing a few step pulses in sync or firing them sequentially is on the order of a few microseconds. That won't make any difference to the motion fidelity of the printer's physical drivetrains. Somebody involved in the RAMBO design just thought it could be useful, and put a reference to it on the Wiki page (in the very first upload!) and it's never been clarified or removed from the Wiki page in the years since. </p>

CC BY-SA 3.0
2016-04-29T06:29:34.710Z
Right, so since Marlin writes the pins sequentially, it makes no difference at all? Or do the ports have limited "refresh rate" so-to-speak, perhaps making it more likely that writes in quick succession appear at the same time? I think the last bit about "a few milliseconds" is inaccurate since step rates tend to be in the 10kHz range.
Tom van der Zanden
CC BY-SA 3.0
2016-04-29T17:54:16.763Z
Oh yeah, I meant microseconds, not milliseconds. I'll fix that.
Ryan Carlyle
CC BY-SA 3.0
2016-04-29T17:57:12.653Z
In order for the pins to write simultaneously from a series of sequential commands in the human-readable code, the compiler would have to be optimizing the pin write commands together. I doubt it does that, since Bresenham's has to decide whether to pulse each stepper in a particular interrupt tick... that kind of conditional is not really something susceptible to compile time optimization. Hypothetically, I suppose it's possible, but I doubt the Arduino IDE would be able to do it.
Ryan Carlyle
CC BY-SA 3.0
2016-04-29T02:00:33.500Z
2016-04-29T17:57:39.593Z
2016-04-29T17:57:39.593Z
Ryan Carlyle
<p>The wiki page for the <a href="http://reprap.org/wiki/Rambo" rel="nofollow">RAMBo board</a> mentions:</p>

<blockquote>
  <p>Step and Direction pins are on their own ports for synchronous movement capability</p>
</blockquote>

<p>What does this mean, and how does it affect printing? Do I need special firmware to take advantage of this?</p>

<electronics><firmware>
What does it mean for step and dir "to be on their own ports"?
Tom van der Zanden
# What does it mean for step and dir "to be on their own ports"?

(Asked by: username_0 on 2016-04-28)

The wiki page for the [RAMBo board](http://reprap.org/wiki/Rambo) mentions:

> Step and Direction pins are on their own ports for synchronous movement capability

What does this mean, and how does it affect printing? Do I need special firmware to take advantage of this?

**Tags:** electronics, firmware

---

## 1 answers

### Answer by username_1 on 2016-04-29. Score: 4 | Accepted answer

A "port" for the AVR microcontroller is a set of eight IO pins that are controlled together at a hardware level. The underlying machine code can write an entire byte to set the status of all 8 pins at once. So in principle, all the step pins on the RAMBO board can be triggered exactly simultaneously.

The Arduino IDE hides this behavior from firmwares by abstracting the port's byte handling as a function call for each individual pin. That means programmers only have to know the Arduino PIN number, not which port and position on the processor is being used. And then the modern firmwares typically used by RAMBO do a further layer of abstraction to make it easy for the same firmware to be used by different boards, by changing pin assigned names in a config file (usually pins.h) and not assuming any specific port selection was made during board design.

There's no guarantee for open-source firmware that a particular pin selection was made in hardware. Lots of 3D printer controller boards even have pretty dumb pin assignments, like using hardware-PWM-capable pins for stepper signals rather than PWM'd heaters. Marlin and Repetier have chosen flexibility over performance optimization in this regard. They pretty much let the board designer use any pin for anything. When they have to do stuff like run heater PWM control or fire a bunch of step pulses as fast as possible, they emulate that in software rather than taking advantage of specific hardware that isn't always available.

In this specific case, there may not actually be all that much performance gain/loss. Writing to an output pin is pretty fast. The amount of time difference between firing a few step pulses in sync or firing them sequentially is on the order of a few microseconds. That won't make any difference to the motion fidelity of the printer's physical drivetrains. Somebody involved in the RAMBO design just thought it could be useful, and put a reference to it on the Wiki page (in the very first upload!) and it's never been clarified or removed from the Wiki page in the years since.

> **Comments:**
> **username_0**: Right, so since Marlin writes the pins sequentially, it makes no difference at all? Or do the ports have limited "refresh rate" so-to-speak, perhaps making it more likely that writes in quick succession appear at the same time? I think the last bit about "a few milliseconds" is inaccurate since step rates tend to be in the 10kHz range.  
> **username_1**: Oh yeah, I meant microseconds, not milliseconds. I'll fix that.  
> **username_1**: In order for the pins to write simultaneously from a series of sequential commands in the human-readable code, the compiler would have to be optimizing the pin write commands together. I doubt it does that, since Bresenham's has to decide whether to pulse each stepper in a particular interrupt tick... that kind of conditional is not really something susceptible to compile time optimization. Hypothetically, I suppose it's possible, but I doubt the Arduino IDE would be able to do it.  

---

