Thursday, February 3, 2011

MARG sensors + Bluetooth

MARG (Magnetic, Angular Rate, and Gravity) sensor array used for AHRS (Attitude and Heading Reference Systems).



Android OpenGL 3D display on Samsung Spica (i5700).


Sparkfun 9DOF sensor stick SEN-10389, later replaced by SEN-10321.

Using ATmega328P, operated at 3.3V supply and 8MHz crystal. At this speed, reading sensors' measurements and computing "AHRSupdate" take about 31ms to complete. Default compiler setting is used on WinAVR. With 25Hz sampling rate, this leaves mega328p extra 9ms to do other tasks. Bluetooth SPP (serial) communication is buffered and interrupt driven, so no processing time is wasted in reading and sending data to the android phone.



References:
(1) Sebastian Madgwick's Alternative AHRS (MARG) algorithm - Quaternion implementation of Mayhony's DCM filter incorporating magnetic distortion compensation.
(2) Fabio Varesano's FreeIMU. Also using Madgwick's implementation of the DCM filter on Arduino platform.
(3) Rotation convertions by Martin Baker. Very good discussion on quaternions and other 3D representation like Euler angles and transformation matrix.
(4) OpenGL Transformation Matrix by Song Ho Ahn
(5) Similar discusion on diydrones.com started by Harinath

Android project examples:
Android Bluetooth
Bluetooth Chat
Android OpenGL Projects
OpenGL ES tutorial
Android Bluetooth Oscilloscope

Special thanks to the generous guy who gave me these toys, Thank you very much!


Wednesday, January 19, 2011

Tuesday, December 14, 2010

N6610 LCD 3D Demo Part II

Instead of drawing only the edges of a polyhedron, this time we draw the faces and 'fill' it with corresponding colors. This demo now uses a dsPIC (16-bit and 40MIPS core) for "faster" and "smoother" graphics in the N6610/N6100 LCD (w/ pcf8833 controller). See "lcd6610.h" for the used pinouts.



There are several ways of "hidden surface removal". The easiest way, and most appropriate for drawing convex polyhedron is the use of Backface culling. "Backface" will determine whether a surface (e.g. triangular face) is need to be drawn or not.
/-----------------------------------------------------------------------------------/
Draw3D routine:


triangle color-fill routine:

(*another version of using dsPIC hardware multiplier/divider is included in the download)

detect whether a triangle is facing backward.


Complete MPLAB+C30 project (dsPIC33FJ16GS504):
n6610lcd_3D_demo_part2.zip


Wednesday, December 8, 2010

N6610 LCD 3D Demo

Nokia 6610/6100 LCD 3D projections demo using Microchip's PIC18F25J11. PIC18F25J11 is clocked at 12MHz external oscillator with 4xPLL enabled. It's operated at 3.3V supply, same with the LCD (and so, direct connections and higher spi clock rates are possible).

The demo is all about simple 3D projection - no rendering, no raycasting, etc., just the plotting of edges/lines. It displays common polyhedrons like tetrahedron, hexahedron(cube), octahedron, square pyramid, and triangular prism.

"3Ddemo.c"

*based on original sources:
Nokia 6100 LCD with CCS C
3D Vector objects in C using the PIC micro

Microchip C18 project:  n6610lcd_3D_demo.zip

Thursday, November 18, 2010

Nokia LCDs - Proteus VSM Models

Proteus VSM models for some Nokia LCDs


LCD controllers used:
PCF8833    - Nokia 6100/6610/6610i
S1D15G14 - Nokia 3530/3510i/3595
PCF8814    - Nokia 1100

Download: Nokia LCDs - Proteus VSM Models.zip
(MODELS + LIBRARY + some demos)
* just copy the files to their corresponding folder

//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------
UPDATES:
11-21-10
    - N6610LCD model (&symbol) was updated based on the datasheet of PCF8833 alone,
        but the result was different from expected. =(
        again, this model still have lots of problems!
    - found a bug on the N3530LCD model (PASET & CASET commands affected),
        corrected model will be uploaded soon.
    - I apologize for I cannot upload the source codes (msvc++ 2008) for these projects.
        ( Proteus ISIS itself is NOT free. VSM SDK, I assume, is also not open-source).
        ask for code snippets here: "Creating Proteus Models" ,instead.

Thursday, October 14, 2010

PIC18F USB LC Meter

Inductance and Capacitance Meter using Microchip's PIC18F2550 connected to USB using HID class (Plug-n-Play).

* f1, f2. and f3 are the frequencies defined by the equations stated on Digital LC Meter.



diagram using internal Analog Comparator and Timer Peripherals of PIC18:

schematic with actual values:
*simulation on Proteus 7 is NOT working (particularly the LC oscillator part and internal pull-up on RB0)

download link (HEX and PC app): PIC18F2550_USB-HID_LC-Meter.zip
elab.ph forum link:   PIC18F2550 USB LC Meter

 # edit (10-20-10)
added "Calibration option" ( same PIC18F firmware )
  • reference capacitance range is 1.0nF +/- 5%
  • Fosc (20MHz crystal with PLL) frequency range is 48MHz +/- 200ppm

# edit (08-14-11)
 V1.2 ->  updated host-side application,
          -> should now work both on 32-bit OS and 64-bit OS hosts.


Thursday, September 23, 2010

Android Bluetooth Oscilloscope


*This application is tested only with Samsung Galaxy GT-i5700 Spica (rooted Android 2.1 OS, i570EXXJD1 Baseband version).
The transmitter circuit uses Microchip's dsPIC33FJ16GS504 for the analog-to-digital conversion of the input signals on two channels. The processed data on the dsPIC are then transmitted to the phone (for waveform display) via the LMX9838 bluetooth SPP module.


specs/ranges:
  • time per division: {5us, 10us, 20us, 50us, 100us, 200us, 500us, 1ms, 2ms, 5ms, 10ms, 20ms, 50ms }
  • volt per division: {10mV, 20mV, 50mV, 100mV, 200mV, 500mV, 1V, 2V, GND}
  • analog input (depends on external pre-amplifier configuration): {-8V to +8V }


The source codes for the bluetooth communication is based on Bluetooth Chat example from http://developer.android.com. That example contains three java source files. And, I've completely copied the "DeviceListActivity.java", which is used for searching remote bluetooth devices. Then I've modified the "BluetoothChatService.java" to use only the RFCOMM Client functions, and used the well-known UUID "00001101-0000-1000-8000-00805F9B34FB" for the Bluetooth RFCOMM/SPP.
 
For the plotting of waveforms, I'm using SurfaceView object to draw on its canvas. This tutorial found on www.helloandroid.com helps me a lot for this task: "How to use canvas in your android".



The rest of the job mainly involves porting of my previous Python S60 script to JAVA language. It was too painful on my side, because I had to convert a single script file to multiple java + xml source files! Nonetheless, it was a good experience for me on learning the Android SDK (JAVA programming).

Project source codes for Android and dsPIC (with APK and HEX) :
AndroidBluetoothOscilloscope.zip

Electronicslab.ph forum link : Android Bluetooth Oscilloscope

Here are some interesting projects that are also based on the Bluetooth Chat example:
Bluetooth Controlled Model Car
SPRIME

Special thanks to:
Samdroid Forum  for the customized/rooted firmwares for our Spica.
Tipidcp Spica users for sharing their tips and experiences with this android phone.

----------------------------------------------------------------------
#edit (10-15-2010)
Here's now my circuit. Nothing special on it, all are based on existing circuits.

*The dsPIC I have used is most probably NOT the best choice for this project because of the many left unused peripherals (extra pins). But, this is the only part readily available in my bin and it has the fastest ADC (2 x 2MSps) among the chips I have.
*If you prefer to change the input range via the op-amp preamp, the computation is located on the "adc.xmcd" file.
*You can use other SPP bluetooth modules aside from LMX. (accdg to manufacturer, it's already obsolete)

----------------------------------------------------------------------
#edit (9-14-2011)

It's almost a year now, and yet some people are still interested in this project (considered to be obsolete). So I've decided to place the source repository also on Google Code site. You can either Browse or use git to have your own local copy:

   git clone https://code.google.com/p/android-bluetooth-oscilloscope/

See also the Changes, if you want also to learn on how to modify the code. I've started the first 'commit' with a simple "hello world" from the SDK project template. And then changes were made until the desired final oscilloscope application is achieved.