Sign in to follow this  
Followers 0
gleblanc

Analog Input Questions

10 posts in this topic

Hi guys. Working on setting up my analog input module (Q00CPU with a Q68ADI card). I'm not entirely sure if I've got all my ducks in a row, so I'd appreciate a double check. CPU and cards are as follows: Q00CPU QX40 QX40 QY50 QY50 QJ71C24N-R2 Q68ADI Q68DAIN This gives me a starting address for the Q68ADI of 0x0060 (because the serial module is 32 points, and all other modules are 16 points) I would like to read input on channels 1 through 7 (inclusive). I'd like to average the values over a 3 second range. Here's what I've written for the setup parameters LDP X60 TO K6 K0 H7F K1 TO K6 K9 H7F7F K1 TO K6 K1 K3000 K7 SET Y69 LD Y69 ANI X69 RST X69 I'm fairly confident I've written the above correctly, based on the manual. Now I get into the sticky part. I'm assuming that the A to D conversion happens continuously, and that the intelligent module handles the averaging internally, using the data from now back 3 seconds. What I want to do is read the channel values independently. I see that in the buffer memory (memory address 10; Un\G10) there is an A/D conversion completed flag. Can I address this directly, using bitwise operators? I'd like to do something like: LD T12 AND X60 AND U6\G10.0 FROM K6 K11 D11 K1 Which should check that my timer is done, the module is ready, Channel 1 conversion is complete, and then read the channel 1 value into D11. Will that work? Thanks, Greg I've also attached the complete project for GX Developer, in case I screwed up the conversion to Instruction List. November 2010.zip

Share this post


Link to post
Share on other sites
I'm not steady in GX Developer (in fact I don't have it on my machine), but the addressing is correct!

Share this post


Link to post
Share on other sites
I don't believe that will work. According to my reading of the manual, the A/D conversion flag only resets when you turn Y9 on (section 3.4.7 point 2). That means you will need to be constantly cycling that bit on and off to reset the conversion flags. Plus, you can't reset them individually, so you would need to wait till the are all set before you can reset them all. If you need to read both immediate and averaged values, I would recommend turning off the averaging in the card and average using some PLC code. Incidentally, if you want to make your code more readable, then you can use MOV and BMOV commands instead of TO/FROM commands. Use the Un\Gn addresses to access the buffer memory locations. The TO/FROM commands have a slight speed advantage for moving blocks, but for moving individual data it's the same.

Share this post


Link to post
Share on other sites
Something like: MOV U6\G11 D11 vs. FROM K6 K11 D11 K1 Seems like six of one and half a dozen of the other to me. The first one is a normal MOV instruction, so you have to read the arguments to figure out that it's doing something "special" (reading from the A/D card). The second one is a FROM instruction, which immediately says "Hey, I'm not just coping data around in memory." There are more arguments to the second instruction, though if you do a BMOV, you've added another argument, and now they both have identical information (the MOV command lacks the length argument of the FROM instruction). Mostly just playing devil's advocate there. Hmm, in ladder view the MOV is more readable, since the "U6\" sticks up above the MOV. What does it look like in the new fangled software? Greg

Share this post


Link to post
Share on other sites
If you don't care about immediate values then you don't need to worry about the conversion flag. Conversion is continuous. I find the MOV instruction to be more intuitive because you aren't using constants for addressing since that's done by the Un\Gn address. It's just easier to read. EDIT: It looks the same in the new-fangled software. I haven't found significant differences except that you don't have access to Instruction List. Edited by JRoss

Share this post


Link to post
Share on other sites
In your example code, you should reset Y69, not X69 but i assume this is a typing mistake. If you want the card to average, then write to the card: average processing + average time + the value of the average time (in milliseconds). Seems ok in your example. You can then read the values from the card every scan. The card will do the averaging internally and one can not know when the card puts it out (there is no flag that signals a new value has been calculated). But the value will only change each 3 seconds, even if you read the values continuously. So in your example, the timer is not necessary. Just do the FROM instruction every scan. You can use the timer if you want to reduce the number of read instructions to the card but there's not really any point in doing so. The conversion completed flag is only used when for example you initialise the card (like you did in the first program using Y69). After initialising, the conversion completed flag goes to off and only goes on again after the first conversion is done. After that, it stays on. For example, if channel 1 has 3 seconds average time and channel 2 1 second, then after initialising, the conversion completed flag of channel 1 will turn on after 3 seconds and the one from channel 2 will turn on after 1 second. It means the channel has done it's first average measurement and is ready to be read. So you should use it to avoid incorrect measurements after initialising. I assume there are other instances when the flag goes down (see the manual). Also, there is a general conversion completed flag (an X) and a conversion completed flag for each channel. I tend to agree that the U\G notation is easier to read and use than the FROM TO and it's the default that is used in manuals these days. But it doesn't matter as the result is the same so use whatever you're comfortable with. I think i read somewhere in a manual that the U\G notation is a bit faster than FROM TO. You can even use for example Un\Gn.0,... in your code. However, Mitsubishi warns that if you need to use a lot of those, it's better to read once, move the result into a dataregister and use that instead. Because with every Un\Gn, you are actually reading from the card. Hope this helps. Edited by Mitsu

Share this post


Link to post
Share on other sites
Thanks much, very helpful.

Share this post


Link to post
Share on other sites
It depends on what you need it for. The card averages 3 seconds of values and sends out one new value each 3 seconds but you don't know when. Since in your case, measures should only be taken during a certain period, you could probably make an average value yourself. Set the measurement time small (depending on how many measurements you want to take) and take samples during the measurement period, add them and at the end of the measurement period (meaning your own measurement period), divide by the number of samples you took. So in short, always measure with the card (using a small average time to be able to get a good amount of samples) and use the program to decide what (and when) you want to do with the measured values. Just an idea based on what you wrote. Edited by Mitsu

Share this post


Link to post
Share on other sites
I haven't used the time averaging before, but the sample averaging does change after each conversion using the last x samples. I would think that the time averaging does the same. A simple test would confirm this. Note I said conversion, not scan. They are rarely the same. It doesn't usually matter, but of it does the conversion rates are in the manual. The comm speeds of the FROM/TO and Un\Gn instructions are there too.

Share this post


Link to post
Share on other sites
In the case of using an average time (a number of times can also be used), for example 3 seconds, the card takes multiple samples within these 3 seconds and calculates the average at the end, disregarding the minimum and maximum measured value. The amount of measurements within the average time period depends on how many channels are active on the card. As an example in the manual, 50 ms average time with 4 channels active will result in 104 samples being taken and then averaged. But in the end, even if you read from the card each plc scan, you will only get a new value each 50ms and it will be the average from +/- 104 samples. Edited by Mitsu

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