BEST Robotics Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
widerbestrobot

Junior Member
Registered:
Posts: 23
Reply with quote  #1 
Would it be possible to do something along the lines of a "ladder" function?
By that, I mean a block (or a way of coding the Matlab function block), so that you can have a list of numbers/integers. Then,  every time it receives a 1, it will move down the list by one number/integer and it will stay there until receiving another 1.


Also, would it be possible to do a clock function activated by a button/input port, so that every time the block receives a 1, it would put out a repeating function such as: 

127 for 1 second
0 for 1 second
127 for 1 second
0 for 1 second etc.


to be used for programming a blinking indicator light to tell us when one of the speed change functions is turned on?

Thanks,
widerbestrobot
0
widerbestrobot

Junior Member
Registered:
Posts: 23
Reply with quote  #2 
To expand on what I said earlier, I essentially want to make or find a block that will let me do with a servo what you already do with a dimmer lamp:

Every time you press the button, the lamp will cycle through a list of "positions"
low-medium-high-off-low-medium-high-off.

So for a servo you would have it go:
20 degrees-40 degrees-60 degrees-0 degrees-20 degrees-40 degrees-60 degrees.degrees
0
EvansPhysics

Member
Registered:
Posts: 37
Reply with quote  #3 
1)You could code a custom block that steps through a list of values and then resets at the end.

2) you could simply write your position value to a memory location and then add your increment to it to each time a button is depressed (going up the "ladder").  Set the servo position with a memory read.  use a switch to reset it once you reach the max value or a different button to move down the "ladder"

MOST importantly... I don't think you are allowed to use a blinking indicator. it would seem to violate generic game rule 3.1.4.3 as it would be functional.  We've asked about a similar things in the past.  I'd run it by the Q&A for a definitive answer.
0
shiremath

Moderator
Registered:
Posts: 78
Reply with quote  #4 
If I understand your query correctly, here is an example of how to do this. Notice I use 2 buttons to increase and decrease the servo angle values in increments of 20 degrees.

GearExample.JPG 
The above model uses the Gear transmission block from the VEX library to convert the button values to appropriate gear values i.e. Pressing 5up results in 1 through 4 and pressing 5dn results in 4 through 1. And, pressing any one of them in between increments or decrements the gear factor accordingly. 

Now to use this value to control the servo angle, I have added a MATLAB Function block that has a simple IF-THEN-ELSE routine, similar to what EvansPhysics suggested. See the code below:
GearExample2.JPG 

Note the (127/60) factor is to make sure that you provide an appropriate value to the servo that takes -127 to 127 and converts it to an angle of -60 to 60 degrees.

With this model, now you can cycle the servo angles in both directions, up and down! If you want to increase the servo angle range used here, just change the IF-THEN-ELSE routine accordingly.

You can also change the # of gears that the Gear Transmission block can handle. To do this, click on the small down-arrow on the bottom left corner of the Gear block.

GearExample_block.JPG 
This will open a new view in the Simulink window that shows a 'Chart' block. Double-click on this, and you will find the Stateflow Chart that defines the Gear Transmission block. Here, find the statements that contain "4". Replace these with the max # of gears that you wish, say 6 gears. Double-click on the statements to edit them accordingly. 

GearExample_SF.JPG 
After changing these numbers, go back to the top Simulink diagram using the 'Up To Parent' up-arrow button TWICE.

GearExample_UpParent.JPG 
Now, change the MATLAB Fcn block to use the 6 gears. Run/simulate the model and notice how it behaves with 6 gears of operation.

HTH.

-SH

0
widerbestrobot

Junior Member
Registered:
Posts: 23
Reply with quote  #5 
Is it possible to do that, except that when it reaches the end of the gear transmission it rests back to zero (like a lamp as mentioned earlier).
And the clock function (as mentioned earlier).
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.