BEST Robotics Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
crog419

Junior Member
Registered:
Posts: 1
Reply with quote  #1 
  flag wave test 1.PNG 

0
shiremath

Moderator
Registered:
Posts: 78
Reply with quote  #2 
Here is a program that might actually work for you:
WaveFlag_BESTForum.PNG 

I have also attached the model for your reference. 

A few things:
1) I am guessing you were trying to achieve the waving motion through the MATLAB Function blog. You could have done that for sure. In my solution, I have instead using the "Signal Generator" block from Simulink (its not available in the VEX library but available in the generic Simulink library that you bring up by clicking on the Simulink icon button ( SimulinkIcon.PNG .)in your model. Signal Generator block lets you create a signal of different shapes, in my case I choose a square wave. Why square? - because I want the motor speed to go to a constant positive value (see the value 50 on the blue line in the graph above), stay there for few seconds, and then go down to a constant negative value (-50) for the same amount of time, and continue this pattern. So this pattern will generate the 'waving' motion of the flag. Agreed?

2) I use a Switch block in model to control what happens when the Gamepad button is pressed. I am assuming from your earlier design that you wish to use the button to control the start and stop of flag waving. Correct? If so, the Switch block in this model will give you that behavior. The block takes the Gamepad button input, through the Latch block, as the control input to decide what to do if the button is pressed( >0) or not pressed (<= 0). If former, then top input, i.e. Signal Gen value is passed, else the latter i.e. the 3rd input which is a value of 0. This way, the flag waving can be controlled using a button.

3) Note that you can set the 'amplitude' of the motor input value within the Signal Generator block. In this case, its set to 50 (should be within the upper limit 127). If you want the flag to wave faster, then change this value to a larger one. You can see that I also use a 'Dashboard Scope' block that displays the Signal gen wave form (in blue) and the resulting Motor speed wave form (in orange) . I have set my Stop Time parameter  (meant only for simulation) to 20 instead of the default 'Inf'. And that's why we see the graph's X-axis representing 'time' going up to 20 'simulation' secs.

StoptimeIcon.PNG 

To learn more about the Scope and other Dashboard blocks, watch this: https://www.youtube.com/watch?v=h5xXbMKhVrY These are very powerful tools to use in your Simulink models to help with visual debugging. 

4) If you had a Servo motor instead that could wave the flag, then below is a model for that. Note that the example screenshot below does not incorporate the button control as above. you could include it in this servo example as discussed above. Also, note how I use a Sine wave here instead of a square wave. Any guesses why I do that? Add your response below! 

WaveFlagServo_BESTForum.PNG 
HTH

Sandeep 

For questions related to installation/technical issues- bestrobotics@mathworks.com 

 
Attached Files
zip waveflag_BESTForum.zip (31.69 KB, 1 views)

0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.