Write a program that will check the input of 2-input quadruple NAND , if the NAND gate works properly then the LED connected to RD6 should be ON , otherwise the LED should be ON . Assume PORTC connected to the inputs of quadruple 2-input NAND gates , two LEDs connected to most two bits of PORTD .
Write a program that will check the input of 2-input quadruple NAND , if the NAND gate works properly then the LED connected to RD6 should be ON , otherwise the LED should be ON . Assume PORTC connected to the inputs of quadruple 2-input NAND gates , two LEDs connected to most two bits of PORTD .
Is this a school assignment (it reads like one...)? If not, at the very least we'll need to know what are the functions of PORTs C & D and, more importantly, what is driving the PORTs.
Strange piece of homework where a micro is used to check if some gates work...
If this is not homework (I think it is), it is an utter ridiculous implementation. The micro should be self sufficient to solve the function by simple - if not trivial - programming.
Is this a school assignment (it reads like one...)? If not, at the very least we'll need to know what are the functions of PORTs C & D and, more importantly, what is driving the PORTs.
Strange piece of homework where a micro is used to check if some gates work...
If this is not homework (I think it is), it is an utter ridiculous implementation. The micro should be self sufficient to solve the function by simple - if not trivial - programming.
set pin1 on, set pin2 on; if input =1 then working = false
set pin1 off, set pin2 on; if input =0 then working = false
set pin1 on, set pin2 off; if input =0 then working = false
set pin1 off, set pin2 off; if input =0 then working = false
// repeat these 4 steps for each of the 4 nands
I think the definition of the testing needs to be clarified. Do we just test each individual nand gate as described in post #8 by Dr_Doggy or do we need to test for interaction between the four gates. This would involve cycling the 6 other inputs (2 for each of the other 3 gates.) through each of the 64 possible states for each one of the four tests in post #8 ?
I think it should be sufficient for the OP to implement the table below in pic asm language.
When he gets better in the ASM, he can always improve the program to check for cross-talks between gates and other illegal conditions. For me, It'll be more fun to do it in 6502 or 8051 asm language.
Thanks absf for your help .. Your answers are highly appreciated :
I did some web searches and found that I should make a compare when I write the code . If the four nand gates outputs matching the truth table , then we say the quad two input nand gate is working properly and the GOOD LED is On . But how to compare using PIC assembly ? Comparing with which value ?
Read the data sheet on the PIC that you decide to use and read the instruction set summary. There are two instructions I would chose between but there are other instructions that could be used. You could test one gate at a time using a single bit comparison or you could test the four gates at the same time using a 4 bit comparison. If you don't know which values you are comparing I think you need to chose another subject. The answer has been given in one of the previous posts.
btfsc PORTC,0 ; Check bit0 in PORTC and skip next instruction if bit0 = 0 .
goto k ; This be skipped if bit0 = 0
btfsc PORTC,1 ;Check bit1 in PORTC and skip next instruction if bit1 = 0 .
goto k ; This be skipped if bit1 = 0
k
banksel PORTB
movlw 01h
movwf PORTB ; RD0 in PORTB = 1
return
It could be right for PART OF THE CODE depending on how the gates are connected to the I/O pins of the PIC and how you have set up the input conditions to the gate before this part of the code. It is wrong if it is wired as in the schematic in post #3
It could be right for PART OF THE CODE depending on how the gates are connected to the I/O pins of the PIC and how you have set up the input conditions to the gate before this part of the code. It is wrong if it is wired as in the schematic in post #3
btfsc PORTC,0 ; Check bit0 in PORTC and skip next instruction if bit0 = 0 .
goto p ; This be skipped if bit0 = 0
btfsc PORTC,1 ;Check bit1 in PORTC and skip next instruction if bit1 = 0 .
goto k ; This be skipped if bit1 = 0
You have still not done one of the things that I pointed out in post #14. You seem to be setting PORTB,0 to a "1" which is not connected to anything. You also have RD0 in brackets in the comments. Is that a typing error and should be RB0 ? You are also setting PORTB,0 to a "0" in another part of the program. Think about how you would test a NAND gate. Do you know which connections on a NAND gate are inputs and outputs ?
You have still not done one of the things that I pointed out in post #14. You seem to be setting PORTB,0 to a "1" which is not connected to anything. You also have RD0 in brackets in the comments. Is that a typing error and should be RB0 ? You are also setting PORTB,0 to a "0" in another part of the program. Think about how you would test a NAND gate. Do you know which connections on a NAND gate are inputs and outputs ?
PORTB,0 to a '1' for one nand gate ... I should use this algorithm for the four nand gates and after that it will send a '1' to RD6 once the NAND gate works properly .
RD0 yes this typing error and it should be RB0 . .
I setting the PORTB to 0 if the two input in a NAND gate is 1 1 = 0 . Is this Wrong ?
The connections as shown in the post #3 . The simulation on PROTEUS is not required . I just want to write the code .
1 != 0
boolean for nand is:
A*B = !C
or
!(A*B) = C
i m sorry idk asm, i program all my pic's in c, but I think it would help Les if you can elaborate how you have one nand hooked up, ie quad nand means 4 gates in package , 2input means 2-input and 1 output per gate, which nand pins are hooked up to which pic pins?
#include <p16f877A.inc>
org 0x00
banksel TRISC
clrf TRISC ; Make the PORTC as output
banksel PORTC
btfsc PORTC,0 ; Check bit0 in PORTC and skip next instruction if bit0 = 0 .
; goto p ; This be skipped if bit0 = 0
btfsc PORTC,1 ;Check bit1 in PORTC and skip next instruction if bit1 = 0 .
goto k ; This be skipped if bit1 = 0
k
banksel PORTD ; choose PORTD
movlw 80h
movwf PORTD
end
Here I'm trying just to make a single NAND gate with single LED ... But when I change the 0's and 1's .. The LED is still OFF . WHY ?
I even connected without NANDs the 0 and 1 directly to portc pin0 pin1 and led still OFF