could someone please check this circuit?

Discussion in 'Embedded Systems and Microcontrollers' started by efm, Oct 27, 2006.

  1. efm

    Thread Starter Member

    Sep 14, 2006
    14
    0
    hello,

    i'm making a data logger that consists of 3 LM35s, one LM324 OpAmp, one ADC0808, one
    AT89S51, and a 24LC256 serial eeprom. i've designed the circuit by myself with references from
    the net, and i want to know whether the design is correct or not. and i'm open for suggestions of
    course.

    well, the goal of the circuit is to receive data from the three sensors, and then save it into the
    24LC256 memory, and then the computer will download the data through parallel port.

    please help,
    faizal
     
  2. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    143
    Can you improve the clarity? It is very difficult to read anything on the image.

    Dave
     
  3. efm

    Thread Starter Member

    Sep 14, 2006
    14
    0
    hello dave,
    thanks for the reply,
    well, here is the clearer picture...i zipped it,
    i hope you would see it and tell me whether the design is correct or not,

    faizal
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Greetings efm,

    Your circuit looks as though you have everything covered.

    You may want to look at replacing the LM324 opamps with a rail-to-rail opamp. This will give a little better linearity on your temp readings at the high end of the temperature range.

    I noticed that you chose not to implement a means of connecting to the AT89S51 for the purpose of In-System Programming. I take it that you are planning to socket the AT89S51 and program it off-board.

    hgmjr
     
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I noticed that you have made no provisions for measuring temperatures below 0 degrees Celsius. Is that intentional?

    hgmjr
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You may want to consider assigning the EOC signal from the ADC0808 to one of the external interrupt pins on the AT89S51. That way you will not need to use polling to detect when the A-to-D conversion has been completed.

    hgmjr
     
  7. efm

    Thread Starter Member

    Sep 14, 2006
    14
    0
    hello
    thanks for the reply and for the suggestions!!

    so, what rail-to-rail opamp do you suggest? i found OPA4344P, is it ok?
    and, about the in system programming thing...you're right, i'm planning to program it
    off-board, but i think your idea is good...
    if i want to add the isp to the circuitry, can i just wire the mosi, miso, and sck (p1.5,
    p1.6, p1.7) to the parallel port? or do i have to change the whole circuitry?
    and, is it ok if i do the in system programming while the board is powered?

    btw, thanks for the suggestion for wiring the eoc to interrupt pin. i think i will
    change the design, and i will attach it in my next message.

    and...actually, i want to measure below 0 celcius, but i've bought that lm35d. i didn't
    know that it only measures 0 to 100 celcius.

    well, thanks for all suggestions,
    faizal
     
  8. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    efm,

    The OPA4344 looks like it should work fine.

    As for the ISP hookup, you should be able to consult ATMEL's AT89S51 datasheet for implementations instructions. You will need to take into consideration the requirements of your existing programmer.

    The LM35D datasheet shows how it can be connected for -55 to +150 celsius temp range even while powered by a single supply. You will need to configure your op-amps as differential amplifiers instead of the single-ended scheme you are currently using.

    hgmjr
     
  9. efm

    Thread Starter Member

    Sep 14, 2006
    14
    0
    hello again,

    well, according to my previous circuit layout, i made the pcb layout,
    umm...would you care too see if it's correct or not?
    your help would be greatly appreciated :)

    btw, if i want to connect the board with parallel port, do i have to connect
    parallel port's ground (pin 21-25) to the board's ground?

    thank you,
    faizal
     
  10. efm

    Thread Starter Member

    Sep 14, 2006
    14
    0
    hello,

    according to my previous schematic, i have written a code for the microcontroller. but i haven't uploaded
    it yet, i just scare that it's wrong and will eventually break the microcontroller / memory :)

    here is the code, could someone please tell me whether it will work or not

    Code ( (Unknown Language)):
    1. [SIZE="2"]$MOD51
    2.  
    3. DSEG
    4.  
    5. ORG         30H
    6.  
    7. BYTSTR:
    8.         DS  20H
    9.  
    10. ; ------------------------------------------------
    11. ; CONSTANTS
    12. ; ------------------------------------------------
    13.  
    14. ; EEPROM EQUATES
    15. WTCMD       EQU 10100000B
    16. ADDRH       EQU 0
    17. ADDRL       EQU 0
    18. AD_SDA      BIT P1.0
    19. AD_SCL      BIT P1.1
    20.  
    21. ; ADC0809 EQUATES
    22. AD_OE       BIT P1.5
    23. AD_SC       BIT P1.7
    24. AD_EOC      BIT P1.4
    25. AD_ALE      BIT P1.7
    26. AD_CLK      BIT P1.6
    27. AD0     BIT P3.2
    28. AD1     BIT P3.3
    29. AD2     BIT P3.4
    30. CONV_PORT   EQU P2
    31.  
    32. ; ------------------------------------------------
    33. ; START OF PROGRAM
    34. ; ------------------------------------------------
    35.  
    36. CSEG
    37.  
    38. ORG     0
    39.  
    40. JMP     START
    41.  
    42. START:
    43.     MOV P1, #0FFH
    44.     CALL    MAIN_ROUTINE
    45.     JMP START
    46.  
    47. ; ------------------------------------------------
    48. ; BELOW IS THE ROUTINE TO READ ADC'S OUTPUT,
    49. ; COMPARISON, AND SAVE TO EEPROM
    50. ;
    51. ; Note: Channel Selection
    52. ;   AD2 AD1 AD0 CHANNEL
    53. ;    0   0   0     1
    54. ;    0   0   1     2
    55. ;    0   1   0     3
    56. ; ------------------------------------------------
    57.  
    58. MAIN_ROUTINE:
    59.  
    60.     ; INITIALIZE ADC
    61.     CLR AD_OE
    62.     CLR AD_ALE
    63.     CLR AD_CLK
    64.  
    65.     ; READ FROM CHANNEL 0
    66.     CLR AD0
    67.     CLR AD1
    68.     CLR AD2
    69.     CALL    START_CONVERSION
    70.     MOV R2, A
    71.    
    72.     ; READ FROM CHANNEL 1
    73.     SETB    AD0
    74.     CLR AD1
    75.     CLR AD2
    76.     CALL    START_CONVERSION
    77.     MOV R3, A
    78.  
    79.     ; READ FROM CHANNEL 2
    80.     CLR AD0
    81.     SETB    AD1
    82.     CLR AD2
    83.     CALL    START_CONVERSION
    84.     MOV R4, A
    85.    
    86.     ; COMPARE R2, R3, AND R4
    87.     CALL    COMPARE
    88.    
    89.     ; DELAY FOR ONE MINUTE
    90.    
    91.     ; LOOP
    92.     JMP MAIN_ROUTINE
    93.  
    94. ; ------------------------------------------------
    95. ; RESULT COMPARISON
    96. ; ------------------------------------------------
    97.  
    98. COMPARE:
    99.     ; COMPARES R2 WITH R3
    100.     MOV     A, R2
    101.     SUBB    A, R3
    102.     JNZ COMPARE_2       ; If R2-R3 <> 0, they're not equal, jump to COMPARE_2
    103.     MOV R1, A           ; R2 and R3 is equal, so save R2 in R1...
    104.     JMP     SAVE_R1         ; ...and jump to SAVE_R1
    105.    
    106. COMPARE_2:
    107.     ; COMPARE R2 WITH R4
    108.     MOV A, R2
    109.     SUBB    A, R4
    110.     JNZ COMPARE_3       ; If R2-R4 <> 0, they're not equal, jump to COMPARE_3
    111.     MOV R1, A           ; R2 and R4 is equal, so save R2 in R1...
    112.     JMP SAVE_R1         ; ...and jump to SAVE_R1
    113.    
    114. COMPARE_3:
    115.     ; COMPARE R3 WITH R4
    116.     MOV A, R3
    117.     SUBB    A, R4
    118.     JNZ NO_VOTE         ; If R3-R4 <> 0, they're not equal, jump to NO_VOTE
    119.     MOV R1, A           ; R3 and R4 is equal, so save R3 in R1...
    120.     JMP SAVE_R1         ; ...and jump to SAVE_R1
    121.    
    122. NO_VOTE:
    123.     ; NO TWO OUT OF THREE ARE EQUAL
    124.     MOV R1, #0          ; If no 2 out of three are equal, set R1 as 0
    125.  
    126. SAVE_R1:
    127.     ; SAVE R1 TO EEPROM
    128.     CALL TESTWR
    129.     RET
    130.  
    131. ; ------------------------------------------------
    132. ; ADC CONVERSION ROUTINE
    133. ; ------------------------------------------------
    134.  
    135. START_CONVERSION:
    136.     MOV CONV_PORT, #0FFH
    137.     CLR AD_OE
    138.     SETB    AD_ALE
    139.     CLR AD_ALE
    140.  
    141. START_CLK:
    142.     CPL AD_CLK
    143.     JNB AD_EOC, START_CLK
    144.     SETB    AD_OE
    145.     MOV A, CONV_PORT
    146.     CLR AD_OE
    147.     RET
    148.  
    149. ; ------------------------------------------------
    150. ; BELOW IS THE ROUTINE TO WRITE ONE BYTE TO EEPROM
    151. ; ------------------------------------------------
    152.  
    153. TESTWR:
    154.     MOV R3, #ADDRH
    155.     MOV R4, #ADDRL
    156.     CALL    BYTEW
    157.     RET
    158.  
    159. BYTEW:
    160.     MOV A, #WTCMD
    161.     CALL    OUTS
    162.     MOV A, R4
    163.     CALL    OUT
    164.     MOV A, R1
    165.     CALL    OUT
    166.     CALL    STOP
    167.     RET
    168.  
    169. OUTS:
    170.     MOV R2, #8
    171.     SETB    AD_SDA
    172.     SETB    AD_SCL
    173.     NOP
    174.     NOP
    175.     NOP
    176.     NOP
    177.     NOP
    178.     CLR AD_SDA
    179.     NOP
    180.     NOP
    181.     NOP
    182.     NOP
    183.     NOP
    184.     CLR AD_SCL
    185.  
    186. OTSLP:
    187.     RLC A
    188.     JNC BITLS
    189.     SETB    AD_SDA
    190.     JMP OTSL1
    191.  
    192. BITLS:
    193.     CLR AD_SDA
    194.  
    195. OTSL1:
    196.     SETB    AD_SCL
    197.     NOP
    198.     NOP
    199.     NOP
    200.     NOP
    201.     NOP
    202.     CLR AD_SCL
    203.     DJNZ    R2, OTSLP
    204.     SETB    AD_SDA
    205.     NOP
    206.     NOP
    207.     NOP
    208.     SETB    AD_SCL
    209.     NOP
    210.     NOP
    211.     NOP
    212.     NOP
    213.     NOP
    214.     CLR AD_SCL
    215.     RET
    216.  
    217. OUT:
    218.     MOV R2, #8
    219.  
    220. OTLP:
    221.     RLC A
    222.     JNC BITL
    223.     SETB    AD_SDA
    224.     JMP OTL1
    225.  
    226. BITL:
    227.     CLR AD_SDA
    228.  
    229. OTL1:
    230.     SETB    AD_SCL
    231.     NOP
    232.     NOP
    233.     NOP
    234.     NOP
    235.     NOP
    236.     CLR AD_SCL
    237.     DJNZ    R2, OTLP
    238.     SETB    AD_SDA
    239.     NOP
    240.     NOP
    241.     NOP
    242.     SETB    AD_SCL
    243.     NOP
    244.     NOP
    245.     NOP
    246.     NOP
    247.     NOP
    248.     CLR AD_SCL
    249.     RET
    250.    
    251. STOP:
    252.     CLR AD_SDA
    253.     NOP
    254.     NOP
    255.     NOP
    256.     NOP
    257.     NOP
    258.     SETB    AD_SCL
    259.     NOP
    260.     NOP
    261.     NOP
    262.     NOP
    263.     NOP
    264.     SETB    AD_SDA
    265.     RET
    266.  
    267. END[/SIZE]
    thank you
     
  11. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    143
    Your best bet would be to download the programme to the microcontroller, it is very unlikely that you will damage anything as long as you follow the correct download procedure. It would be much easier for you to decifer if the code works by testing on-line, rather than someone reading through the source code here on the forums.

    Hope it goes well.

    Dave
     
Loading...