Book Image

Learning Lego Mindstorms EV3

By : Gary Garber
Book Image

Learning Lego Mindstorms EV3

By: Gary Garber

Overview of this book

Table of Contents (19 chapters)
Learning LEGO MINDSTORMS EV3
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
10
Other Programming Languages
Index

The EQ My Block


The EQ My Block provides an equation that controls the power of the motors. This equation determines if the robot needs to accelerate to stay upright. We are solving the inverted pendulum problem with this calculation. By the end of the EQ My Block, a new value is generated for the pwr variable block (the power variable).

A series of three Advanced Math blocks are used to calculate the value of the power variable, which in turn leads to the control of the motors. Although the Cdrv variable block affects how we control whether the robot drives forward or backwards, it is the value of the pwr variable block that sets the level of motor speed to keep the robot upright. Essentially, we are trying to determine whether the robot needs to accelerate to stay upright. If the Advanced Math block could handle more inputs, then only one Advanced Math block would be needed. The value of the power variable is based on input from several numeric variable blocks, including the Cdrv, time...