Sunday, December 28, 2014

Second Sun - 2014 Mix

Out Now on Beatport. Exclusive mix of my favourite tunes from 2014 - Second Sun - marks my first mix album on Beatport.


1. Reorder & Ian Standerwick Pres. Skypatrol - Sailing Airwaves [Future Sound of Egypt]
2. The Thrillseekers - When All Else Fails (Club Mix)
3. Luke Bond feat. Roxanne Emery - On Fire (Aly & Fila Remix) [Garuda]
4. Aly & Fila & Jaren - For All Time [VANDIT Records]
5. Aly & Fila & Skypatrol - Running (feat. Sue McLaren) [Future Sound of Egypt]
6. ReOrder Feat. Sue McLaren - Hands Of Time [Subculture]
7. Witness45 & Poonyk - Indiana (New World Remix) [Abora Recordings]
8. Kheiro & Medi Feat. Danny Claire - When You're Home [Black Hole Recordings]
9, Simon Patterson Feat. Sarah Howells - Dissolve [Armind (Armada)]
10. Aly & Fila & Ferry Tayle - Nubia [Armada Music Bundles]




Thursday, December 11, 2014

Visible Light Communication Chronicles Part VI

I have finally finished a working prototype of my VLC system and it works like a charm ;) This prototype has a maximum bandwidth of 1 Mbps and works to a distance of roughly over 2 meters using a collimated light source. After several design iterations i have used newer components like the S1223 30MHz photodetector from Hamamatsu and operational amplifiers from Analog Devices. Analog Devices has some great tools and application notes that simplify designing. The picture below shows the finished prototype of the VLC receiver. The micro-controller interface uses a Cortex-M4 micro-controller from Freescale - The Teensy 3.1 development board from PJRC. The circuit is basically a photodiode transimpedance amplifier using the AD8651 followed by a AD8561 high speed comparator for wave shaping.

Going forward with this project i shall be increasing the bandwidth and experimenting with smaller form factors, controllers, PDs, to facilitate audio, video and data streaming applications...

The final specifications had the feedback resistor with a value of 68 K, feedback capacitor of 2.4 pF for an output voltage swing of 3.3V. The PD was reverse biased by 5V resulting in a capacitance of 20pF. The AD8651 has a Gain Bandwidth Product of 50 MHz and powered by a 3.3V single supply. For the select Rf the 45-degree phase margin bandwidth turned out to be 1.82 MHz and the Cf with a value of 1.2 pF. Since the desired value of Cf was greater than the value of Cf that produces 45 degree PM the circuit was deemed stable. The dynamic range turned out to be 91 dB with total RTO noise of 96 uVolt rms. Since the slew rate of the AD8651 is 41 V/us, the output voltage max swing was chosen as 3.3V which when plugged into 2πfv for f = 1MHz gives approx. 20 V/us, which is less than the max specification

Output signal from the receiver. The transmitter is a single white LED driven by a 1 MHz clock signal.

Below are some graphs i plotted in Matlab to visualize component selection based on the CN0272 circuit note by Analog Devices

Feedback resistor value effect on bandwidth.

Sunday, October 5, 2014

Visible Light Communication Chronicles - Part V - The Boards

The boards are here !! The images shown below are the VLC RX and TX boards i designed as shields for the Arduino UNO. An array of 12 LEDs forms the transmitter, a TEMD6200FX photodiode on the RX board, an Analog Devices XRAD8051 transimpedance amplifier followed by a SY8890 limiting amplifier. The wires on the TX board are test points i added at every stage of the output blocks. The FTDI is an alternative interface to connect the boards on USB-UART to a cellphone over OTG. The control path signalling is implemented using the NRF24L01+ RF module.

Time to solder all them components and get 'em boards runnin' (strong southern accent :P)

Saturday, October 4, 2014

Wireless RGB Light Control (Adafruit BT + NeoPixels)

This is a massive upgrade to my earlier project that i posted a couple a days ago here. The interface using the RoundButtons from Coding4Fun toolkit looks much cleaner and aesthetic. More features like controlling the light intensity, single tap color change, turning off all the LEDs on the shield, reflection of a hardware reset in the phone UI etc. The paragraphs below briefly detail out the two main components.

The Roundbuttons - Created using the RoundButton class from coding4fun toolkit. These buttons have two event handlers registered in the code, one for Hold and other for a Click. Holding a button for a certain duration causes the color selector window to pop up. This window has a Hexagon color picker interface created using the same coding4fun toolkit. Touching and dragging your finger on this picker will update the selected RGB LED color in real-time. Once a color is selected it can be applied to one or more LEDs by clicking on them, this is handled by the Click event handler.

The ColorPicker - The hexagon color picker has a handler registered to it's Color Changed event. The color data received is framed in a transmission packet and sent over the BT interface to the Arduino board in this handler. Adjusting the slider below the color picker adjusts the brightness of the LEDs. The Turn Off button turns off all the LEDs on the shield and also clears the button background color on the UI.


All the round buttons used, follow the xaml template shown below. 40 buttons have been created using the same xaml statement. The only difference is the Name field which is unique for each button. The buttons are placed inside a Grid component therefore the (0, 0) grid position corresponds to the upper left LED near the Reset button on the RGB shield. the buttons have been named in a similar pattern. The button inside the     (0, 0) grid cell is named a_a, the button in cell (0, 1) as a_b, (1, 0) as b_a and so on. All buttons have the same Click and Hold event handler.

When the application is started it establishes a connetion with the Arduino BT shield, which exposes serial ports to the Arduino. (The shield uses the BT Serial Port Profile) The read / write operations on the arduino are done using the softwareserial library at 9600 baud. On the phone side, DataReader and  DataWriter objects are created to read from the Socket (StremSocket class). The socket connects using the ConnectAsync call in the StreamSocket class.

When a button is held for a specific amount of time the Hold Event occurs. This triggers the hold event handler and opens another window that displays the hexagon color picker. The hexagon color picker has a event handler attached to its ColorChanged event. When you touch the color picker and move your finger over it, the ColorChanged handler is continuously called. The OS passes the sender and the Color to the event handler. Inside the event handler, the serial packet to be transmitted to the arduino is built. It has the format as shown below. Hence if i click on button (2, 3) in the grid with full green color selected on the color picker then the packet will be


As the data is sent as a String the "_" is used as a separator. This command will be parsed on the Arduino. Since the X and Y co-ordinate positions in the command are fixed at offsets 0 and 2 respectively the value can be easily obtained by doing a (int)command[0] - 97. extracting the color values requires a little processing. This value can be then sent to the NeoPixel Library. The intensity adjustment follows a similar format with a smaller packet and a command identifier as 'I'. An alternative method would be to send the numerical values corresponding to the buttons directly. But i could not find any means to figure out which button inside the grid had been clicked without using the Name property....(duh)

When the arduino is reset all LEDs on the phone UI need to be turned off. This is accomplished by sending the string "RESET" from the Arduino to the phone. The phone maintains a journal in an custom LEDManager class about the LEDs that are currently active. When the reset command is received, using the DependencyObject with the grid as the parent and the VisualTreeHelper class, a list of all buttons in the parent is created, then iterating over the List, each button's background color is set the to the OFF color which is black. Similarly when the Turn Off button is clicked on the color picker interface it sends a "OFF" command to the Arduino, turning off all the LEDs and clearing the UI.

Most of the actions are demonstrated in the below video where you can see me messing around with the LEDs.

Some Usage scenarios
1. Arduino Powered Up, Windows phone BT turned ON, Application start
In this case the serial link is established between the phone and the arduino hardware and the data packets are exchanged normally between the two.

2. Arduino Powered Up, Windows Phone BT turned OFF, Application start
In this case the application will open a message box indicating the the phone bluetooth connection is turned off. The application UI will be disabled. Application will have to exit and be restarted once the phone BT is turned ON

3. Arduino OFF, Whindows phone BT turned ON, Applicatino start
- Undefined behavior. Application runs without crashing. Re-connect will not happen even when the board is powered up. The application needs to be restarted.

Future upgrades include hooking up the shield with Facebook API, group control of LEDs, Gesture controls, using sensor interfaces on the WP8 to manipulate LED colore etc. Now this is one hell of a way to learn Windows Phone Programming....

Bluetooth communication between Arduino and Windows 8.1
Windows Phone API Reference

Where is all the code ? Here is the code running on the Arduino. The Windows Phone code will make this post the longest ever. Therefore i leave it up to you to implement.

Sunday, September 28, 2014

Adafruit NeoPixels + Windows Phone 8

This is something that i wanted to do since a long time. Individual control of RGB LEDs on the Adafruit NeoPixel Shield over a bluetooth connection using my Lumia 920 running the Windows Phone 8, After extensively surfing MSDN help articles on WP8 APIs etc - Finally finished it this weekend.

Find the updated design, click here

In brief the design goes like this - An Adafruit NeoPixel shield containing 40 WS2812B 4-pin chip RGB LEDs in a 5 x 8 matrix pattern is mounted on an Adafruit Bluetooth Shield, the EZ Link which is stacked over an Arduino UNO. The code running in the Arduino reads the commands received on the serial bluetooth link, parses it and controls the RGB LEDs. The command packet sent from the Windows Phone consists of 5 fields - two fields for the X and Y co-ordinates of the LED and 3 fields for the R,G and B data obtained from the color picker.

The application on the windows phone is simply a grid of tiles created using the Coding4Fun WP toolkit. Each tile is identified uniquely by its name. Each tile can be set to a different color when clicked and has a one to one mapping with the LEDs on the adafruit shield. The color can be previewed in realtime. Some application statistics and setup are shown in below images. Once the code is well-organized i shall put it up here, and no, i did not write 40 event handlers for each of the tiles. There is only one event handler to rule them all :P

Once powered up the Arduino waits for a command on the BT Serial interface. When the application is started on the windows phone it establishes a connection with the BT module. On clicking any of the square tiles in the main application window another window opens up from where the color for that particular LED can be chosen. Alternatively all the LEDs can be turned off using the Turn Off button. The two wires in the pic below are the RX/TX pins from the BT shield connected to the Arduino over the SoftSerial interface...

P.S - The red color of the tiles is the default theme color on application startup. The LEDs do not get affected by this color unless programmed to

Here is an earlier experiment with a s ingle RGB LED breakout using Processing. The code for this can be found in the description of the video....

Monday, September 22, 2014

A Brainfuck Interpreter in C

Brainfuck is an esoteric programming language noted for its extreme minimalism. The language consists of only eight simple commands and an instruction pointer. It is designed to challenge and amuse programmers, and was not made to be suitable for practical use. It was created in 1993 by Urban Müller - Wikipedia

In short brainfuck has eight commands or instructions:

+ : Increments the value at the current cell by one.
- : Decrements the value at the current cell by one.
> : Moves the data pointer to the next cell (cell on the right).
< : Moves the data pointer to the previous cell (cell on the left).
. : Prints the ASCII value at the current cell (i.e. 65 = 'A').
, : Reads a single input character into the current cell.
[ : If the value at the current cell is zero, skips to the corresponding ] .
    Otherwise, move to the next instruction.
] : If the value at the current cell is zero, move to the next instruction.
    Otherwise, move backwards in the instructions to the corresponding [ . 

Here is a basic brainfuck interpreter in C that takes brainfuck code, works on it and produces the intended output. The implementation uses a recursive approach (why ? because brainfuck) and a stack for interpreting the brainfuck code. The examples include a multiplication code, addition of a series of numbers and some ASCII printing. The code is compiled and tested on  Visual C++ 2010 Express.There are several other ways to interpret brainfuck code, this is just one of those...

Next i will try to see the possiblity of implementing this on an FPGA. 

Wednesday, September 10, 2014

Stuff in Assembly - Bubble Sort !

An ARM assembly implementation of B-Sort. Why Bubble Sort ? because - "the bubble sort seems to have nothing to recommend it, except a catchy name and the fact that it leads to some interesting theoretical problems" - Donald Knuth

Created in RVDS 4.0. Output viewed in the memory window of the RV Debugger. Cortex-A8 v7 processor.

Saturday, August 30, 2014

Arduino + TFT LCD

I happened to find this 2.8 " TFT LCD on ebay here manufactured by a chinese company called ARMJISHU. The only way i came to know about this TFT was because of the fact that the manufacturers were generous enough to put their website url on the PCB silkscreen. If this detail would not have been there i would never have known what display driver chip it runs or what touchscreen driver it uses. If you head over to the ARMJISHU site it's all in chinese and i could not find this tft sold as a separate product. It was however sold as a part of their STM32 kit. It was in the CD for this kit (which was a whopping 1.2 GB download from the site) that i found the source code for all the peripherals used by the kit and in the tft example i found that the driver was a SSD1289 and a ADS7843 touch controller. 

Once you know the controller it is pretty easy to find the Arduino drivers for the same. I hooked up the tft to the Arduino MEGA and was able to run some sample code using the UTFT library. The touchscreen never worked with this library from elechouse. I am guessing it's damaged. I saw many posts on the internet about people not being able to use this TFT just because they could not find details about it. I hope this post serves as a reference, if they find this post ;)

 The connections for the ATMega 2560. The colored names are the pins on the TFT header. CS is actually named LCD_CS on the tft pcb. RD pin on the tft header has to be directly connected to 3.3V.

The output. Something does not seem right ? Can you guess the last number in the sequence ?

The hookup guide for the TFT using the Mega can be found in the UTFT pdf manual. The code i used is just the example available in the UTFT lib. One has to just uncomment the Arduino Mega API call and comment out the Uno one. The first parameter to the class variable declaration has to be set to the display model, in this case SSD1289.

While using the ADS7843 library from the link mentioned above you might get some errors in ads7843.h like:

ads7843.h:34: error: ISO C++ forbids declaration of 'Pio' with no type
ads7843.h:34: error: expected ';' before '*' token

In order to fix this, open the ads7843.h file and comment out the line as shown below (the second line too
is of no use hence comment that as well)

Next, open ads7843.cpp file and disable the code shown below from the class constructor

The compilation should now be successful...

Visible Light Communication Chronicles - Part IV - The Photodiode

In this post i will compare the new ambient light sensor that i got - the TEMD 6200FX01 by Vishay to the TEMT 6000 phototransistor [PT]. The TEMD6200FX01 is a PIN photodiode [PD]. More information can be found in its datasheet here. The circuit i hooked up with the PD is shown below.

The PD is reverse biased with a voltage of 3.3V and the output is taken across the 10K load resistor. Looking at the reverse voltage vs capacitance curve from the data sheet i approximated that the diode capacitance will be around  30 pF. The load resistor and the capacitance will determine the cut-off frequency and the time constant. Based on above values these turn out to be as shown below

Hence the cut-off frequency happens to be approximately around 530 KHz with this configuration of the PD.
The LED was modulated with different frequencies and the light was focused on both the PD and the PT. The below waveforms were observed on the scope. The orange trace is the PT output and the blue trace is the PD output. (In case of the PT the circuit is same as before and the output is obtained across a 10K resistor). It was pointless to go beyond 10KHz as the PT output faded away.

100 Hz square wave

1 KHz square wave

10 KHz square wave

The board i designed for mounting the TEMD 6200 0805 SMD so that i could breadboard the test circuit

In the next chronicle i will be hooking up the PD to a transimpedance amplifier...

Friday, August 29, 2014

Arduino + WizNet Ethernet Shield + Xively

I got this WizNet Ethernet Shield that i wanted to try out with the Arduino since the CC3000s proved to be a complete disaster. The shield appeared to be of chinese make and quiet different from the original Arduino Ethernet shield. I stacked my Sparkfun Weather shield on top of it as shown below only to find out that there was no provision to connect the I2C lines from the Arduino. SDA and SCL were not brought out onto the ethernet shield. Even the IOREF pin was not connected which was not helping the weather shield as the temperature and humidity sensor were interfaced using I2C and also needed the reference voltage. Looks like i have to tryout the original arduino ethernet shield sometime which has the I2C header present.Anyways i can only acquire the light sensor data using sparkfun shield using the existing setup.

 The code for the same is as below and what i had shown in an earlier post. The temperature and humidity settings have been zeroed out. The data is sent out to the Xively website.

Alternatively to test how effective the ethernet shield was i sent a value of 0 and 50 alternatively every 2 seconds to the Xively website. The code for that is shown below. Also shown below is the screenshot from the Xively site displaying the incoming data in the graph. Ideally the graph is supposed to be a continuous " saw waveform". The gaps that you can see are the connection to the xively site failing. It takes some amount of time to get back online. But it does recover unlike the CC3000 that goes into some infinite loop. So, apart from the fact that the I2C is messed up, i kinda like this shield. I hope the guys who made this shield add those I2C headers.... :)

Thursday, August 14, 2014

Visible Light Communications - Lumia 920 Windows Phone + Galaxy S5 Android

While i wait for the components to arrive i am trying some new stuff using the existing setup. Here is how i implemented a VLC data transmitter using the Windows Phone 8.0 - A Nokia Lumia 920....

--- A few eons later ---

Well this just did not turn out to be good. I tried to modulate the flash of the camera on both the Lumia 920 Windows phone and Android Galaxy S5 with similar results - It Does Not Work !! The maximum modulation frequency i got was around 33 Hz for both the devices. I believe achieving higher data rates using onboard timer mechanisms of the OS just does not work. If you are reading this and are an expert on Android or Windows Phone Operating systems, i would be glad if you could give this a try or even sugesst me how to achieve high resolution timers that operate without giving any distortion / timing errors if i use them to modulate the camera flash. The image below shows the application. Turn On / Turn Off just switch the flash ON/OFF using the torch mode. Timed button activates a timer based on the DispatchTimer class. The time duration is taken from the Textbox. Similarly the Pool Timer button activates a timer created using the ThreadPoolTimer class.

As an example here is the code from my windows phone program. P.S - This code was adapted from several examples i found on the internet and after doing a brief study on the WP8 How Tos. I do not major in WP8 programming ;) So if you spot something wierd please let me know...

Monday, July 21, 2014

Visible Light Communication - Updates

While i wait for my new sensors to arrive, here are a few updates that i have done to the existing circuits to get the maximum performance using the TEMT 6000, from the sensor point-of-view. With these upgrades i am able to transmit and receive signals upto 20KHz in frequency, distorted of course but not so distorted that they cannot be recovered. Due to certain limitations of the LM324N the output exhibits excessive slew but the signal gets reproduced.

Transmitter Modifications:

Using one of the papers published by Texas Instruments - Design and Application Guide for High Speed MOSFET Gate Drive Circuits i modified my circuit using the components available with me. The rise time at the mosfet drain when it was switched off was significantly improved. This however introduced some ringing at the drain (parasitic drain oscillations). Now this is wierd and could possibly be because of bad probes. Infact i am not using probes at all. The probes on the Digilent Analog Discovery are just regular connectors. The figure below shows the signal at the drain in orange. Ignore the blue signal it is the output of the op-amp at the receiver side. The blue signal needs to be shifted to the left to align it with the drain signal's off period. The other figure is that of the oscillations at the drain.

Receiver Modifications:

The original sparkfun breakout circuit for the phototransistor can be seen here. This utilizes a 10K resistor across which the signal output is obtained. I did an initial analysis for this which is shown in the figure below. As per the datasheet from Vishay, the collector to emitter capacitance is 16pF. At a light intensity of 100 lux the device outputs a current of 50uA when the supply is 5V. So, assuming these conditions and that if i want the output signal Vo to have atleast a 5V swing i.e. Vo = Vcc, the value of the load resistor needs to be computed. Using the datasheet values this evaluates to 100K as shown below. Alternatively this value along with the capacitance will give a time constant of around 1.6 microseconds thereby restricting the bandwidth of the device. I shall leave the bandwidth calculation to you.

THAT's 1.6 Micro Seconds up there !!

So, now if we apply the same to the default sparkfun board with load resistor of 10K we get a maximum output voltage of 500mV and a time constant of 0.16 1.6 microseconds. Hence both circuits have their pros and cons. After doing some more research on the switching times of phototransistor i came across one app note. This app note suggests several techniques to improve rise and fall times of phototransistor. As my circuit is taking output across the emitter which makes it a common collector configuration, this paper states that for a common collector configuration the miller capacitance is absent and it therefore has fast rise times and slow fall times as demonstrated in my earlier posts. The cascode topology was thus feasible option to implement in my circuit. For more information goto the paper. The modified circuit is shown below. Yes, i have an endless supply of BC547s and 557s :P

In this topology, the phototransistor does not see the load resistor R3, only the input resistance of the common base transistor Q3. The output of the sensor is shown below in orange and the output of the op-amp voltage follower is in blue. The transmitter is connected to a 20 KHz square wave signal source. The op-amps are LM324N in quad package.

The slewing in the output starts around  frequencies higher than 900 Hz. The same can be verified by a simple simulation.

Tuesday, July 8, 2014

Visible Light Communications

My experiments with Visible Light Communication can be found here. Most of the circuit components are selected according to their easy availability in my geographical area without spending too much on shipping (seriously a photodiode from Digikey is 1.5 USD + 60 USD shipping !!! ).

All of this can act as a reference for someone in designing a VLC system or atleast act as a guide on how to evaluate sensors etc. Of course sensors may vary but the workflow would somewhat remain the same...

Stage I
Stage One is all about figuring out if i have the right sensors for the job. A sensor with fast rise and fall times and a fast MOSFET based LED driver. Level: Basic

 Stage II

Visible Light Communication Chronicles Part III

Welcome to Part 3 of my experiments with visible light communication. In this post i will reveal the final circuit that i used for transmitting UART data over the link. Alternatively i also managed a successful Manchester encoded data transmission over the VLC link. The circuits for the transmitter and receiver are shown below. This is the most basic configuration and yields a maximum UART data transmission rate of 2400 Baud (with flicker) and transmission of Manchester encoded data stream at 1200 Baud (no flicker).

The transmitter above consists of a P55NF06 N-Channel MOSFET whose gate is driven by one of the Arduino pins. The data stream is directly connected to the gate. This causes variations in the drain to source current and varies the drain source voltage Vds and hence the intensity of the LED. This circuit just acts as a modulator. VDD is kept at 13 Volts and in the ON state the LED draws approximately 0.87 A. In the next iteration of this circuit i plan to buffer the gate input and also add a gate driver for a faster response. The code on the transmitter side is hown below. This is the Manchester encoded data stream using the Manchester library for Arduino that you can find here. The test code is pretty basic and just transmits a string of data. As a homework you've got to figure out other parts of the code yourself. No freebies !! Same goes for most circuits.

As mentioned in earlier posts the receiver consists of a TEMT 6000 ambient light sensor whose output is coupled through a capacitor into a LM324N based non-inverting comparator. The reference voltage to the comparator is selectable between 2.5V and 3.3V. This determines how accurately the signal is re-constructed. The output of the OP-AMP is then connected to an Arduino pin as input via a buffer. The various signals are shown below. The power rails of the LM324N quad are connected to 5V and GND.

The output of the TEMT 6000 is in orange. This signal is fed into the OP-AMP non-inverting input. Observe the non-linearity due to the fall time. This is the signal for a Manchester encoded data at 1200 baud. The signal in blue color is the output of the comparator. Based on the reference voltage set the timing of the manchester data stream is not affected and can be decoded easily.

In the above case i reduced the drain-source voltage Vds to around 8V thereby reducing the intensity of light. Observe the non-linearity in both the rise and fall-times of the TEMT 6000 sensor. However the comparator was successfully able to re-construct the signal. The code on the receiver side is shown below

The plots for UART data are shown below. The first plot is the UART data at 2400 Baud with Vds = 13V. The second plot is the same data at 2400 Baud but with Vds = 8V. Note the effects of LED brightness on the output of the sensor. The orange plot is the sensor output and the blue plot is the comparator output. The dark black horizontal line is Vref at 2.5V.

Complete loss of timing information in this one

This concludes the initial stages of experimentation for the visible light communication link that i want to build. The primary objective right now is to find a high speed sensor whose rise and fall times are in the nanosecond range. Less than or equal to 100 ns preferably. Once i get my hands on the new sensor i will post the details about it here. Until then, take it easy.....

Friday, July 4, 2014

Visible Light Communication Chronicles Part II

This is the continuation from Part I on my experiments with visible light communication that i posted sometime ago here. I set up a basic transmitter - receiver circuit, a square wave was given as an input to the transmitter and the output of the reciever was monitored. The transmitter consisted of a N-channel power MOSFET - P55NF06 driving a LED and the receiver consisted of the TEMT 6000 ambient light sensor. The square wave signal was generated using an Arduino MEGA and all the I/O signals were monitored using the Digilent Analog Discovery. Why i chose the above mentioned MOSFET ? because i already had it in stock and decided to use it. The light source is a commercially available 10 W high power LED which i got over here.


The overall circuit is shown below. The gate of the MOSFET is driven by one of the arduino pins. The sketch on the arduino is nothing but the blinky sketch. By adjusting the parameters to the delay function i could generate a square wave from 2 KHz (delay(1)) to 0.5 Hz (delay(1000). The gate resistors Rs and Rg were chosen such thar R1 << R2. From the datasheet, the P55NF06 N-channel mosfet has a drain-source voltage of 60V and a max drain current of 50A.The gate threshold voltage is around 2-4V. The LED forward voltage is around 7V. When turned ON the LED draws approximately 0.5 A which is within the spec of the MOSFET. The transmitter is assembled on a breadboard (yeah kind of not a good choice for a circuit like this, specially considering the mosfet parasitics, you never know...)


The receiver consists of the TEMT 6000 breakout board powered via a 3.3 V supply and it's output fed into the analog discovery. 

The distance between the RXR and TXR is 6 cm. I kept it small for initial measurements. All the signals seen on the scope of the analog discovery are shown below.

The above square wave has a time period of  2 seconds, 0.5 Hz. The blue signal is the input signal and the orange signal has been captured at the output of the ambient light sensor. Note that the rise time and fall time of both the signals appear to be instantaeneous. Also note that when the LED is OFF the TEMT sensor output does not drop to zero but goes to around 48 mV which as i mentioned in an earlier post is the interference from the fluorescent light in my room. The interference is visible in the above image when the input signal is 0V.

The input signal here is of 5 Hz. The output of the ambient light sensor follows the input given to the MOSFET. Note the ripple in the output when input goes to 0V.

In this case the input signal is of 50 Hz. Notice that the output signal starts exhibiting some non-linearity when the MOSFET turns OFF. The interference due to the fluorescent light starts getting negligible. More on this a scroll later.

In this case the input signal has a frequency of 500 Hz. If we continue to increase the frequency the signal at the output of the TEMT 6000 almost disappears and all we get is a DC voltage. with very faint signs of the input signal. After this initial test i decided to give the output of the UART to the TXR circuit and observe the output on the TEMT 6000. Here are the output response of the light sensor to different baud rates

300 Baud.

600 Baud. OFF time non-linearity starts kicking in.

2400 Baud.

4800 Baud. A still noticeable signal that can be recovered using some extra circuitry.

9600 Baud. Beyond 9600 you can only imagine what will happen to the signal at the sensor output.

To investigate on the TXR side. I used a 5V drain-source supply and switched the MOSFET using a 500 Hz gate signal. The following image shows the scope output. The output (orange) was taken at the drain hence the signal inversion. It can be seen that when the gate voltage drops to 0V, turning off the mosfet, the output voltage increases non-linearly with time.(based on the mosfet turn-off delay parameters). The delta is 46.7 usec. The datasheet says that the turn-off delay is around 30 nsec for the specified test conditions.

Allrighty that is a lot of information in this post. Part 3 of this series will elaborate on the analysis of the circuit, MOSFET parameters and the above plots.  Until then, take it easy...


I did one more test in which i plotted the TEMT6000 output over the drain-source voltage Vds.

The orange plot is the output of the light sensor and the blue plot is Vds, which is inverted as i connected the scope to the drain as shown in the schematic. The nonlinearity that i had seen before was therefore confirmed to be due to the TEMTP 6000 sensor. I did a couple of tests with varying input frequencies and found that in all cases the time it took for the sensor outout to go from maximum to 0V was 1.4 msec.which means that it can handle signals from 1 Hz to 714 Hz approximately. This was true as seen in the output plots above. Increasing the Vcc for the sensor to 5V does not help. Time to find a better sendor or fix the output of this one. I will probably have to make a new board and change the 10K resistor to a more feasible value.