motor control
6 posts • Page 1 of 1
motor control
I'm new to all this but trying to learn - this being said I am trying to control a motor to (example) rotate 15 (?) degrees, reverse, rotate the same amount and continue this action. Anyone help? Thanks
- kbrtom
- Posts: 9
- Joined: Thu Mar 24, 2011 12:40 pm
Re: motor control
Theres no way to tell thyme what the angle of a geom is but their is an alternative way to imput the angle of an object using a mechanized system with variables.
1. open the console by pressing ~ next to the number 1.
2 type the following:
3. make 2 small circles on the box you want to rotate. make sure the circles are directly lined up vertically with the hing controlling everything. This is important. Also, try to make them as far away from eachother as possible. It will increase the accuracy of the system.
4. make 2 off centered hinges on both circles - One for each circle - and make the motors true, the motor speeds 600, and the motor strengths +inf.
5. make a pair of boxes that will constantly collide with the circles. Dont clone them or else it wont work. Fix them to the main box that you want to rotate 15 degrees.
6. on the top box'es onCollide, type the following:
and on the bottom one type:
7. On the hinge that controlls the acutall angle of the main box, go to its script menu and type the following where you see ccw. Remember to make the motor true:
8. Start the sim. If you want to change the range of motion, go to the bottom box'es onCollide and play around with the two numbers that say 0.5. The closer to zero, the less range it has.
Hope this helped. Please let me know,
1. open the console by pressing ~ next to the number 1.
2 type the following:
- Code: Select all
scene.my.pos1 := [0.0]; scene.my.pos2 := [0,0]; scene.my.hingeState := false
3. make 2 small circles on the box you want to rotate. make sure the circles are directly lined up vertically with the hing controlling everything. This is important. Also, try to make them as far away from eachother as possible. It will increase the accuracy of the system.
4. make 2 off centered hinges on both circles - One for each circle - and make the motors true, the motor speeds 600, and the motor strengths +inf.
5. make a pair of boxes that will constantly collide with the circles. Dont clone them or else it wont work. Fix them to the main box that you want to rotate 15 degrees.
6. on the top box'es onCollide, type the following:
- Code: Select all
(e)=>{scene.my.pos1 := e.pos}
and on the bottom one type:
- Code: Select all
(e)=>{scene.my.pos2 := e.pos; scene.my.pos1(0) - scene.my.pos2(0) >= 0.5 ? {scene.my.hingeState := true} : {}; scene.my.pos2(0) - scene.my.pos1(0) >= 0.5 ? {scene.my.hingeState := false} : {} }
7. On the hinge that controlls the acutall angle of the main box, go to its script menu and type the following where you see ccw. Remember to make the motor true:
- Code: Select all
{scene.my.hingeState}
8. Start the sim. If you want to change the range of motion, go to the bottom box'es onCollide and play around with the two numbers that say 0.5. The closer to zero, the less range it has.
Hope this helped. Please let me know,
- Attachments
-
phun picture.png- This is a picture of what it should look like
- (70.24 KiB) Downloaded 1 time
My signature is worth a lot of money, So I'm gonna put this stamp instead:
[$20 PER AUTOGRAPH]
[$20 PER AUTOGRAPH]
- racergonemad
- Posts: 26
- Joined: Tue Aug 17, 2010 7:37 am
Re: motor control
holy...
too complicated.
Simple idea is to make scene.my. variable like scene.my.reverse := false, set motor's ccw property to {scene.my.ccw} and switch value within on collide. For example one "limit" box's onCollide = (e) => {scene.my.ccw = true}, another {... = false}.
Simple idea is to make scene.my. variable like scene.my.reverse := false, set motor's ccw property to {scene.my.ccw} and switch value within on collide. For example one "limit" box's onCollide = (e) => {scene.my.ccw = true}, another {... = false}.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: motor control
thanks for the help - I did exactly as you said and triple checked the script but the box just rotates in the direction of the motor without any hesitation at the speed at which it is set (default) see attachment
- Attachments
-
motor control.phz- (15.42 KiB) Downloaded 39 times
- kbrtom
- Posts: 9
- Joined: Thu Mar 24, 2011 12:40 pm
Re: motor control
Incorrect code.
You forget "?" after condition.
You forget "?" after condition.
- Code: Select all
(e)=>{
scene.my.pos2 := e.pos;
scene.my.pos1(0) - scene.my.pos2(0) >= 0.5({scene.my.hingeState := true})(:)({});
scene.my.pos1(0) >= 0.5({scene.my.hingeState := false})(:)({})
}
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests



