JonnyBooker / split-flap

Code for split-flap display based on: https://github.com/Dave19171/split-flap
https://www.prusaprinters.org/prints/69464-split-flap-display
GNU General Public License v3.0
38 stars 6 forks source link

Split-Flap

Build ESP Master Sketch Build EEPROM Write Sketch Build Arduino Unit Sketch

Split Flap Display

This project has been forked from the brilliant Split Flap Project by David Königsmann. None of this would have been possible without the great foundations that have been put in place.

This project has built on the original project to add extra features such as:

Also the code has been refactored to try facilitate easier development:

3D-files here on Printables!

General

The display's electronics use 1 x ESP01 (ESP8266) as the main hub and up to 16 Arduinos as receivers. The ESP handles the web interface and communicates to the units via I2C. Each unit is resposible for setting the zero position of the drum on startup and displaying any letter the main hub send its way.

Assemble everything according to the instruction manual which you can find on GitHub.

PCB

Gerber files are in the PCB folder. These are the scehematics for the PCB boards and say, what is needed and where. You need one per unit. Populate components according to the instruction manual.

Options to potentially get boards created for you:

Note: Services are offered by these companies to assembly the boards for you. There are surface mounted components to these devices that you might not be able to do yourself like small resistors for instance, which must be flow soldered. It could be worth having the company do this aspect for you.

Unit

Each split-flap unit consists of an Arduino Nano mounted on a custom PCB. It controls a 28BYJ-48 stepper motor via a ULN2003 driver chip. The drum with the flaps is homed with a KY003 hall sensor and a magnet mounted to the drum.

Upload the Arduino sketch Unit.ino in the unit folder to each unit's arduino nano. Before that set the offset with the EEPROM_Write_Offset.ino sketch.

Inside Unit.ino, there is a setting for testing the units so that a few letters are cycled through to ensure what is shown is what you expect. At the top of the file once you have opened the project, you will find a line that is commented out:

#define SERIAL_ENABLE   // uncomment for serial debug communication
#define TEST_ENABLE     // uncomment for test mode where the unit will cycle a series of test letters.

Note: If you experience any problems uploading the unit sketch, you may have to change your Processor to use the old bootloader, called ATmega328p (Old Bootloader).

Remove the comment characters to help with your testing for the next step of Setting the Zero Position Offset.

Set Zero Position Offset

The zero position (or blank flaps position in this case) is attained by driving the stepper to the hall sensor and step a few steps forward. This offset is individual to every unit and needs to be saved to the arduino nano's EEPROM.

A simple sketch has been written to set the offset. Upload the EEPROM_Write_Offset.ino sketch and open the serial monitor with 115200 baudrate. It will tell you the current offset and you can enter a new offset. It should be around 100 but yours may vary. You may need to upload the Unit.ino sketch with the TEST_ENABLE flag uncommented and see if the offset is correct. Repeat until the blank flap is showing every time the unit homes.

Set Unit Address

Every units address is set by a DIP switch. They need to be set ascending from zero in binary. This is how my 10 units are set, 1 means switch is in the up-position: Unit 1 Unit 2 Unit 3 Unit 4 Unit 5 Unit 6 Unit 7 Unit 8 Unit 9 Unit 10
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

ESP01/ESP8266

Pre-requisites

To upload the sketch to the ESP you need to install a few things to your arduino IDE.

To upload sketches to the ESP8266 you can either use an Arduino Uno or you can buy a dedicated programmer. It is highly recommend getting a programmer as it makes uploading programs onto the ESP8266 much faster.

Note: Be wary of ESP8266 programmers that are available which allow USB connection to your PC which may not have programming abilities. Typically extra switches are available so that the ESP8266 can be put in programming mode, although you can modify the programmer through a simple solder job to allow it to enter programming mode. Examples can be found in the customer reviews of Amazon.

Alternatively, you can get a dedicated programmer from Amazon such as this one. This is also available on AliExpress if you are willing to wait a while for it.

Uploading the Static Assets via LittleFS

There are static files located here in the data folder of ESPMaster which will need to be uploaded. These make up the website that will be accessible on your WiFi so you can update the Split-Flap display.

Open the sketch ESPMaster.ino in the ESPMaster folder, change your board to "Generic ESP8266 Module", choose the correct COM-port and click:

Tools -> ESP8266 LittleFS Data Upload

This uploads the website onto the ESP8266's file system.

NOTE: No sketch has been uploaded yet! Only the static files. At the time of writing, this will also only work on an older version of Arduino IDE < version 2. The latest Arduino IDE broke support for Plugins such as the LittleFS plugin.

Updating Settings of the Sketch

There are several options in the Sketch you can modify to customise or change the behaviour of the display. These are marked in the code as "Configurable".

By default, the system will run in an "Access Point" mode where you will be able to connect to the display and put in WiFi credentials directly. This means if you WiFi changes, you don't have to re-upload a new sketch. Screenshot of the WiFi setup portal:

Screenshot WiFi Portal

Alternatively, you can specify credentials directly. You can go ahead and change the credentials in these variables:

const char* wifiDirectSsid = "";
const char* wifiDirectPassword = "";

You will also need to change the WiFi Mode in the code via changing this variable to true:

//Option to either direct connect to a WiFi Network or setup a AP to configure WiFi. Default: false (puts device in AP mode)
#define WIFI_USE_DIRECT false

You will also want to change the timezoneString to your time zone. You can find the TZ database names here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

You can also modify the date and clock format easily by using this table: https://github.com/ropg/ezTime#datetime

There are several helper define variables to help during debugging/running:

Experiments

In the main Sketch under "Configurable Defines", an "EXPERIMENTAL" section has been included. This section has been created for features that are things that can be changed and trialled however aren't going to be necessary to be changed for general use.

Static IP Address

A feature request of being able to set a Static IP Address was created by beroliv (thank you for the suggestion). This was to get around issues whereby in some routers, there was issues in being able to do this.

Code has been added to be able to set a Static IP Address on device. To do this:

  1. Set the WIFI_STATIC_IP variable to true (defaulted to false)
  2. Update the following settings as necessary for your needs:

    IPAddress wifiDeviceStaticIp(192, 168, 1, 100);
    
    IPAddress wifiRouterGateway(192, 168, 1, 1);
    IPAddress wifiSubnet(255, 255, 0, 0);
    
    IPAddress wifiPrimaryDns(8, 8, 8, 8);

Suggestion: Set your device up with a Static IP via your router if possible and to avoid conflicts on your network, however feel free to run this code if you are not able to. Testing this functionality showed it does work in both AP/Direct WiFi modes.

Sketch Upload

So far we've only uploaded static files to the ESP8266. You now need to Upload the sketch to the ESP8266. Click on Upload and the ESP8266 will be upadted with the sketch and you are done. Stick the ESP8266 onto the first unit's PCB and navigate to the IP-address the ESP8266 is getting assigned from your router.

Common Problems