Jump to content

Frequency measure and retain tags in struct?


Hannari

Recommended Posts

Hello,

 

I have a remote IO device that among other things has a digital input that’s connected to an inductive sensor that is placed so it measures a point on a wheel. This is then transferred to my UniStream through CAN.

 

Now I want to measure the frequency so I can then calculate the RPMs and linear velocity.

 

I have been using Somachine (Codesys) where there is a simple frequency measure block dedicated for this. I cannot find one in UniLogic and have been trying whit various contacts, coils and timers with no luck. J Any Ideas how I can do this?

 

Another question, can I not retain tags that are inside instances of structs? I will have multiple IO units like this one that I have made a struct of with around 40 tags. Many of these tags I need to be able to set at the HMI and keep after reboot or power failure. I cannot believe that it is not possible!

 

Please Help.

 

Best regards,

Ari

Link to comment
Share on other sites

How are you bringing the input into the UniStream? Are you using UniCan or another CANbus protocol? How often is this input updated, only once per rotation?

 

If you are using a protocol to transfer the status of a digital input, you would need to generate logic to increment a count each time the input is turned on. Math functions could then be used to predict the RPM calculation based off of the amount of inputs triggered within a set amount of time. The only issue is that if you only count how many inputs came in over the last second you will need to multiply the count by 60 which limits your resolution to 60hz at a time.

 

You can absolutely retain tags and structs within UniLogic. When creating a global instance of a struct make sure to select the retain value check box on the right side of the properties window.

Link to comment
Share on other sites

I will be getting the input through CANopen. The sensor, senses a spot on a turning wheel once per rotation. I will increase those spots if I see that I need higher resolution.

I have been trying to do what you are suggesting Alexander, with incrementing a counter and timing it. However, I am not getting it to work.

I was going to use an encoder in the beginning but thought it would both be simpler and cheaper, just to count the revolutions using an inductive sensor and a metal bolt in the wheel since I do not need that high resolution. But after finding a 400-pulse encoder for $13 in China I have gone back to my original plans. Now I am just waiting for my new encoders to arrive.

Thanks for the hint on the Struct issue. So if I want to have some values retained while others would go back to a preset value at power-up. Do I then need to make two Structs, one for the retained ones and one for the power-up/initial tags? 

Link to comment
Share on other sites

An encoder would likely allow for much greater accuracy and some may even have built in registers for RPM readings.

 

Tags can that have power up values will always overwrite data upon cycling power, so retaining the values would not help. Depending upon how you need to uses the values you could have two separate structs, one with power up values and one that is retained. Though you would need to set up logic for when to use each one.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...