-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pulse generator issue #456
Comments
Can you share the model and some code to reproduce the problem? |
Steps to reproduce:
Matlab version: 2020b update 8 NOTE: setting outport sample time of pluse_timebased.slx to |
After investigations: the first pusle generator model is 'discrete'. At compilation time, I suggest a patch like: #ifdef rtmGetT
time_T tNext = currentCommunicationPoint + communicationStepSize;
double epsilon = (1.0 + fabs(rtmGetT(s_instance->S))) * 2 * DBL_EPSILON;
while (rtmGetT(s_instance->S) < tNext + epsilon)
#else
const int steps = ceil(communicationStepSize / FUNDAMENTAL_STEP_SIZE);
for(int i=0; i<steps; i+=1)
#endif And add |
Hello,
I face a tricky issue with a very simple model:
This simple pulse is configured with 2secs period. Matlab solver is Fixed Discrete with ts=0.005s :
![image](https://private-user-images.githubusercontent.com/18714082/268301625-6074147a-c211-4397-b648-011a61f72b0b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4OTQ0NjYsIm5iZiI6MTczODg5NDE2NiwicGF0aCI6Ii8xODcxNDA4Mi8yNjgzMDE2MjUtNjA3NDE0N2EtYzIxMS00Mzk3LWI2NDgtMDExYTYxZjcyYjBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDAyMDkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE0YWE3NTUyZTEwZGM3NDE4ZjVkMTVkMmRmODU3YzgwOGFmYTJkNDc5ZmQ3ZDRhZGEyY2Y4OWU0ODFlN2FhYmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.i8HBakYKNX-HxLUeX_BP8yzGnLcIaWb-lF5opvBThkY)
Using FMIKit-3.1, the pulse period depends on communication step time managed by FMPy. Note that the paramaters exposed by FMU are:
![image](https://private-user-images.githubusercontent.com/18714082/268300049-8c2958cd-3037-4c8a-8b89-721eca0ef5dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4OTQ0NjYsIm5iZiI6MTczODg5NDE2NiwicGF0aCI6Ii8xODcxNDA4Mi8yNjgzMDAwNDktOGMyOTU4Y2QtMzAzNy00YzhhLThiODktNzIxZWNhMGVmNWRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDAyMDkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYyZWYwNzg4OTIzZjYyZjIxMjNhMWQ5NDJmZWRmZWU0YjEyYTUyZGZhOTI4NjE3MjllNmVlNjRjZmU5ODM2MTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.3bCZYpK_YYjxRNjbWhex3OZy6xXVq0KdLqiQ8vGdFDE)
To workaround this issue, I introduced Clock block:
![image](https://private-user-images.githubusercontent.com/18714082/268299184-ef906de2-b9a6-4390-a116-bf640e8b0c6e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4OTQ0NjYsIm5iZiI6MTczODg5NDE2NiwicGF0aCI6Ii8xODcxNDA4Mi8yNjgyOTkxODQtZWY5MDZkZTItYjlhNi00MzkwLWExMTYtYmY2NDBlOGIwYzZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDAyMDkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3MjI5OTRjMzE4ZmZhY2NkMzM0NGEyZmIwZmFhNzdhZjIzNjFjNjMwMDE1OGNmOWY2ZjgzODMxYjczYWNlN2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.nRMY5PXXwoaJFYu1yxrHq5ljqkb-pWEiaNqUanTZ8ck)
With this model, pulse period is always 2secs whatever the communication step time. Note that the parameters exposed by FMU are slightly different:
Is it a FMIKit issue? a Simulink issue?
kind regards
The text was updated successfully, but these errors were encountered: