SUCCESS!
Glad to hear it!
It's hitting the target. I was right about the encoder being much faster than CTRIO was expecting so I stepped the scale until I got good results. You were right, the scale is way off. I don't know why my calculations were not correct and that bothers me. I need to get the scale value correct, not just close enough.
Here is what I did. 1000Hz out runs the encoder Ch1A input at 400Hz as read by FREQCNT. I have the encoder set for 4X so that's 1600Hz input. 1000/1600 = .625 (10/16) What works is .15 (1/6)
I need to put a scope on the signals to see exactly what they are. Something's wrong, I need to find it!
I'm confused. Are you using the FREQCNT instruction? There is no way a PLC instruction can do that accurately, the scan is too slow. To accurately determine the input frequency of a CTRIO input channel, use the CTRIO's Rate scaling option on that channel. You could also also feed the channel's .iReg1 input into a SLOPE instruction, but the CTRIO will automatically do the work for you...and far more accurately. Be aware that if you use Rate scaling, iReg1 becomes the scaled data (if integer) and the raw position gets moved to iReg2.
So yes, you are right and this is the core of the problem...your actual encoder speed is much higher than what you thought and the resulting scale ratio was wrong. As I mentioned before, that has been the issue in every case to date...and the only reason I didn't push it was due to concern that the VFD was introducing new unknowns.
I discovered a problem not in the documentation for CTRUNPOS. I have it set a bit on error. My program does not clear that bit. When CTRUNPOS is run with the bit set it delays for 10 seconds, resets the bit then physically runs to completion BUT does not set "On Success". It stalls in the Stage waiting to jump on success. If I clear the error bit first it runs correctly. That needs to be noted or fixed whatever is appropriate. I think it should clear the bit on execution then run to completion.
I'm a bit skeptical here. The first thing the instruction does is to clear both the Success and Error bits, and the program doesn't need to clear it. That is a standard methodology we use with every device centric instruction. It is well tested. I just tried a CTRUNPOS with bits for success and error, and also tried it with a transition to stage on success and a bit for error. In both cases, with the error bit set, it immediately cleared the bit, ran to completion, and set the success.
Remember that CTRUNPOS doesn't execute, at all, if the stage it is in is disabled. You might also check the xref to make sure that the error bit isn't being used somewhere else in the program in some way that might be conflicting with the CTRUNPOS box.
Thank you for looking into my problem. Last year when I was planning the project design I inquired about this application. You said you thought it would work. I was not going to rub it in your face but don't need to. Your were right, it works. I still need to tweak it and set up the rest of the moves. I need to see how loading will effect it and if there is a temperature effect. The machine will not be temperature controlled.
I just reread my responses to your initial request. I would hardly consider what I said to be a glowing endorsement of the concept, I although I allowed that it might work. I also said that the VFD might create some latency that would prove to be a problem. Nevertheless, it did work...and I'm very happy for you.
BTW,I didn't get instruction I asked for on saving a Trend and sending it. Do use FILE, EXPORT, PROJECT?.. I would like to save waveforms but can't determine how.
On the toolbar of the Trend View, there are options for exporting ("Exp") and streaming a running capture to disk ("Rec"). The export option gives you the ability to specify how the data is generated. Both of these options generate text data files that can be loaded into a spreadsheet for post processing or viewing.
You can also do screen grabs with a screen capture tool. I personally like Screen Hunter.