Friday 17 July 2015

Nixie Clock with RTC and Bluetooth module



    Although 7 segment LED clocks with radio and alarm circuits are very common in our days and can be found in almost any house, they have some drawbacks like the following:

1. synchronization is done from the 50Hz / 60Hz power line
2. it cannot be used in other grid frequencies that in the one that it was designed
3. they do not have precise backup possibilities
4. they do not have daylight saving
5. you cannot shut down the lights and still have the clock functionality
6. can be powered up just from 230VAC 50Hz/120VAC 60Hz power line

 Because of these drawbacks the designed device presented in this document has the following advantages:
- it uses a RTC circuit that allows the use of a small battery, so the clock will never lose the time, even if it's plugged out(solutions for 4, 5)
- the RTC circuit retains the day, month and year so a daylight saving algorithm can be implemented(solution for 3)
- the RTC circuit has it's own oscillator(solution for 1, 2)
- has a voltage source for all the circuits that can operate either from AC or from DC so it can be powered up with usual DC sources with more than 12V or from a transformer with an output between 12 and 20VAC(solution for 6)

      And above all of mentioned advantages of this design compared to existing 7 segment LED display clocks, the vintage and retro look and feel of Nixie tubes makes from this apparently simple device an one of a kind  special clock.






THE IMPLEMENTATION OF THE CLOCK

NIXIE TUBES BASICS
NIXIE tubes, also known as cold cathode displays or cold cathode tubes are electronics devices used for displaying digits, symbols and alphabetical characters. They are based on the glowing effect of the current passing through a low pressure gas. When a voltage is applied between two metallic terminals, the gas near the terminals is ionized and plasma is generated. The color of the glowing light is dependent of the gas inside the tube.(http://en.wikipedia.org/wiki/Nixie_tube)



NIXIE tubes work with high voltages, of about 140-170V DC and absorb a current of a few milliamp. Most of the Nixie tubes have a common anode, which is the metallic mesh, cylindrically shaped and 10 cathodes, shaped as digits (form 0 to 9) or in some cases other symbols, that are places one in front of another, inside the cylinder. When one wants a cathode to glow, he applies high DC voltage on the anode on the tube, which is in series with a current limiting resistor  and pulls the cathode to the ground (with a driving circuit). There are tubes with two anodes(one responsible for even numbers and one for odd numbers), and cathodes are connected in pairs in parallel (0 with 1, 2 with 3, etc). When one wants to activate one cathode he uses the corresponding anode with the corresponding cathode group. Just the cathode that has the active anode surrounding it will light up.


Nixie tubes have a life or 10-20 000 hours, but it can be extended more than two times by  lowering the anode current and the voltage. There are Nixie tubes , like Philips ZM1000R that have been made with special combination of gases that have a  life of 50 000 or more. Nixie tubes are prone to mechanical failures as cracks of the glass casing, or in cathode poisoning(when some cathodes are not light up as often or at all compared to other cathodes). Cathode poisoning can be avoided if all cathodes are activated(one at a time) periodically, during the operation of the Nixie tube. If one or more cathodes present with poisoning effect, a high current pulse(20mA usually) for short amounts of time are highly likable to “heal” the affected cathode.






DEVICE BLOCK DIAGRAM



1. Power supply schematic

The power supply of the device consists of a full wave rectifier that accepts as input either AC either DC voltage. The output of the rectifier is filtered with an 1000uF capacitor and then fed to two voltage stabilizers: 7805 that generates 5V for the microcontroller, RTC circuit and multiplexers and a 7812 that generates 12V for the alarm, and for the boost power supply for the tubes.





The high voltage for the tube anodes is generated using a boost power supply topology, with a N-MOS transistor as a switching element, and a 1Amp fast rectifier diode as the peak detector. The controller for this power supply is the well known 555 circuit used as an astable multivibrator. The feedback is done by controlling the control voltage inside the circuit using a NPN transistor controlled by a voltage divider that measures the output voltage and feeds current to the base of the NPN transistor.




This schematic is found all over the internet and it is not my intellectual property


2. The microcontroller
The microcontroller is an ATMEL AVR family unit, ATMEGA8535. This microcontroller is pin to pin compatible with ATMEGA16, ATMEGA164, ATMEGA32, ATMEGA324, it has 4 IO ports of 8 bits each that will be used either for inputs, from the buttons, either for output for controlling the tubes, either for communication with the RTC circuit or with the UART.


The microcontroller implements a finite state machine(FSM) and controls the driver of the tubes and reads inputs from the buttons. It continuously reads the RTC circuit and it stores into the RTC circuit the alarm and the hour set by the operatorThe pull-up resistors are not used, the circuit has internal pull down resistors.








3. Driver of the tubes

    The driver is implemented using NPN transistors with a VCEO of more than 80V. The model used is BSX21, models used in old computers that used Nixie tubes as display unit. The transistors have a 5K resistor in series with the base. The 5K resistor is powered by the microcontroller or by the multiplexers and it assures enough current through CE junction, sending the transistor in saturation, thus dissipating the minimum amount of energy.





    If ic is the current through the collector, with a worst case scenario of hfe=20 , output voltage in high state of 3V and a voltage drop between BE junction of 1V, the current in the collector would be about 8mA. But the current through the collector can be maximum the current through the cathode of the tube, the same with the anode that is no more than 2.5mA. Thus, by these approximations we can conclude that the transistor is in saturation. Even if the transistor is not saturated, the power dissipation is still very small, insignificant.

   



    Because of the limitations of the microcontroller, and taken in consideration that maximum one cathode should be lit up at a time, and that not all cathodes are active ( H1 H2 : M1 M2 → H1 : {0 , 1, 2}, H2: {0-9}, M1 : {0-5}, M2: {0-9} ) the microcontroller with control directly some of the transistors and by multiplexers other transistors.





    4. Alarms and configuration buttons

    The device has 5 buttons: Sleep Up Down Set Alarm that have a 100nF capacitor in parallel with them to counteract the effect of bouncing in mechanical buttons. Internal pull-up resistors are used to keep the logic level on the inputs to High when buttons are not pressed.




    The alarm setting has 3 possibilities: a buzzer can act as the alarm, a radio can be powered up through a relay or the alarm can be completely shut off

    5. The PCB
   
The PCB respects basic design rules known by most engineers:
use a ground plane to reduce the noise in the PCB traces. Ground plane should be continuous, with minimum cuts as possible
use decoupling capacitors of 100nF for each integrated circuit on its VCC/ VDD pins
separate digital circuits from analog circuits on the board to reduce interference (capacitive and inductive coupling known as crosstalk)
if ground island plans form try to connect them with thicker traces or with small plans with the biggest ground plan
respect isolation distances for the voltages used on the board

Special conditions have been found and respected for the boost power supply and they will be discussed later in the document.





ALGORITHM OF THE MICROCONTROLLER

The algorithm of the microcontroller is in fact the implementation of a finite state machine.
The algorithm basically performs regularly read function of the RTC circuit. When the SET button is pressed, either minutes or hours flashes.  By pressing the UP / DOWN ,hours, or minutes, depending on which group is in a state of blinking can be changed. To write the new time in the  RTC circuit you press SET for a longer amount of time. To cancel the current operation  the SLEEP button or the ALARM button has to be pressed
When the Alarm button is pressed, either minutes or hours flashes.  By pressing the UP / DOWN ,hours, or minutes, depending on which group is in a state of blinking can be changed. To write the new time in the  RTC circuit you press Alarm for a longer amount of time. To cancel the current operation  the SLEEP button or the Set button has to be pressed
When the alarm is active, it can be silenced by pressing the ALARM OFF. If the operator want to disable it, this can be done by ALM signal switch interrupts.
Also, if the user wants to stop the display, but wants the functionality clock (alarm) to remain active, it may achieve this by operating the ENABLE pin switch that switches the high voltage source that is used to supply tubes onto the  position that is controlled by the microcontroller through EN_HVI signal  the signal  being held at 0V.
For further developments, a jack connector pin to pin compatible with blue-tooth modules was made ​​available. The user can attach a module that is interfaced  by serial connection and he can implement functions to configure the clock from its mobile devices.








DIFFICULTIES ENCOUNTERED AND THE SOLUTION
1. DS1302









Confusion about communication:
    DS1302 uses a Simple 3-Wire Interface for communication. This is not I2C, neither TWI, neither SPI. In the datasheet, the connection between the microcontroller and the DS1302 circuit is done directly
CE has named Reset in previous versions. Its functionality remains the same as in the old circuit and it affects just the communication buffers, and not the RTC functionality.
    It is advised to follow the recommendations in the datasheet and not schematics found on the Internet. The circuit has internal pull down resistors and with pull up resistors you obtain just more current drawn from the PSU, as the pull up resistors form an equivalent resistor with the internal pull down resistors.






2. The boost power supply



Designing PCB for boost power supply has to take in consideration minimizing the hot loops and lowering parasitic inductions.


Also, the design has to be done in such a way to reduce impedances. Vias and ground planes cuts raise impendaces.

http://cds.linear.com/docs/en/application-note/an136f.pdf


3. EMI

    The device is supposed to work wherever it is placed, so it has to be immune to EMI. In the PCB design, AN139 from LT (“ Power Supply Layout and EMI” ) should be taken in consideration.



http://cds.linear.com/docs/en/application-note/an139f.pdf



FUTURE DEVELOPMENT

For future development, the following will be taken in consideration:
developing software for microcontroller so that in can be configured by bluetooth
develop software for Android phone to communicate with the clock for configuration
embed the functionality of the radio onto the board
redesign the device to use less pins of the microcontroller and multiplex in time, the light-up of the digits at the natural frequency of the tubes




Wednesday 25 March 2015

BikeAngel - it might save you bike, money and time

BikeAngel is an antitheft device aimed to reduce the possibility of a bike being lost and never found again.
 
I am a member of the team developing BikeAngel. My implications are for the development of the device itself (the hardware) and part of the embedded software.

The project can be found here:

https://www.kickstarter.com/projects/bike-angel/bike-angel

It's difference from the rest of the devices that have similar specifications is the fact that it is placed inside the frame of the bicycle and it is not visible and it is very hard to access.




The device consists of a GSM module, a GPS module. The positioning is determined from the GSM cell and the GPS position and the GPS coordinates are transmitted through GSM or GPRS.

Some say that, being inside the bicycle frame means that it is shielded - it's not. Try putting you phone in the microwave oven(with the oven turned off , don't start it...you can even let it unplugged)  and call it(don't turn on the oven).
The phone will ring without a problem.

Put your phone inside a metal case(a STR8 parfume metal casing). It will still work. Shielding depends on materials, thickness, and other stuff, it's not so easy to understand.

And remember, there is an opening on the top.

The device will have an autonomy of 30 days and it will have rechargeable batteries.

I hope I raised your interest for this device. I am opened for suggestions and questions.