LG 42LB5D

From LinuxMCE
Jump to: navigation, search
Version Status Date Updated Updated By
710 Unknown N/A N/A
810 Unknown N/A N/A
1004 Unknown N/A N/A
1204 Unknown N/A N/A
1404 Unknown N/A N/A
Usage Information

Features

Basics

  • 42" (diagonal) widescreen LCD television
  • Good build quality on the whole, though some edges on the plastic casing were left "sharp" (I'm OCD about fit and finish)
  • Not that heavy for its size (one person can lift it, in or out of packing carton)

Special features and nice touches:

  • RS232 port at the back to allow external control (by LinuxMCE for example)
  • Power LED is red on standby, and switches to green when set is on (thank goodness, blue-LED fever is abating! :-)
  • Brightness can be instantly adjusted via two remote buttons -- the only thing better would be a photosensor that adjusts things automatically for ambient light (but that's what hacking is all about ;-)

Picture fidelity

  • Crisp picture when provided with full quality source (e.g. true HD)
  • Crisp picture with some ghosting when using the RGB-PC input with a standard (though longer than average) VGA video cable -- I will try to add a photo of the effect; the lowest-tech connections (S-Video, RF, and the like) for PC video are NOT recommended!
  • A touch blurry with low-end sources (S-Video, RF) like older game systems, but still a fairly good overall picture; I have yet to test other signal methods with my game systems (requires special cables I don't yet have).

Usability

  • The OSD UI and remote are excellent. Both the menus and the buttons are laid out sensibly, and the system incorporates a great idea for settings that are cyclic (most are): the first time you press a button (e.g. aspect ratio), it brings up an OSD reminder of the current setting; subsequent presses will cycle through the available options. It's simple, and effective at preventing accidental setting changes by a single inadvertent button press on the remote.

Resolutions:

  • 1024x768
  • 1280x768
  • 1360x768

Adding new template

Here is a description of adding a Template for LG LCD TV with serial connections for control. According to the manual the following models should work: LCD TV MODELS 37LB5D / 42LB5D / 47LB5D 52LB5D/ 32LB4D / 37LB4D / 42LB4D I have the 42LB5D, so I know that this one works.

Specify device data and parameters

On the LinuxMCE admin website go to: Advanced > Configuration > Device Templates

Select: Manufacturer 'LG', Device Category 'TVs/Plasmas/LCD's/Projectors' and press 'Add device template'

Description : XXLB4/5D
Implements DCE : yes
Command line : Generic_Serial_Device
Device Category  AV TVs/Plasmas/Projection... #77
Manufacturer LG

Also have added following parameters (You need to add them one by one under the header 'Device data'):

Device data
Current Data 	                                    Comments 	                    Default Value
#37 COM Port on PC(string) 	              The serial port 						
#76 COM Port ParityBit/Stop(string) 	      Parity/Stop bits (factory defaults) 	N81 		
#78 COM Port BaudRate(string)                Baud rate (factory default) 	        B9600 		
#157 Discrete Volume(bool) 	              Indicates if the volume on...             1 

Settings are factory defaults and shouldn't be changed (9600 baud rate, 8 bits, 1 stop bit). Make sure that the check box for Allowed to Modify is checked, so that you can change to the appropriate COM port later.

'Edit Ruby code' (on template page)

'Add/remove commands'

First, I clicked on 'Add/remove commands' and clicked on commands that are supported by device...

  • Ruby Internal Commands
  • Standard TV

'Add Ruby snippets to commands'

Edited corresponding Ruby snippets for each command. Basically those are just simple strings that get send on rs232 to take proper action on device according to received command from LinuxMCE... Use the extended editor for the multiline entries (otherwise ruby won't understand it and gives lot's of errors)

#193 Off
	log('Sending OFF Command') 
        <$"ka 01 00\r"$> 	
#192 On
	log('Sending ON Command') 
        <$"ka 01 01\r"$> 	
Inputs
#419 Antenna
		
#316 AV 1
	log('Switching Input to AV1') 
        <$"kb 01 02\r"$> 	
#317 AV 2
	log('Switching Input to AV2') 
        <$"kb 01 03\r"$> 	
#712 Component 1
	log('Switching Input to Component 1') 
        <$"kb 01 04\r"$> 	
#713 Component 2
	log('Switching Input to Component 2') 
        <$"kb 01 05\r"$> 	
#426 External 3
	log('Switching Input to HDMI 3') 
        <$"kb 01 09\r"$> 	
#361 HDMI
	log('Switching Input to HDMI 1') 
        <$"kb 01 07\r"$> 	
#767 HDMI 2
	log('Switching Input to HDMI 2') 
        <$"kb 01 08\r"$> 	
#376 Input 3
	log('Switching Input to HDMI 3') 
        <$"kb 01 09\r"$> 	
#154 RGB
	log('Switching Input to RGB/PC') 
        <$"kb 01 06\r"$> 	
#166 Tuner
	log('Switching Input to Analog Tuner') 
        <$"kb 01 01\r"$> 	
#873 Tuner - Digital
	log('Switching Input to Digital Tuner') 
        <$"kb 01 00\r"$> 	
Aspect Ratios
#879 16:9
	log('Switching Aspect Ratio to 16:9') 
        <$"kc 01 02\r"$> 	
#877 4:3
	log('Switching Aspect Ratio to 4:3') 
        <$"kc 01 01\r"$> 	
Disk Handle
#48 Eject Disk
		
DSP Modes
#116 DSP Mode
	log('Switching DSP Modes: Toggled Only') 
        <$"mc 01 52\r"$> 	
General
#190 Enter/Go
	log('Sending Enter/Go Command') 
        <$"mc 01 44\r"$> 	
Internal
#373 Private Method Listing
	def log(line)
          $log = File.open("/var/log/pluto/" + device_.devid_.to_s + "_Generic_Serial_Device.log", "a")
          $log.puts "(***):" + line.to_s
          $log.close
        end 	
#351 Process IDLE
		
#350 Process Incoming Data
	buff = ''
        loop do
          buff=conn_.Recv(30,200)
          if buff.empty?
            log('Nothing Received')
            break
          end
          log('Received: ' + Regexp.escape(buff.to_s))
          if buff.include?("OK")
            log(Regexp.escape(buff.to_s) + ': Command Processed Successfully')
          elsif buff.include?("NG")
            log(Regexp.escape(buff.to_s) +': Command Processed Unsuccessfully')
          end
        end 	
#355 Process Initialize
	for iRetry in 0...4
          print "Initializing unit\n"
          conn_.Send("ke 01 01\r") # Send UnMute Command
          buf = conn_.Recv(30,200) # Expected Return # ke 01 01\r\ne 00 OK01x\r\n
          if !buf.nil? && buf.include?("OK")
            print "Initialized ok\n"
            print "Setting volume to 30%\n"
            cmd_313(15)
            SetDeviceDataInDB( device_.devid_, 158, "15" )
            # 158 = DEVICEDATA_Volume_Level_CONST
            return
          end
          print "Failed to initialize. Wait 1 secs and try again\n"
          sleep(1)
        end
#DisableDevice( device_.devid_, true )
#print "The device would not respond. Disabling it.\n" 	
#384 Process Receive Command For Child
		
#356 Process Release
		
Misc
#548 Menu
	log('Sending Menu Command') 
        <$"mc 01 43\r"$> 	
#676 Video Mute
	log('Sending Video Mute Command') 
        <$"kd 01 00\r"$> 	
Numbers
#364 -/--/---
		
#204 0
	log('Sending 0 ') 
        <$"mc 01 10\r"$> 	
#205 1
	log('Sending 1 ') 
        <$"mc 01 11\r"$> 	
#206 2
	log('Sending 2 ') 
        <$"mc 01 12\r"$> 	
#207 3
	log('Sending 3 ') 
        <$"mc 01 13\r"$> 	
#208 4
	log('Sending 4 ') 
        <$"mc 01 14\r"$> 	
#209 5
	log('Sending 5 ') 
        <$"mc 01 15\r"$> 	
#210 6
	log('Sending 6 ') 
        <$"mc 01 16\r"$> 	
#211 7
	log('Sending 7 ') 
        <$"mc 01 17\r"$> 	
#212 8
	log('Sending 8 ') 
        <$"mc 01 18\r"$> 	
#213 9
	log('Sending 9 ') 
        <$"mc 01 19\r"$> 	
#363 Back / Clear Entry
	log('Sending Back/Clear Command ') 
        <$"mc 01 1A\r"$> 	
On-Screen Menu Navig
#240 Back / Prior Menu
	log('Sending Exit Command ') 
        <$"mc 01 5B\r"$> 	
#225 Display
		
#368 Help
		
#86 Menu (Show Menu)
	log('Sending Menu Command ') 
        <$"mc 01 43\r"$> 	
#201 Move Down
	log('Sending Move Down Command ') 
        <$"mc 01 41\r"$> 	
#202 Move Left
	log('Sending Move Left Command ') 
        <$"mc 01 07\r"$> 	
#203 Move Right
	log('Sending Move RighCommand ') 
        <$"mc 01 06\r"$> 	
#200 Move Up
	log('Sending Move Up Command ') 
        <$"mc 01 40\r"$> 	
Simple Control
#92 Pause
	log('Sending Pause Command ') 
        <$"mc 01 BA\r"$> 	
#139 Play
	log('Sending Play Command ') 
        <$"mc 01 B0\r"$> 	
#102 Record
	#log('Sending Record Command ') 
        #<$"mc 01 BD\r"$> 
#64 Skip Back - Channel/Track Lower
	log('Sending Channel Down Command ') 
        <$"mc 01 01\r"$> 	
#63 Skip Fwd - Channel/Track Greater
	log('Sending Channel Up Command ') 
        <$"mc 01 00\r"$> 	
#95 Stop
	log('Sending Stop Command ') 
        <$"mc 01 B1\r"$> 	
Sound & Volume
#97 Mute
	if @mute
          <$"ke 01 00\r"$>
        else
          <$"ke 01 01\r"$>
        end
        @mute=!@mute 	
#313 Set Volume
	@volume=level.to_i()
        ilevel = @volume.to_i
        log( 'setting volume to '+ ilevel.to_s)
        log('Sending the Following Command: kf 01 '+ilevel.to_s(16)+'\r')
        <$"kf 01 "+ilevel.to_s(16)+"\r"$>
        SetDeviceDataInDB( device_.devid_, 158, ilevel.to_s)
        # 158 = DEVICEDATA_Volume_Level_CONST # "volume and corresponding device data set\n" 	
#90 Vol Down
	log('lowering volume from ' + @volume.to_s)
        cmd_313(@volume-1) 	
#89 Vol Up
	log('Increasing volume from ' + @volume.to_s)
        cmd_313(@volume+1) 	
Speed Ctrl
#125 Scan Back/Rewind
	log('Sending Rewind Command ')
        <$"mc 01 8F\r"$> 	
#93 Scan Fwd/Fast Fwd
	log('Sending Fast Fwd Command ')
        <$"mc 01 8E\r"$> 	
#98 Slow Scan Back
		
#99 Slow Scan Forward
		
TV
#136 Previous Channel
	log('Sending Previous Channel Command ')
        <$"mc 01 B2\r"$> 	
	

Adding device

This is a simple process that you can now add via the LinuxMCE Admin Website at Wizard > A/V Equipment

Add device based on created template

Just search for the device template that you created and select it from the list

Specify COM port for it

Just tell LinuxMCE which com port to use.

Assing it to new room

Tell LinuxMCE which room to assign this device

Specifiy Audio pipe connections to inputs on receiver

Tell LinuxMCE how you have thing attached to the LG TV and how the LG TV is attached to the computer.

I have it attached via RGB port and I have my cable box attached to AV1 and my HDTV connected to Tuner-Digital input.

Making Plug&Play

This is not needed to use the TV, but I post as an option. Location: /usr/pluto/pnp

   vi /usr/pluto/pnp/20_LGLCD.sh

add the following and then make the file executable.


 #!/bin/bash
#Play and Play script for LG TV's Models Numbers:LGXXLB4/5D
#Set ID needs to be set to 01
#Serial feedback is very slow so it requires several seconds to get feedback
#Device Template Number:1905 on my local Machine.
#Serail Command for Power On ka 01 01 
#Serial Command for Power OFF ka 01 00
#Returns two different strings depending on whether or not the TV is On or Off, so we will try to turn it ON then resend the ON command as it returns proper string (ka 01 01\r\na 00 OK01x\r\n)
echo "LG TV Detection script queue $2"
/usr/pluto/bin/TestSerialPort -p $3 -P N81 -b 9600 -t "ka 01 01\r"
sleep 5s
/usr/pluto/bin/TestSerialPort -p $3 -P N81 -b 9600 -t "ka 01 01\r" -i 5 -s "OK01x\r"
if [[ "$?" -ne 0 ]]; then
echo "It's not a LG TV"
/usr/pluto/bin/MessageSend dcerouter -r 0 $1 1 806 224 $2 13 "$4" 44 0
else
echo "It is a LG TV"
/usr/pluto/bin/MessageSend dcerouter -r 0 $1 1 806 224 $2 13 "$4" 44 1905
fi

the plugin will run the script with 4 parameters: the device id of the plugin, the unique id for this event (the PK_PnpQueue), a path where the device is located (ip address for ethernet devices, serial port for rs232 devices, etc.), and the name of the pnp detection script.

The detection script should attempt to determine what device template is on the path using any appropriate means. If it finds a match, it should fire a message using the paramters it received, such as this:

/usr/pluto/bin/MessageSend dcerouter -r 0 $1 806 224 $2 13 "$4" 44 1905(this is the template id for the devicetemplate you created above)


=========================

== == Adapting these instructions for other LG rs232 TVs == ==


This seems to be a good template for LG TVs with serial ports. Some of the command need to be changed for later models <$xb 01 90\r$> instead of <$kb 01 07\r$> for inputing HDMI 1 for example, but generally a good guide for adapting it to your TV.

The major problem is undocumented above but is critical to making this work: You need to look up the device id number of your LG TV from the Wizard \ Devices \ AV Equipment in the upper left hand corner and replace the number "158" in all the scripts above with this number (for example, in my case 310). This allows the script to process successfully.

Otherwise it will cause a compile error in 7.10 in the "follow log" on the "advanced" link of the A/V device and will not allow your template to run. The compile error will state that it found a "kend" and was expecting "$end".

The code that breaks it is:


  1. 355 Process Initialize
  for iRetry in 0...4
         print "Initializing unit\n"
         conn_.Send("ke 01 01\r") # Send UnMute Command
         buf = conn_.Recv(30,200) # Expected Return # ke 01 01\r\ne 00 OK01x\r\n
         if !buf.nil? && buf.include?("OK")
           print "Initialized ok\n"
           print "Setting volume to 30%\n"
           cmd_313(15)
           SetDeviceDataInDB( device_.devid_, 158, "15" )
           # 158 = DEVICEDATA_Volume_Level_CONST
           return
         end
         print "Failed to initialize. Wait 1 secs and try again\n"
         sleep(1)
       end


which is also necessary for the volume set, volume up and volume down commands the way they are written. Carefully replacing "158" with the LG TV device ID number on your setup in the extended editor will make all these commands functional.

Please note that the description for the plug and play implementation discussed above has not been tested with this fix.