Host Engineering Forum

General Category => CTRIO and CTRIO2 => Topic started by: rgbarr on November 24, 2020, 06:01:17 PM

Title: Do-More H2 & CTRIO2 - Not getting expected output
Post by: rgbarr on November 24, 2020, 06:01:17 PM
I have a Do-More H2-DM1E with a CTRIO2 module using a quadrature encoder. I have it configured to read RPM. I have the output of the CTRIO counter saved as an integer value a D register in the Do-More.The output in the register does not match what I see in the monitor screen. I've tried BCD and floating point values also.The monitor value is correct but the value in the D register doesn't correspond to anything that can I can make sense of. I've used this same configuration with a DL-250-1 many times and never had a problem though in that case the values are stored as BCD in consecutive V registers. I've added an attachment showing the values I'm getting in Data View as well as the configuration of the CTREGRD. The value in the D1 register does not change even if the input to the CTRIO is removed. The value it shows is completely arbitrary. Am I missing something in the configuration?

Any help would be greatly appreciated.
Title: Re: Do-More H2 & CTRIO2 - Not getting expected output
Post by: Greg on November 25, 2020, 04:56:23 PM
Hi rgbarr, I'm pretty sure (off the top of my head) that if you are scaling the count (i.e. you are doing RPM), then the value that will be designated as "Ch1Fn1 Accumulator" will be in $CTRIO_005_C1F1.iReg2 and not .iReg1. I don't have one configured to test at the moment, so I could be wrong.
Title: Re: Do-More H2 & CTRIO2 - Not getting expected output
Post by: rgbarr on November 30, 2020, 10:32:58 AM
Register 2 gives the raw encoder count with no scaling. The register 1 value is correct but when reading the register using CTREGRD with the Source Register as "0 - Ch1Fn1 Accumulator" and the destination as D1, I found that by using Scan Toggle to trigger CTREGRD, it will update D1 but with the Register 2 (raw value) not the scaled value. How do I read Register 1?
Title: Re: Do-More H2 & CTRIO2 - Not getting expected output
Post by: franji1 on November 30, 2020, 11:00:33 AM
In Do-more, if you've configured the scaling for that channel, there should be a heap item for that channel/function with a .fReg1 member
Title: Re: Do-More H2 & CTRIO2 - Not getting expected output
Post by: rgbarr on November 30, 2020, 01:03:15 PM
I was able to copy that heap item to the D1 register. Either the CTREGRD command doesn't work as expected or I'm misunderstanding it's usage.

Thanks for your help.
Title: Re: Do-More H2 & CTRIO2 - Not getting expected output
Post by: Greg on November 30, 2020, 04:32:13 PM
Upon closer examination of what you are doing, if you will notice your picture shows ST1 ($On) as the input to the CTREGRD. This will not work. CTREGRD's input leg is edge-triggered as denoted by the little triangle. When I experimented with this my raw count was stored in .iReg2 and the scaled RPM value was in .fReg1 because I chose floating-point in the scaling. If, however, I chose the scaling to be integer, then the raw count was still showing up in .iReg2, but the scaled RPM value was not in .iReg1 instead of .fReg1.

However, each execution of the CTREGRD instruction would read the raw counts value in .iReg2 each time. But this is not a continuous read. As franji1 pointed out, there is no need to do a CTREGRD instruction unless you are trying to remember a count on a power-up or something. But that's another story.