WAGO 750-638 (2 channels, 16-bit, 500 Hz)

Hello

I am working on a project to read values from various flowmeters via the WAGO 750-638 module (2 channels, 16-bit, 500 Hz). Unfortunately, I don’t know where to start on the CODESYS 3.5 side.

Would you have a tutorial or documentation that could guide me regarding the hardware configuration of this card, the functional blocks (FB/FC) to use, and the integration into CODESYS?

I haven’t found much on the forum aside from the module’s technical documents.

Thank you in advance for your help.

This module doesn’t have complex operation that requires the use of any special library or function blocks. Use the “Process Image” section of the 750-638 hardware manual as your guide to operation, and then simply map variables to the various process image inputs and outputs in the module’s “KBus I/O Mapping” area.

Hello

Thank you for your feedback.

The idea is to read pulses and increment the two counters (reading in only one direction).
I added the card and declared my variables, as well as created my persistent variables (the two counters that will be exposed via OPC UA).
Normally, my S0 (cpt1_status) and S1 (cpt2_status) inputs should be equal to 0 (00000000b), I did the initialization in my main program (is this correct? I don’t think so because each time it will reset my S0 and S1).

1/ How can I test whether I have indeed received a pulse in order to increment my counter?
2/ I’m afraid either of missing some pulses or, conversely, of counting the same pulse multiple times.

The Status bytes (i.e. Cpt1_Status) is read-only from the PLC-code. This is an INPUT to the plc, generated by the 638 module itself to indicate some status conditions. So instead of trying to set it to zero, you would monitor it for various conditions and then take action if needed.

Please don’t declare your Persistent Variable within the “VariablePersistent” object itself. This can lead to issues. Instead, declare your CompteurTot1 variable within PLC_PRG or a GVL. Then open the VariablePersistent object in a tab, right-click, and choose “Add all instance paths”. Use that variable in your programs using the declared namespace, not the VariablePersistent namespace.

Remember that the 750-638 module is inherently a counter input. It will count the pulses for you and the result will increment Compteur1 all on its own. Some plc code will be required if you want to store this value as a persistent retained variable. The module itself will reset to zero on power up. You will need to create a routine to use the “Counter setting value 1” and _OUT1 control byte to transfer your retained value into the module on power up. Then the counter can increment from there (and other code can take that value and load it back into the retained variable).

thanks for your feedback,

I wanted to confirm a few points with you:

  • Normally, it’s not necessary to reset the physical counter (set_compteur1) — it automatically resets to zero after a restart or power outage, correct?
  • Is it the same in case of overflow? Should the value to test be <65535 or 65536? It’s not very clearly detailed in the manual, and I’m concerned there might be an offset or that I might miss a pulse.

I declared my variable compteurTot1 (persistent) as REAL, and I associated it with a variable of type WORD to handle the overflow. Could that cause a problem? Or should I instead manage the MSB and LSB separately (most significant bit and least significant bit), then combine them into a REAL variable afterward?

thanks in advance

Correct, you don’t need to initialize the module counter to zero on boot, it always starts at zero after power cycle.

The overflow behavior is controlled by Control Byte bit 0. If bit 0 is off, the counter won’t rollover beyond 0xFFFF, it will freeze there. If bit 0 is on, the counter will automatically rollover from 0xFFFF → 0x0000.

thank you for your help and your responsiveness

I believe that if I disable bit 0, the counter will not exceed 0xFFFF but will reset (in my case to 0x0000) and start counting again until it reaches 0xFFFF once more. It won’t remain stuck.

I set 0 (b00000000) when configuring the board for C0, C1; normally there’s no need to write to these variables again—my counter will automatically reset after reaching 0xFFFF, meaning there’s no need to read S0 and S1 and take action.

Sorry, my mistake, you are correct. I looked at the highlighted description too quickly - the “0” condition is the automatic rollover when overflow occurs.

Hello,

I have four WAGO APIs, each equipped with several impulse cards.

On one of the cards, the counter value remains stuck at 1, and the card no longer counts. However, I know it has counted before, as the totalizer contains recorded values.

I have tried restarting/resetting the API, but the issue persists: the read value remains 1 on both channels of the card.

Unfortunately, I do not have a spare card to perform a test (a purchase request is currently being processed). I would like to know if the problem could be coming from the card itself or from another component (for example, the API program), given that the same code is used on all APIs.

Any advice or feedback would be appreciated.

Thank you in advance.

You mention “several” impulse cards. If you have more than one on the same system, try swapping their physical positions (including swapping the wires) to see if the issue follows the module or follows the assembly position. If the issue follows the module, you probably have a hardware problem. If the issue follows the assembly position, you probably have a wiring or sensor problem (or an API issue).