In this project, I’m making a Tablet PC with a Raspberry Pi with Raspbian and a LCD Touchscreen display. I bought a LCD Touchscreen from chalkboard electronics.
Before designing the tablet, I had to set up the touchscreen. The biggest problem that I had was the power output of Raspberry Pi’s USB was smaller than the power needed from the touchscreen. These are the steps that I went through.
- Change power source of the touchscreenAt first, I changed power source of the touchscreen, because I wanted my tablet to have one power source(battery). Therefore I have to use a battery for the Raspberry Pi, and power the touchscreen through Raspberry Pi’s USB. To change the power source, you can look up this link.
You need to de-solder and solder to change the power source of this Touchscreen. So if you don’t have soldering tool, then I recommend you to use different product. - Lower the brightness of the touchscreen
I said, Raspberry Pi’s USB output current is <500mA. And the Touchscreen’s default current is 1.2A. I can lower the consuming current of the touchscreen by decreasing brightness of touchscreen’s backlight. If you see their webpage, they provide method to decrease back-light brightness(link). But if you have problem with that method, there is another option. Actually, I had problem with using HIDAPI, which they recommended. So I used different method.Basically what they are doing is sending hex code to HID device. You can do same thing with Pyusb with python.
This is simple python script that I used.import usb.core import sys dev = usb.core.find(idVendor=0x04d8,idProduct=0xf724) # was it found? if dev is None: sys.exit("Device Not Found") #raise ValueError('Device not found') # set the active configuration. With no arguments, the first # configuration will be the active one dev.set_configuration() # get an endpoint instance cfg = dev.get_active_configuration() intf = cfg[(0,0)] out_ep = usb.util.find_descriptor( intf, # match the first OUT endpoint custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_OUT) in_ep = usb.util.find_descriptor( intf, # match the first OUT endpoint custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_IN) assert out_ep is not None assert in_ep is not None # write the data data = '\x00\x20\x0A ' #Report ID(0), Command, Backlight value out_ep.write(data) ret = in_ep.read(in_ep.wMaxPacketSize)
This code sets the brightness of backlight to 10. More detail protocol is in the webpage.
- Change setting of the Raspberry PiEven though you go through previous steps, you can’t use touchscreen. If you plug HDMI and USB cable and power the Raspberry Pi, nothing shows up in the display. Still, you can see the backlight is on. When you power the touchscreen at the booting time, it works fine.
I spent a lot of time to solve this issue. I couldn’t find out exact reason for this issue. But I guess Raspberry Pi’s USB turns on little late, so touchscreen can’t be turned on the booting time. As a result, Raspberry Pi can’t recognize the touchscreen.So I change HDIM configuration. You can change HDMI settings in ‘/boot/config.txt’. I added below options in the file.
hdmi_force_hotplug=1 #Use HDMI mode even if no HDMI monitor is detected hdmi_group=1 #Depends on the display's resolution hdmi_mode=39 #Depends on the display's resolution
This options forces the Raspberry Pi to use HDMI with specific resolution. If you don’t set the resolution(hdmi_group, hdmi_mode), then the display output breaks. More detail explanation of config.txt is in this link.
So finally I powered the touchscreen with the Raspberry Pi.
In the video, you can see that the screen is unstable. I think that is due to unstable USB power during booting.
i use touchscreen with usb power on the raspberry. I use a hub-usb 2 ports with alimentation. One port is take by the touchscreen and the second on the raspberry power. the usb management is on my usb raspberry. the hub-usb power is on my external battery 2,1A/5V 10000ma.
it’s work perfectly.
LikeLike
Yes. I think your method works fine, too. But I though it would be more simple without extra usb hub. But I’m actually thinking of using usb power hub, because brightness is too dark.
LikeLike
You can also put max_USB_current=1 in /boot/config.txt for extender USB power to 1,2A. I wait raspberry 3 for à best USB power
LikeLike
Yeah, I can change the USB max current setting. But, as I know, that current configuration is for 4 USB combined(https://www.raspberrypi.org/forums/viewtopic.php?f=46&t=102634). But, still I think I’ll try that setting and test for the brightness change.
And I have a question. Is their any saying that Raspberry Pi 3 will support higher USB power? If it is true, then I might wait for that.
LikeLike
I will say you when i have rpi3 i’m waiting delivery
LikeLike
Hello, raspberry pi 3 isn’t more power. I think it was 1,2a for all usb and ethernet without usb_max_current option. I tested the screen on my pi3 and 10 minutes after power screen power off and power on and power off etc…. Since my test my screen is broken 😦 .
LikeLike
Thanks for useful information. It is too bad that your screen is broken…
LikeLike
Tried to use the above program with my Raspberry PI and the when the line dev.set_configuration() is run python complains that the resource is busy. I do have the correct dev and the 10″ screen is plugged in and displaying the raspberry pi desktop just fine.
Any ideas what to try? Thanks Jerry
LikeLike