Thursday, 28 June 2007

Testing Softwares

Most of the testing software are testing the electronics circuits. Which are work normally or not. Test by giving Low-High bits to the checking points. Procedures for developing testing software are : -

(1) Define the checking points
(2) Define the port and pins for Input and Output to Micro-p
(3) Define the bit pattern (Data) for Input and Output processing
(4) Write program (Micro-p, Application)
(5) Download and Debug


I'll explain detail for each steps at next posts.

Wednesday, 27 June 2007

Get Electronics Projects (for Technological students)

This web sites provide simple electronics projects for students, they include Source Codes, Instruments list, PCB Designs, Circuit Diagrams. Complete and....simple.

www.electronics-lab.com
www.bobblick.com
www.microchipc.com

Tuesday, 26 June 2007

VB source code for RS232

Simple VB source code for Receive and Transmit data to RS232.

At Form1

Dim startfra As Byte
Dim header As Byte
Dim checksum As Integer

Dim outvalue As String
Dim invalue As String

Dim InByte As Byte
Dim OutByte As Byte

Dim instring As String

Dim buff As Byte

Dim i As Byte

Dim tcount As Integer

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub Pause(milli As Long)
Sleep (milli)
End Sub

Private Sub Form_Load()
tcount = 0
header = &H0 'Define Output
MSComm1.Settings = "19200,N,8,1"
MSComm1.InputLen = 1
MSComm1.RTSEnable = True
MSComm1.CommPort = 1
MSComm1.PortOpen = True
startfra = &H55
OutByte = &H0
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
Timer1.Interval = 1
End Sub

Private Sub Form_Unload(Cancel As Integer)
OutByte = &H0
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End
End Sub

Private Sub MSComm1_OnComm()
instring = ""
For i = 0 To 4
If MSComm1.CommEvent = 2 Then
instring = MSComm1.Input
If MSComm1.InBufferCount = 2 Then
buff = Asc(instring)
Select Case (buff)
Case 7
OutByte = &H1
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
Case 11
OutByte = &H2
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
Case 13
OutByte = &H4
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
Case 14
OutByte = &H8
checksum = checksumOut(header, OutByte)
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
Case 15
OutByte = &H0
checksum = checksumOut(header, OutByte)
If tcount = 2 Then
MSComm1.Output = Chr(startfra) & Chr(header) & Chr(OutByte) & Chr(InByte) & ChrW(checksum) 'Output to RS232
End If
End Select
End If
End If
Next
End Sub

Private Sub Timer1_Timer()
MSComm1.Output = Chr(setval1) & Chr(setval2) & Chr(setval3) & Chr(setval4) & Chr(setval5) End Sub
-----------------------
At Module

Public Enum packet
setval1 = &H55
setval2 = &H80
setval3 = &H0
setval4 = &HF
setval5 = &H71
End Enum

Public Function checksumOut(header As Byte, OutB As Byte) As Integer
If OutB = 0 Then checksumOut = &H0 Else checksumOut = &H100 - ((header + OutB) And &HFF)
End Function

Receiving Data from RS232

There has a problem, when reading data from RS232. Transmit data are OK, I mean the transmit value from Software and checking from Hardware are the same. But at read data from HW by means of SW is different. It has an algorithm to calculate data for same with send and receive. When you have got a value (Bit stream) from HW, inverse that string and make NOT.

Eg: Read value -> 1011 to 1101 (Reverse) and than NOT(1101)=0010 <- its Answer

RS232 and USB

You can connect Rs232 with USB port. But it need ONE IC between that 2 ports, converter IC. You can use any converter IC for this case. But, one important thing is that, the range of voltage for that IC is mostly +5V t0 -5V. Some computers output voltage is sometimes more that that. For that case, you should insert one voltage regulator device to regulate voltage to get constant +5V to -5V.
If you don't, your IC can be die. At that time, its difficult to find error.


Circuit Diagram for RS232 and USB
Converter Cable

Monday, 25 June 2007

UART

UART

Universal Asynchronous Receiver/Tansmitter is a type of "asynchronous receiver/transmitter", it is a piece of computer Hardware that translates data between parallel and serial interfaces. Used for serial data telecommunication, a UART converts bytes of data to and from Asynchronous start-stop bit streams represented as binary electrical impulses.

UARTs are commonly used in conjunction with other communication standards such as RS-232.

Developing a Microcontroller Software

For developing Micro-p (Microcontroller Program), the needs are....
(1) Program Codes (Assembly/ Interpretor level). To develop software, it needs Assembler, Interpretor or Compiler. This is a C compiler for Silicon Labs series Microcontroller. In Myanmar, normally using BASIC Assembler. But any low-high level programming language/ any compiler can used to develop Micro-p. The "same" Source Code can be used.


(2) Microcontroller (in Myanmar mostly used PICxxx series)


(3) Programmer Circuit board (PCB)


This PCB is for only PICxxx series microcontrollers. According the using of Microcontroller, the programmer (PCB) are different.

RS232 DB-9 and DB-25

There are normally TWO types of RS232 DB-9 and DB-25. Here is the cross connection between that TWO ports.

RS232 (COM port)


This is RS232 (COM) port, in electronics COM ports are called RS232. This picture is RS232 9 pin female connector and Pin assignments.
Usually use pin 2, 3 and 5. Pin-2 is for transmit low byte (4 bit) data. Pin-3 is for receive low byte (4 bit) data. Pin-5 is for ground. So you can send only 16 channels for using that 3 pins. You can use normally up to 255 channel by using Pin-7 and 8 for next 4-bit high byte, combination all 8-bit (Low+High) channels.

Introduction for Electronics

Electronics

This Blog for for Electronics Hardware and related Software. Nothing special, just for remembering my knowledges.
In Electronics components, similar with Computer, have TWO parts Hardware and Software.
(1) Hardware includes Resister, Transistor, Capacitor, etc...
(2) In Software, there are TWO catagories,
(a) Micro-p (Microchip, Microcontroller programming)
(b) Application Software (Connect with PC computer)

Micro-p
This programs are write by Assembly or C languages. Used low level commands. After finishing, convert them to the form of Machine language and download to Microchip.

Application Software
Write by Visual Basic or Visual C, but you can use any languages which can control computer ports. Mostly used Serial ports (COM1, 2, ..) and parallel ports.
After that it must communicate with Microchip via RS232 controller.