What goes in the "diagnostic byte"?

XanXan
edited December 2013 in BlinkyTape Fun
The stock firmware sketch includes writing a byte (more accurately, 4 bits packed in a byte) to serial port after each show. One of them is the button state. What are the others for?

Comments

  • The other three bits are the states of the expansion pads on the back of the BlinkyTape controller. There are two extra digitial I/O connections (D7 and D11 in Arduino), and one extra analog input (A9 in Arduino).

    These pins aren't required for normal operation, however we put them in to make it possible to connect up extra sensors, buttons, or other stuff. The diagnostic bits are used during production, to verify that each input works and isn't shorted to another pin or disconnected. The test rig does this by connecting a 5V signal to the first pin, reading the diagnostic bit and checking that only that pin went high, setting it back low to show that the pin went low, and then repeating for the other pins. It's part of the test procedure that tests all of the functional inputs and outputs on the BlinkyTape.

    The code in the Production sketch that makes the diagnostic bit is here:
    (https://github.com/Blinkinlabs/BlinkyTape/blob/master/ProductionSketch/ProductionSketch.ino)

    // BUTTON_IN (D10): 07 - 0111
    // IO_A(D7): 11 - 1011
    // IO_B (D11): 13 - 1101
    // ANALOG_INPUT (A9): 14 - 1110

    char c = (digitalRead(BUTTON_IN) << 3)
    | (digitalRead(IO_A) << 2)
    | (digitalRead(IO_B) << 1)
    | (digitalRead(ANALOG_INPUT) );
    Serial.write(c);

    The Arduino examples and PatternPaint animations don't send this byte, as it's not required for normal operation. If you do have a use for it, it's of course a simple deal to add it back into your Arduino sketch!
Sign In or Register to comment.