Saturday, October 26, 2013

Li-Fi

I guess we all have heard of Wi-Fi or also known as Wireless Local Area Network (WLAN) as defined by Wi-Fi Alliance where the communication protocol is based on IEEE 802.11standards.  

Now comes a new term called "Li-Fi" where it uses light as a medium to transmit data.  It had been demonstrated at the University of Edinburgh where the Li-Fi technology was used  to stream high definition video.  It uses light as medium instead of electromagnetic waves.

The technology behind the Li-Fi is basically using Orthogonal Frequency Division Multiplexing or also known as OFDM with a little modification.  With this technology one able to split the data stream into thousand of parallel streams with using multiple carrier frequencies to modulate the light sources in order to achieve high throughput transmission.

You can imagine with the light source around us such as light bulb, tube light, street light, etc. able to transmit data.  When ever there is light one able to transmit and receive data.  I will investigate into this technology further and maybe build some working prototype. 


Tuesday, August 20, 2013

ARDUINO!

I came across an open source development board known as "Arduino".  What does it difference from other 
Arduino UNO R3
open source board such as Beagle Board and Raspberry Pi?  Does it able to run Linux, Android, Win OS, etc.?  For those who first encounter Arduino may have the same questions like I do. 

Arduino is very popular in US and Europe especially for hacker where you want a quick hardware to do a simple or even a little more complicated control.  It is completely open source where the hardware schematic and its firmware library is available from Arduino website (http://www.arduino.cc).  You can download the Arduino development environment from their website as well; C compiler is provided free-of-charge.  There is no license or code limitation for compiler.  

There are many version of Arduino boards depending on which application you would like to design.  The one shown on photo is the Arduino UNO R3 which I think one of the most purchased. I downloaded the hardware schematic (http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf) from Arduino website and after going through the schematic, the designer is using two Atmel ATMega micro-controller on board.  The ATMega16U2 is a USB micro-controller where it is programmed to be USB-to-UART converter.  The other ATMega328 is the main micro-controller for Arduino UNO.  The firmware you wrote will be flashed into the ATMega328 which you click on the upload button.  There are other version Arduino boards that only used one micro-controller and this will reduce the board size and suitable for portable application.

It doesn't stop there!  There are daughter boards or also known as Arduino Shields where it is designed as an added companion to a Arduino board.  Some of the example of Arduino Shields are GSM Shields, Ethernet Shields, Motor Shield, etc.  

Just ordered the Arduino UNO R3 board and waiting for delivery.  Once I tried out the board, I will write more on the experience.

Sunday, July 28, 2013

Medical Electronics For Chronic Illness

Chronic illness is defined as a person that has a disease more than three months such as cancer, arthritis,diabetes, HIV/AIDS, etc.  According to World Health Organization (WHO) the mortality rate in the world due to chronic illness was reported to be 60% of all death.  This rate was reported in 2005 this mean that the rate in year 2013 will be higher based of our pollution rate and all.  In US alone the 70% death rate is due chronic illnesses such as heart disease, cancers, stroke, chronic respiratory disease, diabetes, Alzheimer's disease, mental illness and kidney diseases.  90% of the seniors have at least one chronic disease. 

The mortality rates can be reduces tremendously if we could have early detection and response to be sent to
the respective health institutions.  With our modern technology this can be done easily especially using embedded technology coupled with communication technology (Bluetooth, GSM, etc.).  Different type of sensors can be attached to a person body and the sensors are constantly monitoring the person. All the sensors' reading are sent to a base station located at home via wireless such as Bluetooth, etc. The reading will be transmitted to a remote location (hospital, health institution, etc.) via GPRS network, internet, etc.  There are many ways to send the sensors' reading to a remote location.  One of the method is to transmit the data via GPRS network and for those location where wireless data network is unavailable, Power-Line-Carrier (PLC) can be used to transmit the data.  PLC considered a full proof method of transmitting the data to remote location as power grid is available even though at some remote area. With this method, the infrastructure costs is much more cost effective; as long as power grid is available the communication to remote location is possible.  One only need the PLC transceiver to do so.   Power-Line-Carrier is very interesting topic and there are many types of protocol for PLC.  Next, I will cover some of the PLC technologies.

Tuesday, July 16, 2013

Smart Light Bulb

I guess we all are familiar with smart home automation with smart appliances where your refrigerator could
tell you supply shortages inside the fridge and smart enough to produce grocery list for you.  Who will think even a small light bulb is also smart?  Well, it is coming soon and most lighting manufacturers are making their lighting products smarter.  It will be much more easier to do so with the use of light-emitting-diode or LED technology.  Solid State Lighting (SSL) has come a long way and it has been a privilege for me to witness the evolution of its development till now. 
The traditional Edison bulb requires no additional circuitry to burn the tungsten.  In fact, the hotter its get the better its illumination.  Unlike the Edison bulb, LED requires DC current to operate and the cooler its get the better its illumination; the direct opposite of incandescent lamp. 

How do we operate the SSL on AC power line?  Simple!  We need an AC to DC power supply squeeze into a tiny housing.  The LED driver chipset has improved over time and now even the designer includes a single stage power factor correction internally that makes the power factor as close as possible to 1; most of the time measurement will shows around 0.95~0.99.  Not only that but overall bill-of-materials also been reduced in order to reduce the driver printed circuit board (PCB) size to reduce the overall system costs.  How about AC LED?  Are this LED really operate on AC?  No!  Diode is always a Diode. Thomas Edison discovered the principle of diode during its light bulb discovery but he is not aware of its application until later.  There are several ways to operate the LED on direct AC line.  One of the technique is to use high voltage VF (forward voltage) LED, as high as possible, in order to reduce the power loss from the additional voltages.  One can use a current source either at the front- or back-end; there is advantage and disadvantage by doing so.  This is a straight forward technique without any control and monitoring that may affect the power factor and system efficiency.  By putting intelligent into this technique, one could monitor the AC line and switch a string of LED accordingly to make sure the Current Phase and Voltage Phase are aligned; high power factor.  As the AC goes up and down, different array of LED will be switched on / off.  One drawback of this technique is more LEDs are required in order to achieve the same brightness compared to conventional AC-DC driver and linear AC LED.  Other techniques are existed......soon to be discovered.

Now, we have the power supply smart enough, what else can do to make the light bulb smarter?  Communication? YES! By adding communication to it one will be able to communicate with the light bulb and tell it what to do or how is it doing?  I stop here for now as the rest is trade secret :).  I leave it to the reader to imagine what else he/she could put into his/her light bulb. 

Monday, July 8, 2013

Using Microchip MCU Timer 1/3/5 Module with Gate Control

Previously, I covered the Timer 0 module which is much easier to use and configure.  Timer 1, 3, or 5 module is more complicated and lots more to configure as it provides more features.  

Timer 1/3/5 Module Block Diagram

Timer 1/3/5 module is quite similar to Timer 0 except it is a 16-bit timer and an additional Gate Control input feature.  What is Gate Control?  Timer 1/3/5 module can be configured to count freely or disabled/enabled counter via Gate circuitry.  The Gate circuitry can be driven from multiple sources selected via TxGSS<1:0> bits in TxGCON register (refer to block diagram upper corner top left).  They are,

Timer 1/3/5 Gate Pin
If TxG gate pin is selected as the source, an external source will be used to enable/disable the count.  

Timer 2/4/6 Match to PR2/4/6
The free counter Timer 2/4/6 register will increment until it matches with user set value in the PR2/4/6 register (Period Register).  When match happens the Timer 2/4/6 will reset to zero on the next increment and a low-to-high pulse will be asserted to the Timer 1/3/5 Gate circuitry.

For example, user set the PR2 = AA55h.  Assume Timer 2 counts from 00h, once Timer 2 match the preset PR2 value AA55h, the comparator in the Timer 2 module will generates a match signal which will be used to assert the Timer 1/3/5 Gate module circuitry if this source is selected.

Comparator Output sync_CxOUT
Comparator module output (sync_CxOut) can be selected as one of the Gate circuitry source.  When the comparator condition is met, sync_CxOut will be asserted to Timer 1/3/5 Gate circuitry.  The asserted signal will be latched on the falling edge of clock source whereas the timer increment is latched on the rising edge of clock source in order to prevent from race condition.

Unlike Timer 0, Time 1/3/5 is a 16-bit timer where the timer value is accessed through TMRxH and TMRxL.  Writing to TMRxH or TMRxL will update the timer.  One can choose either internal or external clock source.  When internal clock source is chosen the timer increment on every instruction clock cycle compared to external clock source where the timer increment on every rising edge of clock input to the TxCKI pin.  Some Microchip MCU do support secondary low-power 32.768 kHz clock oscillator which is normally used for real time clock.  

Monday, July 1, 2013

BEAGLEBONE BLACK

The BeagleBone Black is the latest board of the Beaglebone board family.  With its credit-card-size
Linux computer, BeagleBone Black is a truly open hardware and software development platform.  It includes all the necessary accessories to start developing, providing a truly low cost embedded systems compared to the nearest competitor.  Furthermore, it is built on a proven ecosystem that speeds up development time for project, product or prototype.  

BeagleBone Black is built around the Sitara 1GHz AM335x ARM Cortex -A8 processor from Texas Instrument.  It provides a more advanced user interface and up to 150% better performance than ARM11.  Besides the powerful processor, BeagleBone Black has built-in 2GB Flash on-board helps to boost the overall performance.  It comes pre-loaded with Angstrom Linux distribution.  Large memory will also free up the use of microSD or used of additional storage.  Besides Flash memory, it has also comes with blazing speed 512MB DDR3 memory that helps to enhanced the user experience.  Other peripherals such as microHDMI, microSD, 10/100 Ethernet, USB host, etc. are available on-board.  It has an expansion header that provides access to digital I/O, analog input, serial communication port, and much more.

Developing on the BeableBone Black is similar to Arduino and the development software is available free-of-charge and open source.  BeagleBone Black is only selling for USD45.  This is a MUST TRY!!!

Wednesday, June 26, 2013

Microchip PIC16F688

I had used the Microchip PIC16F688 for many applications up to now such as Motion Control, Remote Control, Sony PS1 keypad emulator, etc. I came across a tear down for Nike+ product and it is interesting to find Microchip PIC16F688 on board. The PIC16F688 is used to control the Nordic RF transmitter, nRF402. The communication between these two devices are via Serial Peripheral Interface or in short SPI.


Next topic I will discuss further on SPI communication, different mode of SPI and all.  See ya next time......

Using Microchip MCU Timer 0

All Microchip micro-controllers, from PIC10F to PIC32F, has Timer 0 module.  Few years back the Timer 0 module only support 8-bit timer but later in some part Microchip enhanced the Timer 0 module to include the 16-bit timer.  



The block diagram on top is the 8-bit Timer 0 module and bottom is the 16-bit Timer 0 module.  Referring to the block diagram, both the front end blocks are the same except the timer registers, TMR0L and TMR0H (TMR0 High Byte).  

If Timer 0 module is configured as 8-bit timer (set T08BIT bit in T0CON register), only TMR0L register is used.  Else, if configured as 16-bit timer (clear T08BIT bit in T0CON register), TMR0L and TMR0H register are used.  TMR0H is actually a high byte of TMR0L which is not directly readable or writable, any write/read on/from TMR0H has no effect.  In order to read the 16-bit timer, one just need to read the TMR0L register.  Likewise, any write to TMR0L register will also write TMR0H in 16-bit timer mode.

Moving from left to right of the block diagram, the input clock can be either from T0CKI pin or internal instruction clock cycle (Fosc/4) where Fosc is the micro-controller operating clock.  If the clock input from T0CKI pin, one needs to define the timer count increment on high-to-low or high-to-low transition of the clock at T0CKI pin.  It can be set via PSA bit in the T0CON register.

The Prescaler is programmable where it is used to slow down the clock count, basically.  The 3-bit Prescaler is used to select which prescaler to use with the timer.  It ranges from 1:256 to 1:2.  What does this mean?  If you set the Prescaler to 1:2 meaning every 2 clock transition it only counts as 1 count.  

How do you calculate the timer period with Prescaler?
For example, operating clock is 4 MHz (Fosc) and Prescaler is set to 1:32.  
Instruction clock cycle =  Fosc/4 = 4 MHz/4 = 1 MHz
After Prescaler = 1 MHz / 32 = 31.25 kHz, or 1 tick = 32 uSec

One can monitor the Timer 0 interrupt flag bit in order to determine timer set has expired or overflow. 

How do you set the Timer 0 to overflow every 1 mSec?
From the example above, 1 tick is 32 uSec.  
For 1 mSec, number of ticks = 1 mSec / 32 uSec = 31.25 tick ~ 31 ticks
Set Timer 0 to 31 ticks to overflow = 256 ticks - 31 ticks = 225 ticks (8-bit timer mode)
After setting TMR0L to 225, it will counts from 225 to 256 and roll over to 0.  Rolling over will assert the TMR0 interrupt flag bit.  One can monitor the TMR0 interrupt flag bit to determine the time expire or overflow.  
NOTE: Please make sure to clear the TMR0 interrupt flag bit else it keeps going into the interrupt service routine and if polling method is used it will directly skip the code.

For 16-bit mode, the maximum number of ticks is 65536 instead.
Set Timer 0 to 31 ticks to overflow = 65536 ticks - 31 ticks = 65505 ticks (16-bit timer mode)

Please bear in mind some Microchip micro-controllers do have TMR0 on/off bit so need to remember to turn on the Timer 0 module else it won't work.  I hope I cover most of the Timer 0 module function.  If you have any question, please drop me an email.


Monday, June 24, 2013

Timer In Microchip MCU

Timer is a MUST have module in any micro-controller.  Almost all applications require Timer feature some where in the codes and will be heavily used if you are running time event in your code especially when you are using Real-Time-Operating-System (RTOS).  

There are several Timer module in a Microchip micro-controller, smaller part such as PIC10F consisted of Timer0 module and as we move on to larger part such as PIC32F there will be more and more Timer module up to five modules.  

Next, I will drill down in detail on each Timer modules and how to configure them.  


Saturday, June 22, 2013

Watchdog Timer Hung Up Eliminator

First time when I start to work with micro-controller the first I did is to look at the feature summary usually on the first few pages of the datasheet or product manual.  For a beginner, the first word that I came across and a little strange though, "Watchdog".  The first impression to me it is some feature built-in to the micro-controller to watch after the micro-controller to prevent hacker or protect against any theft.  NOT! My impression is way off from the actual usage of "Watchdog".  What is "Watchdog" anyway?

"Watchdog" is a feature built-in to most or all micro-controller / processor to prevent any software hung up in case the code can't get out from an infinite loop.  Once it is enabled, Watchdog timer is running on the background using either the internal oscillator or external oscillator connected to the processor.  Depending on which micro-controller or processor the Watchdog timer can be configured to expire at certain time period.  In case of code hung up the Watchdog timer will expire and force the micro-controller or processor to Reset and start the code from beginning.  Due to this the programmer requires to reset the Watchdog timer in the software to prevent from unintentional Reset.   

For Microchip micro-controller the extended Watchdog timer is programmable from as short as 4 millisecond to as long as 2 minutes.  In order to enable the Watchdog timer in a Microchip micro-controller one just set a bit in the Configuration Bit.  For PIC18F2XK22, the Watchdog timer configuration is resided in CONFIG2H (different Microchip micro-controller will have different location for the Watchdog timer configuration).  For resetting the Watchdog timer, the Assembly code is "CLRWDT" that will takes 1 instruction cycle to execute and if you are using Hi-Tech C-compiler just write "CLRWDT();" to reset the Watchdog timer.

That's all about Watchdog timer.  To know more about Watchdog timer, you can get a general definition from Wikipedia (http://en.wikipedia.org/wiki/Watchdog_timer).  Next time I will share with you on Timer module in a micro-controller.

The First Encounter

My first encounter on embedded systems is during my final year at university back in the 90's.  I took the digital design laboratory class and it is the first time I had the chance to work with Motorola 8051 micro-controller.  I used the micro-controller for robotics arm control for final year project.

We have seen embedded systems come a long way and with the most powerful processor in the market, we couldn't imagine all the applications we can create where we turn most of our childhood dream into reality.