Problem with running simulator or my code is wrong ? help please

Grant666

Member
Hi All

I cant get this part of the code to work in the simulator? Basically I'm using a 28X, reading the portA inputs off a switch matrix to give me six modes depending on the switches that are active. However when I try to run this on the simulator ( pixace editor 5.5.5)
turning on the portA button, loads a 5 into the simulator and the outputs will not activate. So I either have the code wrong, or not using the simulator correctly....
So any answers on this would be wonderful

Thank you

Code sample below


chksw:
if portA pin1 = 1 and pin2 = 0 and pin3 = 0 then lightR1 ; AND funtction to match switch input matrix
if portA pin1 = 0 and pin2 = 1 and pin3 = 0 then lightR2
if portA pin1 = 0 and pin2 = 0 and pin3 = 1 then lightR3
if portA pin1 = 1 and pin2 = 1 and pin3 = 0 then lightR4
if portA pin1 = 1 and pin2 = 0 and pin3 = 1 then lightR5
if portA pin1 = 0 and pin2 = 1 and pin3 = 1 then lightR6
goto chksw


lightR1:
high B.0 ;turn on Rollover 1 ligh
goto chksw
 

1968neil

Senior Member
Your pin naming syntax is wrong if you have a look at manual 2 = page 109
i think the PORTA was used on the older 28X ic's and is now redundant with the new editor
the code below should now work for you, you'll need to change the outputs in the lightR subroutines to suit your needs but should get you on your way

Regards
Neil


Code:
chksw: 
if pinA.1 = 1 and pinA.2 = 0 and pinA.3 = 0 then lightR1    ; AND funtction to match switch input matrix
if pinA.1 = 0 and pinA.2 = 1 and pinA.3 = 0 then lightR2
if pinA.1 = 0 and pinA.2 = 0 and pinA.3 = 1 then lightR3
if pinA.1 = 1 and pinA.2 = 1 and pinA.3 = 0 then lightR4
if pinA.1 = 1 and pinA.2 = 0 and pinA.3 = 1 then lightR5
if pinA.1 = 0 and pinA.2 = 1 and pinA.3 = 1 then lightR6
goto chksw

lightR1:
high B.0    ;turn on Rollover 1 ligh
goto chksw


lightR2:
high B.1    ;turn on Rollover 1 ligh
goto chksw

lightR3:
high B.2    ;turn on Rollover 1 ligh
goto chksw

lightR4:
high B.3    ;turn on Rollover 1 ligh
goto chksw

lightR5:
high B.4    ;turn on Rollover 1 ligh
goto chksw

lightR6:
high B.5    ;turn on Rollover 1 ligh
goto chksw
 

Grant666

Member
Advice on Code

Your pin naming syntax is wrong if you have a look at manual 2 = page 109
i think the PORTA was used on the older 28X ic's and is now redundant with the new editor
the code below should now work for you, you'll need to change the outputs in the lightR subroutines to suit your needs but should get you on your way

Regards
Neil


Code:
chksw: 
if pinA.1 = 1 and pinA.2 = 0 and pinA.3 = 0 then lightR1    ; AND funtction to match switch input matrix
if pinA.1 = 0 and pinA.2 = 1 and pinA.3 = 0 then lightR2
if pinA.1 = 0 and pinA.2 = 0 and pinA.3 = 1 then lightR3
if pinA.1 = 1 and pinA.2 = 1 and pinA.3 = 0 then lightR4
if pinA.1 = 1 and pinA.2 = 0 and pinA.3 = 1 then lightR5
if pinA.1 = 0 and pinA.2 = 1 and pinA.3 = 1 then lightR6
goto chksw

lightR1:
high B.0    ;turn on Rollover 1 ligh
goto chksw


lightR2:
high B.1    ;turn on Rollover 1 ligh
goto chksw

lightR3:
high B.2    ;turn on Rollover 1 ligh
goto chksw

lightR4:
high B.3    ;turn on Rollover 1 ligh
goto chksw

lightR5:
high B.4    ;turn on Rollover 1 ligh
goto chksw

lightR6:
high B.5    ;turn on Rollover 1 ligh
goto chksw
Hi Neil
Thanks for the advice, it works nicely.
 
Top