Beagle Board - beagleboard.org
Jeff Xia
Published © GPL3+

ENGI 301 Split Flap

Mechanical split flap displays controlled with the Pocket Beagle.

BeginnerWork in progressOver 2 days6
ENGI 301 Split Flap

Things used in this project

Hardware components

Stepper Motor
Digilent Stepper Motor
×2
M4 Nut
×1
M4 Bolt, 10 mm
×1
Stepper Motor Driver
×1
Pocket Beagle
×1
Level Converter
×1
Jumper wires (generic)
Jumper wires (generic)
×1
PocketBeagle
BeagleBoard.org PocketBeagle
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Laser Cut Files

Rhino file with cut lines

Schematics

Fritzing

Fritzing diagram of the wiring

Code

Introduction Code

Python
Code that introduces myself
# -*- coding: utf-8 -*-
"""
--------------------------------------------------------------------------
Introduction
--------------------------------------------------------------------------
License:   
Copyright 2021 Jefferson Xia

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------

Program to introduce myself

--------------------------------------------------------------------------
"""
import time
from bbpystepper import Stepper

# ------------------------------------------------------------------------
# Splitflap Module Initialization
# ------------------------------------------------------------------------

mod1 = Stepper(pins=["P2_18", "P2_20", "P2_22", "P2_24"])
mod2 = Stepper(pins=["P2_2", "P2_4", "P2_6", "P2_8"])

# ------------------------------------------------------------------------
# Main script
# ------------------------------------------------------------------------

if __name__ == '__main__':

    mod1.rotate(-90)            
    mod2.rotate(-105)
    time.sleep(2)
    mod1.rotate(-9)            
    mod2.rotate(-54)
    time.sleep(2)
    mod1.rotate(-18)            
    mod2.rotate(-126)
    time.sleep(2)
    mod1.rotate(-243)            
    mod2.rotate(-81)
    

Timer Code

Python
Code that starts a timer
# -*- coding: utf-8 -*-
"""
--------------------------------------------------------------------------
Timer
--------------------------------------------------------------------------
License:   
Copyright 2021 Jefferson Xia

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------

Program for a simple timer

--------------------------------------------------------------------------
"""
import time
from bbpystepper import Stepper

# ------------------------------------------------------------------------
# Splitflap Module Initialization
# ------------------------------------------------------------------------

mod1 = Stepper(pins=["P2_18", "P2_20", "P2_22", "P2_24"])
mod2 = Stepper(pins=["P2_2", "P2_4", "P2_6", "P2_8"])

# ------------------------------------------------------------------------
# Global variables
# ------------------------------------------------------------------------

rotation = 40

# ------------------------------------------------------------------------
# Main script
# ------------------------------------------------------------------------

if __name__ == "__main__":
    
    while(1):
        for i in range(9):
            print(i+1)
            for k in range(17):
                mod2.rotate(-2, rotation)
            time.sleep(1)
        for j in range(17):
            mod1.rotate(-2,rotation)            
            mod2.rotate(-2,rotation)

Randomizer Code

Python
Code that displays random characters
# -*- coding: utf-8 -*-
"""
--------------------------------------------------------------------------
Random Display
--------------------------------------------------------------------------
License:   
Copyright 2021 Jefferson Xia

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------

Program for a two module splitflap display to display random combinations of characters

--------------------------------------------------------------------------
"""
import time
import random
from bbpystepper import Stepper

# ------------------------------------------------------------------------
# Splitflap Module Initialization
# ------------------------------------------------------------------------

mod1 = Stepper(pins=["P2_18", "P2_20", "P2_22", "P2_24"])
mod2 = Stepper(pins=["P2_2", "P2_4", "P2_6", "P2_8"])

# ------------------------------------------------------------------------
# Main script
# ------------------------------------------------------------------------

if __name__ == "__main__":
    
    while(1):
        mod1.random_rotate()
        mod2.random_rotate()
        time.sleep(1)
    
    
    

Stepper Motor LIbrary

Python
This library belongs to Pete Bachant, I've added a randomize step function.
""" 
bbpystepper is a Python module used to control a stepper motor via the 
BeagleBone
"""

from __future__ import division
import Adafruit_BBIO.GPIO as GPIO
import time
import math
import random


def initialize_pins(pins):
    for pin in pins:
        GPIO.setup(pin, GPIO.OUT)

def set_all_pins_low(pins):
    for pin in pins:
        GPIO.output(pin, GPIO.LOW)
        
def wavedrive(pins, pin_index):
    for i in range(len(pins)):
        if i == pin_index:
            GPIO.output(pins[i], GPIO.HIGH)
        else:
            GPIO.output(pins[i], GPIO.LOW)

def fullstep(pins, pin_index):
    """pin_index is the lead pin"""
    GPIO.output(pins[pin_index], GPIO.HIGH)
    GPIO.output(pins[(pin_index+3) % 4], GPIO.HIGH)
    GPIO.output(pins[(pin_index+1) % 4], GPIO.LOW)
    GPIO.output(pins[(pin_index+2) % 4], GPIO.LOW)


class Stepper(object):
    def __init__(self, steps_per_rev=2048.0,
                 pins=["P2_18", "P2_20", "P2_22", "P2_24"]):

        self.pins = pins
        
        initialize_pins(self.pins)
        set_all_pins_low(self.pins)
        
        self.angle = 0
        self.steps_per_rev = steps_per_rev
        
        # Initialize stepping mode
        self.drivemode = fullstep
    
    def rotate(self, degrees=-360, rpm=45):
        step = 0
        
        # Calculate time between steps in seconds
        wait_time = 120.0/(self.steps_per_rev*rpm)
        
        # Convert degrees to steps
        steps = math.fabs(degrees*self.steps_per_rev/360.0)
        self.direction = 1
        
        if degrees < 0:
            self.pins.reverse()
            self.direction = -1
        
        while step < steps:
            for pin_index in range(len(self.pins)):
                self.drivemode(self.pins, pin_index)
                time.sleep(wait_time)
                step += 1
                self.angle = (self.angle + self.direction/self.steps_per_rev \
                *360.0) % 360.0
        
        if degrees < 0:
            self.pins.reverse()
    	
        set_all_pins_low(self.pins)
        
    def random_rotate(self, lowlim=9, highlim=360, rpm=45):
    
        self.rotate(random.randint(-highlim, -lowlim), rpm)
    
    def zero_angle(self):
        self.angle = 0


def main():
    stepper = Stepper(pins=["P2_2"])
    stepper.rotate()
    

if __name__ == "__main__":
    main()

Git Repository

Code for the split flap is under splitflap

Credits

Jeff Xia

Jeff Xia

1 project • 0 followers
Thanks to Scott Bezek.

Comments

Add projectSign up / Login