Find Dot Matrix Printer Head Values In Vb6 Programming

  • Uploaded by: Kiran
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Find Dot Matrix Printer Head Values In Vb6 Programming as PDF for free.

More details

  • Words: 1,796
  • Pages: 16
Dot Matrix Printer Head Values

 

DOT MARTIX PRINTER HEAD VALUES This is the Visual Basic 6.0 program to create a simple application that helps you to find out Dot Matrix printer’s print head Hex values.

Where I have used this program? I am an Embedded System Programmer and was working on Printer Mechanism. Once a situation occurred that I have to do some paper work regarding Dot Matrix printer head hex values. I try to explain you what exactly was the requirement. Normal dot matrix printer prints a 9X5 (9 by 5) matrix of dots to resemble a character, as illustrated below for character A, LSB Æ 

MSB Æ  ÅColumn Number 1 to 5 (L to R) Above 9X5 matrix with black dots represent a character A. Thus in a 9X5 dot matrix you need to activate set of dots to print a particular character on paper. For that you have to do lot of paper work. Some times you may have to discard the shape which you have created and may have to do it again, which will result into lot of “NRE Paper cost”. It is not over if you have created a character on paper, you need to send the Hexadecimal code of that matrix to printer ports to print that character.

How to get Hex values from above matrix? Explained for character A. 1. Start with column number 1 and get the binary values of the dots. 2. In column number 1 starting from MSB, the binary value we get as 111111100 3. Same for other columns, we get 000010010, 000010001, 000010010 and 111111100 for columns 2, 3, 4 and 5 respectively. 4. Now get the hex values of these binary numbers, using scientific calculator provided in Windows. 5. And then you have to send that hex value to printer port to print A. 6. Hex value came as {0x1FC, 0x012, 0x011, 0x012, 0x1FC}.

Programmer: Kiran P



Dot Matrix Printer Head Values

  It was really a head ache for me to do that much paper work and R&D on Printer Values. So I have designed a GUI in Visual Basic which helped me to get the value easily and made my work simple. I have provided the complete VB code here for your reference. Enjoy.

Starting with GUI. I will not explain you how to program in VB. I will consider that you know at least basic programming in VB6.0. I have provided my GUI design here, check it out.

1. Button “Clear All” will clear all the check marks on check box. 2. Button “Preview” will show the character format you have designed on preview box. 3. Button “GET VALUE” will provide Binary, corresponding Decimal and Hex values on Text Box provided for each column check marks on check boxes.

Programmer: Kiran P



Dot Matrix Printer Head Values

  Below is the value for character A.

Now you might have clearly understood.

Programmer: Kiran P



Dot Matrix Printer Head Values

 

Below is the VB code. '************************************************ ' '

(C) Kiran P Programmer: Kiran P

'************************************************ Option Explicit Dim i As Integer 'Bit value Holder 'This starts with 0 to 8 total it can hold 9 values. Dim bit(8) As Integer 'Temp Decimal Value Holder Dim temp1 As Integer Dim temp2 As Integer Dim temp3 As Integer Dim temp4 As Integer Dim temp5 As Integer -------------------------------------------------------------------------------------------------------------------------Private Sub cmd_clear_Click() For i = 0 To 8 chk_bx(i).Value = 0 chk_bx2(i).Value = 0 chk_bx3(i).Value = 0

Programmer: Kiran P



Dot Matrix Printer Head Values

  chk_bx4(i).Value = 0 chk_bx5(i).Value = 0 Next End Sub ----------------------------------------------------------------------------------------------------------Private Sub cmd_getVal_Click() Call funct1

Call funct2

Call funct3

Call funct4

Call funct5 End Sub -------------------------------------------------------------------------------------------------------------Private Sub funct1() Text1.Text = "" For i = 0 To 8 If (chk_bx(i).Value = 1) Then bit(i) = 1 Text1.Text = Text1.Text & bit(i) Else

Programmer: Kiran P



Dot Matrix Printer Head Values

  bit(i) = 0 Text1.Text = Text1.Text & bit(i) End If Next 'Reverse the string to display MSB first Text1.Text = StrReverse(Text1.Text) 'get decimal value temp1 = 256 * bit(8) + 128 * bit(7) + 64 * bit(6) + 32 * bit(5) + 16 * bit(4) + 8 * bit(3) + 4 * bit(2) + 2 * bit(1) + bit(0) 'display decimal value Text11.Text = temp1 'get hex value Text6.Text = Hex$(temp1) End Sub ---------------------------------------------------------------------------------------------------------------Private Sub funct2() Text2.Text = "" For i = 0 To 8 If (chk_bx2(i).Value = 1) Then bit(i) = 1 Text2.Text = Text2.Text & bit(i) Else bit(i) = 0 Text2.Text = Text2.Text & bit(i) End If

Programmer: Kiran P



Dot Matrix Printer Head Values

  Next Text2.Text = StrReverse(Text2.Text) temp2 = 256 * bit(8) + 128 * bit(7) + 64 * bit(6) + 32 * bit(5) + 16 * bit(4) + 8 * bit(3) + 4 * bit(2) + 2 * bit(1) + bit(0) Text12.Text = temp2 Text7.Text = Hex$(temp2) End Sub -----------------------------------------------------------------------------------------------------------------------Private Sub funct3() Text3.Text = "" For i = 0 To 8 If (chk_bx3(i).Value = 1) Then bit(i) = 1 Text3.Text = Text3.Text & bit(i) Else bit(i) = 0 Text3.Text = Text3.Text & bit(i) End If Next Text3.Text = StrReverse(Text3.Text) temp3 = 256 * bit(8) + 128 * bit(7) + 64 * bit(6) + 32 * bit(5) + 16 * bit(4) + 8 * bit(3) + 4 * bit(2) + 2 * bit(1) + bit(0) Text13.Text = temp3 Text8.Text = Hex$(temp3) End Sub

Programmer: Kiran P



Dot Matrix Printer Head Values

  --------------------------------------------------------------------------------------------------------------------Private Sub funct4() Text4.Text = "" For i = 0 To 8 If (chk_bx4(i).Value = 1) Then bit(i) = 1 Text4.Text = Text4.Text & bit(i) Else bit(i) = 0 Text4.Text = Text4.Text & bit(i) End If Next Text4.Text = StrReverse(Text4.Text) temp4 = 256 * bit(8) + 128 * bit(7) + 64 * bit(6) + 32 * bit(5) + 16 * bit(4) + 8 * bit(3) + 4 * bit(2) + 2 * bit(1) + bit(0) Text14.Text = temp4 Text9.Text = Hex$(temp4) End Sub -------------------------------------------------------------------------------------------------------------------------Private Sub funct5() Text5.Text = "" For i = 0 To 8 If (chk_bx5(i).Value = 1) Then bit(i) = 1

Programmer: Kiran P



Dot Matrix Printer Head Values

  Text5.Text = Text5.Text & bit(i) Else bit(i) = 0 Text5.Text = Text5.Text & bit(i) End If Next Text5.Text = StrReverse(Text5.Text) temp5 = 256 * bit(8) + 128 * bit(7) + 64 * bit(6) + 32 * bit(5) + 16 * bit(4) + 8 * bit(3) + 4 * bit(2) + 2 * bit(1) + bit(0) Text15.Text = temp5 Text10.Text = Hex$(temp5) End Sub ------------------------------------------------------------------------------------------------------------------Private Sub cmd_priew_Click() Call disp1 Call disp2 Call disp3 Call disp4 Call disp5 End Sub -------------------------------------------------------------------------------------------------------------------Private Sub disp1() For i = 0 To 8 If (chk_bx(i).Value = 1) Then

Programmer: Kiran P



Dot Matrix Printer Head Values

10 

  lb1(i).BackColor = vbYellow Else lb1(i).BackColor = vbBlack End If Next End Sub ---------------------------------------------------------------------------------------------------------------Private Sub disp2() For i = 0 To 8 If (chk_bx2(i).Value = 1) Then lb2(i).BackColor = vbYellow Else lb2(i).BackColor = vbBlack End If Next End Sub -----------------------------------------------------------------------------------------------------------------------Private Sub disp3() For i = 0 To 8 If (chk_bx3(i).Value = 1) Then lb3(i).BackColor = vbYellow Else lb3(i).BackColor = vbBlack End If

Programmer: Kiran P

Dot Matrix Printer Head Values

11 

  Next End Sub -------------------------------------------------------------------------------------------------------------------------Private Sub disp4() For i = 0 To 8 If (chk_bx4(i).Value = 1) Then lb4(i).BackColor = vbYellow Else lb4(i).BackColor = vbBlack End If Next End Sub -----------------------------------------------------------------------------------------------------------------------------Private Sub disp5() For i = 0 To 8 If (chk_bx5(i).Value = 1) Then lb5(i).BackColor = vbYellow Else lb5(i).BackColor = vbBlack End If Next End Sub ------------------------------------------------------------------------------------

Programmer: Kiran P

Dot Matrix Printer Head Values

  Hope you have understood the program. I have declared 5 Check Boxes each with array of 9 (0 to 8). For preview option I have used 5 Labels each with array of 9. These each array of Labels and Check Boxes resemble each column of the matrix. I did this because if I have declare a single check box of arrays 45 then I need to declare 45 integers, named “bit”, to hold all the check box values. So to reduce the variable I have declared them as array of 9 so that I can use “bit” variables for holding values of each column of Check Box. If you still have any doubt regarding this program, send me a mail to [email protected] with your name and doubts. Any suggestion to improve the program is also acceptable. Programmer: Kiran P E-Mail: [email protected]

Below chart gives Hexadecimal values for 9X5 dot matrix printer. //Hex Code To Use

Symbol and Code

{0x000,0X000,0X000,0X000},

//”

0

{0x13F,0X000,0X000,0X000},

//!

1

{0X001,0X002,0X001,0X002},

//"

2

{0x028,0x1FF,0x028,0x1FF,0x028},

//#

3

{0X04C,0X092,0X1FF,0X064},

//$

4

{0x048,0x020,0x010,0x048},

//%

5

{0X0E4,0X11A,0X142,0X140},

//&

6

{0X001,0X002,0X000,0X000},

//'

7

{0X07C,0X041,0X101,0X000},

//(

8

{0X000,0X101,0X041,0X07C},

//)

9

{0x030,0x018,0x030,0x000},

//*

10

{0x010,0x010,0x0FE,0x010,0x010},

//+

11

Programmer: Kiran P

12 

Dot Matrix Printer Head Values

  {0x100,0x080,0x000,0x000},

//,

12

{0x010,0x010,0x010,0x010},

//-

13

{0x000,0x000,0x100,0x000},

//.

14

{0x080,0x070,0x01C,0x007},

///

15

{0x0FE,0x101,0x101,0x0FE},

//0

16

{0x002,0x1FF,0x000,0x000},

//1

17

{0x0F2,0x111,0x111,0x10E},

//2

18

{0x082,0x111,0x111,0x0EE},

//3

19

{0x018,0x014,0x1FE,0x011},

//4

20

{0x09F,0x111,0x111,0x0E1},

//5

21

{0x0F8,0x114,0x112,0x0E1},

//6

22

{0x003,0x1C1,0x079,0x00F},

//7

23

{0x0EE,0x111,0x111,0x0EE},

//8

24

{0x10E,0x111,0x111,0x0FE},

//9

25

{0x001,0x000,0x101,0x000},

//:

26

{0X100,0X081,0X000,0X000},

//;

27

{0X010,0X028,0X044,0X082},

//<

28

{0x028,0x028,0x028,0x028},

//=

29

{0X082,0X044,0X028,0X010},

//>

30

{0X002,0X171,0X009,0X006},

//?

31

{0X0FE,0X119,0X125,0X0BE},

//@

32

{0x1FE,0x011,0x011,0x1FE},

//A

33

{0x1FF,0x111,0x111,0x0EE},

//B

34

Programmer: Kiran P

13 

Dot Matrix Printer Head Values

  {0x0FE,0x101,0x101,0x0C6},

//C

35

{0x1FF,0x101,0x101,0x0FE},

//D

36

{0x1FF,0x111,0x111,0x183},

//E

37

{0x1FF,0x111,0x011,0x003},

//F

38

{0x0FE,0x101,0x111,0x0F1},

//G

39

{0x1FF,0x010,0x010,0x1FF},

//H

40

{0x101,0x1FF,0x101,0x000},

//I

41

{0x081,0x101,0x101,0x0FF},

//J

42

{0x1FF,0x028,0x044,0x183,0x101},

//K

43

{0x1FF,0x100,0x100,0x180},

//L

44

{0x1FF,0x002,0x006,0x002,0x1FF},

//M

45

{0x1FF,0x00C,0x018,0x060,0x1FF},

//N

46

{0x0FE,0x101,0x101,0x0FE},

//O

47

{0x1FF,0x011,0x011,0x00E},

//P

48

{0x07E,0x181,0x181,0x17E},

//Q

49

{0x1FF,0x011,0x031,0x1CE},

//R

50

{0x08E,0x111,0x111,0x0E2},

//S

51

{0x003,0x001,0x1FF,0x001,0x003},

//T

52

{0x0FF,0x100,0x100,0x0FF},

//U

53

{0x00F,0x078,0x1C0,0x078,0x00F},

//V

54

{0x1FF,0x080,0x040,0x080,0x1FF},

//W

55

{0x101,0x0C6,0x038,0x0C6,0x101},

//X

56

{0x001,0x006,0x1F8,0x006,0x001},

//Y

57

{0x181,0x161,0x119,0x10D,0x103},

//Z

58

{0X1FF,0X101,0X101,0X000},

//[

59

Programmer: Kiran P

14 

Dot Matrix Printer Head Values

  {0X007,0X01C,0X070,0X080},

//\

60

{0X000,0X101,0X101,0X1FF},

//]

61

{0X002,0X001,0X002,0X000},

//^

62

{0x100,0x100,0x100,0x100},

//_

63

{0x001,0x002,0x000,0x000},

//`

64

{0x0E8,0x114,0x114,0x0F8},

//a

65

{0x1FF,0x0A0,0x110,0x0E0},

//b

66

{0x0F8,0x104,0x104,0x104},

//c

67

{0x0E0,0x110,0x0A0,0x1FF},

//d

68

{0x0F8,0x114,0x114,0x118},

//e

69

{0x1FC,0x112,0x012,0x004},

//f

70

{0x138,0x144,0x144,0x1FE},

//g

71

{0x1FF,0x008,0x008,0x1F0},

//h

72

{0x104,0x1FD,0x100,0x000},

//i

73

{0x100,0x104,0x105,0x0FC},

//j

74

{0x1FF,0x028,0x044,0x082},

//k

75

{0x100,0x1FF,0x100,0x000},

//l

76

{0x1F8,0x004,0x1F8,0x004,0x1F8},

//m

77

{0x1F8,0x004,0x004,0x1F8},

//n

78

{0x0E0,0x110,0x110,0x0E0},

//o

79

{0x1FC,0x042,0x042,0x03C},

//p

80

{0x03C,0x042,0x042,0x1FC},

//q

81

{0x1FC,0x108,0x104,0x104},

//r

82

{0x098,0x124,0x124,0x0C8},

//s

83

{0x0FC,0x110,0x110,0x080},

//t

84

Programmer: Kiran P

15 

Dot Matrix Printer Head Values

  {0x0FC,0x100,0x100,0x0FC},

//u

85

{0x01C,0x0E0,0x100,0x0E0,0x01C},

//v

86

{0x0FC,0x100,0x0F0,0x100,0x0FC},

//w

87

{0x110,0x0A0,0x040,0x0A0,0x110},

//x

88

{0x01C,0x120,0x120,0x0FC},

//y

89

{0x110,0x190,0x150,0x130,0x110},

//z

90

{0x010,0x0EE,0x101,0x101},

//{

91

{0x000,0x1FF,0x000,0x000},

//|

92

{0x101,0x101,0x0EE,0x010},

//}

93

{0x010,0x008,0x010,0x008},

//~

94

In above chart, symbol represents the symbol which printer will going to print if send corresponding Hex value to the port, and code represent the code value of look up table if you declare the above chart in a 100X5 array of look up table. Some symbol uses only 4 columns in which case you can send 0x000 for 5th column.

Programmer: Kiran P

16 

Related Documents

Printer Matrix
April 2020 6
Vb6
October 2019 20
Vb6
November 2019 14
Vb6
October 2019 10

More Documents from ""