Sign in to follow this  
Followers 0
Ron Macam

CNT Question

14 posts in this topic

Hi mates, Can i use the CNT to count until 300,000 times? Thanks again guys for the much help :D

Share this post


Link to post
Share on other sites
Hello Ron, I suggest you download the programming manual for this CPU series, which includes a detailed description and usage examples of all instructions, including the CNT instruction. We can keep answering your questions, but with just the answers you will not learn as to why it is like it is. One of the important things when using instructions, is to know how to enter the operands, and what you can use as operand data. Register at myomron.com, go to /downloads/1.Manuals/PLCs/CPUs/CQM1H/ and download manual W364-E1-04. Small hint: here's what it says about the SV operand of the CNT instruction...

Share this post


Link to post
Share on other sites
Yep, but will we keep answering the simple questions??? I saw this question, and did think come-on, but there will always be someone that answers the simple ones, & we all learnt somewhere.... Another hint.... why would one want to count to 300,000? Why not break it up into more manageable quantities? As you should know, a 16-binary no is limited to 65535, and a BCD no 9999, in the short form that is.... The CQM1 is BCD based, you possibly need to research computed numbering systems. Edited by lostcontrol

Share this post


Link to post
Share on other sites
Thanks for the link on the manual :D

Share this post


Link to post
Share on other sites
Another hint...forget the counter and increment or decrement a double register

Share this post


Link to post
Share on other sites
pfort is right ;) I will assume a CJ/CP1L/CS series and in this case use a differentiated version of the instruction ie @++L D0000 every time you want to count Then do a simple >=L compare to set a bit and reset the counter if you want to ie @MOV &0 D0000 @MOV &0 D0001

Share this post


Link to post
Share on other sites
Hi mate, I manage to simulate the @++L instruction on CJ1M, but im using CQM1H so what's the equivalent instruction? Thanks again

Share this post


Link to post
Share on other sites
Look up the ++ instruction in the CJ1M manual (or help file), then find the corresponding instruction in the CQM1H manual (or help file)...

Share this post


Link to post
Share on other sites
"INC" Increment instruction is equivalent except that you can only increment a single word with it. If you need to increment a dble word i suggest ADDL. That is a dble word addition. Theses instruction are BCD, so you may need conversions between binary and BCD.

Share this post


Link to post
Share on other sites
Sry, didn;t know you were using a CQM1H, as pfort suggest you will need to in this case use BCD math ie numbers with #. and as pfort suggests a single word BCD can only go to #9999 therefore for a double word length use the ADDL function.

Share this post


Link to post
Share on other sites
You can still use @INC then when word 1 reaches 9999 do a compare and @INC word 2.

Share this post


Link to post
Share on other sites
Could the CY (carry flag) be used in this case ? Havn;t tried it. then no need for comparison, hopefully go back to zero and CY flag turned on to INC next word.

Share this post


Link to post
Share on other sites
Interesting thought Sleepy - you must have woken up momentarily.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0