Board indexPortal
Last visit was: It is currently 14. Dec 2019 17:51


All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
FollowersFollowers: 0
BookmarksBookmarks: 0
Views: 643

AuthorMessage
 Post subject: die Kollision zu vermeiden
PostPosted: 29. Jul 2013 11:37 

Joined: 05.2013
Posts: 27
Gender: None specified
Hallo,

sorry for my poor deutsch!

die Kollision mit lib_922 immer bei mir. Heute hinzufüge ich eine neue Mehode wie folgend,
und die Ergebnis seht gut aus:
colli_flag ist von der state_machine

Quote:
void SetAndTransmitObject(unsigned char objectNr)
{
unsigned char send_obj_count;
unsigned int m;
unsigned char n;

EX1=0;
send_obj_value(objectNr);
while((fb_state>0) || TR1 || wait_for_ack);
send_obj_count=1;
while( colli_flag && send_obj_count<4 ) {
if(colli_flag) colli_flag = 0;

//CSMA/CD, after a random time-delay resend!~
switch(send_obj_count) {
case 1:
if(colli_timedelay<15000)
colli_timedelay = 30000- colli_timedelay;
break;
case 2:
if(colli_timedelay<10000)
colli_timedelay = 20000-colli_timedelay;
break;
case 3:
if(colli_timedelay>10000)
colli_timedelay -= 10000;
break;
case 4:
while(colli_timedelay>5000)
colli_timedelay -= 5000;
break;
}

srand(colli_timedelay);//seed colli_timedelay
for(n=0;n<10;n++)
for(m=0;m<rand();m++);

EX1=0;
send_obj_value(objectNr);
while((fb_state>0) || TR1 || wait_for_ack);
send_obj_count++;
}
EX1=1;
}


Edit by StefanT: set code to pre format to make it readable


Top
Offline Profile  
 
 Post subject: Re: die Kollision zu vermeiden
PostPosted: 30. Jul 2013 20:21 
User avatar

Joined: 05.2013
Posts: 268
Location: Salzburg
Gender: Male
This makes the app busy wait until the telegram is sent. I might be wrong, but I think the collision problem is (or shall) be handled inside the library.


Top
Offline Profile  
 
 Post subject: Re: die Kollision zu vermeiden
PostPosted: 30. Jul 2013 22:29 

Joined: 05.2013
Posts: 27
Gender: None specified
StefanT wrote:
This makes the app busy wait until the telegram is sent. I might be wrong, but I think the collision problem is (or shall) be handled inside the library.

Hallo, Stefant

yes, you are right, but:

in the statemachine there is a resend-mechanism, repeat_count flag.
But:

1. when the kollision happens, we must wait a while to resend. If we wait for the same time in different "Controller", the kollision happens always!
2. when the tel_arrived the telegramm[]-array changed, so we just do the repeat_count++ and repeat the init_tx(), but we do actually send the received telegramms.

so we should do the repeat in main-loop. And main-loop has the low priority so the interrupts just like INT1 or T1 should not wait for the sent.

(maybe we should add the if(tel_arrived) process_tel(); after the while())

all of these are just my analysis, should be verified, but for me the problems seem solved.


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group | Theme created StylerBB.net
phpBB3 free Forum by UserBoard.org | All Rights Reserved.
» Contact & Abuse Support-Forum Gooof Webdesign free forum Dein Forumo Forum web tracker