My newest project is to build a pocket sized, battery powered portable video projector that accepts a standard composite input. It all started when I received an old jvc (circa 1998) vhs camcorder with a tiny color lcd viewfinder. I took it apart and started hacking it. I quickly found the composite input to the display driver but was unable to get the screen to accept input without tethering it to the camera's main board (which told me that the camera was somehow initializing the driver board for the display). I powered the screen with 12V and 5V but nothing happened without connecting three specific wires to the mainboard. Time went by and I decided to pick up the project again recently. I once again noticed the group of three wires that seemed fishy so the first thing I though was SPI. I looked up all the data sheets and traced these three to the Mitsubishi M62353FP which is a 8 channel DAC and confirmed that they were three wire SPI thanks to the datasheet. The outputs led to some inputs for the display driver (Sony CXA1854AR) which controlled color, contrast, etc. I tried sniffing the data that was coming from the camera's mainboard with my PICKIT2's logic tool, but it didn't make much sense. Instead I measured the analog voltages on each of the DAC's outputs, calculated the binary values using a formula from the datasheet and wrote up a driver for my PIC which sends a four bit address (for each of the 8 outputs) followed by the 8 bit output value. I wired everything up, plugged it in and everything worked like a charm (well colors are a bit washed out but that can be fixed by adjusting the software a little). So now onto making the optics for the projector.
Here's a shot of the tiny LCD (Sony LCX005BK). Pretty low resolution but it was free so I wont complain.
Here is the backlight. High voltage and not so bright so it needs to go.
This is the other side of the backlight. Note the step up transformer and switching mosfet.
Finally here is where I am at right now. I am running it all off of a 12V wallwart, using a LM7805 linear regulator for the 5V line (when I go to make this battery powered I will use a lithium rechargeable battery and a TI step up converter module to get the 12V). My PIC is on the right (with a little development board I made to make things easier) with code to set display values. I plan on adding buttons to allow the user to change brightness, contrast, saturation, etc on the fly. On the left is the display driver. and I attached a 1W white led as a replacement for the original backlight.
Sorry about the blurry display shots, photographing a .5" lcd is a lot more difficult than it would seem.
Full set up with my ipod outputting video. More to come soon.
datasheets available below: CXA1854AR M62353FP
Update! Working on optical assembly and took some test photos of video projection.
Here's my test setup with the optical assembly and projection lens in the center.
Picture of projection (about 10" or so) onto a glossy white screen in my room with blinds shut but lots of light seeping in.
Had to drag the setup into my bathroom to get a completely dark background. Once again image is around 10". I noticed that I nicked the lcd's polarizing filter a bit and that there are some dead/stuck pixels in the screen which show up in the image. Oh well, I got all the parts for free and this is merely a proof of concept so I don't really care.
Update: Made tons of progress on this project. Demo video below and pictures and explanation to come.
My newest project has been implementing a software SPI routine so that my pic (which lacks hardware SPI) can communicate with a cheap nokia 84x48 graphical lcd (later I will show how I wired it up). I've written subroutines in assembly for setting x,y address of the lcd's ram as well as sending data or commands for initialization (8bit, but could be easily modified to work with 9bit color lcd protocols I've seen). I plan on using a look up table to store standard character hex data so that I can make things easier for myself in upcoming projects. I know that my code is pretty inefficient so I plan on fixing it a little later (but not bad for just reading the datasheet and a few hours of coding). I just have the mcu writing "Hello World!" and drawing a video game character sprite at the bottom (I converted the image by hand, but I could easily write a program to do that for me). This is just the beginning, I plan on using this, as well as everything else I've been working on in my projects to come. I plan on adding the ability to animate/scroll text and images and will update the site with the code once I get the chance. I also plan on describing the SPI protocol and lcd commands in detail. For now I will post the code to just write "Hello World" and draw a sprite.
Start BSF 03h,5 ;switch from bank 0 to 1
MOVLW b'00000000' ;Out RB to output
MOVWF 06h
MOVLW b'00000' ;Out RA to output
MOVWF 05h
BCF 03h,5 ;switch from bank 1 to 0
;RB0=sclk
;RB1=sda
;RB2=D_C
;RB3=Sce
;RB4=reset
;RB5=disp pwr
Begin
bsf 06h,3 ;disable serial
bsf 06h,5 ;power on display
nop
bcf 06h,4 ;reset
nop
bsf 06h,4 ;release from reset
; sel extended instruction set (h=1)
movlw b'00100001'
movwf 0Ch
call spi_command
; set Vop (Contrast)
movlw b'10111001'
movwf 0Ch
call spi_command
; sel normal instruction set (h=0)
movlw b'00100000'
movwf 0Ch
call spi_command
; display normal mode
movlw b'00001100'
movwf 0Ch
call spi_command
Here is my newest project I've been working on. I'll get more details up when I have the time. In the mean while enjoy the video.
Update: Sorry its been awhile since my last update. I've been busy with work and my other projects. The capacitive sensing input is really simple because everything is done in software. Here's my hand drawn schematic for the input stage generalized so that any mcu can be used (For some reason I haven't yet installed a schematic program on my netbook and I don't feel like booting up my other laptop).
It's amazing that all you really need is a single gpio and a resistor (the capacitance is provided by the traces on the breadboard). The ten megaohm resistor allows the discharge rate for the stray capacitance to be slowed down enough for the uC to measure. The uC just continually charges up this capacitance, puts the pin into high impedance by making it an input, and then counts until it measures the "capacitor" is discharged. This count can then be analyzed to determine if the pin has been pressed or not (the count increases if the button is pressed because your finger adds to the stray capacitance in parallel which increases the discharge time). That's pretty much all that's necessary other than some fancy algorithms for error proofing detection.
Update 2: I've finally gotten around to porting my capacitive touch sensing code to C. The code should work for most PICs and can be easily modified to change pin assignments and whatnot to work on any other chip you might need. Below you will find the function freqcapsense. All you need to do is call it and it will sense whether RA0 is being touch or not. I've included averaging multiple samples and an adjustable threshold in order to tweak the sensitivity and accuracy for any given setup. You can have it return a 1 or 0 for touch status or by commenting out the if else statement at the end and uncommenting the return current statement it will return the raw period value it is reading from the pin. Enjoy.
int freqcapsense(){ unsigned int avg; unsigned int current=0; unsigned int thresh=29;
I threw together this demo this morning after finding two snes controllers last night for $1.90 each at a thrift store.
Controller after I meticulously cleaned it.
Next I researched online a bit to find out how to read the button presses (this pdf helped: http://www.parallax.com/dl/docs/prod/prop/hydra-ch6all-v1.0.pdf). The controller uses a active low 16bit wide shift register (last 4bits are always high). Read the pdf for the specifics of pulsing the latch and clock. All that needs to be hooked up is +5v, gnd, Clock, Latch, and Data (the pinout can be found here: http://pinouts.ru/Game/snescontroller_pinout.shtml). I used solid core copper wire that was folded over once to thicken it enough to hold when inserted in the connector socket since I didn't have a proper connector.
Perfect for prototyping.
Next I wired up the breadboard. The first part was the power supply which consists of a AA battery and a max756 to step it up to the 5v needed by the controller, lcd, and pic.
Indicator led and switch to turn on the power.
Next I wired up the PIC16f84A with an external RC clock and icsp header.
Finally I wired the controller (to port A) and lcd (to port B) up and started coding.
The lcd printing button presses.
The code basically initializes the lcd and then continually polls the controller and when a certain button is pressed sends the character to the display. This way the display types the button presses and when you want to clear the screen you just press start or select.
For now I will post the code below (in assembly, and sorry about the formatting, it looked much nicer in mplab) and will upload a schematic and video of it in action when I get some time.
Note: The code provided below is not optimized and is rather messy. Remember that I am not responsible if you try and make this and it doesn't work or ends up blowing up. This was just meant as a proof of concept and a neat morning wake up exercise for me.
UPDATE:
Sorry its been awhile, I've been busy at school, but here is the schematic. Note that I left out the step up converter circuitry.
;Writes SNES key presses to HD44780 compatable LCD in 4bit mode
COUNT1 equ 08h ;delay constants
COUNT2 equ 09h
Start BSF 03h,5 ;switch from bank 0 to 1
MOVLW b'00000000' ;Out RB to output
MOVWF 06h
MOVLW b'11100' ;Out RA0,1 to output, RA2-4 to input
MOVWF 05h
BCF 03h,5 ;switch from bank 1 to 0
;RS = RB0, EN = RB1, D4-D7 = RB2-RB5
;CLK = RA0, Latch = RA1, Data = RA2
Begin
call LongDelay
call LongDelay
;initialize LCD
movlw b'00001010' ;Out EN high
call Out ;;;;
movlw b'00001000' ;Out to 4 bit operation (note: 1 nibble
operation)
call Out ;;;; ;Out EN low
movlw b'00001010' ;Out EN high
call Out ;;;;
movlw b'00001000' ;Function Out, 8 bit
call Out ;;;; ;Out EN low
movlw b'00100010' ;Out EN high
call Out ;;;;
movlw b'00100000' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Out EN high
call Out ;;;;
movlw b'00000000' ;Display ON, Cursor On, Cursor Blinking
call Out ;;;; ;Out EN low
movlw b'00111110' ;Out EN high
call Out ;;;;
movlw b'00111100' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Out EN high
call Out ;;;;
movlw b'00000000' ;Entry Mode, Increment cursor position, No
;--------------------------------------------
buttonB
movlw b'00010011' ;Out EN,RS high
call Out ;;;;
movlw b'00010001' ;B
call Out ;;;; ;Out EN low
movlw b'00001011' ;Out EN,RS high
call Out ;;;;
movlw b'00001001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonY
movlw b'00010111' ;Out EN,RS high
call Out ;;;;
movlw b'00010101' ;Y
call Out ;;;; ;Out EN low
movlw b'00100111' ;Out EN,RS high
call Out ;;;;
movlw b'00100101' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
Clear
movlw b'00000010' ;Out EN,RS high
call Out ;;;;
movlw b'00000000' ;Clear
call Out ;;;; ;Out EN low
movlw b'00000110' ;Out EN,RS high
call Out ;;;;
movlw b'00000100' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonUp
movlw b'00010111' ;Out EN,RS high
call Out ;;;;
movlw b'00010101' ;Up
call Out ;;;; ;Out EN low
movlw b'00010111' ;Out EN,RS high
call Out ;;;;
movlw b'00010101' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonDown
movlw b'00010011' ;Out EN,RS high
call Out ;;;;
movlw b'00010001' ;Down
call Out ;;;; ;Out EN low
movlw b'00010011' ;Out EN,RS high
call Out ;;;;
movlw b'00010001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonLeft
movlw b'00011111' ;Out EN,RS high
call Out ;;;;
movlw b'00011101' ;Left
call Out ;;;; ;Out EN low
movlw b'00111111' ;Out EN,RS high
call Out ;;;;
movlw b'00111101' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonRight
movlw b'00011111' ;Out EN,RS high
call Out ;;;;
movlw b'00011101' ;Right
call Out ;;;; ;Out EN low
movlw b'00111011' ;Out EN,RS high
call Out ;;;;
movlw b'00111001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonA
movlw b'00010011' ;Out EN,RS high
call Out ;;;;
movlw b'00010001' ;A
call Out ;;;; ;Out EN low
movlw b'00000111' ;Out EN,RS high
call Out ;;;;
movlw b'00000101' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonX
movlw b'00010111' ;Out EN,RS high
call Out ;;;;
movlw b'00010101' ;X
call Out ;;;; ;Out EN low
movlw b'00100011' ;Out EN,RS high
call Out ;;;;
movlw b'00100001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonL
movlw b'00010011' ;Out EN,RS high
call Out ;;;;
movlw b'00010001' ;L
call Out ;;;; ;Out EN low
movlw b'00110011' ;Out EN,RS high
call Out ;;;;
movlw b'00110001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return
buttonR
movlw b'00010111' ;Out EN,RS high
call Out ;;;;
movlw b'00010101' ;R
call Out ;;;; ;Out EN low
movlw b'00001011' ;Out EN,RS high
call Out ;;;;
movlw b'00001001' ;2nd nibble
call Out ;;;; ;Out EN low
movlw b'00000010' ;Clear outputs, EN high
movwf 06h
return