Thursday, November 20, 2014
Interface Relay with PNP transistor
One technique relay drivers from the microcontroller or computer can be made with the driver PNP transistors like the article "Interface Relays With PNP Transistor" ini.This circuit interface is simple and easily applied to a microcontroller or computer parallel port. Interface Relays With PNP Transistor uses 2 transistors 2N3904 and 2n2905/2N2907 UAH as a power relay drivers. The advantages of this circuit can menggeran relay with considerable power with TTL logic input from the computer and microcontroller. Source voltage required to follow the relay circuit is used, for example using a 12V relay, the source voltage to 12V or 24V relays the 24V voltage source. Detailed relay interface circuit and microcontroller or computer can be seen in the following figure.

Function diodes mounted parallel with the relay to prevent backflow into the transistor due to magnetic induction of the relay coil, therefore these diodes must be installed. For installation with a microcontroller or computer which need to be noticed is the Grund computer or microcontroller circuit must be connected to ground in series Interface Relays With this PNP transistors.
RS232 to RS485 Circuit
The new archetypal of RS485 advocate overcomes the RTS controlled botheration accomplished by our chargeless design. However, to do that requires a microprocessor, so there is a greater complication to the design. We advertise this unit, although currently we are attached our sales to barter who can pay by coffer alteration – which in absoluteness is bounded Australian companies.
This architecture has been almost agitation free, and if you crave quantities we can acclimate the adapter pinout to clothing your appliance – about again the accessory will no best fit the simple little D25 case in which you see it pictured.
![]() |
| RS232 to RS485 Circuit |
* Data (vs RTS) controlled – does not rely on PC handshake timing
* DB25 RS232 connector compatible with PC
* TxD and RxD translated from RS232 to RS485
* Direction of transmission controlled by Data
* Handshake loop the PC connection so it works with all software
* RS485 signals output on D9 male with lots of Ground pins
* Indicator LED(s) to show communications traffic
* Line powered – powered by RS232 handshake lines
* RS485 Termination resistor not included
* Pullup/Pulldown resistors on RS485 to establish line-idle condition
* Baud rate is dipswitch selectable 1200 – 115.2k
Wednesday, November 19, 2014
NIMH battery charger
Series NIMH Battery Charger with IC LT4060 is a NIMH battery charger is powerful, effective and efficient. Featur owned by IC LT4060 is a specialization of a NIMH battery charger. NIMH Battery Charger with IC LT4060 can perform safely charging NIMH batteries because it comes with a battery temperature protection is in charge and the peak level detection system of the battery voltage is in charge. Battery temperature protection system from the excessive use of NTC temperature sensor. Series NIMH Battery Charger with IC LT4060 also features a charging indicator that will light up when charging and will die when the battery is full. IC 4060 used in this NIMH battery charger from Linear Technology is a production that is designed special for NIMH battery charger.
Image Series NIMH Battery Charger with IC LT4060

Description Series NIMH Battery Charger with IC LT4060
R2 potentiometer used for setting the maximum temperature (at set at the value of 4K)
LED D1 is a battery charging indicator
Charger Power Transistor (Q1) can be replaced with PNP transistors are capable of a current of 3A - 5A
Simple Power Supply with 2 transistors
Power Supply in this post is using a regulator which is composed of 2 pieces of NPN transistor. A transistor acts as a power regulator and a transistor again serves as a controller output voltage. Power Supply has an adjustable output with a range of 6-12 VDC. The part that serves as a power regulator is Q1 TIP31. Then the controller output voltage is a voltage divider composed of R3, R4, VR1 and R2 provide bias to the base of Q2 to control the power regulator Q1. In a series of power supply is mounted 5.1 V zener diode which serves to make the minimum limit the output voltage with Q2.
Power Supply With transistor circuit is quite simple and can be made with the PCB holes, so for those who want to try to directly mempraktikannya. May the power supply circuit can be useful for readers, especially for friends who need a power supply circuit with the regulator transistor.
8051 Tutorial Part 1 Serial Communication
One of the 8051s many powerful features is its integrated UART, otherwise known as a serial port. The fact that the 8051 has an integrated serial port means that you may very easily read and write values to the serial port. If it were not for the integrated serial port, writing a byte to a serial line would be a rather tedious process requring turning on and off one of the I/O lines in rapid succession to properly "clock out" each individual bit, including start bits, stop bits, and parity bits.
However, we do not have to do this. Instead, we simply need to configure the serial ports operation mode and baud rate. Once configured, all we have to do is write to an SFR to write a value to the serial port or read the same SFR to read a value from the serial port. The 8051 will automatically let us know when it has finished sending the character we wrote and will also let us know whenever it has received a byte so that we can process it. We do not have to worry about transmission at the bit level--which saves us quite a bit of coding and processing time.
Setting the Serial Port Mode
The first thing we must do when using the 8051s integrated serial port is, obviously, configure it. This lets us tell the 8051 how many data bits we want, the baud rate we will be using, and how the baud rate will be determined.
First, lets present the "Serial Control" (SCON) SFR and define what each bit of the SFR represents:
| Bit | Name | Bit Addres | Explanation of Function |
| 7 | SM0 | 9Fh | Serial port mode bit 0 |
| 6 | SM1 | 9Eh | Serial port mode bit 1. |
| 5 | SM2 | 9Dh | Mutliprocessor Communications Enable (explained later) |
| 4 | REN | 9Ch | Receiver Enable. This bit must be set in order to receive characters. |
| 3 | TB8 | 9Bh | Transmit bit 8. The 9th bit to transmit in mode 2 and 3. |
| 2 | RB8 | 9Ah | Receive bit 8. The 9th bit received in mode 2 and 3. |
| 1 | TI | 99h | Transmit Flag. Set when a byte has been completely transmitted. |
| 0 | RI | 98h | Receive Flag. Set when a byte has been completely received. |
Additionally, it is necessary to define the function of SM0 and SM1 by an additional table:
| SM0 | SM1 | Serial Mode | Explanation | Baud Rate |
| 0 | 0 | 0 | 8-bit Shift Register | Oscillator / 12 |
| 0 | 1 | 1 | 8-bit UART | Set by Timer 1 (*) |
| 1 | 0 | 2 | 9-bit UART | Oscillator / 64 (*) |
| 1 | 1 | 3 | 9-bit UART | Set by Timer 1 (*) |
(*) Note: The baud rate indicated in this table is doubled if PCON.7 (SMOD) is set.
The SCON SFR allows us to configure the Serial Port. Thus, well go through each bit and review its function.
The first four bits (bits 4 through 7) are configuration bits.
Bits SM0 and SM1 let us set the serial mode to a value between 0 and 3, inclusive. The four modes are defined in the chart immediately above. As you can see, selecting the Serial Mode selects the mode of operation (8-bit/9-bit, UART or Shift Register) and also determines how the baud rate will be calculated. In modes 0 and 2 the baud rate is fixed based on the oscillators frequency. In modes 1 and 3 the baud rate is variable based on how often Timer 1 overflows. Well talk more about the various Serial Modes in a moment.
The next bit, SM2, is a flag for "Multiprocessor communication." Generally, whenever a byte has been received the 8051 will set the "RI" (Receive Interrupt) flag. This lets the program know that a byte has been received and that it needs to be processed. However, when SM2 is set the "RI" flag will only be triggered if the 9th bit received was a "1". That is to say, if SM2 is set and a byte is received whose 9th bit is clear, the RI flag will never be set. This can be useful in certain advanced serial applications. For now it is safe to say that you will almost always want to clear this bit so that the flag is set upon reception of any character.
The next bit, REN, is "Receiver Enable." This bit is very straightforward: If you want to receive data via the serial port, set this bit. You will almost always want to set this bit.
The last four bits (bits 0 through 3) are operational bits. They are used when actually sending and receiving data--they are not used to configure the serial port.
The TB8 bit is used in modes 2 and 3. In modes 2 and 3, a total of nine data bits are transmitted. The first 8 data bits are the 8 bits of the main value, and the ninth bit is taken from TB8. If TB8 is set and a value is written to the serial port, the datas bits will be written to the serial line followed by a "set" ninth bit. If TB8 is clear the ninth bit will be "clear."
The RB8 also operates in modes 2 and 3 and functions essentially the same way as TB8, but on the reception side. When a byte is received in modes 2 or 3, a total of nine bits are received. In this case, the first eight bits received are the data of the serial byte received and the value of the ninth bit received will be placed in RB8.
TI means "Transmit Interrupt." When a program writes a value to the serial port, a certain amount of time will pass before the individual bits of the byte are "clocked out" the serial port. If the program were to write another byte to the serial port before the first byte was completely output, the data being sent would be garbled. Thus, the 8051 lets the program know that it has "clocked out" the last byte by setting the TI bit. When the TI bit is set, the program may assume that the serial port is "free" and ready to send the next byte.
Finally, the RI bit means "Receive Interrupt." It funcions similarly to the "TI" bit, but it indicates that a byte has been received. That is to say, whenever the 8051 has received a complete byte it will trigger the RI bit to let the program know that it needs to read the value quickly, before another byte is read.
Setting the Serial Port Baud Rate
Once the Serial Port Mode has been configured, as explained above, the program must configure the serial ports baud rate. This only applies to Serial Port modes 1 and 3. The Baud Rate is determined based on the oscillators frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillator frequency divided by 12. This means if youre crystal is 11.059Mhz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is always the oscillator frequency divided by 64, so a 11.059Mhz crystal speed will yield a baud rate of 172,797.
In modes 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1 overflows, the higher the baud rate. There are many ways one can cause timer 1 to overflow at a rate that determines a baud rate, but the most common method is to put timer 1 in 8-bit auto-reload mode (timer mode 2) and set a reload value (TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.
To determine the value that must be placed in TH1 to generate a given baud rate, we may use the following equation (assuming PCON.7 is clear).
- TH1 = 256 - ((Crystal / 384) / Baud)
If PCON.7 is set then the baud rate is effectively doubled, thus the equation becomes:
- TH1 = 256 - ((Crystal / 192) / Baud)
For example, if we have an 11.059Mhz crystal and we want to configure the serial port to 19,200 baud we try plugging it in the first equation:
TH1 = 256 - ((Crystal / 384) / Baud)
TH1 = 256 - ((11059000 / 384) / 19200 )
TH1 = 256 - ((28,799) / 19200)
TH1 = 256 - 1.5 = 254.5
As you can see, to obtain 19,200 baud on a 11.059Mhz crystal wed have to set TH1 to 254.5. If we set it to 254 we will have achieved 14,400 baud and if we set it to 255 we will have achieved 28,800 baud. Thus were stuck...
But not quite... to achieve 19,200 baud we simply need to set PCON.7 (SMOD). When we do this we double the baud rate and utilize the second equation mentioned above. Thus we have:
TH1 = 256 - ((Crystal / 192) / Baud)
TH1 = 256 - ((11059000 / 192) / 19200)
TH1 = 256 - ((57699) / 19200)
TH1 = 256 - 3 = 253
Here we are able to calculate a nice, even TH1 value. Therefore, to obtain 19,200 baud with an 11.059MHz crystal we must:
1. Configure Serial Port mode 1 or 3.
2. Configure Timer 1 to timer mode 2 (8-bit auto-reload).
3. Set TH1 to 253 to reflect the correct frequency for 19,200 baud.
4. Set PCON.7 (SMOD) to double the baud rate.
Writing to the Serial Port
Once the Serial Port has been propertly configured as explained above, the serial port is ready to be used to send data and receive data. If you thought that configuring the serial port was simple, using the serial port will be a breeze.
To write a byte to the serial port one must simply write the value to the SBUF (99h) SFR. For example, if you wanted to send the letter "A" to the serial port, it could be accomplished as easily as:
- MOV SBUF,#A
Upon execution of the above instruction the 8051 will begin transmitting the character via the serial port. Obviously transmission is not instantaneous--it takes a measureable amount of time to transmit. And since the 8051 does not have a serial output buffer we need to be sure that a character is completely transmitted before we try to transmit the next character.
The 8051 lets us know when it is done transmitting a character by setting the TI bit in SCON. When this bit is set we know that the last character has been transmitted and that we may send the next character, if any. Consider the following code segment:
CLR TI ;Be sure the bit is initially clear
MOV SBUF,#A ;Send the letter A to the serial port
JNB TI,$ ;Pause until the TI bit is set.
The above three instructions will successfully transmit a character and wait for the TI bit to be set before continuing. The last instruction says "Jump if the TI bit is not set to $"--$, in most assemblers, means "the same address of the current instruction." Thus the 8051 will pause on the JNB instruction until the TI bit is set by the 8051 upon successful transmission of the character.
Reading the Serial Port
Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to read the value stored in the SBUF(99h) SFR after the 8051 has automatically set the RI flag in SCON.
For example, if your program wants to wait for a character to be received and subsequently read it into the Accumulator, the following code segment may be used:
JNB RI,$ ;Wait for the 8051 to set the RI flag
MOV A,SBUF ;Read the character from the serial port
The first line of the above code segment waits for the 8051 to set the RI flag; again, the 8051 sets the RI flag automatically when it receives a character via the serial port. So as long as the bit is not set the program repeats the "JNB" instruction continuously.
Once the RI bit is set upon character reception the above condition automatically fails and program flow falls through to the "MOV" instruction which reads the value.
Tuesday, November 18, 2014
Running LED with 4017
Running LED with 4017 complete with PCB layout. The series of 8 LED current is the basis for creating an 8-point LED. Slightly different from the running LED with IC 4017 (decade counter), 8 running this led is lit in sequence, but that has been previously flame does not die when the led is lit afterwards. 8 led to death after led to the fire-8. Meanwhile in the running LED (decade counter), the system LED lights like "point", there is only one LED that flashes between the tenth led.

The main component is the IC 74LS164 (SHIFT REGISTER), with its timer is astable multivibrator circuit (using IC NE555).
The series will be more efficient when using a stable power supply (regulator) using IC Regulator 7805. Under this scheme a series of stable power supply 5 volts dc.

Programming Learning MCS51
Programming Learning MCS51
The mention of constant data (immediate addressing mode): MOV A, # $ 20. Constant data is data that was in the instructions. Examples of this instruction has the data meaning a constant $ 20 (as a constant data marked with #) on-copy it into the accumulator A. What needs to be properly addressed in this order is the number $ 20 is part of the instruction.
Read More..
Learning Programming MCS51 becomes mandatory we learn if we want to use the MCS51. In the first part of this Learning Programming MCS51 we will learn together about the basic programming language MCS51 microcontroller. Where to program MCS51 outline there are 2 core parts of pemrogramanya language is "Words Work" and "Object". In the article Programming MCS51 this first part we will study first the "verb" is a command group Peng-copies of data, the command group arithmetic and logic command group.
Reference to DATA IN PROGRAMMING MCS51
Data can be in many different places, thus known a few ways to describe the data (in English often referred to as Addressing Mode), among others, as follows:
The mention of constant data (immediate addressing mode): MOV A, # $ 20. Constant data is data that was in the instructions. Examples of this instruction has the data meaning a constant $ 20 (as a constant data marked with #) on-copy it into the accumulator A. What needs to be properly addressed in this order is the number $ 20 is part of the instruction.Reference to data directly (direct addressing mode), this method is used to refer to data residing in memory by calling the memory number where the data are: MOV A, $ 30. Examples of these instructions have the meaning of data in the memory number $ 30 in-copy it to the accumulators.
At first glance these same instructions to the instruction constant data above, the difference above instructions using the # which marks the $ 20 is a data constant, whereas in this instruction because there was no sign # then $ 30 is a number from memory.
The mention of indirect data (indirect addressing mode), this method is used to refer to data residing in memory, if memory data storage is changing its location so that the memory number is not called directly but in-titip her into another register : MOV A, @ R0.
In this instruction versatile R0 register is used to record the number of memory, so that this instruction has a memory meaning that the number recorded in the contents of R0-copy it into the accumulator A.
Sign @ is used to mark the memory number stored in R0.
Compare this with the instruction memory number directly mention above, in this instruction first memory numbers are stored in R0 and R0 appoint a role which memory is used, so that if the value of R0 change the designated memory will also be changed as well.
In this instruction registers R0 functioning multipurpose container for the address register (indirect address register), other than all-purpose registers R0 R1 can also be used as a container for the address register.
Reference to data in the register (register addressing mode): MOV A, R5. This instruction has the meaning of data in all-purpose register R5 is copy it into the accumulator A. This instruction makes all-purpose registers R0 to R7 as a place to store data that is very practical that it works very fast.
The data referred to in the discussion above all in the data memory (including all-purpose registers are also located in data memory). In writing the program, often required standard table that is stored along with the program. Tables of this kind is really a data residing in program memory!
For this purpose, MCS51 have any mention of data in memory means programs conducted by indirect (indirect addressing code mode): MOVC A, @ A + DPTR.
Notice in this MOV instruction is replaced with MOVC, the additional letter C is meant to distinguish that this instruction is used in the program memory. (MOV without the letter C means that the instruction used in the data memory).
Sign @ is used to mark A + DPTR is used to indicate the number of contents in-memory copy it to the accumulator A, in this case the value stored in the DPTR (Data Pointer Register - 2 bytes) plus the value stored in accumulators A (1 byte) is used to refer to the program memory numbers.
Verb in AT89Cx051
Overall AT89Cx051 have as many as 255 kinds of instruction, which was formed by combining the verb and objects. "The verb is the group discussed the following:
PENG GROUP-COPY-DATA AN MCS51
Basic code for this group are MOV, abbreviation of MOVE, which means to move, though more correct to say this command have meaning copying the data. This can be explained the following: after the instruction MOV A, R7 done, accumulators A and all-purpose register R7 contains the same data, originally stored in R7.
MOV command is distinguished according to the type of memory AT89Cx051. This command is on the memory data is written into MOV, for example:
MOV A, $ 20
MOV A, @ R1
MOV A, P1
MOV P3, A
To use the program memory, this command is written into MOVC, there are only 2 types of wear MOVC instructions, namely:
MOVC A, @ A + DPTR; DPTR as register indirect
MOVC A, @ A + PC, PC as the register indirect
In addition, there is also known MOVX command, the command that is used for external data memory (X singkatakan from External). This command is only available to the MCS51 family members who have an external data memory, for example AT89C51 and so forth, and certainly not known by the group that tidam AT89Cx051 have external data memory. There are only 6 kinds of wear MOVX instruction, these instructions are:
MOVX A, @ DPTR
MOVX A, @ R0
MOVX A, @ R1
MOVX @ DPTR, A
MOVX @ R0, A
MOVX @ R1, A
GROUP ARIMATIK (ADD, ADDC, SubB, DA, MUL and DIV)
ADD and ADDC command
The contents of accumulators A plus the number 1 byte, the sum will be collected back in the accumulator. In this operation Carry bit (C flag in the PSW - Program Status Word) serves as a reservoir overflow of the sum. If the sum of the abundance (a value greater than 255) will carry bit value 1 , if not Carry bit value 0. ADDC same with ADD, only in bits Carry ADDC value in the previous process involved summed together.
Numbers 1 byte is added to the accumulator, can be derived from a constant, from the all-purpose register, memory data from memory number is called directly or indirectly, as shown in the following example:
ADD A, R0; register versatile
ADD A, # $ 23; a constant
ADD A, @ R0; no memory indirect
ADD A, P1; no direct memory (port 1)
ORDERS IN PROGRAMMING SubB MCS51
The contents of Accumulator A less the number 1 byte follows with Carry bit value, the reduction will be accommodated again in the accumulators. Carry bits in this operation also serves as a reservoir overflow of the reduction. If the reduction is abundant (score less than 0) bits Carry would be worth 1 , if not Carry bit value 0.
SubB A, R0; A = A - R0 - C
SubB A, # $ 23; A = A - $ 23
SubB A, @ R1
SubB A, P0
DA command
DA command (Decimal Adjust) is used after the command ADD, ADDC, or SubB, used to convert 8-bit binary value stored in the accumulator into 2 pieces decimal number, each consisting of 4-bit binary value.
MUL AB ORDERS IN PROGRAMMING MCS51
8-bit binary number in accumulator A is multiplied by an 8-bit binary number in register B. The result of multiplication of binary 16-bit, 8 bit binary number that greater weight be accommodated in the register B, while the other 8 bits are accommodated in the smaller weight accumulator A.
OV bit in the PSW (Program Status Word) is used to mark the result of multiplying the existing value in register B. OV bit will be worth 0 if register B is worth $ 00, if not worth OV bit 1.
MOV A, # 10
MOV B, # 20
MUL AB
DIV AB ORDERS IN PROGRAMMING MCS51
8-bit binary number in accumulator A is divided by an 8-bit binary number in register B. The result of the division of 8-bit binary numbers stored in the accumulator, while the rest of the division of 8-bit binary number stored in register B.
OV bit in the PSW (Program Status Word) is used to mark the value before the division that exists in the register B. OV bit will be worth 1 if register B originally worth $ 00.
GROUP LOGIC (ANL, ORL and XRL) IN PROGRAMMING MCS51
This command group used to perform logic operations MCS51 microcontroller, logic operations can be done is the AND operation (operation code ANL), OR operation (operation code ORL) and the Exclusive-OR operation (XRL operation code).
The data used in this operation can be data that is in the accumulator or data that are in-memory data, this is a little different with arithmetic operations that must be actively melihatkan accumulators.
Operating results are accommodated in the first data source.
AND logic operation is widely used to me 0 a few specific bits of an 8-bit binary number, the way to forming an 8-bit binary numbers as a data-ANL constant in a number of origin. Bit-0 want in a represented by 0 in constant data, while other bits given the value 1, eg
Instructions ANL P1, #% 01111110 will result in bit 0 and bit 7 of Port 1 (P1) value 0 while the other bits remain unchanged in value.
OR logic operation is widely used to me 1 a few specific bits of an 8-bit binary number, the way to forming an 8-bit binary numbers as constant data in a number-ORL origin. Bit-1 want in a represented by 1 in constant data, while other bits given the value 0, eg
Instructions ORL A, #% 01111110 will result in bit 1 to bit 6 of the accumulator value 1 while other bits remain unchanged in value.
Exclusive-OR logic operation is widely used to reverse the value (complement) some particular bits of an 8-bit binary number, the way to forming an 8-bit binary numbers as constant data in a number-XRL origin. Bit you want behind-the value represented by 1 in constant data, while other bits are the value 0, eg
Instructions XRL A, #% 01111110 will result in bit 1 to bit 6 of the accumulator turned value, while other bits remain unchanged in value.
Subscribe to:
Posts (Atom)
