Powered ankle-foot orthoses have significant potential as both assistance and rehabilitation devices for individuals with lower limb muscle impairments. Recently, we developed an untethered pneumatically powered ankle-foot orthosis (PPAFO) for outside-the-lab walking assistance or therapy. It is critical to recognize gait modes (i.e. level walking, stair ascend/descend) because improper actuation can dramatically increase fall risk. Gait mode recognition is a challenging task for the PPAFO because the sensor array is very limited and a new mode must be recognized at the earliest possible time to prevent inappropriate actuation and decrease fall potential. While manual mode switching is implemented in most powered orthotic/prosthetic device control algorithms, we propose an automatic gait mode recognition scheme by tracking the 3D position of the PPAFO from an inertial measurement unit (IMU). The experiment results showed that, with an optimized threshold, the controller was able to identify the position and gait mode at the very beginning of the mode change, to allow for proper actuation control.