Saturday, June 24, 2017

Homemade Cheap ESD Safe Electronics Storage Box

Storing and finding electronic components can be a pain. I tried many solutions over the years until I found a solution that suits my needs - making boxes from 2mm plastic sheets. The cost is very low and can be made in whatever sizes you need.

Electronics storage box diy 1

How to make a custom box for storing electronic components

The box was designed in OnShape and the project can be found here https://cad.onshape.com/documents/bdcbefb1306a25bba44fdde5/w/06b2584dee706d902beec3c1/e/dadceb10cd0a694270b8739b

You don't need to learn OnShape unless you want to use other dimensions than those provided. 

All boxes have the same external size 25 x 25 cm for stacking them but the size and the number of compartments inside can vary.

 
Electronics storage box diy 2

Inside the CAD project you can find 2 drawing files: 5x5 rows results is 25 compartments per box and 6x7 rows, 42 compartments - 6 rows on horizontal axis and 7 on vertical.

For 25 compartments option the inner dimension is 47x47 mm and for 42 compartments 40x33 mm.


The above jig files can be printed from inside OnShape or downloaded as pdf files from below. It is important that they are printed as 1 to 1 scale. Then in the spreadsheet calculator file "Electronics Storage Box Dimension Calculator" specify how many rows and columns you desire. For example 6 columns and 7 rows.

Electronics Storage Box Dimension Calculator

With this setup the calculated results are: 42 number of compartments, 39mm width and 33mm height. We need 5 vertical spacers or dividers with the dimensions 244mm by 30mm, and 6 horizontal spacers with the dimension of 246mm by 30mm. After stacking them on top of each other with scotch tape, place the 256 mm paper jig on the horizontal spacers and the 244 mm jig on the vertical ones.

Notice the 2mm grooves on the paper jigs. Place some scotch tape on each one so when they are cut the paper won't tear off. I cut the grooves using a jigsaw and because the blade is under 2mm thick is a bit difficult but I don't have some better tool. A router would be better I think. Also, the cutting speed must not be too high so the plastic doesn't melt. Even so at the end I need to use a cutter with a long blade to separate them without breaking.

After the spacers are ready, place the vertical ones under the horizontal ones. This way you can pull the horizontal ones latter if you have some big components and want to join two compartments on the horizontal axis.

The dimensions for the external parts of the box can also be found in the spreadsheet calculator.

The hardest part of the this project is gluing the 4 sides of the box on the bottom part. See the CAD project to see how they are placed in relation to each other. I use superglue for this but the disadvantage is that it leaves a white deposition after drying. Good for copying the fingerprints but not very esthetic. There is glue for acrylic but I can't find it here where I live. Nevertheless I'm quite happy with the results.

How to cut acrylic or plastic sheets

This kind of plastic is very easy to cut and is in a way similar to glass cutting. I use a metal ruler and then a cutter to score a few times on the cutting marks. If the cutter blades are not good quality this won't work well. Ask me how I know. After that they can be snapped. Place the sheet on a table with the scored mark just a bit over the edge of the table. Then place some wood board above the plastic sheet and press on it to hold the plastic sheet pressed against the table. Now from this sandwich only the scored mark should be visible hanging over the table. Finally, use some narrow beam of wood long enough to press on the entire plastic sheet at once and place it near the cut and push on it hard. After a very loud bang the plastic sheet acrylic should have a perfect straight cut.

For smaller sheets this won't work so I use some pliers to remove the unwanted bit. Wearing protective glasses, use the pliers to gently push down the plastic lip from one end to the other so it can brake nicely in one piece.

Labels and the cover

The top cover is held using some wide transparent scotch tape. With the cover closed in place, place the scotch tape on the outside then on the inside.

For the labels, again i use a spreadsheet file that can be downloaded from below. After printing with a 1 to 1 scale I use a ruler and a cutter to cut the labels. Here the glue can be any cheap one.

The box label is made out from cable concealer 5cm wide where the label can be inserted.

Homemade Electronics Storage Box DIY 3

Even though the box is made out of plastic the components are protected from ESD. Notice how the pins of the through hole parts are pressed inside a conductive foam. Also the SMD parts like microcontrollers are stored on a conductive foam or inside ESD protected tubes.

Electronics storage box diy 3

 
Electronics storage box diy 4


Electronics storage box DIY 5

Notice how larger components can take 2 compartments or more. You don't need to make all compartments bigger if some parts are big and other small. Just break the spacers where you need to join the rows.

Electronics storage box DIY 6

Each box or compartment can have a certain type of parts. E.g. only resistors or capacitors.

Electronics storage box DIY 7

Electronics storage box DIY 8

Electronics storage box DIY 9

For capacitors, resistors and inductors I have dedicated boxes and the values are labeled so I can find the parts easy.

Electronics storage box DIY 10

But how to find a part is all these boxes? Using an index file of course.

Indexing electronics parts inside storage boxes

Each box has a label with a number and each compartment has a number. A spreadsheet index file is used and each part is associated with a box and a compartment number. Inside a compartment there can be multiple parts if they can fit with each one having some markings on them such as order code, values...

The index spreadsheet file can be downloaded from here as an example:

Electronics parts index

In the below video is the first box made. I left it here for entertainment purposes.



Download

Electronics Storage Box - Labels.ods

Electronics Storage Box Dimension Calculator.ods

5x5 rows.pdf

6x7 rows.pdf

Thursday, June 8, 2017

Salvage a VFD from a broken DVD

I had a broken DVD Player Philips DVP5960 so I thought to use the display with my other projects. The display is a Vacuum Fluorescent Display or VFD for short. This VFD is mounted on a front board alongside with an IR receiver and 4 tactile buttons and it is controlled by the ET16312N driver chip. You can use this front board for a digital clock or anything else that needs a display and a few buttons. The buttons can be desoldered and positioned elsewhere extended by wires.

To  create all this circuitry from scratch would be difficult. The ET16312N driver needs +5V, +12V and -24V. Also you would need to create an AC signal, multiplex the grids, drive the anodes, etc. but all this is already build for oyu on the front board. The power supply from the DVD Player can be used but I want to power the VFD from batteries so I will try to make a power supply myself.
The weird thing is that on the 12V line the VFD driver draws about 53 mA even if the display is off or dimmed. On -24V it draws about 6 mA. So yeah, it is not well suited for batteries unless you physically turn of the power using a transistor controlled by the MCU when the display is in standby.


Philips DVP5960 Front Board together with Crapduino
Philips DVP5960 Front Board together with Crapduino

Connecting the VFD to the DVD Player Powers Supply

I disconnected the front board from the main board and also the power supply from the main board, then I connected the power supply to the front board using breadboard jumper wires. You need to be careful that the wires are connected right so you don't blow the chip. For this a datasheet will be helpful and a lot of attention. You can download the datasheet for ET16312N chip down bellow.

Philips DVP5960 Main Board and Power Supply
Philips DVP5960 Main Board and Power Supply
DVP5960 Power Supply Connector Schematic
DVP5960 Power Supply Connector Schematic

This connector from the front board (image bellow) was connected to main board but now is connected to the power supply (image above) and microcontroller using jumper wires.
DVP5960 Front Board Connector Schematic
DVP5960 Front Board Connector Schematic

Connecting the VFD to an AVR Microcontroller

Front board connector pinout:
1 - MIC - microphone. Not available on DVP5960
2 - AGND - analog ground. Connected to GND on power supply
3 - +12V - connected to pin 5 on power supply
4 - -24V -  connected to pin 8 on power supply
5 - IR - signal from infrared receiver located on front board. I didn't need it so i left it disconnected
6 - DV33 - digital voltage 3.3V. Used by the IR receiver sensor and the standby LED. I left it disconnected
7 - GND -  connected to GND on power supply
8 - DATA - used to transmit and receive data between MCU and the VFD driver chip. Connect it to a MCU pin
9 - CS - connect it to a MCU pin
10 - SCLK -  connect it to a MCU pin
11 - LED- - ground for the Standby LED. I left it disconnected
12 - POWER_K - i think it activates the power through main board to front board but since I connected the front board directly to the power supply i didn't need it

Don't forget to connect the ground from the power supply that the MCU is powered on to the ground of the DVD Player's power supply.

Now that all the connections are set up you can test the VFD by sending something to be displayed. If you need the library to drive the VFD chip you can download it visiting this post Library for interfacing AVR microcontrollers with ET16312N VFD driver.


Communication protocol between a Vacuum Fluorescent Display (VFD) driver chip and a microcontroller

Here I will describe the ET16312N driver chip but almost all VFD drivers use the same protocol with few minor differences. The datasheet for the ET16312N can be downloaded down below.

This chips can control multiple types of displays like 11-segment & 11-digit to 16-segment & 4-digit. They require 5V to power themselves and -24V (-30V max) to drive the VFD. Apart from that they can also implement a 6 x 4 matrix key scanning, 8 steps dimmer circuit, 4 LED output ports and 4-bit general purpose input port.


The first thing to do is to initialize the display by telling the driver how many digits and segments the VFD has. In my case the VFD has 7 digits and 15 segments including the colon symbol. So each digit is formed by segments.

Vacuum Fluorescent Display (VFD) digits
Vacuum Fluorescent Display (VFD) digits


Sending commands and data to a VFD driver chip

If we look at the protocol diagram we can see that in order to send commands or data to the driver, the CS must be pulled LOW, then the SCLK is set to LOW and then HIGH after each bit is sent. The data is transmitted on the rising edge when the SCLK is HIGH. The bits are transmitted using the DATA pin - when DATA pin is HIGH for a 1 bit and LOW for a 0 bit. After all the bits are sent, the CS and SCLK are pulled HIGH.

Protocol for sending data to a VFD driver chip
Protocol for sending data to a VFD driver chip

Now that we know how to send commands, let's initialize the display by telling the driver what display we have.
Looking at the datasheet we can see that the first three bits describe the number of digits and segments. In example case (7 digits, 15 segments) the byte to be transmitted is 0b00000011. Since this is a command, after we transmit this byte the CS is set to HIGH again and that instructs the VFD driver chip that the transmission is over.

Sending a character to the VFD


To display characters you need to tell the VFD driver what segments needs to be turn on. On my particular DVD Player the segments have the following numbering.

VFD Segment Numbering
VFD Segment Numbering. Please excuse the crudity of this drawing, my cat drew it.
Since the driver support up to 16 segments, it expect 16 bits (or 2 bytes). The most significant byte must be sent first. Let's send the character 'A'. Is up to us what segments we choose to form the 'A' character. In this case the segments are 14, 2, 7, 3, 15, 1, 9, 16. The two bytes are:
0b11100001 - first byte to be transmitted. It includes segments 9, 14, 15, 16. So here the first bit represents segment 9 and bit 8 represents segment 16.
0b01000111 - the second byte to be transmitted. It includes segments 1, 2, 3, 7.

VFD driver chip data setting commands
VFD driver chip data setting commands
To send data first a command needs to be sent to tell the VFD driver chip what we are trying to do. In this case we want to display a character so we use the first 2 bits - write data to display memory. Notice that the bit 7 must always be 1.
Now the protocol is:
- CS is pulled LOW
- SCLK is pulled LOW and back HIGH for each 16 bits. The bits are transmitted using the DATA pin.
- after all the bits are sent, the CS and SCLK are pulled HIGH.


Reading data from a VFD driver chip

Reading data from a VFD driver chip
Reading data from a VFD driver chip
If we need to read key data or SW data first we send the command like when we chose to write data to display memory, then a delay time of 1 microsecond must be added and then we read the data from the driver but this time on the falling edge when SCLK is LOW.
The protocol is:
- send o command with instruction of what do you want to read
- add a delay time of 1 microsecond
- set DATA pin as input HIGH
- set SCLK HIGH
- set CS LOW
Now for every 8 bits to be received:
- set SCLK LOW
- check if DATA pin is HIGH or LOW and store the bits data
- set SCLK HIGH (repeat this steps 8 times)
After the loop when all bits are received:
- set DATA pin as OUTPUT
- set CS HIGH

Download section

Technical Manual - Philips - DVP5140, DVP5140K, DVP5142, DVP5965K, DVP5960
Datasheet - VFD Driver chip HT16512 similar to ET16312N

Saturday, June 3, 2017

Library for interfacing AVR microcontrollers with ET16312N VFD (Vacuum Fluorescent Display) driver

I had a broken Philips DVP5960 DVD player and I thought it's a good idea to salvage and use the VFD display in some project. And so this code was born.




Vacuum Fluorescent Display (VFD) from a DVD Player controlled by AVR MCU
Vacuum Fluorescent Display (VFD) from a DVD Player controlled by AVR MCU

To know more about the communication protocol between the microcontroller and the VFD driver chip, visit this post Salvage a VFD from a broken DVD.





Currently supported VFD - Vacuum Fluorescent Display chip drivers by OnVFD:

- ET16312N
Supports:
4 digits, 16 segments
5 digits, 16 segments
6 digits, 16 segments
7 digits, 15 segments
8 digits, 14 segments
9 digits, 13 segments
10 digits, 12 segments
11 digits, 11 segments

You only need three pins from the MCU to communicate with the VFD driver: CS, SCLK and DATA. I've described what each one does in the above linked post.

Included functions

void VFDInitialise(void);

- used to initialise the display. This function sets the MCU pins and the number of VFD digits and segments, clears the display and sets the cursor to first digit.

void VFDWriteString(const char *string);

- a function to display string data type
The macro VFDWriteStringPosition(string, position) can be used to write a string to a specific position (only on X axes).

void VFDWriteInt(int16_t number, int8_t nrOfDigits, bool displayColonSymbol);

- a function for displaying int data type.
int16_t number - the first parameter is the number to be displayed
int8_t nrOfDigits - number of digits the number is formed by. If this number is greater than the actual number of digits, the displayed number will be padded with zeros.
bool displayColonSymbol - it can be true or false and indicates whether you want the colon symbol to be displayed or not. Note that the colon is only available at a certain digit position and depends on the type of VFD display.
The macro  VFDWriteIntPosition(number, nrOfDigits, position, displayColonSymbol) can be used to write an int to a specific position (only on X axes).

void VFDClear(void);

- clears the display by writing a space on all the digits and sets the cursor back to position 1.

void VFDSetCursorPosition(uint8_t position);

- accepts a number from 1 to VFD's maximum number of digits. If position is 0 the cursor will be set at the last digit, if the position is greater than the maximum digits the cursor will be set to first digit.

The macro VFDHome() can be used to move the cursor to first digit.

VFDdisplayOn(DIMMING);

- macro. Turn on the display. Dimming parameter can be a number from 0 to 7 - 0 is minimum and 7 is maximum.

VFDdisplayOff();

 - maco. Turns off the display. Key scan continues.

VFDSetBrightness(BRIGHTNESS);

 - macro. Change the display's brightness/dimming. Brightness parameter can be a number from 0 to 7 - 0 is minimum and 7 is maximum.


Functions related to VFD driver chip

uint8_t VFDReadKey(void);

- reads the key matrix and return a byte with the key button that is currently pressed. On my DVD's front panel there are only 4 buttons so they are not really arranged in a full matrix.

uint8_t VFDReadKeyButton(uint8_t delay);

- this function uses the above function to read the key matrix with some functions added. It returns 0 if no button is pressed or the number of the button pressed. In my case the returned byte from the VFD chip driver looks like this 0b0000 0001 if no button is pressed. The first LSB is always 1. If button 1 is pressed the byte is 0b0000 0011, button 2 is 0b0000 0101. So this function counts from the LSB not including the first bit and returns the button number. How the buttons correspond to numbers depends on the board layout.

uint8_t delay - this number depends on the delay time in your code. All this number is used for is to increment a global variable each time the function runs and when the number of the variable match this parameter the function returns the pressed button. Is like debouncing. I didn't add the delay inside the function so the main code doesn't have to wait for this function to terminate. The proper way would be to use an interrupt but this is easier to implement. You could add a 1ms delay in the main loop for example and make the delay equal to 50 and the button will be read every 50 ms.

uint8_t VFDReadSW(void); 

most VFD driver chips include 4-bit general purpose input port and can be used to attach 4 buttons. It returns 1 byte binary data. The first bit represents button 0, second bit button 2, third bit button 3 and fourth bit button 4.

void VFDControlLEDs(uint8_t leds);

- control up to 4 leds. First bit represents led 0 and bit 4 represents led 4. For the VFD driver chip 0 means led ON and 1 means led OFF but the function takes care of bit flipping.

Other extra functions

void VFDdisplayAllFonts(void);

- display all available characters by scrolling them. The speed can be changed by modifying VFD_SCROLL_SPEED.

void VFDscrollText(const char *string);

- pass a string to this function to be scrolled on the display. The speed can be changed by modifying VFD_SCROLL_SPEED. After the function completes, the cursor is set to first digit. Clearing the display is not necessary.

VFDDegreeSymbol();

- macro. Display the degree symbol without C or F.

void VFDBusySpinningCircle(void);

- busy indicator formed by 4 segments at 45 degrees, each one fading behind the other and spinning in circle at the same time at about 1 revolution per second. Text can be displayed in the mean time. Check the video to see it.

void VFDSegmentsTest(void);

- lights up a segment from 1 to 16 every 2 seconds and displays the number. Useful if the screen is not supported by the library and you want to modify the code.


void VFDBlinkUserInput(uint8_t cursorStartPosition, uint8_t length);
- i have made this function for myself and i left it in the code i case someone want to use it and is not too confusing. It is useful for a menu. When the user selects something to modify e.g. time, temperature, etc., you can make a function that enters in a loop until the user presses a button. In that loop you can put this function and the characters at the cursor position will blink showing to the user what is about to modify. If there is a space than an underscore will be blinked. To keep track of the cursor position you can use cursorPositionX because the code will correct for 0 or over the number of digits values.
uint8_t cursorStartPosition - from what position to blink the display.
uint8_t length - how many characters to blink.

 

How to use OnVFD

Open the OnVFD.h file and in the SETUP section modify the MCU IO replacing the DDR and PORT and PIN data according to your setup.

Then bellow that you have the display configurations.

// VFD Display settings
 
// Number of segments for each digits 
#define VFD_SEGMENTS    15
 
// Number of digits
#define VFD_DIGITS      7

// The scroll speed in milliseconds used by the VFDscrollText function
#define VFD_SCROLL_SPEED  400 // In milliseconds

To save space many extra functions are skipped by the compiler using defines. If you need any of those functions write 1 to that define.

// Write 1 to enable the following functions
#define ENABLE_READ_SW_AND_KEY        0 // Enables functions to read SW and KEYs
#define ENABLE_TEXT_SCROLL            0 // Function for scrolling a text
#define ENABLE_DISPLAY_ALL_FONTS      0 // Display and scroll all available characters
#define ENABLE_MENU_INTERFACE_RELATED 0 // Enables VFDBlinkUserInput function
#define ENABLE_BUSY_INDICATOR         0 // Enables VFDBusySpinningCircle function
#define ENABLE_SEGMENTS_TEST          0 // A function to test segment numbering

Example:
/*************************************************************
 INCLUDES
**************************************************************/
#include "ET16312N.h"

int main(void){
 
    VFDInitialise();

  
    
    // Display text
    VFDWriteString("ON VFD");
    _delay_ms(5000);
    VFDClear();
 
    // Display time with colon
    // On my VFD display the colon is available when cursor 
    // is on digits 3 and 5. So we start from position 2 and display
    // two digits 21 so digit 1 will be on position 3 and the colon 
    // will be available.
    VFDWriteInt(21, 2, true); // hours
    // Minutes will be 01 even if we pass 1, the second parameter is 2 
    // meaning that two digits will be displayed 01.
    VFDWriteInt(1, 2, true); // minutes
    VFDWriteInt(10, 2, false); // seconds
    _delay_ms(5000);
    VFDClear(); 

  
    // Dim the display
    VFDscrollText("DIMMING THE DISPLAY TO SAVE POWER");
    VFDSetBrightness(1);
    _delay_ms(2000);
    VFDSetBrightness(7);
    _delay_ms(2000);
 
    // Turn off and on the display
    VFDdisplayOff();
    _delay_ms(3000);
    VFDdisplayOn(7);
 
    // Busy indicator example
    VFDscrollText("BUSY INDICATOR");
    for(i=0; i<8000; i++){
        VFDHome();
        VFDBusySpinningCircle();
        VFDSetCursorPosition(3);
        VFDWriteString("WAIT");
    }
    VFDClear();
    _delay_ms(2000);
 

  
    while(1){

  
  
    }
}


Download OnVFD library:

ET16312N v1.0