Click here to Skip to main content
Click here to Skip to main content

Tagged as

Hardware Controls for the Lilliput PC745

, 24 Apr 2010
Rate this:
Please Sign up or sign in to vote.
AV1/2, FM emission, Volume & Brightness control on the Lilliput PC745

Introduction

The Lilliput PC745 is a 7" touchscreen with integrated ARM processor and Windows CE 5.0. It was designed primarily for in car usage. The problem is that controls such as the FM emission AV1 and AV2 input selection, volume control, and screen brightness control are not documented anywhere else.

The following document will provide information on how to control these physical devices on your PC745.

pc745.jpg

Using the Code

Step 1

Download project zip file, extract it and Import the "LilliputPC745.vb" into your project. Each of the properties and functions has been summarized, with brief descriptions of what they are and how to use them.

The module has been configured to setup the COM2 (IRDA) serial port, so you don't have to worry about it. Just be sure to use "LilliputPC745.Open()" to start serial communication.

Step 2

When your program starts, you probably want to do the following when your form loads.

Private Sub Form1_Load(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles MyBase.Load
    ' add event handler to AV_Mode so that when the unit switches to or from AV
    ' the main program can be notified
    AddHandler LilliputPC745.AV_Mode, AddressOf AV_Mode
    ' Start serial communication
    LilliputPC745.Open()
End Sub 

Step 3

The Event Handler AV_Mode lets the following event occur in your form:

'The following function is called from an even in lilliputPC745.vb
Private Sub AV_Mode(ByVal AV As Boolean)
   If AV = True Then
       'AV is enabled
   Else
       ' AV is disabled
       ' Back to PC mode
   End If
End Sub  

This will run when the unit either enters AV1 or AV2 or when it returns to display. It will return "True" when in AV mode and "False" when in display mode.

Step 4

The rest of the functions are quite simple to:

  • switch to AV1, simply use "LilliputPC745.AV1()"
  • switch to AV2, make use of "LilliputPC745.AV2()"
  • adjust the brightness, use "LilliputPC745.Brightness ="
  • adjust the volume, use "LilliputPC745.Volume ="
  • adjust the FM emission frequency, use "LilliputPC745.FM_Mhz ="
  • enable the FM emission, use "LilliputPC745.FM_Open()"
  • disable the FM emission, use "LilliputPC745.FM_Close()"

Step 5

In order to exit the AV mode, and to adjust the AV setting, you need to input the touch screen coordinates so that the AV menu can appear and be controlled. First read the coordinates using "MousePosition.X" and "MousePosition.Y". Create a new Point, assign the mouse location to the point and make "LilliputPC745.Touch" equal to that point.

Private Sub Form1_MouseDown(ByVal sender As Object, _
	ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
   ' Send touch coordinates to unit for AV menu usage
   Dim Coordinate As Point
   Coordinate.X = MousePosition.X
   Coordinate.Y = MousePosition.Y
   LilliputPC745.Touch = Coordinate
End Sub 

Step 6

This step is quite important. Before closing your program, you must end the serial communication on COM2. The following code shows how you can do this, using the LilliputPC745.vb Module. If you close the program before closing the serial port, you will have problems restarting the serial port.

Private Sub Form1_Closing(ByVal sender As Object, _
	ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
   LilliputPC745.Close() 	' Close the port, or there will be 
			' problems re opening it
End Sub  

Source Code

Here is the source code for the LilliputPC745.vb Module:

Imports System
Imports System.IO.Ports

''' <summary>
''' Hardware communication module for the Lilliput PC745.
''' Created by Marco van der Merwe (22 April 2010)
''' </summary>
Module LilliputPC745
   Dim FM_On As Boolean = False ' This boolean is used to switch on the FM emission
   Public Event AV_Mode(ByVal AV As Boolean)
   WithEvents COM2 As New SerialPort("COM2", 9600, Parity.None, 8, StopBits.One)

   ''' <summary>
   ''' Open Communication session
   ''' </summary>
   Public Sub Open()
       If COM2.IsOpen = True Then ' check com port open
           COM2.Write(Gen_ChkDig("T46")) ' Hardware Startup command
       Else
           COM2.Open() ' open the serial port COM1
       End If
   End Sub

   ''' <summary>
   ''' Close Communication session
   ''' </summary>
   Public Sub Close()
       If COM2.IsOpen = True Then
           COM2.Close()
       End If
   End Sub


   Private Sub COM2_DataReceived(ByVal sender As Object, _
	ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
	Handles COM2.DataReceived
       ' Check the input commands, if the AV is on or off
       Dim str1 As String = COM2.ReadExisting()
       If str1 = "V426" Then 'AV Opened
           RaiseEvent AV_Mode(True)
       End If
       If str1 = "V415" Then 'AV Closed
           RaiseEvent AV_Mode(False)
       End If
   End Sub

   ''' <summary>
   ''' Adjust Screen Brightness, 
   ''' Range: 0 ~ 100
   ''' </summary>
   Public WriteOnly Property Brightness() As Integer
       Set(ByVal value As Integer)
           If (value < 100) And (value > 0) Then 	' Check if input brightness 
						' with in range
               ' Format brightness string and generate check digit
               If COM2.IsOpen = True Then 'check com port is open
                   COM2.Write(Gen_ChkDig(value.ToString("T71000")))
               End If
           End If
       End Set
   End Property

   ''' <summary>
   ''' Adjust Speaker Volume, 
   ''' Range: 0 ~ 100
   ''' </summary>
   Public WriteOnly Property Volume() As Integer
       Set(ByVal value As Integer)
           If (value < 100) And (value > 0) Then  	' Check if input volume 
						' with in range
               ' Format volume string and generate check digit
               If COM2.IsOpen = True Then ' check com port is open
                   COM2.Write(Gen_ChkDig(value.ToString("T72000")))
               End If
           End If
       End Set
   End Property

   ''' <summary>
   ''' Enable FM Emission
   ''' </summary>
   Public Sub FM_Open()
       FM_On = True
   End Sub

   ''' <summary>
   ''' Disable FM Emission
   ''' </summary>
   Public Sub FM_Close()
       FM_On = False
   End Sub

   ''' <summary>
   ''' Adjust FM Emission Frequency, 
   ''' Range: 77.0 ~ 108.9
   ''' </summary>
   Public WriteOnly Property FM_Mhz() As Double
       Set(ByVal value As Double)
           If (value <= 108.9) And (value >= 77.0) Then 	' Check if input freq 
							' with in range
               If COM2.IsOpen = True Then ' check com port is open
                   If FM_On = True Then ' check if FM emission enabled
                       COM2.Write(Gen_ChkDig(value.ToString("T95000.01")))
                   Else
                       COM2.Write(Gen_ChkDig(value.ToString("T95000.00")))
                   End If
               End If
           End If
       End Set
   End Property

   ''' <summary>
   ''' Switch to AV1
   ''' </summary>
   Public Sub AV1()
       If COM2.IsOpen = True Then ' check if com port open
           COM2.Write(Gen_ChkDig(Gen_ChkDig("T531")))
       End If
   End Sub

   ''' <summary>
   ''' Switch to AV2
   ''' </summary>
   Public Sub AV2()
       If COM2.IsOpen = True Then ' check if com port open
           COM2.Write(Gen_ChkDig(Gen_ChkDig("T532")))
       End If
   End Sub

   ''' <summary>
   ''' Sent touch coordinates to AV switch for AV menu usage
   ''' Range: X=0~800, Y=0~480
   ''' </summary>
   Public WriteOnly Property Touch() As Point
       Set(ByVal Touch As Point)
           Dim str_X As String ' used to format X coordinate
           Dim str_Y As String ' used to format Y coordinate
           ' Make sure that the input coordinates are within range
           If (Touch.X >= 0) And (Touch.X <= 800) And (Touch.Y >= 0) _
			And (Touch.Y <= 480) Then
               str_X = Touch.X.ToString("000") ' Format the X coordinate 000 to 800
               str_Y = Touch.Y.ToString("000") ' Format the Y coordinate 000 to 480

               If COM2.IsOpen = True Then 'check if com port open
                   ' Send out the command T04 and combine with string X 
                    ' and string Y then
                   ' generate check digit
                   COM2.Write(Gen_ChkDig("T04" & str_X & str_Y))
               End If
           End If
       End Set
   End Property

   ' The following function generates the check bit
   Private Function Gen_ChkDig(ByVal In_Data As String)
       Dim Out_Data As String 'Data output string
       Dim int_Sum As Integer 'Sum of all digits
       Dim x As Integer   'This is a counter integer used in the forloop
       Dim chrTemp As Char

       ' Skip the first char, which is a letter
       ' Check the length of the string
       ' Separate into characters
       ' Sum all digits
       For x = 2 To Len(In_Data)
           chrTemp = Mid(In_Data, x)
           int_Sum = int_Sum + Val(chrTemp)
       Next x

       ' take mod 10 of the sum and add that to the string
       Out_Data = In_Data & CStr(int_Sum Mod 10)

       'Return the string with the added check digit 
       Return Out_Data
   End Function
End Module

Serial Commands

Commands are sent to the Hardware through the IRDA port, which has to be configured as follows:

Com2 (IRDA)
Bits per Second 9600
Data bits 8
Parity None
Stop Bits 1
Flow Control None

Data is sent through COM2 (IRDA) port, at the end of each command there is a check digit. The check digit is calculated by summing all of the individual digits and then taking the modulus of the sum. See the attached zipped Excel sheet.

Start-up
Command T46

Video Inputs
Video 1 T531
Video 2 T532

Touch Screen
Command T04######
X Min T04000###
X Max T04800###
Y Min T04###000
Y Max T04###480

FM Emission
Command Open T95###.#1
Command Closed T95###.#0
F Min (77.0Mhz) T95077.0#
F Max(108.9Mhz) T95108.9#

Brightness
Command T71###
Increments 5
Min T71000
Max T71100

Volume
Command T72###
Increments 5
Min T72000
Max T72100

The Touch screen values have to be returned to the hardware when in AV mode so that the AV mode menu can appear, which will enable you to exit back to Windows.

Points of Interest

I asked Lilliput's support team if they can provide me with some information several times and got no response, so I took the matter in my own hands by reverse engineering it!

I actually had a lot of fun, trying to get the touch screen to work in the AV mode, if you don't return the proper command sequence it just hangs.

It also took me a long time to figure out what kind of check digit is used at the end of each command. I was pulling my hair out doing all kinds of crazy math, when I realized that I need to put a load of data into an Excel file, and massage the data. After about 2 days of pondering, I figured out how that was done.

I spent about 2 weeks to figure out how all of it works, and now I want to share it with the world so that when the next person comes around, lucky them Wink | ;) .

I'm a firm believer in open source, and I just hope that someone finds this information useful. If you use this, please let me know what you are doing with your PC745.

History

  • 22nd April, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

bigbro_1985
Engineer
Qatar Qatar
My love for imagining, designing and creating just about anything REAL or VIRTUAL has lead me on this path. Whether it be 1’s and 0’s, soldering an IC to a PCB or getting under the car just to get my hands dirty, I like to do it DIY.
Life is a journey, and it’s all about learning and creating…
 
Some Achievements in my life:
• Founder of the Doha College Robotics Club
• President and founder of the CNA-Q Robotics Club
• Developed Fly-By-Wire Over Ethernet (FBWOE) for boats.
• Telecommunication Engineering Technology Diploma
• X10 Home Automation system as part of a Green Home project
Developed a Vehicle Accessory Computer Interface (VACI)
• Autonomos Turtle Monitoring Robot
Virtual Autonomous Remote Presence (VARP)
• Electrical Engineering Degree from Purdue
• Various Industrial Automation projects ranging from manufacturing car parts to plastics, shaving cream and even ice-cream. I have worked with various robotic systems, VFD's, HMI's, PLCs, industrial networking/data collection systems, and Machine Vision systems.

Comments and Discussions

 
GeneralSome basic questions about PC745 Pinmemberalmafuerte835-Sep-10 11:17 
AnswerRe: Some basic questions about PC745 Pinmemberbigbro_19855-Sep-10 22:45 
GeneralRe: Some basic questions about PC745 Pinmemberalmafuerte836-Sep-10 18:18 
GeneralRe: Some basic questions about PC745 Pinmemberbigbro_19858-Sep-10 6:48 
GeneralCross Threading Issue on Serial Recieve Pinmemberbigbro_19854-Sep-10 21:41 
Generalmini problem :) Pinmemberexodon11-Aug-10 0:01 
GeneralRe: mini problem :) Pinmemberexodon20-Aug-10 4:03 
AnswerRe: mini problem :) Pinmemberbigbro_198529-Aug-10 7:45 
GeneralRe: mini problem :) Pinmemberexodon20-Oct-10 20:46 
GeneralRe: mini problem :) Pinmemberbigbro_198521-Oct-10 1:42 
QuestionPC745 .net program install Pinmemberaryeh12321-Jul-10 4:21 
AnswerRe: PC745 .net program install Pinmemberbigbro_19856-Aug-10 23:31 
NewsLilliput PC745 Tricks Pinmemberbigbro_198515-May-10 9:33 
GeneralZip file cannot be download PinmemberKL Chin22-Apr-10 21:55 
AnswerRe: Zip file cannot be download Pinmemberbigbro_198524-Apr-10 12:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 24 Apr 2010
Article Copyright 2010 by bigbro_1985
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid