CourseWare Wiki
Search
Log In
b181
help
common
robot_pan_tilt_megarobot_en
Warning
This page is located in archive.
Differences
This shows you the differences between two versions of the page.
View differences:
Side by Side
Inline
Go
Link to this comparison view
Go
Go
help:common:robot_pan_tilt_megarobot_en [2014/02/19 13:28]
zimmerk
help:common:robot_pan_tilt_megarobot_en [2018/02/03 10:49]
Line 1:
Line 1:
-
==== Pan-Tilt unit Megarobot ====
-
-
Pan-Tilt Unit consits of two drives AI-701 manufactured by Megarobotics. Drive AI-701 form a servo which is controlled by commands via RS-232 interface. The servo directly interprets commands. There is no intermediary control unit between the PC and the drive.
-
-
There are two drives always connected to the one computer via RS-232 bus. Recipient of the control command is determined by the identification number (ID). The azimuth drive (horizontal) has ID == 0, and the drive for the elevation (vertical) has ID == 1. ** Do not change the ID ** -- you can easily cause malfunction of the device. For the same reasons, it is also prohibited to change the speed of the serial communication interface (baud rate).
-
-
-
* Manufacturer ([[http://www.megarobot.net/|MEGAROBOT.NET]]) provides also manual {{:help:common:aimotor701_manual_megarobot.pdf|AI-701}}.
-
* For simple testing, one can use the "AI MOTOR - Tool v1.26", which is already installed in the workplace.
-
* We encourage the student to read a short description of the "{{:help:common:zaciname_s_aimotorem.pdf|Zacínáme s AI-MOTORem}}", provided by ([[http://www.megarobot.net/|MEGAROBOT.NET]]), where the first step of working with the drive in that program are described.
-
-
==== How to control the PT unit ====
-
-
-
Pan-Tilt unit can be controlled in MATLAB using [[http://www.mathworks.com/help/matlab/matlab_external/getting-started-with-serial-i-o.html|Serial Port I/O]].
-
-
- Pan-Tilt is initialized by the following sequence of commands <code>ser = serial('COM1');
-
set(ser,'BaudRate',57600);
-
fopen(ser);</code>
-
- You can control the PT unit by writing corresponding control bytes (see {{:help:common:aimotor701_manual_megarobot.pdf|manuál}}) to the file ''ser'' using command ''fwrite''.
-
- To simplify the PT control the following function is provided:<code>ptmove(ser, pan_pos, tilt_pos);</code> where ''pan_pos'' corresponds to the absolute rotation angle around vertical axis, ''tilt_pos'' corresponds to the absolute rotation angle around horizontal axis. Range of values for ''pan_pos'' and ''tilt_pos'' is from 0 to 254. I covers approximately 80 degrees in a given direction. To set the unit into the initial position (i.e. the position camera optical axis is perpendicular to LCD screen) use the following values ''pan_pos==127'', ''tilt_pos==127''.<code>function ptmove(ser, pan_pos, tilt_pos, speed)
-
if nargin<4
-
speed = 3;
-
end
-
-
sermove(ser, speed, 0, pan_pos);
-
sermove(ser, speed, 1, tilt_pos);
-
end
-
-
function sermove(ser, speed, pantilt, pos)
-
b1 = uint8(hex2dec('ff'));
-
b2 = uint8(bitshift(uint8(speed), 5) + uint8(pantilt));
-
b3 = min(max(uint8(pos), uint8(0)), uint8(254));
-
b4 = uint8(bitand(bitxor(b2, b3), uint8(hex2dec('7f'))));
-
fwrite(ser, [b1 b2 b3 b4]);
-
end
-
</code>
-
- In the end, the communication is close as follows:<code>fclose(ser);
-
delete(ser);</code>
-
help/common/robot_pan_tilt_megarobot_en.txt
· Last modified: 2018/02/03 10:49 (external edit)