0
\$\begingroup\$

I have a LG TV (32SL8000), which has a RS232 Control Port. I tried to control it with an Arduino and a TTL to Serial Converter (MAX3232). I looked up the commands from the manual.

Serial.begin(9600);
Serial.println("ka 0 01"); //Turns on TV
Serial.println("ka 0 00"); //Turns off TV

Turning on the TV works perfectly, but any other command doesn't work.

I don't know how to fix this problem.

Thanks for your help

The Manual

\$\endgroup\$
2
\$\begingroup\$

I have quite a bit of experience controlling LG displays serially, and while I haven't seen anything like what you report, I can make some observations and guesses that may help:

  1. My LG control code has probably been run against dozens of models by now, and I don't think I've ever run across one that behaved as you say. Then again, I don't think we've yet run across an SL model.

    (Only the two letters in the middle of the model code seem to matter when it comes to compatibility, plus an optional "C" at the end.)

  2. Most LGs accept only power-on commands while powered off, so that you cannot tell "powered off" from "caught fire, fell overboard, and presently at the bottom of the ocean being chewed on by something from an H.R. Giger film." These are the non-C displays, as a rule. "C" stands for "commercial," and this distinguishes models intended for use with automatic control systems.

    The "C" models will often at least accept "power status" commands while powered off, so you can probe it before you send any state-changing commands.

  3. After powering the display on, you have to wait out its 12-ish second warm-up time before you can send anything else. Some LGs will respond with the "OK" reply immediately on receipt of the command, thus leaving the wait time up to your program, while others won't give the "OK" until they're actually ready to accept another command. (The former are more common.)

  4. You aren't by chance plugging the Android board into the USB port for power, are you? If so, that may be enough to trigger this restriction, found on page 112 of the linked manual:

    "During USB operations such as Dvix or EMF, all commands except Power(ka) and Key(mc) are not executed and treated as NG."

You only give the two command strings you've succeded with. What command strings are you failing with, specifically?

Have you tried all the listed commands, or only failed with a few and gave up?

\$\endgroup\$
  • \$\begingroup\$ Great points. Regarding #4: I started to quote that exact line. I would guess this restriction is in place to prioritize USB operations over RS232 and prevent contention. So, as you point out, drawing power could be misconstrued by the TV as a controller. But since RS232 power on/off (ka) commands are permitted for execution irrespective of any Dvix or EMF device, powering the Arduino through the USB port shouldn't inhibit the OPs attempts to power off the TV. Could cause other command failures though - so still a valid point. \$\endgroup\$ – Blair Fonville Jul 29 '17 at 4:27
  • \$\begingroup\$ @BlairFonville: The quote is consistent with the report: he says only power on and power off commands are accepted, which are both ka commands. He probably didn't even try kc commands; thus my final paragraph. As to why LG did this, my long experience with them is that their firmware developers only have the vaguest notions about what their integrator community actually wants. I have yet to come across a really nice display control protocol, and I'll tell you that LG is far from the best of even that low-spec bunch. \$\endgroup\$ – Warren Young Jul 29 '17 at 5:39
  • \$\begingroup\$ actually he said powering the TV on works; not off. \$\endgroup\$ – Blair Fonville Jul 29 '17 at 5:41
  • \$\begingroup\$ @BlairFonville: I read "Turns off TV" in the comment as a success, and "all other commands" being all but those two. But you're right, it is ambiguous. My point #3 could explain a ka 0 0 failure. \$\endgroup\$ – Warren Young Jul 29 '17 at 5:43
  • \$\begingroup\$ Yes, it is a bit ambiguous. But it was clarified in a follow-up chat room. \$\endgroup\$ – Blair Fonville Jul 29 '17 at 5:45
2
\$\begingroup\$

First - The manual specifies a carriage-return following each command:

  • [Command 1] : First command to control the TV.

(j, k, m or x)

  • [Command 2] : Second command to control the TV.

  • [Set ID] : You can adjust the set ID to choose

desired monitor ID number in option

menu. Adjustment range is 1 ~ 99.

When selecting Set ID ‘0’, every connect- ed set is controlled.

Set ID is indicated as decimal (1~99) on

menu and as Hexa decimal (0x0~0x63)

on transmission/receiving protocol.

  • [DATA] : To transmit command data.

Transmit ‘FF’ data to read status of com- mand.

  • [Cr] : Carriage Return

ASCII code ‘0x0D’

  • [ ] : ASCII code ‘space (0x20)’

The Serial.println function ends the line with a carriage-return (0x0D) and a line-feed (0x0A). Try using Serial.print instead, and manually supply the line ends. The LF is garbage to the instrument, and is likely invalidating subsequent commands.

I would recommend using a computer and a serial terminal while debugging this. You want to make sure you understand the communications instruction set well, before trying to write your own program. If it were me, I would start with a computer and TeraTerm, or something similar.

Second - Is your cable crossover? Make sure your cable has the correct pinout for a crossover.

Third - Set ID 0 is a catch-all, but since you only have a single display connected to your serial port, it may be more logical to specifically target your ID. This way, query commands will be properly addressed. Go into your TV's Option menu and assign an ID (it probably defaults to 1, which would be fine).

Fourth - Since the Set ID field is a hex representation, it may be expecting a set field width of 2. Try sending 00 instead of 0 - or better yet (per the suggestion above), 01 or whatever your Set ID is.

Eg: Power On: ka 01 01[CR] and Power Off: ka 01 00[CR]

Fifth - Make sure to read the ACK replies to everything. For instance, if you send ka 01 01[CR], the TV will reply with a 01 OK01x on success.

To query the Power Status, you would send a read request, like so: ka 01 ff[CR], to which the TV should reply exactly as above a 01 OK01x to indicate that the TV with ID 01 is ON.


Code Listing



Power ON                    : ka 01 01[CR]
Power OFF                   : ka 01 00[CR]
Energy Saving - OFF         : jq 01 00[CR]
Energy Saving - Minimum     : jq 01 01[CR]
Energy Saving - Medium      : jq 01 02[CR]
Energy Saving - Maximum     : jq 01 03[CR]
Energy Saving - Auto        : jq 01 04[CR]
Energy Saving - Screen Off  : jq 01 05[CR] 
Input Select  - DTV Antenna : xb 01 00[CR]
Input Select  - DTV Cable   : xb 01 01[CR]
Input Select  - Analog Ant. : xb 01 10[CR]
Input Select  - AV or AV1   : xb 01 20[CR]
Input Select  - AV2         : xb 01 21[CR]
Input Select  - Component1  : xb 01 40[CR] 
Input Select  - Component2  : xb 01 41[CR]
Input Select  - RGB-PC      : xb 01 60[CR]
Input Select  - HDMI1       : xb 01 90[CR]
Input Select  - HDMI2       : xb 01 91[CR]
Input Select  - HDMI3       : xb 01 92[CR]
Input Select  - HDMI4       : xb 01 93[CR]
Aspect Ratio - 4:3          : kc 01 01[CR] 
Aspect Ratio - 16:9         : kc 01 02[CR]
Aspect Ratio - Zoom         : kc 01 04[CR]
Aspect Ratio - Set by Prog  : kc 01 06[CR]
Aspect Ratio - Just Scan    : kc 01 09[CR]
Aspect Ratio - Cinema Zoom1 : kc 01 10[CR]
Screen Mute - OFF           : kd 01 00[CR]
Screen Mute - ON            : kd 01 01[CR]
Video Out Mute on           : kd 01 10[CR]
Volume - Mute ON            : ke 01 00[CR]
Volume - Mute OFF           : ke 01 01[CR]
Volume - Relative UP        : mc 01 02[CR]
Volume - Relative DOWN      : mc 01 03[CR]
Volume Control [00-64 Hex]  : kf 01 00[CR]
Picture - Contrast  [Adjust 00 - 64 Hex]    : kg 01 00[CR]
Picture - Brightness [Adjust 00 - 64 Hex]   : kh 01 00[CR]
Picture - Color  [Adjust 00 - 64 Hex]       : ki 01 00[CR]
Picture - Contrast [Adjust 00 - 64 Hex]             : kk 01 00[CR]
Picture - Color Temperature  [Adjust 00 - 64 Hex]   : xu 01 00[CR]
OSD (On Screen Display) - OFF                       : kl 01 00[CR]
OSD (On Screen Display) - ON                        : kl 01 01[CR]
Remote Control Lock - OFF                           : km 01 01[CR]
Remote Control Lock - ON                            : km 01 00[CR]
Audio - Treble Adjust  [Adjust 00 - 64 Hex]         : kr 01 00[CR]
Audio - Bass Adjust  [Adjust 00 - 64 Hex]           : ks 01 00[CR]
Audio - Balance Adjust [Adjust 00 - 64 Hex]         : kt 01 00[CR]
\$\endgroup\$
  • \$\begingroup\$ I have already tried Serial.print("ka 0 00\r"); and Serial.print("ka 0 00\n");. Doesn't work either. \$\endgroup\$ – Apatus Jul 19 '17 at 15:23
  • \$\begingroup\$ @Chaos_ how much time are you allowing between commands? \$\endgroup\$ – Blair Fonville Jul 19 '17 at 15:26
  • \$\begingroup\$ For testing purposes I just have one command inside the void loop with a delay on 1s (delay(1000);) \$\endgroup\$ – Apatus Jul 19 '17 at 15:27
  • \$\begingroup\$ @Chaos_ are you reading back the Ack after each command? \$\endgroup\$ – Blair Fonville Jul 19 '17 at 15:28
  • \$\begingroup\$ How can I do that? \$\endgroup\$ – Apatus Jul 19 '17 at 15:29
0
\$\begingroup\$

According to the manual set the ID value for the monitor (default is 0), use the ID in the command string send to the TV.

Command Format

[Command1][Command2][ ][Set ID][ ][Data][Cr]

Each command is acknowledged so read that and make a confirmation weather the command is Ok or has error

the command you are using is not having CR character at the end try using as listed below

Serial.println("ka 0 01\r"); //Turns on TV
Serial.println("ka 0 00\r"); //Turns off TV

Note: try to capture the return data to verify the command is OK or having errors

\$\endgroup\$
  • \$\begingroup\$ Your code is wrong. And you're mistaken where you write "the command you are using is not having CR". In fact it does have a CR. To see why, read my answer where I addressed this point a while ago. \$\endgroup\$ – Blair Fonville Jul 29 '17 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.