Hello guys, I'm having a hard time trying to inplement a custom counter.
It works if I start it from 0, but that is a problem for me as the output pins should never be all LOW. I want to start the counter from 1023 (PIN 14 to 23 HIGH) and it dosen't work. All the pins stay LOW.
I do get a lot of warnnings and errors but it dosen't look like it matters.
I have the latest WinCupl version from microchip website and windows 7.
Not working code:
Name Counter1 ;
PartNo 00 ;
Date 07.12.2020 ;
Revision 01 ;
Designer ME ;
Company Private ;
Assembly None ;
Location ;
Device g22v10 ;
/* *************** INPUT PINS *********************/
PIN 1 = clk;
PIN [14..23] = [Q9..Q0];
field counter = [Q0..Q9];
Sequenced counter {
present 'D'1023 next 'D'55;
present 'D'55 next 'D'119;
present 'D'119 next 'D'247;
present 'D'247 next 'D'95;
present 'D'95 next 'D'127;
present 'D'127 next 'D'611;
present 'D'611 next 'D'357;
present 'D'357 next 'D'870;
present 'D'870 next 'D'87;
present 'D'87 next 'D'103;
present 'D'103 next 'D'39;
present 'D'39 next 'D'63;
present 'D'63 next 'D'1023;
}
Working code:
Name Counter1 ;
PartNo 00 ;
Date 07.12.2020 ;
Revision 01 ;
Designer ME ;
Company Private ;
Assembly None ;
Location ;
Device g22v10 ;
/* *************** INPUT PINS *********************/
PIN 1 = clk;
PIN [14..23] = [Q9..Q0];
field counter = [Q0..Q9];
Sequenced counter {
present 'D'0 next 'D'55;
present 'D'55 next 'D'119;
present 'D'119 next 'D'247;
present 'D'247 next 'D'95;
present 'D'95 next 'D'127;
present 'D'127 next 'D'611;
present 'D'611 next 'D'357;
present 'D'357 next 'D'870;
present 'D'870 next 'D'87;
present 'D'87 next 'D'103;
present 'D'103 next 'D'39;
present 'D'39 next 'D'63;
present 'D'63 next 'D'0;
}
Many thanks,
Georgian.
Unfortunatly it dosen't work. I made the modification as you sugested and i get an error and the cod ewon't compile.
Code:
Sequence counter {
present 'D'0 next 'D'807;
/* present 'D'1023 next 'D'55; */
present 'D'807 next 'D'119;
present 'D'119 next 'D'247;
present 'D'247 next 'D'95;
present 'D'95 next 'D'127;
present 'D'127 next 'D'611;
present 'D'611 next 'D'357;
present 'D'357 next 'D'870;
present 'D'870 next 'D'87;
present 'D'87 next 'D'103;
present 'D'103 next 'D'39;
present 'D'39 next 'D'63;
present 'D'63 next 'D'807;
}
Error:
I got it working. Finaly. I had to invert the output pins and also invert all my numbers. The start/stop ZERO is now All pins HIGH and i'm verry happy with it. I did think about this method, but with external NOT gates... did't thing it could be possible to invert all output pins at once.
field counter = ![Q9..Q0];
Sequence counter {
present 'D'0 next 'D'960;
present 'D'960 next 'D'968;
present 'D'968 next 'D'96;
present 'D'96 next 'D'928;
present 'D'928 next 'D'896;
present 'D'896 next 'D'912;
present 'D'912 next 'D'412;
present 'D'412 next 'D'666;
present 'D'666 next 'D'153;
present 'D'153 next 'D'936;
present 'D'936 next 'D'904;
present 'D'904 next 'D'0;
/*present 'D'904 next 'D'0;*/
}
Thank you for the tip. Heave a great day.