Re: [Beremiz-devel] Beremiz-devel Digest, Vol 89, Issue 1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Beremiz-devel Digest, Vol 89, Issue 1

Beremiz-Devel mailing list

matiec return -8

Latest software versions matiec and Beremiz from https://bitbucket.org/skvorl/.

Project see attachment.

09.04.2018 17:07, [hidden email] пишет:
Send Beremiz-devel mailing list submissions to
	[hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
	https://lists.sourceforge.net/lists/listinfo/beremiz-devel
or, via email, send a message with subject or body 'help' to
	[hidden email]

You can reach the person managing the list at
	[hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beremiz-devel digest..."


Today's Topics:

   1. Calculate greatest_tick_count__
      ([hidden email])
   2. matiec return -8 ([hidden email])


----------------------------------------------------------------------

Message: 1
Date: Mon, 9 Apr 2018 15:12:41 +0500
From: [hidden email]
To: [hidden email]
Subject: [Beremiz-devel] Calculate greatest_tick_count__
Message-ID:
	[hidden email]
Content-Type: text/plain; charset="utf-8"; format=flowed

Hi, all!

I have: 2 periodic task with time 10 and 3 ms.
Code:

1) config.c :
unsigned long long common_ticktime__ = 1000000ULL; /*ns*/
unsigned long greatest_tick_count__ = (unsigned 
long)18446744073709551601UL; /*tick*/
// greatest_tick_count__ = (unsigned long)0xFFFFFFFFFFFFFFF1
// for main target unsigned long = 32 bit -> greatest_tick_count__ = 
0xFFFF FFF1 = 4294967281 (dec)

2) plc_main.c:
unsigned long __tick = 0;
void __run(void)
{
 ??? __tick++;
 ??? if (greatest_tick_count__)
 ??????? __tick %= greatest_tick_count__;
...
 ??? config_run__(__tick);
...
}

3) resource1.c:
void RESOURCE1_run__(unsigned long tick) {
 ? TASK1 = !(tick % 10);
 ? TASK2 = !(tick % 3);
 ? if (TASK1) {
 ??? PROGRAM_DO1_body__(&INSTANCE1);
 ? }
 ? if (TASK2) {
 ??? PROGRAM_DO2_body__(&INSTANCE2);
 ? }
}

What do We see when __tick = greatest_tick_count__?
First. __tick = 0
Second. Call TASK1 and TASK2.
Third. Invalid period calls TASK1

Time diagram:
__tick = 4294967270. Call TASK1 (period = 10 ms)
__tick = 4294967271. Call TASK2 (period = 3 ms)
__tick = 4294967274. Call TASK2 (period = 3 ms)
__tick = 4294967277. Call TASK2 (period = 3 ms)
__tick = 4294967280. Call TASK1 (period = 10 ms) Call TASK2 (period = 3 ms)

Moment: __tick = greatest_tick_count__ = 4294967281 -> __tick == 0

__tick = 0. Call TASK1 (period = 10 ms) Error! Delta TASK1 (10 ms) = 1.
 ???????????????? Call TASK2 (period = 3 ms)? Error! Delta TASK2 (3 ms) = 1

__tick = 3. Call TASK2 (period = 3 ms)
__tick = 6. Call TASK2 (period = 3 ms)
__tick = 9. Call TASK2 (period = 3 ms)
__tick = 10. Call TASK1 (period = 10 ms)

It's a bag?

Regards,

Aleksandr Safronov!




------------------------------

Message: 2
Date: Mon, 9 Apr 2018 16:20:45 +0500
From: [hidden email]
To: [hidden email]
Subject: [Beremiz-devel] matiec return -8
Message-ID:
	[hidden email]
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi, All!

I have 3 programs (3 Instance) and 3 tasks with call period 5 ms (T#5s0ms).

Build return:

?????????? ? ????? -8 (pid 15809)
??????: ?????????? ??? ? C ?????? ??? ?????? -8
????????? ????????? ????!


Best Regards,
Aleksandr Safronov

-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

------------------------------

Subject: Digest Footer

_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel


------------------------------

End of Beremiz-devel Digest, Vol 89, Issue 1
********************************************

-- 
С уважением,
Сафронов Александр
Инженер отдела разработки
ООО "К-СОФТ ИНЖИНИРИНГ"
Best Regards,
Safronov Aleksandr
Developer, Firmware Development Team
LLC "K-SOFT ENGINEERING"

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

beremiz.xml (133 bytes) Download Attachment
plc.xml (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Beremiz-devel Digest, Vol 89, Issue 1

Beremiz-Devel mailing list
As a temporary workaround I propose to do the following:

1 Since task intervals (used in resource1.c) already have a common divisor equal to "1", after counting common_ticktime__
The search for the largest number can be reduced to the following:

unsigned long tick_mod_array[task_num]; // array of tick tasks, before calculate "common_ticktime__"
For example:
>void RESOURCE1_run__(unsigned long tick) {
>  TASK1 = !(tick % 2500);
>  TASK2 = !(tick % 2501);
>  TASK3 = !(tick % 2500);
>  TASK3 = !(tick % 3000);
>  TASK3 = !(tick % 500);

unsigned long tick_mod_array[] = {2500, 2501, 2500, 3000, 500};


unsigned long get_greatest_tick()
{
    unsigned long long greatest_tick = tick_mod_array[0];
    for(char(?) i = 1; i < task_num; i++)
    {
        if (greatest_tick < tick_mod_array[i]) {
            if(tick_mod_array[i] % greatest_tick) {
                greatest_tick *= tick_mod_array[i];
            } else {
                greatest_tick = tick_mod_array[i];
            }
        } else {
            if (greatest_tick != tick_mod_array[i]) {
                if (greatest_tick % tick_mod_array[i]) {
                    greatest_tick *= tick_mod_array[i];
                } else {
                    //greatest_tick = greatest_tick;
                }
            } else {
                // greatest_tick == tick_mod_array[i]
                // continue
            }
        }
    }

    for found max for range unsigned long:
    if (greatest_tick >> 32) {
        ERROR;
    } else {
        greatest_tick *= (((unsigned long)(-1)) / greatest_tick);
    }
    return (unsigned long)greatest_tick;
}

I ran a simple test for this code. It's Ok!

But there is another problem -  out of range unsigned long!

Thanks!

Sorry my English)

09.04.2018 17:07, [hidden email] пишет:
Message: 1
Date: Mon, 9 Apr 2018 15:12:41 +0500
From: [hidden email]
To: [hidden email]
Subject: [Beremiz-devel] Calculate greatest_tick_count__
Message-ID:
	[hidden email]
Content-Type: text/plain; charset="utf-8"; format=flowed

Hi, all!

I have: 2 periodic task with time 10 and 3 ms.
Code:

1) config.c :
unsigned long long common_ticktime__ = 1000000ULL; /*ns*/
unsigned long greatest_tick_count__ = (unsigned 
long)18446744073709551601UL; /*tick*/
// greatest_tick_count__ = (unsigned long)0xFFFFFFFFFFFFFFF1
// for main target unsigned long = 32 bit -> greatest_tick_count__ = 
0xFFFF FFF1 = 4294967281 (dec)

2) plc_main.c:
unsigned long __tick = 0;
void __run(void)
{
 ??? __tick++;
 ??? if (greatest_tick_count__)
 ??????? __tick %= greatest_tick_count__;
...
 ??? config_run__(__tick);
...
}

3) resource1.c:
void RESOURCE1_run__(unsigned long tick) {
 ? TASK1 = !(tick % 10);
 ? TASK2 = !(tick % 3);
 ? if (TASK1) {
 ??? PROGRAM_DO1_body__(&INSTANCE1);
 ? }
 ? if (TASK2) {
 ??? PROGRAM_DO2_body__(&INSTANCE2);
 ? }
}

What do We see when __tick = greatest_tick_count__?
First. __tick = 0
Second. Call TASK1 and TASK2.
Third. Invalid period calls TASK1

Time diagram:
__tick = 4294967270. Call TASK1 (period = 10 ms)
__tick = 4294967271. Call TASK2 (period = 3 ms)
__tick = 4294967274. Call TASK2 (period = 3 ms)
__tick = 4294967277. Call TASK2 (period = 3 ms)
__tick = 4294967280. Call TASK1 (period = 10 ms) Call TASK2 (period = 3 ms)

Moment: __tick = greatest_tick_count__ = 4294967281 -> __tick == 0

__tick = 0. Call TASK1 (period = 10 ms) Error! Delta TASK1 (10 ms) = 1.
 ???????????????? Call TASK2 (period = 3 ms)? Error! Delta TASK2 (3 ms) = 1

__tick = 3. Call TASK2 (period = 3 ms)
__tick = 6. Call TASK2 (period = 3 ms)
__tick = 9. Call TASK2 (period = 3 ms)
__tick = 10. Call TASK1 (period = 10 ms)

It's a bag?

Regards,

Aleksandr Safronov!

-- 
С уважением,
Сафронов Александр
Инженер отдела разработки
ООО "К-СОФТ ИНЖИНИРИНГ"
Best Regards,
Safronov Aleksandr
Developer, Firmware Development Team
LLC "K-SOFT ENGINEERING"

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Beremiz-devel Digest, Vol 89, Issue 1

Beremiz-Devel mailing list
IMHO, it's quite complex and memory consuming!

I think we need somethink less complex...

Best regards,
Paul Beltyukov

2018-04-10 14:39 GMT+05:00 <[hidden email]>:
As a temporary workaround I propose to do the following:

1 Since task intervals (used in resource1.c) already have a common divisor equal to "1", after counting common_ticktime__
The search for the largest number can be reduced to the following:

unsigned long tick_mod_array[task_num]; // array of tick tasks, before calculate "common_ticktime__"
For example:
>void RESOURCE1_run__(unsigned long tick) {
>  TASK1 = !(tick % 2500);
>  TASK2 = !(tick % 2501);
>  TASK3 = !(tick % 2500);
>  TASK3 = !(tick % 3000);
>  TASK3 = !(tick % 500);

unsigned long tick_mod_array[] = {2500, 2501, 2500, 3000, 500};


unsigned long get_greatest_tick()
{
    unsigned long long greatest_tick = tick_mod_array[0];
    for(char(?) i = 1; i < task_num; i++)
    {
        if (greatest_tick < tick_mod_array[i]) {
            if(tick_mod_array[i] % greatest_tick) {
                greatest_tick *= tick_mod_array[i];
            } else {
                greatest_tick = tick_mod_array[i];
            }
        } else {
            if (greatest_tick != tick_mod_array[i]) {
                if (greatest_tick % tick_mod_array[i]) {
                    greatest_tick *= tick_mod_array[i];
                } else {
                    //greatest_tick = greatest_tick;
                }
            } else {
                // greatest_tick == tick_mod_array[i]
                // continue
            }
        }
    }

    for found max for range unsigned long:
    if (greatest_tick >> 32) {
        ERROR;
    } else {
        greatest_tick *= (((unsigned long)(-1)) / greatest_tick);
    }
    return (unsigned long)greatest_tick;
}

I ran a simple test for this code. It's Ok!

But there is another problem -  out of range unsigned long!

Thanks!

Sorry my English)

09.04.2018 17:07, [hidden email] пишет:
Message: 1
Date: Mon, 9 Apr 2018 15:12:41 +0500
From: [hidden email]
To: [hidden email] Subject: [Beremiz-devel] Calculate greatest_tick_count__ Message-ID: [hidden email] Content-Type: text/plain; charset="utf-8"; format=flowed Hi, all! I have: 2 periodic task with time 10 and 3 ms. Code: 1) config.c : unsigned long long common_ticktime__ = 1000000ULL; /*ns*/ unsigned long greatest_tick_count__ = (unsigned long)18446744073709551601UL; /*tick*/ // greatest_tick_count__ = (unsigned long)0xFFFFFFFFFFFFFFF1 // for main target unsigned long = 32 bit -> greatest_tick_count__ = 0xFFFF FFF1 = 4294967281 (dec) 2) plc_main.c: unsigned long __tick = 0; void __run(void) { ??? __tick++; ??? if (greatest_tick_count__) ??????? __tick %= greatest_tick_count__; ... ??? config_run__(__tick); ... } 3) resource1.c: void RESOURCE1_run__(unsigned long tick) { ? TASK1 = !(tick % 10); ? TASK2 = !(tick % 3); ? if (TASK1) { ??? PROGRAM_DO1_body__(&INSTANCE1); ? } ? if (TASK2) { ??? PROGRAM_DO2_body__(&INSTANCE2); ? } } What do We see when __tick = greatest_tick_count__? First. __tick = 0 Second. Call TASK1 and TASK2. Third. Invalid period calls TASK1 Time diagram: __tick = 4294967270. Call TASK1 (period = 10 ms) __tick = 4294967271. Call TASK2 (period = 3 ms) __tick = 4294967274. Call TASK2 (period = 3 ms) __tick = 4294967277. Call TASK2 (period = 3 ms) __tick = 4294967280. Call TASK1 (period = 10 ms) Call TASK2 (period = 3 ms) Moment: __tick = greatest_tick_count__ = 4294967281 -> __tick == 0 __tick = 0. Call TASK1 (period = 10 ms) Error! Delta TASK1 (10 ms) = 1. ???????????????? Call TASK2 (period = 3 ms)? Error! Delta TASK2 (3 ms) = 1 __tick = 3. Call TASK2 (period = 3 ms) __tick = 6. Call TASK2 (period = 3 ms) __tick = 9. Call TASK2 (period = 3 ms) __tick = 10. Call TASK1 (period = 10 ms) It's a bag? Regards, Aleksandr Safronov!

-- 
С уважением,
Сафронов Александр
Инженер отдела разработки
ООО "К-СОФТ ИНЖИНИРИНГ"
Best Regards,
Safronov Aleksandr
Developer, Firmware Development Team
LLC "K-SOFT ENGINEERING"

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel