Free Circuit Design with or without Microcontroller <DATA:BLOG.PAGETITLE></DATA:BLOG.PAGETITLE>Free Circuit Design with or without Microcontroller

Drop Down Menu

Multi Fixed Pulse Generator (MFPG)

This Multi Fixed Pulse Generator (MFPG) was made for test the accuracy count of measuring equipment. This free circuit design only have three switch and three output with 12 Mode operations. Basically we can make more than three switch and outputs as much as we want and more then 12 Mode operations. Here is the table of function mode :



table pulsa generator


How this design work :

If this MFPG turn ON it will on Mode 0 as default mode and if we push Sw1 the out1, out2 and out3 will generate 500 Pulse with 1k Hz Frequency with the upper pulse time about 200uS and the lower time about 800uS. For the Sw2 or Sw3 and other Mode you can see on the table 1 above.

To change the default mode 0 to other mode just simply push and hold Sw1 and push Sw2 refer to the mode number we want than release the Sw1 and the Led will flash as much as the number of mode we set. We can count the Led Flash for ensure not going to the wrong mode. If in case we forgot how much times the Sw2 has pushed for the mode of operation we want than we can RESET it to the default mode 0 by push and hold Sw1 and push Sw3 once and release both Switch.

Here is the free circuit design of MFPG :

pulse generator circuit

Like you can see the circuit above it base on ATMEL micro controller AT89C2051 2K Bytes of reprogrammable flash memory, you can change it with newer version like AT89S2051 it will be same function for this design. And if we design more than 12 mode or more than three output and or more than three switch look like we need more memory space and therefor we can using AT89C4051 or AT89S4051 4K Bytes of reprogrammable flash memory.

Because of a very simple of this free circuit design, i don't make any special PCB design instead i using multi purpose PCB around 3Cm * 4Cm for main circuit and 3Cm * 1Cm for three switch, it should be more than enough. Here is the final picture of this design :

picture pulse generator

Now we will describe how the circuit work.

Because this circuit base on Atmel micro controller AT89C2051 and the circuit very simple therefor we will not to describe the circuit it self but more to the firmware.

Here is a little part of the code :

(wait for about one second)

LOOP: SETB P3.7            ; turn on LED
JB SW1, L1
SJMP KON1

L1: JB SW2, L2
SJMP KON2

L2: JB SW3, LOOP
SJMP KON3

At first time of MFPG turn on it will delay about one second to process the rest of the code. This is useful for prevent an unstable power supply while it turn on by switch or any contacted metal material. The above code will turn on LED and scanning Sw1, Sw2 and Sw3, if the switch not pushed the micro controller will looping around the above code and will not do any things. But if Sw1 is pushed it will jump to KON1, and for Sw2 if pushed will jump to KON2 and for Sw3 will jump to KON3. Here is the little code of KON1 :

KON1:       JNB SW2, KE_MODE
KON1A:     JB SW1, KE_kedip
                 JNB SW3, RESET1
                 SJMP kon1

The above code for Sw1 if it pushed it will scanning again for Sw2, if Sw2 is pushed it will jump again to KE_MODE otherwise it will scanning for Sw3 and if Sw3 is pushed it will jump to the RESET1 subroutine otherwise it will looping again in this subroutine until Sw1 is release, and if Sw1 released it will jump again to KE_kedip subroutine.

ke_kedip: jnb sw1, kon1
MOV R7,#100
ACALL DELAYMS
jnb sw1, kon1

The above code just for make sure there is no any bouncing of the switch.

mov r0, kedip
cjne r0, #0, lagis
sjmp ke_out

lagis: cjne r0, #20, lgg1
sjmp lgl
              ...
              ...
              ...

lgl: mov kedip, #0
ajmp loop

The above code to check the mode data between 0 to 20 (decimal), 20 dec to Hex is 14. The total of mode 0 to 12 is 13 mode that's why if it reach to 14 it will clear back to 0. If mode data 0 than it will jump to ke_out subroutine to take out the appropriate data to the output data lines. If mode data 20 than it will jump to lgl to clear back to 0 than looping again.

lgg1: mov r0, mode
lg11: clr p3.7
MOV R7,#150
ACALL DELAYMS
MOV R7,#250
ACALL DELAYMS
SETB p3.7
MOV R7,#150
ACALL DELAYMS
MOV R7,#250
ACALL DELAYMS
djnz r0, lg11

This code will turn off led for about 0.4 sec and on again for 0.4 sec and it will repeat according to mode of operations. But of course this subroutine will not execute every time you push the switch, it only will called on every time of setting mode of operation, and the setting of the operation will stored inside the register of micro controller, it use for next time when the switch is pushed than ke_out subroutine will read that register and take the appropriate data to the data line out of pulse according to the Table 1 above.

This Multi Fixed Pulse Generator base on 1 K Hz, but we can change it according to what we like, let's see  this subroutine :

PUL_O1: SETB OUT1
SETB OUT2
SETB OUT3
ACALL D200US
CLR OUT1
CLR OUT2
CLR OUT3
ACALL D800US
RET

PUL_O2: SETB OUT2
SETB OUT3
ACALL D200US
CLR OUT2
CLR OUT3
ACALL D800US
RET

PUL_O3: SETB OUT3
  ACALL D200US
CLR OUT3
ACALL D800US
RET

D200us: MOV r7, #87
D200: DJNZ R7, D200
RET

D800uS: MOV R6, #2
MOV R7, #102
D800: DJNZ R7, D800
DJNZ R6, D800
NOP
RET

Above code D200us and D800uS is time delay for 200uS and 800uS, and Frequency = 1 / T. So if we like to change to the other frequency than we have to recalculate the register R6 and R7.

Here is the source code for AT89C2051.

Here is How to Convert 5v Pulse to 24v Pulse

No comments:

Post a Comment