Robotics
Robotics
Programming is the methodology or steps necessary to build a program. During this process, the
program is written according to the syntax of a programming language, it is tested, improved,
installed, and maintained.
A program is a set of instructions called commands that, written in a specific way (syntax) result in a
computer or robot performing a certain task correctly and quickly.
For a program to be considered of high quality, it must be accurate, clear, efficient, and portable.
A programming language is the set of symbols, words, and rules (syntax) that control a computer’s
physical and logical behavior. It allows the programmer, among other things, to specify the data that
will be processed and stored in the computer.
Block-structured programming language
These languages contain a section of code that allows a group of statements to be handled as one,
removing the obstacle of syntax and concentrating on the logic of programming.
The graphical user interface in Rogic is simple, it allows you to control the robot through icons that
simulate a flow diagram based on logic. You can perform easy programming exercises or add
sequential, conditional, and cyclic control structures. At this stage, we will get to know the graphical
environment of Rogic, which is a block programming language.
B. Button area
A. Options menu
Rogic’s main screen
C. Programming area
The Menu in Rogic contains the File, Setting, Mode and About options that display various
commands, such as saving and opening a program, as well as configuration and updates for the
robot.
File It contains the options: New To start a new program.
Open To open a program in order to Save To save a program we are still editing.
execute it or edit it.
Save As To save a program for the first time, it allows us
to choose the location where we want to save it.
Exit. to quit the program. Setting This option allows us to adjust the CPU port where
the robot will be connected to the computer.
Mode Robot updates, Bluetooth wireless connection, About It shows information about the Rogic’s
and virtual remote control. version we are using.
Download
BUTTON AREA It compiles and downloads the program in the
Robot CPU.
These are buttons used to download the program
directly to the CPU of the robot you have created, Run
as well as to run and stop a program. It starts the execution of the program (to see the
robot in motion, it must be connected to the
computer).
Stop
It stops the running program (when the robot is
connected to the computer).
www
It is the link to the official website.
Exit
It closes the program.
COMMAND AREA
Delete commands. The programming blocks to be deleted are placed on this icon.
Programming Area
Navigation bars
Delete commands
Functions
It is the first command button that appears on the Rogic
screen. When you select it for the first time, the
subcommand “New” (void) is displayed. This allows us to
create functions.
• A function is a group of orders to which we
assign a name, this name is necessary to be
able to call the function during the execution of
the program.
While: The robot evaluates a condition and, if the condition is true, the robot
will repeat the instructions inside While.
Loop: This command orders the robot to repeat one or more times the
instructions that are within the Loop status.
The button If Else presents programming commands that allow the conditioning of the actions of our robot.
• IF Else: Status of conditional control, the Robot evaluates a condition with the
help of its sensors. If the condition is true, the Robot performs instructions, if the
condition is false, it processes different instructions.
• IR Remote Control 5: It conditions the movements of the robot through a 5-button
remote control and an infrared receiver.
• IR Remote Control 8: Conditions the movement of the robot through an 8-button
remote control and an infrared receiver.
• Bluetooth R/C 12: Conditions the movement of the robot through a 12-button
remote control and a Bluetooth module.
• Bluetooth R/C 10: Conditions the movement of the robot through a 10-button
remote control and a Bluetooth module.
• Contact S/W: Conditions the actions of the robot using contact sensors.
• Rand: Random control function.
Sensors
A sensor is a device that detects events or changes in its physical or chemical environment, measures
magnitudes, and sends this information to a processor for further reading or processing.
Smart Rogic is an application used to program the functioning of a robot from a distance, through
communication by Bluetooth and a personal computer or a mobile device, such as a cellphone, a
tablet, or an iPad.
The application is downloaded from the Play Store or App Store (Apple) in any mobile devices or on
a webpage.
SmartRogic
Download the program
Undo
Redo
Remove program
Button area: In this area, the communication between the mobile device and the robot is generated
to execute the program elaborated on Smart Rogic. It contains the following buttons:
The Bluetooth is a communication protocol that allows the wireless transmission of data (pictures, music,
contacts, among others) and voice between different devices placed near each other, within a radius of,
generally, ten meters.
The use of Bluetooth has been associated with cell phones since they were the first devices to incorporate this
protocol.
Nevertheless, nowadays this wireless technology is present in smartphones, tablets, portable computers,
mouse, keyboards, printers, headphones, tv, digital cameras, MP3 players, or game console.
Bluetooth connection 1. Click on settings
Sensors: Actuators:
Controller:
They allow the robot to Mechanisms that allow
It processes the
become aware of its the robot to
information it receives
surroundings and send communicate and infer
and transforms it into
information to the in its environment.
actions.
controller.
BASIC OPERATION
Environment (Program)
Feedback
Output devices:
Input devices: Processing devices:
They can be different
In computers it is the
They are generated actuators such as
CPU, in robots they
through the sensors. motors, servomotors,
are called controllers.
LEDs, horns, etc.
PROGRAMMING STRUCTURES
Instruction n
Example:
• Operating current
It is the amount of current that the motor requires. The greater the load the motor has, the higher
the current it needs.
Increase in current with respect to the load
Current
Load
DC motor parameters
• Speed
It refers to the speed with which the motor shaft rotates; is given in revolutions per minute (rpm). In
our case, we will use engines with speeds of up to 100 rpm and 600 rpm.
• Torque
It is the force that the motor exerts on the load. The larger the torque, the heavier the load may be.
• Speed Control
It is controlled through a PWM (Pulse-Width Modulation) signal composed of a series of pulses. In
Rogic, we can choose a speed on a scale of 0 to 15, which are the margins of PWM signals that
the program uses to control the speed of a motor, where 0 indicates that the voltage sent to the
motor is equal to 0V and 15 is the maximum voltage that the controller can send to the motor,
which is between 5V and 7V, considering that the speed of a motor depends on the voltage it
receives.
Microwave
oven
Common
uses
Connection
between
blocks
Command block
DC Motor
Connection port
Ahead
Behind
Speed
Example: We program Motor 1 and Motor 2 with a forward direction and a speed of 10 units.
Servomotor
command block
Delay
It is one of the most used
functions in programming, it
makes the processor wait a
defined time before executing the
next instruction.
Delay
Songs
Video games
Means of
transportation
Softwares
Robots
Common
uses
LED
Light Emitting Diode
As we can see in the figure below, energy flows from the highest voltage to the lowest.
In this electrical circuit, the energy leaves the positive terminal and passes through the resistor, which
absorbs energy just like the led; it then emits light to check that there is electricity flowing through the
circuit and, finally, the circuit is closed by connecting it to the negative terminal.
Electricity Resistor
flow
5 volts
LED
battery
Common
uses
BUZZER
Example:
If we have plugged a horn into the OUT 1 port on the CPU and it is given the
instruction to make a sound for two seconds, turn it off for a second and then turn it on
again for a second, the programming in Rogic would look graphically as follows:
ON
We use this command to turn on the
devices connected to the CPU output
ports.
Combination of ON, OFF, and Delay commands. When we find more than one LED light in
the robot and we want to perform an on/off sequential programming, we must understand the
use of the OFF command. This is because we must give the precise indications to be made
to each of the ports. Just as we can turn all the ports on and off at the same time, we can
also indicate that they turn on one by one at a certain time, interspersed or also
intermittently. This type of programming can be done with the combination of ON, OFF and
Delay commands.
Introduction to Robotics
Stage 3 Conditional Programming Structures
Programming
Structures
• If Else
3.2 Conditional
commands
• IR Sensor
• Remote Control
3.3.Sensor
• Contact Switch
3.1 What are the conditional control structures?
They are programming structures that, when evaluating a condition, allow to decide which alternative the program flow
will follow depending on the result. Rational and logical operators are used to establish complex conditions.
• Simple
• Compound or double
• Multiple or nested
Simple
Types of conditional structures
For the correct operation, we must be sure that the remote control as well as the control sensor are in the same communication channel by
moving the switch on each one of them with the same numeric pattern.
3.3 Sensor
Contact Switch
Sensor that measures the presence of the object that is detected by directly making physical contact. When the
height of the plunger changes, the sensor calculates internally the amount of the displacement. Contact sensors are
simple and basic, they are used mainly for detecting height, thickness, or object deformation.
3.4 Activities
3.4 Activities
3.4 Activities
3.4 Activities
Introduction to Robotics
Stage 4 Cyclic Programming Structures
1. The expression or condition that is evaluated each time the cycle repeats.
The programming is made through command lines, they are special words that, by being
written in certain way, called syntax, they make the CPU to understand that it is receiving an
instruction.
Programming by blocks is a graphical programming language that uses interconnected
programs that hide the command line. It allows us to learn the programming logic avoiding syntax
errors.
With the Rogic software we can see lines of code that hide our program by clicking the right
mouse button on the programming area, the Rogic Editor Open screen will open and we can
visualize our programs in line of code.
The While syntax in the Rogic editor looks as the example below:
While (condition)
{
instruction block
};
Characteristics:
b. Command block
When adding the Loop programming command in the
programming area and clicking the upper right button, the
following screen will appear:
● In the text chart you write the amount of times an
instruction will be repeated and confirm to apply it.
for (name of the variable with value initialization; stop condition; increment or decrement)
{
//instructions to execute in each repetition (iteration)
} //end of the cycle
The Break command ends the repetitive
cycle without analyzing the cycle’s
condition.
C. Break When the sentence Break is executed
a. Operation there is a jump to the first line outside the
for that contains it. We must consider
that if we are in nested cyclic structures
it only comes out from the first repetitive
structure that contains it.
Inside the command While there is the
command Break.
b. Command block
c. Diagram of the Break structure
d. Rogic Editor