# Program/thread to create global variables to count total # of parts formed everyday

**URL:** <https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181>\
**Category:** URScript\
**Created:** [August 9, 2022, 6:07pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181 "2022-08-09T18:07:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon92957640](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon92957640](https://forum.universal-robots.com/u/anon92957640)\
**Post date:** [August 9, 2022, 6:07pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/1 "2022-08-09T18:07:27Z")

</div>

I use a counter to count the total number of parts formed by the cobot using global variables. However, I would like to track how many parts are formed in every specific day. I am hoping this is something easy that I am unable to figure out, any assistance would be appreciated.

Clarifying:  
I already have a counter and a Global variable in the Installation tab that counts the total number of parts formed.

I am however looking to find out how many parts are formed everyday the cobot runs. I need a script in the program that creates a new global variable everyday, stores the number of parts formed. I am looking to find out if there is a way to use the date from the controller to create a variable everyday.

---

<div class="post-metadata">

**Author:** ![anon507564](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@anon507564](https://forum.universal-robots.com/u/anon507564)\
**Post date:** [August 9, 2022, 6:25pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/2 "2022-08-09T18:25:47Z")

</div>

Are you looking for something like a variable in the TP or like something you can export to a spreadsheet?

For the former you should be able to create a counter variable in your Installation then add a counter to your program(s) to increase that counter by 1 every cycle.

In the Installation Tab:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/5/5a2ef07bea483117066711b842b551844e568c80.png)

in the program(s)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/b/b332f3d3693d74a664ec22091a116499ef519420.png)

I haven’t tested if this is modal when you power off the TP but it is when the robot is powered down.

:edit: I tested modality and it seems to work, but I’m only running on the simulator not the physical cobot because it’s running production.

To reset the counter you can change the value in the Installation tab.

For the latter you’ll have to wait for someone much smarter than me to help you export the variable.

Oh, look, a pregnant man emoji. 🫃 So dumb. 🙄

---

<div class="post-metadata">

**Author:** ![anon92957640](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon92957640](https://forum.universal-robots.com/u/anon92957640)\
**Post date:** [August 9, 2022, 6:43pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/3 "2022-08-09T18:43:33Z")

</div>

Thanks for the reply, however, I already have a counter and a Global variable in the Installation tab that counts the total number of parts formed, like the one you described.

I am however looking to find out how many parts are formed everyday the cobot runs. I need a script in the program that creates a new global variable everyday, stores the number of parts formed. I am looking to find out if there is a way to use the date from the controller to create a variable everyday.

---

<div class="post-metadata">

**Author:** ![anon507564](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@anon507564](https://forum.universal-robots.com/u/anon507564)\
**Post date:** [August 9, 2022, 6:54pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/4 "2022-08-09T18:54:30Z")

</div>

Oh, ok. I misunderstood.

I don’t remember ever seeing a date or time variable. However, the RUN tab has a counter in it so there is something somewhere, just have to find it. 🙂

I imagine you could use the existing Timer variable and just count out 24 hours in a thread, but I foresee a lot of issues with that.

Sorry I couldn’t help otherwise.

🫃 Must be distracted by the pregnant man emoji. 😂

---

<div class="post-metadata">

**Author:** ![MikeM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mikem/32/3114_2.png) [@MikeM](https://forum.universal-robots.com/u/MikeM)\
**Post date:** [August 10, 2022, 2:41am UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/5 "2022-08-10T02:41:05Z")

</div>

Check this URcap out: [Get Controller Time](https://forum.universal-robots.com/t/urcap-sample-get-controller-time-in-urscript/1256)

This was built some time back, if you’re savvy with JavaScript/Python (or possibly have created a URcap before) you can modify this one to check controller time each day. You may need to add some functions for DateTime, but you could create a function to verify time elapsed and reset a count.

I’ve messed with this abit unfortunately I haven’t had the time or capacity to reconstruct the URcap (personally… I would like to see these functions added to Polyscope in future update)

**Note: if you plan to use a function involving time, like any PC if its not connected to the web it will drift so make sure to update the time in the robot settings if it’s running offline.**

---

<div class="post-metadata">

**Author:** ![anon507564](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@anon507564](https://forum.universal-robots.com/u/anon507564)\
**Post date:** [August 10, 2022, 12:34pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/6 "2022-08-10T12:34:32Z")

</div>

> [@MikeM](#):
>
> I would like to see these functions added to Polyscope in future update)

2nded (seconded?)

I’m actually surprised nobody has wanted/needed a Time() function in URScript.

And why is that pregnant man emoji still here? Does UR _really_ think that’s possible? 🫃

---

<div class="post-metadata">

**Author:** ![WattsUp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/wattsup/32/5732_2.png) [@WattsUp](https://forum.universal-robots.com/u/WattsUp)\
**Post date:** [August 10, 2022, 1:24pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/7 "2022-08-10T13:24:18Z")

</div>

Do you plan to clear those variables after so long?

I would be concerned about a every growing variable list. It would certainly make it difficult to find the info youre looking for.

---

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [August 10, 2022, 1:47pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/8 "2022-08-10T13:47:50Z")

</div>

3rded (Thirded)

I’d welcome this feature for processing FIFO in a curing station.

---

<div class="post-metadata">

**Author:** ![anon507564](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@anon507564](https://forum.universal-robots.com/u/anon507564)\
**Post date:** [August 10, 2022, 2:05pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/9 "2022-08-10T14:05:34Z")

</div>

> [@WattsUp](#):
>
> Do you plan to clear those variables after so long?

Initially I thought he was gonna reset every 24 hours. But re-reading his post he does say

> [@anon92957640](#):
>
> that creates a **new global variable everyday,**

So valid question. 🙂

Obligatory pregnant man emoji 🫃

---

<div class="post-metadata">

**Author:** ![anon92957640](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon92957640](https://forum.universal-robots.com/u/anon92957640)\
**Post date:** [August 10, 2022, 4:39pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/10 "2022-08-10T16:39:40Z")

</div>

Yes, to keep the Global Variables list clean, I would reset the variables every month.

---

<div class="post-metadata">

**Author:** ![anon92957640](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon92957640](https://forum.universal-robots.com/u/anon92957640)\
**Post date:** [August 10, 2022, 5:37pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/11 "2022-08-10T17:37:25Z")

</div>

This works perfectly, I can now use these functions to create a script to generate, store and reset the daily counts. Thanks.

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [August 11, 2022, 1:54pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/12 "2022-08-11T13:54:23Z")

</div>

If it gives you any peace of mind, the forum is almost certainly just using a generic Android or similar API for importing emojis. So if you’d like to take up arms against the pregnant man emoji you can email Google and Apple. 🙃

---

<div class="post-metadata">

**Author:** ![anon507564](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@anon507564](https://forum.universal-robots.com/u/anon507564)\
**Post date:** [August 11, 2022, 3:42pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/13 "2022-08-11T15:42:55Z")

</div>

UR has the ability to add/delete emoji’s as they see fit. I find it sad that a forum based on supposed physical science would see this as acceptable.

Pretending to be something you’re not is fine, people do it all the time. But expecting society to go along with your imaginary world is offensive at best.

🫃

🤡

---

<div class="post-metadata">

**Author:** ![sven.gleich](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sven.gleich](https://forum.universal-robots.com/u/sven.gleich)\
**Post date:** [August 15, 2022, 2:19pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/14 "2022-08-15T14:19:43Z")

</div>

Another idea is to write the amount of parts every day at the end of the day in the log file and then clear the variable. In the log file you have automatically date and time written. (This is how we do it and keep the daily production figures.)

---

<div class="post-metadata">

**Author:** ![abelch](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@abelch](https://forum.universal-robots.com/u/abelch)\
**Post date:** [August 15, 2022, 3:06pm UTC](https://forum.universal-robots.com/t/program-thread-to-create-global-variables-to-count-total-of-parts-formed-everyday/23181/15 "2022-08-15T15:06:36Z")

</div>

Another option would be a 3rd party URCap, if the robot is/can be connected to the internet.  
We have used Insights by Robotiq and Beacon by Hirebotics to get KPIs. They save history and you can see them from your PC/Phone.

See the links below for more info. Free/Pricing info is listed on their pages.  
[Insights (robotiq.com)](https://insights.robotiq.com/)  
[Beacon: Cloud Software for UR Cobots (hirebotics.com)](https://www.hirebotics.com/beacon)
