Showing posts with label Adafruit. Show all posts
Showing posts with label Adafruit. Show all posts

Friday, July 21, 2017

pcDuino and the Adafruit 5" LCD HDMI Display




After my inability to get the 7" LVDS display to work with the pcDuino I thought I would have a go with the 5" Adafruit display that I use with my Raspberry Pi. While not plug and play, it is significantly easier than the LVDS.

The Adafruit 5" 800x480 HDMI Backpack




This backpack features the TFP401 for decoding video, and for the touch version, an AR1100 USB resistive touch screen driver. Connecting the pcDuino to the screen is easy, just plug a HDMI cable into both.

You can power the display from a USB port on your pcDuino/Raspberry Pi but it is probably better to have a separate supply. Particularly for the pcDuino since it only has one USB port which you probably want to use for the keyboard and mouse.

With the default 5" 800x480 display and 50mA backlight current, the current draw is 500mA total. You can reduce that down to 370mA by running the backlight at half-brightness (25mA).

The gotcha with this display is that the TFP401 decoder chip does not contain a video scaler, it will not resize/shrink video! This means that you must feed it a resolution of 800x480 @ 60Hz or you wont see anything!

Forcing the resolution of LightDM


LightDM is the display manager running in Ubuntu. fortunately it is fairly straight forward to set the resolution used by LightDM. To find out the name of your display you can type xrandr into terminal. This indicated that my display was called LCD. Note you can't do this via SSH, you need to be on the pcDuino with the screen attached.

Next you need to find out the parameters for your screen so that we can add a new display mode. Type the following into a terminal screen.

$cvt 800 480
Then copy what comes after modeline. It should look something like: "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync. To create and add a new display mode you then type:

$xrandr --newmode "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync
xrandr --addmode LCD 800x480_60.00
You can then make sure that the new mode works:

$xrandr --output LCD --mode 800x480_60.00

With a bit of luck LightDM will now fill your LCD screen.

To ensure that this is done every time the pcDuino boots, you can add it to the profile bash script we attempted to use to load the touch driver in the last post.

ubuntu@ubuntu:~$ sudo nano /etc/profile
Add the following lines to the end of the file, save, exit and reboot.

# Set resolution for the Adafruit 5" Screen
xrandr --newmode "800x480_60.00"   29.50  800 824 896 992  480 483 493 500 -hsync +vsync
xrandr --addmode LCD 800x480_60.00
xrandr --output LCD --mode 800x480_60.00



Tuesday, January 10, 2017

Mission Package 2 - Voice Recognition for AVA (Part 1)

Overview


The next step in AVA's evolution is to add voice recognition. There are many different approaches but I have chosen a Raspberry Pi 2 as the hardware platform because I also want to use it as the master node when implementing ROS (Robot Operating System) down the track. I will then connect the various Arduino's that AVA uses as sub nodes. This will replace the dodgy serial messaging system that I am using to communicate between microprocessors at the moment.

Figure 1. Using Disk Utility to determine SD Card Reader BSD Number.


Install Raspbian on a SD Card


Note that these instructions are for installing Raspbian directly, if you are using NOOBS then replace steps 3-6 with extract the downloaded archive and copy across onto the SD Card. Done.
  1. Download a copy of Raspbian.
  2. For macOS users, place your microSD card in a USB Card Reader. Your microSD needs to be empty and formatted in FAT32. You can format and name your card using SD Card Formatter. Select overwrite format.
  3. We now need the BSD number of our SD Card Reader. The official RPi installation instructions suggests using "About this MAC" but that didn't work for me (I am running El Capitan). So the alternate method is to fire up Disk Utility (see Figure 1). From this we can see that the Device name is disk3s1 and thus the BSD number is disk3. You need Disk Utility for the next step, so you might as well use it to determine the BSD number
  4. Unmount the partition so that you will be allowed to overwrite the disk. To do this, go back to Disk Utility and select the partition and click unmount (top of the screen); do not eject it, or you will have to reconnect it. 
  5. Extract the img file from the file you downloaded in Step 1. This can be harder than it should be. If you have problems with the standard Mac unzip then use The Unarchiver.
  6. From Terminal, run the following command:
sudo dd bs=1m if=path_of_your_image.img of=/dev/diskn

Remember to replace n with the number that you noted before (i.e. 3 in our case). Also, you need to include the complete path of your Raspbian image file. An easy way to find a file’s exact location is to drag and drop the file into the Terminal window. As this is a sudo command you will need to enter your Mac password.


Figure 2. RaspberryPi and 5" Touchscreen.


Writing to the SD Card will take a few minutes and Terminal doesn't indicate progress. You can check the progress by sending a SIGINFO signal (press Ctrl+T). That’s it! You can now eject the microSD card and plug it into your Raspberry Pi.

Adafruit 5" Display



Figure 3. Adafruit 5" Display.

As shown in Figures 2 and 3, we are using the Adafruit 5" touchscreen display as our monitor. This next bit only applies if you happen to be using the same bit of kit.

The display is a mini panel-mountable HDMI monitor with a built-in touchscreen. This backpack features the TFP401 for decoding video, and includes the attached display.

The TFP401 is a DVI/HDMI decoder from TI. It can take unencrypted video and pipe out the raw 24-bit colour pixel data - HDCP not supported! The 5" display is 800x480 resolution, which is just enough to run most software, but still small enough that it can be used in portable or embedded projects without the bulk.

You can power the entire display from a USB port. With the default 5" 800x480 display and 50mA backlight current, the current draw is 500mA total. You can reduce that down to 370mA by running the backlight at half-brightness (25mA). With the backlight off, the decoder and display itself draws 250mA. If you want more backlight control, there's a PWM input, connect that to your microcontroller or other PWM output and you can continuously dim the backlight as desired.

The touch screen shows up as a USB mouse so no special drivers are needed. You can power the driver over USB as long as your computer can supply 500mA on the USB port, and then feed it video via the HDMI port.

Note the TFP401 decoder chip does not contain a video scaler, it will not resize/shrink video! I suspect this is what causes the Raspberry Pi some trouble.

The default installation of Raspbian (and other linux variants) doesn't work with this display. The NOOBS installer works for some reason but once you boot into Raspbian the same problem as a direct install occurs (i.e. wavy lines and unreadable text).

To fix this, you need to update the config.txt file. You will either need to plug in a different display to your Raspberry Pi or do it on your laptop and copy the file onto the SD card. You can download a copy of the required config.txt file from the Reefwing Gist repository.

If you look closely at Figure 2, you will see that we are using a Raspberry Pi 2 Model B V1.1. This should give us sufficient processing power, if not I'll move to a Raspberry Pi 3.

No Sound from the Speakers?


While you are playing around with the config.txt file, it is probably worth testing that your speakers are working. You can do this by typing on your Raspberry Pi (CLI):

speaker-test

You should hear pink-noise hiss from the speakers. If not then add the following line to your config.txt file and reboot.

dtparam=audio=on

To test volume levels, it helps to have human voices for the test. To hear a female voice say "front left" and "front right", from either speaker, you can use:

speaker-test -t wav -c 2

In part 2 we will download the actually voice recognition and test to speech software.