# Externally controlling a Boolean pulse generator

Posted 11 days ago
174 Views
|
5 Replies
|
4 Total Likes
|
 I am using a Boolean pulse generator in one of my models and plan to wrap a control system that will vary the period. I have already set the period as a parameter and perhaps should have chosen a variable. My question: how do I set the value from outside? I have added a connector and tried to use it to set the value for the pulse generator but the compilation fails. What is the method of dynamically controlling the period of a Boolean pulse generator? Or, is there another component I should be using? Thanks in advance for any help, Mark
5 Replies
Sort By:
Posted 10 days ago
 Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST Your post is too vague. Please describe your subject extensively providing the details, examples, code, and other relevant ideas, so it is clear what exactly you are looking for and the relevance to Wolfram Technologies.
Posted 10 days ago
 I have pruned this down to its most basic example. Please see attached. This shows the example where I want to vary the period of the Boolean pulse generator based on a parameter or variable. I did try changing the output of the table to a "variable" but that made no difference. When I attempt to compile, it gives this error message: Building "BooleanExample" as experiment "BooleanExample 1" started at 15:01:07 Error: interactive [2:40-2:59] Component pulse1.period of variability PARAM has binding somePeriod of higher variability VAR. Build finished at 15:01:09 (took 00:01). Error: No executable generated /Users/markross/Library/Caches/com.wolfram.SystemModeler/WolframSystemModeler-12.1/sme.12.1.0_1595973667_1557810404.exe Error: No settings file generated /Users/markross/Library/Caches/com.wolfram.SystemModeler/WolframSystemModeler-12.1/sme.12.1.0_1595973667_1557810404.sim I have used the Boolean pulse generator where I set the period to some parameter and that works as expected. The ability to dynamically change the period is what I have not been able to figure out. Attachments:
Posted 10 days ago
 Mark,You can't change a parameter during a simulation. Only variables can be changed. The problem is not with the table but with the pulse generator. The pulse generator has a parameter "period". period can only be modified at compile time (or from Mathematica during real time simulations). You can write a block that takes the period as an input and outputs the pulses you want. I am using a boolean pulse generator in one of my models and plan to wrap a control system that will vary the period. Are you trying to make a variable PWM signal (each cycle is fixed in duration but the % of time spent high is variable) or are you trying to vary the period of a fixed duty cycle waveform (the duty cycle is always a fixed percentage but the duration of the cycle is variable)? The first case is straightforward. The second case is a bit trickier because you need to decide how to handle changes in period (I assume you only want to allow changes after the completion of the previous cycle). Depending on what you want, I might be able to post something that will help you.Regards,Neil
Posted 10 days ago
 Mark,I put together a quick example for you of a way to get a variable pulse width output (I assumed that this is what you wanted):With a combi time table of:This gives the variable pulses:Note that I chose "ConstantSegments" under smoothness and "HoldLastPoint" under extrapolation to make the table easier to construct.My table entries are frequency in hertz (0.2 hz, followed by 0.4hz, 1hz, etc.) but you can change that easily to period if that helps your model. Attached is the model.Regards,Neil Attachments:
Posted 10 days ago
 Hi Neil, Thank you for the reply and the example! Yes, this is just what I want: the ability to dynamically set the period. Regards, Mark
Community posts can be styled and formatted using the Markdown syntax.