I’m trying to work with my Groov EPIC learning center in CODESYS. I’ve configured the momentary button (module 0, channel 1) to use the counter feature. This works as expected. As you can see in the screenshot below, I’ve mapped the Feature Value
channel to a UDINT
variable that updates when the input is toggled on.
I’m having trouble resetting the counter, though. I see where I need to do it under “Discrete Inputs Control”, but I can’t map the Feature Clear
channel to a BIT
or BOOL
variable. I can create a variable using RESET_COUNTER AT %QX1.2 AS BOOL;
, but that doesn’t work if I have multiple devices and I want to map the reset to a field inside a STRUCT
. Anytime I try to enter a variable path starting with “Application,” I can’t type a period in the path for the Feature Clear
channel.
Am I missing something here? Going about this entire incorrectly?
You have to create a new variable not map to an existing one. Add the tag name without anything before it and when you call it in the code do the same.
1 Like
@JCampbell: I figured out that I could do that, but just wondered if there is a reason why I can’t map it the same way I do other items. I can make it work either way, I guess, but it’s a whole lot less convenient this way.
At first the way Codesys maps variables to IO seems inconvenient but I would suggest to keep your logic code separated from I/O mapping. In other words, just create a regular non mapped variable in your code and map it in the mapping I/O screen.
There are a few reasons for this. First you can reuse code by creating multiple instances. For example, if you have a function block that represents a flow meter, when another flow meter is needed you can just instantiate another instance of your flow meter function block and just map the variables to the new function block.
By mapping your variables in your code the code is less general and built for a single purpose. I found this video useful for when I was starting out with Codesys.
I find it useful to create mapping routines. This way you do not have to do a full download if you need to move a tag. You can create map input and output routines.
1 Like