WinCUPL, ATF22V10BQL - State machine not working. - Page 1
Forum section: electronics / general

author: georgian
author_rank: Regular Contributor
timestamp: December 09, 2020, 10:43:22 pm
content: 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: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'1023next 'D'55;present 'D'55next 'D'119;present 'D'119next 'D'247;present 'D'247next 'D'95;present 'D'95next 'D'127;present 'D'127next 'D'611;present 'D'611next 'D'357;present 'D'357next 'D'870;present 'D'870next 'D'87;present 'D'87next 'D'103;present 'D'103next 'D'39;present 'D'39next 'D'63;present 'D'63next 'D'1023;}Working code: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'0next 'D'55;present 'D'55next 'D'119;present 'D'119next 'D'247;present 'D'247next 'D'95;present 'D'95next 'D'127;present 'D'127next 'D'611;present 'D'611next 'D'357;present 'D'357next 'D'870;present 'D'870next 'D'87;present 'D'87next 'D'103;present 'D'103next 'D'39;present 'D'39next 'D'63;present 'D'63next 'D'0;}Many thanks,Georgian.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: December 09, 2020, 11:09:50 pm
content: I think the issue is that the PLD registers will reset to zero on power-up, and your not-working code doesn't say what to do in that case, so nothing happens.Should just be a case of adding a present 0 next 1023 line to the state machine.

author: georgian
author_rank: Regular Contributor
timestamp: December 09, 2020, 11:17:33 pm
content: I can't have any 0. I'm using the upper 3 bits for latch enable on some 4511 ICs. Having this pins LOW will show some unwanted 0 on the display.For example, my clock shows 00 00 00 -> 12 23 20 -> 00 00 00 -> 12 23 21 -> 00 00 00 and it should be 12 23 20 -> 12 23 21 - > ...I don't mind having the 0s on first start, but after that there should be none.EDIT*** 1023 is just a random number that dosen't do anything bad.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: December 09, 2020, 11:34:36 pm
content: Quote from: georgian on December 09, 2020, 11:17:33 pmSo adding a line as I suggested should solve the issue - it will only ever be 0 from power-up until the first clock pulse.As there is no "next 0" line, it will never return to 0For a simple example, if you wanted 123123 etc.0->11->22->33->1would output 0123123123....

author: georgian
author_rank: Regular Contributor
timestamp: December 09, 2020, 11:39:33 pm
content: Unfortunatly it dosen't work. I made the modification as you sugested and i get an error and the cod ewon't compile.Code:Code:Sequence counter {present 'D'0next 'D'807;/* present 'D'1023next 'D'55; */present 'D'807next 'D'119;present 'D'119next 'D'247;present 'D'247next 'D'95;present 'D'95next 'D'127;present 'D'127next 'D'611;present 'D'611next 'D'357;present 'D'357next 'D'870;present 'D'870next 'D'87;present 'D'87next 'D'103;present 'D'103next 'D'39;present 'D'39next 'D'63;present 'D'63next 'D'807;}Error:

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: December 10, 2020, 09:25:54 am
content: So you've effectively run out of space in the device. First thing to try is to initialise to a different state from the 0 power-up state, as there may be one that optimises better.Also try the inverted-output method.

author: georgian
author_rank: Regular Contributor
timestamp: December 10, 2020, 09:58:26 pm
content: 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.Code:field counter = ![Q9..Q0];Sequence counter {present 'D'0next 'D'960;present 'D'960next 'D'968;present 'D'968next 'D'96;present 'D'96next 'D'928;present 'D'928next 'D'896;present 'D'896next 'D'912;present 'D'912next 'D'412;present 'D'412next 'D'666;present 'D'666next 'D'153;present 'D'153next 'D'936;present 'D'936next 'D'904;present 'D'904next 'D'0;/*present 'D'904next 'D'0;*/}Thank you for the tip. Heave a great day.