Hey everyone, great forum,
Very new to PIC's and PICAXE, so please don't hurt!
The concept is to use the PIC as a 3 to 8 decoder ie. (74HS138) however I need the PIC to latch until the input pulses again,
So 1st pulse turn output on, 2nd pulse turn output off, simple!
(inputs 0 to 3 are binary so a combination activates the relevant output)
Here's the code I've made.
This is based on the 28X/40X chip,
Here are the problems/questions.
In the simulator it shows a 28 pin chip I would prefer to have more in/outputs and use the 40 pin, do I need to issue a command at the start of the program.
As you can tell from the program I'm still learning,
If the input stays in the state for too long the output turns on and off which is no good for the project. It would be better if I could tell if the output was high already rather than using a varible.
When the simulator is running does it run at the chips processor speed?
Sorry if this is in the manual but it's very deep!
Some pointers wuld be helpful. Thanks in advance.
Very new to PIC's and PICAXE, so please don't hurt!
The concept is to use the PIC as a 3 to 8 decoder ie. (74HS138) however I need the PIC to latch until the input pulses again,
So 1st pulse turn output on, 2nd pulse turn output off, simple!
(inputs 0 to 3 are binary so a combination activates the relevant output)
Here's the code I've made.
Code:
TOP: '1 2 4 8
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 0 AND b0 = 0 THEN HIGH PORTC 4 : LET b0 = 1 : ENDIF '1
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 0 AND b1 = 0 THEN HIGH PORTC 5 : LET b1 = 1 : ENDIF '2
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 0 AND b2 = 0 THEN HIGH PORTC 6 : LET b2 = 1 :ENDIF '3
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 0 AND b3 = 0 THEN HIGH PORTC 7 : LET b3 = 1 :ENDIF '4
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 0 AND b4 = 0 THEN HIGH PORTB 0 : LET b4 = 1 :ENDIF '5
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 1 AND PIN3 = 0 AND b5 = 0 THEN HIGH PORTB 1 : LET b5 = 1 :ENDIF '6
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 1 AND PIN3 = 0 AND b6 = 0 THEN HIGH PORTB 2 : LET b6 = 1 :ENDIF '7
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 1 AND b7 = 0 THEN HIGH PORTB 3 : LET b7 = 1 :ENDIF '8
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 1 AND b8 = 0 THEN HIGH PORTB 4 : LET b8 = 1 :ENDIF '9
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 1 AND b9 = 0 THEN HIGH PORTB 5 : LET b9 = 1 :ENDIF '10
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 1 AND b10 = 0 THEN HIGH PORTB 6 : LET b10 = 1 :ENDIF '11
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 1 AND b11 = 0 THEN HIGH PORTB 7 : LET b11 = 1 :ENDIF '12
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 0 AND b0 = 1 THEN LOW PORTC 4 : LET b0 = 0 : ENDIF '1
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 0 AND b1 = 1 THEN LOW PORTC 5 : LET b1 = 0 : ENDIF '2
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 0 AND b2 = 1 THEN LOW PORTC 6 : LET b2 = 0 :ENDIF '3
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 0 AND b3 = 1 THEN LOW PORTC 7 : LET b3 = 0 :ENDIF '4
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 0 AND b4 = 1 THEN LOW PORTB 0 : LET b4 = 0 :ENDIF '5
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 1 AND PIN3 = 0 AND b5 = 1 THEN LOW PORTB 1 : LET b5 = 0 :ENDIF '6
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 1 AND PIN3 = 0 AND b6 = 1 THEN LOW PORTB 2 : LET b6 = 0 :ENDIF '7
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 1 AND b7 = 1 THEN LOW PORTB 3 : LET b7 = 0 :ENDIF '8
IF PORTC PIN0 = 1 AND PIN1 = 0 AND PIN2 = 0 AND PIN3 = 1 AND b8 = 1 THEN LOW PORTB 4 : LET b8 = 0 :ENDIF '9
IF PORTC PIN0 = 0 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 1 AND b9 = 1 THEN LOW PORTB 5 : LET b9 = 0 :ENDIF '10
IF PORTC PIN0 = 1 AND PIN1 = 1 AND PIN2 = 0 AND PIN3 = 1 AND b10 = 1 THEN LOW PORTB 6 : LET b10 = 0 :ENDIF '11
IF PORTC PIN0 = 0 AND PIN1 = 0 AND PIN2 = 1 AND PIN3 = 1 AND b11 = 1 THEN LOW PORTB 7 : LET b11 = 0 :ENDIF '12
GOTO TOP
Here are the problems/questions.
In the simulator it shows a 28 pin chip I would prefer to have more in/outputs and use the 40 pin, do I need to issue a command at the start of the program.
As you can tell from the program I'm still learning,
If the input stays in the state for too long the output turns on and off which is no good for the project. It would be better if I could tell if the output was high already rather than using a varible.
When the simulator is running does it run at the chips processor speed?
Sorry if this is in the manual but it's very deep!
Some pointers wuld be helpful. Thanks in advance.