Using motors and rotary encoders
In this lecture you will learn the term actuator. You will see how motor can be used. You will see how you can define a turn angle, apply speed and change turn directions. You will also learn how a motor can be used as an input sensor, to read rotation information. This lecture also details the instructions needed to coordinate the movements of multiple motors. This is important if you wish to use multiple motors to drive forward or turn a robot on a path.
The simplest way to connect the motor
The EV3 motors can be easily connected to the A, B, C or D ports of the Brick. You can find these ports above the Brick's LCD screen. Users are lucky that the microcontroller on the Brick can automatically detect all connected input or output devices and let's Ozeki 10 reach those devices via Bluetooth. But now please concentrate on the A, B, C, D output ports, which can accept both EV3 Medium and EV3 Large motors. You can see both motors connected on the Figure 1 below.
Figure 1 - Look how the Lego Mindstorms EV3 motors are connected to the Brick
- Lego Mindstorms EV3 Brick
- EV3 motor (Medium or Large)
- EV3 cable (for each motor)
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Connect Brick via Bluetooth: http://www.ozeki.hu/index.php?owpn=6065
- Lego connection installed: http://www.ozeki.hu/index.php?owpn=6067
Video tutorial: 'How to use the Lego motors in OZEKI 10'
Start Control Panel through any browser!
Make sure that the motor is effectively connected to the Brick. Start by opening Ozeki 10 in your browser client. The server should be installed on the same machine the Bluetooth has been previously paired, because if the OS sees it, Ozeki 10 can see it as well. If your Brick hasn't been paired with your Ozeki 10 server machine yet, you can pair it by checking the following page at http://www.ozeki.hu/index.php?owpn=6065. Log in with the same login details you always use on Ozeki and start the Control Panel (Figure 2) to easily add your Lego motor. You will really enjoy that the Control Panel can easily control everything around you. In this guide it will move motors.
Figure 2 - Opening the Control Panel through the GUI
Select the motor from the connection list!
The connection list is the best way to show all available and offline Ozeki 10 connections. If you can see all Lego devices on the Ozeki 10 connection list, then you should see a similar list seen on Figure 3 below. Do not panic if the list is empty, just do the following smart guide how to connect the Lego Mindstorms EV3 products to Ozeki 10 on the following page: http://www.ozeki.hu/index.php?owpn=6067. You will see the icon of 'Motor_1' appear on the connection list and by clicking the 'Details' button next to it. You will find yourself on the device chat window.
Figure 3 - This is how you can see the detected Lego Mindstorms EV3 devices
Chat with the motor to move it!
This is a chat system you can use to communicate with your devices. As seen on Figure 4, you can ask all available commands by sending 'help'. In this example the following command was used: 'A 80 240'. Then a motor movement command is used, which can rotate both Medium or Large motors. The motor command set is after this step-by-step guide you have easily done. You can try to build something new and control it with your own ideas. Testing your devices in chat is always a good idea before doing anything else. Do not forget, use 'help' to check the command set of your device.
Figure 4 - Move your Lego motor with Ozeki chat
Check how your motor instantly moves!
You will hear the motor instantly move and when you look at it, it will be exactly positioned to the selected angle (Figure 5). You can try it again from Ozeki chat, but now look at the motor and realize how fast it is. What are you waiting for? Use your imagination. You can build your small Lego car or helicopter. This way you can actually realize the true power of these motors. At the bottom of this guide you will see an 'Additional information' section of both Medium and Large motors.
Figure 5 - Look how the motor rotates to the required position
Take a glimpse at the motor events in Ozeki 10!
By taking a look back on the screen, you can do a lot of interesting things. For example you can check the history of the motor communication by navigating to the 'Event' tabpage. It clearly shows that the motor movement command was sent from your Ozeki 10 (Figure 6). These commands can be easily understood and will be described on the tables just below the screenshot. If you do not remember what your device did, you can always go back to the 'Events' tabpage. In Ozeki 10 each device has it's own events section. There is also a combined events page in the Control Panel.
Figure 6 - Take a glimpse on the rotation event sent towards the motor
Control your Lego EV3 motor with Ozeki's command set
This command example table contains a few messages, which can control your LEGO motor through Ozeki 10. Try some commands with the chat interface by clicking the 'Send' button, although the messages can be routed from any Ozeki 10 connection. This can simply move your motors. The best thing in Ozeki 10 is that you are capable to create program codes using block diagrams, which can send the same commands you can see on the Commands Table below.
|off||stop all motors|
|on||start all motors at full speed|
|on 50||start all motors at 50% of speed|
|70||start all motors at 70% of speed|
|AB||start A and B motors at full speed|
|D -30||start D motor backwards at 30% of speed|
|BCD 80 360||start B, C and D motors at 80% and rotate 360 degrees|
|20 720||start all motors at 20% and rotate 720 degrees
(speed: [-100 – 100%] negative values mean opposite direction)
(rotation: value in degrees, where 0 means infinite number of steps)
Commands Table - Contains messages controlling Lego Mindstorms EV3 motors
The rest of the command set can be used on all Ozeki 10 sensors or actuators, including Lego Mindstorms products. You should always start by typing 'help'. It provides you the full command set for the actual device, which you would like to control through chat. Did you know that all devices are Ozeki chat users? If the device is a sensor, it is advised to subscribe to the measurements. Although in this case the device is an actuator. Motors do not send events to Ozeki 10, so it is not necessary to subscribe to them. You can use the Basic commands Table below for your own discretion.
|help||request the command set|
|subscribe||subscribe to device messages|
|unsubscribe||unsubscribe from device messages|
|subscribers||shows the list of subscribers|
Basic commands Table - General commands for all devices
It is good to know that the speed of the Medium motor is 240-250 RPM. For beginners RPM stands for Round Per Minute, which means that you can rotate your LEGO parts exactly 4 times each second. The rotation speed can depend on the battery power and the weight load of the motor. If you are a higher grade student, it is good to know that the torque of the servo is 8 Newton on 0.01 m from which you can calculate the power required from the battery.
Vice versa the Large motor is stronger. It has exactly a 20 N running torque on every 0.01 m, which makes it twice as strong as the Medium motor. It's backslash, is it's slower speed. It can rotate around 2 and a half times each second with it's 160 RPM rotation speed. It is good to know that both motors are precise. They can both position themselves to a certain angle according the received command. This is guaranteed by the tacho feedback sensor, which measures rotation speed.
- The touch sensor and sensor messaging
- Capturing infrared signals using the IR sensor
- How to measure light intensity and how to capture color information
- Distance measurement, the ultrasonic sensor
- Orientation in space, the gyroscope sensor
- Using the LCD display
- Using indicator leds on the Lego Brick
- Power management and working with the brick battery
- Playing sounds on the Lego speaker