Sign in to follow this  
Followers 0
shane

High speed counter

20 posts in this topic

Hi, I am using a CPM2A with connected encoder (300ppr) to input 0.00, 0.01 and 0.02. I have set the high speed counter to up/down input mode with software reset and want to use comparison table to give an output if the count is between specific range. My problem is this: 1. The PV value cannot be reset when input 0.02 is ON. What am I doing wrong? 2. I have also program a PRV(62) to read the PV value and store in DM100. When I turn the encoder, I can see the value in SR248 is changing but DM100 remains 0. Can the PV be stored in DMs this way? I am using the encoder attached to a rotating shaft to give cam outputs. Thanks.

Share this post


Link to post
Share on other sites
I tried to attach my program along, but it doesn't appear in the post. How do I do it? High_Speed_Counter_test.cxp

Share this post


Link to post
Share on other sites
First rule of thumb is that i never use the PRV instruciton to read the counter value every scan unless it is absoultely required to do so. Why ? becaue of the excution time of the instrctuin can can other problems. If you want to look at the valuse simply monitor the double word of 248,249 in your watch window. This might be the problem without looking further into the program, i will have a quick look at it though......

Share this post


Link to post
Share on other sites
In regards to your code. good first effort.... However a couple of points.... Only execute the CTBL once. Ie on a posititive edge transistion. This can be achieved with the @ placed in the insctruction @CTBL or alternatlvely use the first scan bit like you did every where else. Also i would register the date as you have done before executing the CBTL insction. Move this CTBL instruciton to after the reg of the data. Remove the PRV altogether as mention in above post. Have in internal bit triggering the reset bit of 252.00 as a coil.. Give this a go and let us know how you get on..

Share this post


Link to post
Share on other sites
Thanks. I have modified the program accordingly: - removed PRV altogether - use 1st scan bit for CTBL - programmed CTBL after registering data - added input 0.02 to trigger 252.00 The comparison works at low speed. However, at faster speed (about 400rpm), the counter value (at 248) registers more than 1000, which means the input 0.02 never resets it. At 400rpm with 300ppr, the frequency is about 2kHz but the maximum achievable is 20KHz for up/down mode. Why can't it reset? Also, I read in the manual, there are hardware and software reset. What is the difference? If input 0.02 is used to reset 252.00, is this considered hardware or software reset? HSC_modified.cxp

Share this post


Link to post
Share on other sites
If you are using the z phase to reset the counter ie input 2 then i suggest that you look at the settings if the use of the high speed counter. In you program u have got software reset only enabled. Tick the Z phase and software box and giva a go. I have only used the software reset in the past (you could set up the last range to do this. Mainly because if the machine is shut down the High Speed Count Data is lost. Have a Merry Christmas and a Happy New Year.........

Share this post


Link to post
Share on other sites
I have tried previously changing the settings but to no avail. (Setting=Z-phase and software reset) I have abandoned the idea of hardware reset and set up as you've mentioend. I am using the last range AR11.07 (comparing HSC is in the range of 300 and 300) to reset 252.00. My concern is only this: 1. I reset the HSC if it is within range 300 and 300. Would this cause the increment to count less one pulse for every rotation, causing the cam output to drift after running long time? 2. How do I set up for more than 7 comparison ranges? I remember if using instruction HDM (old instruction from C28K) that is has 16 ranges. Thanks for bearing with me Merry Xmas and Happy New Year.!! HSC_modified.cxp

Share this post


Link to post
Share on other sites
See attached functionality from the programming manual. I remebered this just today and looked and up and it confirmed what i thought. You for hardware / sftware reset you must have the 252.00 forced on all the time then the input 0.02 will reset the counter.... As regards to more comparisons, i do not think that you can set more then 8 ranges in range compare however 16 targets can be set for target comparison. In regards to the old C40k, with out looking into to it to deeply, i believe that the instruction you are referring to is scan dependant. That is it is refreshed efvery cycle of the scan time only not indepandant as is the case for the CPM2A. Jay might correct me if i am wrong. Therefore i believe that you could use the BMCP instruction and compare it to 248. This will give you 16 ranges to work with.

Share this post


Link to post
Share on other sites
Thanks for reminding me of using BCMP. That might work if in need for more ranges. With regards to forcing 252.00 to ALWAYS_ON, i doubt that it'll work based on what i read in the manual; that is to turn OFF 252.00 following a reset from 0.02 for at least one cycle time (i wonder how to program this), but i'll give it a try anyway tomorrow.

Share this post


Link to post
Share on other sites
You could use the scan flag into a counter and count to 2 to ensure the bit is off, or on for at least 1 cycle.

Share this post


Link to post
Share on other sites
Funny how those old tricks come into use today.

Share this post


Link to post
Share on other sites
Here is an even funnier old trick. Came across an old C20. Very limited memory. Had an expansion rack. Memory area is chockers with program. Changes to be done. Compares to be used. Counters use 1 less word than compare function and = > flags. Mission accomplished. Next guy that came along would have been scratching his head for hours.

Share this post


Link to post
Share on other sites
Hmm, i've looked everywhere for scan flag (for CPM2A), where can i find it?

Share this post


Link to post
Share on other sites
It appears the CPM2A does not have one as I have been unable to find it also. Perhaps you can use the cycle too long flag and set the cycle time detection below the actual cycle time. I am not sure if it will work but is worth a try.

Share this post


Link to post
Share on other sites
How about 2 scan flag? LD NOT 219.00 OUT 219.00

Share this post


Link to post
Share on other sites
Thanks Jay, but unless 219.00 is a special relay (2 scan flag); which i cannot find in CPM2; the count at 248 would not reset if the encoder is turning fast. I have tried with internal relay (200.01) and programmed as you recommended: LD NOT 200.01 OUT 200.01 200.01 will be ON for the second scan, but at 3rd scan, 200.01 will be OFF, and ON again at 4th scan. If the reset input comes in at the 3rd scan, then it would not reset. At about 400rpm and 300pulse/rev, this would mean 2kHz (or 2 pulse/msec). My average program scan time is about 10.0ms, that means there's a great chance it would not see the reset input. Btw, is it possible to try interrupt input (at input 0.03 to inc, 0.04 to dec, 0.05 to reset to 0)? This is getting harder than i thought it would be.

Share this post


Link to post
Share on other sites
Just a thought....havn;t got a cpm2a to try but since input 0.02 is set for High Speed counter doens't this mean that ther is no filter on this input, therefore if it goes high during a scan then automatically it would be registered as having turned on? Therefore if you were to code this normally in the ladder logic to fire a DIFD you could reset the bit on the negative transistion for a single scan...see where i am going with this????

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