Posts

Showing posts from April, 2014

LPC812 RC5 IR Remote Control Codec

Image
    Since LPC812MiniKit is application oriented, we will publish a series of applications available now.      LPC812 has an advanced peripheral SCT, which is suitable for timing related algorithm. NXP has offered comprehensive application notes and demo codes for SCT in LPC812.  Although SCT in LPC812 has only two state variables, its counterpart in LPC18XX/43XX has much more variables. It is still very handy for most simple timing applications, such as infrared remote control used in consumer electronics. You can donwload cookbook of LPC812 SCT from LPCware.com. There are serveral demo projects for Keil inside the zip file, which has rc5_send and rc5_receive. RC5 is widely used in many devices from Philips electronics, including TV, DVD, lighting and others. Philips has introduces RC6 standard to replace it, but RC5 is still popular. Labs on LPC812 Mini Kit The rc5_send and rc5_receive are straigh forward. You can test them on LPC812MiniKit easily. RC5_RECEIVE Lab Setup         You ca

Firmata for LPC812 is available now

Image
    pyFirmata and Firmata for LPC812 As mentioned in previous blog, I ported Firmata from Arduino to my LPC812MiniKit in order to instantiate MCU on board.  I used pyFirmata as the starting point for my demo testing code. And it can be used a baseline for future desktop applications in Windows/Linux/OSX.   In microcontroller side, Firmata for LPC812's footprint is 9KB ROM and 1KB RAM, including serial driver, ring buffer management, printf, system timers, SCT, PWM and firmata protocol parsers.   Quick testing for analog channels I have learnt a testing trick from Sparkfun, print analog bar in console. By this way, we can quick check analog channels such as PWM, ADC, DAC or sensor raw data. It works like a osilloscope, excepts vertial scanning.   SCT PWM library During my development, I found some problemes and bugs. Among them, SCT based PWM takes longer time than my expectation. I have to say, NXP's SCT is a great and flexible pheripheral. And they have offered related tutoria

Firmata, a legacy protocol demands more patches

Image
    During my development of Firmata for LPC812MiniKit, I found a serious issue.  The current Firmata protocol only supports up to 16 channels of PWM/ADC .    Cause Since Firmata originates from the legacy MIDI protocol. It heritates many things from last century (too old).  The MIDI devices have common features. For example, the musical keyboard has many keys and a few analog control, including volume, pitch. As a result, MIDI protocol defines up to 128 channels digital I/O and up to 16 channels analog I/O.  On the other hand, MIDI is kind of ASCII protocol. It reserved MSB as command, all 8bit value has to be split into two byte, one byte carries 7bit, the other carries 1 bit. That's stupid ever.   When Firmata was designed for Arduino, it follows MIDI. So we can believe the designer should have background of music. Here comes the bottleneck. Although in morden microcontrollers, analog channels are still limited against to digital pins.  Usually we can find 4/6/8 PWM/ADC on chip.

Python Firmata libraries

Image
    In order to abstract the hardware with Firmata, I must build up a test loop. First I will use a mature desktop firmata host application to test the firmware, then using the tested firmware to speed up the development for Android class libraries and APK. I am used to use Python to setup a rapid application to test the LPC812MiniKit. Simplest approach ever.   Firmata for Python   There are two Python libraies available for Firmata applications: pyduino: http://code.google.com/p/pyduino/  (depends on pySerial, protocol 2.0) pyFirmata: https://github.com/tino/pyFirmata (depends on pySerial, protocolv2.1 and Python3)   By manually inspecting the source code, I found pyduino is older than pyfirmata. pyduino's main file pyduino.py is only 10KB, the latest update timestamp is 2009. The coding style is quite close to mine, who has background of embedded systems like microcontroller firmware development.   On the other hand, pyFirmata is more complete and up to date, the latest update is