TFT LCD дисплей с резолюция 320x240 за
RASPBERRY PI
Проекта е взаимстван от следната публикация: SpritesMods.com
RASPBERRY PI е компютър с размерите на кредитна карта, чиято цена само е около 35Euro. Това го прави изключително достъпен за много широк кръг от хора.
Въпреки ниската си цена той е снабден със SoC BCM2835 на фирмата Broadcom, който съдържа в себе си доста мощен ARM1176JZFS процесор работещ на 700MHz, модул за операции с плаваща запетая, Videocore 4 графичен процесор способен да плейва видео с BluRay качество използвайки кодек h264 при 40MBit/s скорост на потока и богат набор от периферия. За съжаление обаче е нужен телевизор или монитор за извеждане на информацията.
Този проект показва как телевизора може да бъде заменен с TFT LCD дисплей с резолюция 320x240, която е достатъчна за представяне на текстова и дори и графична информация.
Подобни дисплеи са доста разпространени и евтини. Могат да се намерят в Ebay за около $20. Единственият им недостатък, е че се нуждаят от поне 21 входно изходни линии за комуникация. 16 бита за данни, SC, RS, RD, WR, RESET
В проекта този им недостатък е избегнат, като вместо паралелен трансфер на данни се използва SPI шина. По този начин са нужни само 3 линии за комуникация.
Като недостатък може да се посочи, че при използване на серийна комуникация се постига доста малък брой кадри в секунда. Но това не пречи дисплея да може да се използва за показване на не много динамична информация.
В допълнение към дисплея има и touch panel който може да замени мишката и дори клавиатурата нужни за въвеждане на информация. За комуникация с него са нужни още 3 линии.
Първата стъпка е изграждането на преобразувател от серийни (SPI) към паралелни данни, чиято принципна схема е:
Малко обяснение за това как работи схемата:
Серийните данни постъпват през SPI_MOSI по предният фронт на SPI_SCLK в каскадно свързаните преместващи регистри CD4094. Когато е разрешен чрез SPI_CS0 брояча CD4040 брои до 32 като след 16-я клок изхода Q5 отива в състояние 1. В това състояние всяка промяна във вътрешното състояние на преместващите регистри се отразява и на паралелните им изходи. След 32-я клок състоянието на Q5 преминава в 0 и в този момент вътрешното състояние на преместващия тегистър се "застопорява" към паралелните му изходи. В същият този момент се разрешава въвеждането на данните в LCD-то чрез неговия CS вход.
По този начин при изпращане на 4 байта към SPI шината се трансферират 16 бита данни и управляващите сигнали (CS, DC, RD, WR, BL_CNT) към LCD дисплея. Използвайки тази схема се повишава скоростта на трансфер на блокове от данни каквито са променените страници от фрейм буфера защото не е нужно селектиране на SPI шината(доста бавен процес) за всяка изпращана дума към LCD-то.
Следващата стъпка е да се напише драйвер за гореописания конвертор. Или да се използва вече готов такъв, който можете да намерите тук и просто да копирате всичко на SD картата на Raspberry-то
Ако искате да следвате дългият път можете да следвате следващите инструкции:
1. Следват се инструкците описани тук, като преди компилирането се прилага следният пач ssd1289-linux.3.6.11.diff върху сорсовете с командата "patch -p1 -i ssd1289-linux.3.6.11.diff" изпълнена от директорията ~/linux
2. Във файла /etc/modprobe.d/raspi-blacklist.conf се коментира реда blacklist spi-bcm2708
3. Във файла /etc/modules се добавя ред със съдържание ssd1289
4. След рестарт модула ssd1289 би трябвало да се е заредил успешно. Това може да се провери с командата "lsmod | grep ssd1289"
5. Най-лесно работоспособността на LCD дисплея може да се провери като конзолният изход се пренасочи към новият фреймбуфер с командата "con2fbmap 1 1" или стартирайки X на новият фреймбуфер с командата "FRAMEBUFFER=/dev/fb1 startx"
6. Ако искаме това пренасочване да стане още при зареждане на системата трябва да променим съдържанието на файла /boot/cmdline.txt на следното: "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:1 fbcon=font:ProFont6x11"
Коментари:
hi, ebay sale this Touch TFT LCD Display Module with SPI Interface. I think this is really nice, but I want to know, can I use the driver with this LCD??
thanks
Hi Valdodov,
I have followed the schematic and every thing seems to be in order. However, CE0 is always high, which resets the Binary counter. Is that supposed to be the case ?
Hi joe and Alan,
Q5 goes LOW (this activates LCD's CS) after 16 clocks and stays in this state for next 16 clocks. After 32th clock everything latches to the LCD.
if like Joe mentioned here. You said 16 clock cycles of the SPI. How can it be possible for the 3rd shift register have anything in it ?
I am just curious . Thank you
I congratulate you on the project. However, i want to clarify. isnt Q5 in the ripple counter every 32 not 16?
Hi Valdodov,
I am trying to get this LCD to setup with my raspberry pi, but I don't have any experience in either how the Pi environment works or where I need to go to change those files.
Is it possible to do if I have raspbian installed on my Pi? If so, is it possible for you to walk me through at least maybe through the beginning process of setting up the config and kernel files?
I would really appreciate it if you could help me out.
Thanks,
Kush
Hi , I have ITDB02-3.2S LCD with SSD1289 Controller , can I used your driver? thanx
hey ,first of all thank you for the tutorial ,most informative.
i have a problem though ,i have a 2.8" 18-bit color TFT LCD with touchscreen breakout board with a ILI9325 controller from adafruit ,here is the link for it :http://www.adafruit.com/products/335
here is two photo of the display's pins :
dfrom what i've come to understand is that this display needs 8 pins wired for the data input output,4 for the touch screen,4 for the control inputs,backlight and power ofcourse
but i still can't get it to work ,how to wire the data and control pins to a raspberry pi model B ,do i have to wire them to gpios of my choice,and when loading the fbtft module assign them one by one ? and if so what module should i use.
ps:i've tried this and didn't work
can any one please help with this ,its really important
thanks in advance
Hi hikmet,
The answer is - nowhere.
You can't read from the LCD. You can only write to it.
Hi Valdodov,
Where do we connect the RD pin from 74HC4094
Hi Ramses Leon,
the easiest way is first to apply the patch and then modify drivers/video/ssd1289.c file. After that you can compile the kernel.
The PEN_DOWN_STATE_PIN is defined in arch/arm/mach-bcm2708/bcm2708.c file you could change it to:
#define PEN_DOWN_STATE_PIN 11
Hi Efel Nava,
the linux touch screen driver ads7846 supports both ads7846 and ads7843 chips.
The only thing you have to do is to specify correct chip in struct ads7846_platform_data
static struct ads7846_platform_data ads_info = {
.model = 7843,
..........
}
This structure is placed in arch/arm/mach-bcm2708/bcm2708.c file. If you appply my patch you will find it.
Hi,
I want to try the same with a 16-bit ILI9320 controller and a TSC2046 TP controller (it suppose to be the upgrade version of the ADS7846).
I have some questions,and I hope you could answer.
I'm new in the driver development so I do not know if I can just modify the .diff you provide with the registers and init sequence of the ILI9320 and later compile using your instructions.
Also how do you define that the PEN_DOWN_STATE_PIN is in the GPIO #11 (like in your diagram) instead of the #17 in the .diff
Thanks in advance
Greetings,
First of all I want to congratulate your great job and thank you for sharing your knowledge. I'm currently trying to do the same. I was able to connect a ILI9325 2.4" but I has no idea of how to apply the touch panel driver. As I can see, you have touch screen support, but I have two questions, the driver is for the ADS7846, does your TFT board is built-in that driver? I have a ADS7843 and according to the datasheet is compatible with ADS7846 only if the VREF is modified. Can you give me any suggestion or advise to enable the touch panel?
Thanks in advance
Hi Adam,
I have used +3.3V directly from Raspi.
The reason you have use 3.3V with 74hc4094 is because Raspi's and LCD inputs are not 5V tolerant.
Hi Valdodov,
did you get all 3,3V from the raspberry? I have a Display with just 3,3V Input and I read that raspis 3,3V can only give 50mA so I better create the 3,3V from the 5V, or? Is there a special reason why to use the Shift things with 3,3V? All 74HC4094 I find can be driven from 2 to 6V.
Great work!
Adam
Hi I have a 5.0 " TFT LCD touch panel ssd1963 rev 4.3, can I use your board to connect the LCD to my raspberry?
How much does it cost?
Hi lerppu,
if you want to build the PCB by your self, then do it.
First learn to use Schematic editor then PCB editor.
I can recommend you KiCad. It is free.
Good luck
Hi Carlos,
it is possibe.
You should edit arch/arm/mach-bcm2708/bcm2708.c file the part is:
{
.modalias = "spi-ssd1289",
.max_speed_hz = 32000000, // it can be .max_speed_hz = 4000000, which is 4MHz
.bus_num = 0,
.chip_select = 0,
.mode = SPI_MODE_2,
}
It is possible to decrease the spi bus speed for test circuit with HCF4094 ?
if it is possible, can you tell me how to do?
Thanks!
Hi,
Is there any chance you could share the pcb design, i have hard time routing the design i made of your schematic (i'm complete beginner) but would want to build it myself.
Hi Stefan Stoichev,
If you want I can sell you ready for use PCB. If you want LCD too you have to wait about a month for delivery.
Hi Vlado,
do you have plans to sell pre-made, ready to connect modules?
Thanks!
Stefan
Hi Theodore Flokos,
please write me to the e-mail: valdodov@gmail.com
Hello I wanted to ask you how much this board costs ready to use ? and if not ready to use at least with surface mount components soldered
and provided the other compoenents too ?
Hi Patrick,
they should work perfetly.
Hi. I've been following your work with these screens, and I'm inspired to try this project myself. I currently have six screens (linked below) laying around and I'd love to be able to connect one to a raspberry pi. They are slightly different than the screen you are using, but they have the same lcd controller. Do you think it could work?
"http://www.ebay.com/itm/261053931637?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649"
Thanks,
Patrick
Hello Valentin,
Great work figuring this out! Would you be so kind as to contact me regarding an order? I don't see any way of contacting you.
reinierweerts (at) gmail.com
Thank you in advance,
Reinier
hello,
I am very interested in buying one of your pcb.
How do I??
Greetings.
DVDint@ymail.com
Hi Zaini Hafid,
i can't understand your question
Hi André Moreira,
it is not possible to use I2C instead SPI bus because it is very slow
is any setting again in rapsberry when I buy LCD module + SPI to parallel converter??? I really need this module
How difficult is to use i2c instead of SPI? I have some i2c port expander that supposedly can do the same thing of c4094.
Hi ,
i'm interested by making what you've done.
i have a question : is it possible to do the same adaptation with a 7" tft display touchscreen sold for arduino mega or due?
thanks
picture attached
Hi Mickey,
As I wrote before the price for PCB only is 15EURO. On this PCB you can mount SPI to paralel converter, IO expander, Real time clock and DS2482 I2C to one wire converter.
If you want all of them soldered to the PCB we can discuss the price.
Hi again,
what is the price and how do I pay. Do you have pictures?
Thks
Mickey
Hi Mickey,
you are correct for the PCB.
If you want I can sell one to you.
Hi Valdodov,
you gave a price below for the serial to parrallel convertor- do you sell a pcb?
Thks
Mickey
Hello Valvodov,
I am looking for a LCD with touchscreen solution to connect to the Raspberry PI ....resolution around 320x240 or even higher but on a 4,3 inch or 5 inch screen.
DO you have a solution and how much could it cost ?
Best regards,
Araico
Hi Gregor,
Please read the text, and not just watch the video.
Hi jose,
The price of LCD module + SPI to parallel converter is 30EURO.
The price of SPI to parallel converter only is 15EURO.
If you want express delivery you have to pay its price.
hi valdodov.
i have a 3.2 TFT LCD from SainSmart http://www.sainsmart.com/sainsmart-3-2-tft-lcd-display-touch-panel-pcb-adapter-sd-slot-for-arduino-2560.html which I'ld like to connect to my Raspberry Pi.
In your video I only see a standard GPIO Cable plugged into the Pi (with 26pins). The 3.2 TFT has 40 Pins so I must use Jumper wires instead of that cable.
Or do you use any adapter kit/board between Raspberry and the TFT?
Thanks in advance,
greetz Gregor
I want to buy one of those screens ready to use
jruizdecastilla@hotmail.com
regards
jose
Hi Jan Pacák,
1. Yes you can run SPI on 16MHz.
2. Yes you should connect RS with DC
3. For back light - you can connect LED-A to +5V through current limiting resistor.
4. You should use pin 3 of SN74HC4040N for Strobe/LCD_CS as it is shown on the circuit above.
Hello, thank oyu for this project.
I tried to follow, but I'm not successfull. I carefully conected everything on breadboard.
a) Am I capable to run 16MHz on breadboard? I have no osciloscope, so I'm quite blind. I think I have to practice a bit of soldering...
b) I have little bit different display,i have same pinout as described here: http://www.elecfreaks.com/wiki/index.php?title=3.2%22_TFT_LCD_Screen_Module
The biggest differencies are
b1) PIN4 RS - this should be connected to DC?
b2) BL_CNT - there is no souch a pin, in forum is written, that this should keep backlight on/off - i assume i shoould add mosfet to drive led-a pin by this.
C) I bought SN74HC4040N, the pin Q5 is on pin 2, should i connect this to pin 2?
THnak you for your naswers.
Jan
Hi Nick,
On first look it is possible.
Please give me a feedback if you succeed. It looks that this shift registers are faster at 3.3V than 4094.
Hi!
Can I use the 74HC595 8-Bit shift register to build the SPI to Parallel converter?
TY.
Hi flex,
it is strange. Did you connect LED directly to SPI_SC0 or in series with a resistor?
I don't understand this "all the four IC's are feeded with 3.3V. the 4094s and the 4040 on its VCC-pins to 3.3V AND to GND through the cap".
The capacitors should be connected in parallel to the IC's power supply.
That means +3.3V should be connected to pin 16 of the IC's and GND should be connected to pin 8 of IC's.
Hi P3T3,
you should read very carefully code in ssd1289.c file.
change this
static struct fb_var_screeninfo ssd1289_var __initdata = {
.xres = 320,
.yres = 240,
.xres_virtual = 320,
.yres_virtual = 240,
.width = 320,
.height = 240,
.bits_per_pixel = 16,
.red = {11, 5, 0},
.green = {5, 6, 0},
.blue = {0, 5, 0},
.activate = FB_ACTIVATE_NOW,
.vmode = FB_VMODE_NONINTERLACED,
};
I hope that it will solve your problem.
hi valdodov,
the LED goes to SPI_CS0 and GND. so far i got no correct output without this LED. this is pretty strange for me.
i also got blinking LEDs on every single data-line wich goes to the LCD (D0-D15)
all the four IC's are feeded with 3.3V. the 4094s and the 4040 on its VCC-pins to 3.3V AND to GND through the cap. the OE-pins of the 4094s to 3.3V as well.
i also tried to connect LCD's BL_CNT directly to +5V. no success.
i just mean the command starting with FRAMEBUFFER :) it's a variable, i know
Hi Valentin,
can you explain to me how to change size of framebuffer data blocks? Now they are 2048, but I need size in multiple of 240 (for example 3840 = 16*240). My device uses ILI9327 which is a bit specific with memory management. I have started wiring and coding with your circuit and patches and everything works except data transfers from framebuffer memory to LCD memory. My results are on Raspberry Forum
Thank you very much
Hi flex,
how exactly did you connect this LED?
What is the supply voltage of 4040 and 4094? It should be 3.3V.
P.S. There is no "FRAMEBUFFER" command. It is a shell variable. Before start X (startx) you should set this variable (FRAMEBUFFER=/dev/fb1)
hi valdodov,
thanks for your help. now my lcd has an output. but its a bit strange. sometimes the console works fine, but sometimes there is something like this:
the framebuffer command never has worked for me. only flashing colors.
i also had an LED on the strobe line from the 4040. i noticed that there is no output when i remove this led. something is not set up completely, i think.
do you know how to fix this?
Hello
did you consider to recieve data to Atmega 8 to put them pararel to lcd. Is it possible?
I see that there are enough ports to do taht. SPI is also avaliable...
Hi elhanan,
if you look carefully you will notice that CS goes somewhere. RD and RESET are not needed for proper operation of the LCD.
signals CS, RD and RESET in the schematics are Not connected anywhere. shuld thay be like that?
Reagrds!
Elhanan
Hi Mark,
Can you try to connect LCD's BL_CNT directly to +5V.
Hi Robert,
can you give me a link to your LCD datasheet?
Hi Valdov. Thank you for putting up the instructions for this.
I have managed to get video to display on my sainsmarts 3.2”, however there is a lot of flickering and the image doesn’t seem bright enough.
Video here;http://www.youtube.com/watch?v=QcjSrGYaI0M
Did you ever experience this before? Or have any advice?
My setup;
M74HC4040B1R
http://www.newark.com/jsp/search/productdetail.jsp?SKU=89K0902
74HC4094N
http://www.newark.com/jsp/search/productdetail.jsp?SKU=07WX3748
5v to TFT
3.3v to ICs
Reset through 10k resistor
the diode I am using is 1N4001. If I remove it, I get the same results.
Hi Valdodov!
After few hours of working i made circuit but i've got nothing on lcd. I made connection DC to RS ofocurse.Reset from LCD throw 10kOhm to VCC.
My display has a LE (latch enable) pin - i made connection to VCC. Like it was written in pdf.
After connecting lcd i have data on MOSI, CS0 and SCLK. But my SCLK looks on oscilloscope like packet data. I got some impulses than break. And than so on - impulses and break.
The problem is that there is no data on D0-D15... So i have data, clk and strobe and nothing on data (0-15) pins. Any idea?
Touch panel works - i see impulses on INT and MISO.
Hi valdodov, I mean an image (jpeg) of the actual data converter you made. I'm a bit new to this, so I'm curious what a finished result should look like.
Hi Mike Andersen,
what do you mean with "picture"?
Hi Robert,
Thanks for documenting all of this, valdodov, I'm looking forward to trying this myself. Could you please provide a picture of the SPI to parallel data converter? Thanks!
Hello
i found your descirption (it's really ok) but my display do not have BL_CNT and DC. What is that?
Reagrds!
Hi flex,
hi valdodov,
thanks a lot. that's helping me setting the driver up.
but i do have some questions in terms of the wiring to get the lcd working.
1. pin RESET from the third 4094 connects to pin 23 from LCD? according to the lcd data sheet, pin 23 is RESET. because in your wiring diagram RESET connects to nowhere. and pin 23 on the LCD is +5V with resistor. what is right?
2. same for RD from third 4094
3. SPI_SCLK, SPI_MOSI and SPI_CS0 are both connected to circuit AND LCD!?
4. TX and RX are for touch, right?
5. ground behind the diode ist provided or required? i think it's required.
6. and last one: do i use ground (pin 25 from raspberry) on LCD pin 2 and pin 26?
sorry for those stupid questions, i'm not so much familiar with electronics. but i try :)
thanks in advance!
flex
Hi flex,
there are 3 folders in the archive.
I hope that it will help you.
hi valdodov.
after copying the compiled files to root i can't get module ssd1289 loading at boot. it say's that it isn't found.
so i tried the long way. but while applying the patch there is another error. "can't find file to patch at input line 4"
i copied the patch to /home/pi/linux and used your command.
you can plz help?
Нов коментар