Вы находитесь на странице: 1из 16

Ccon102

sensor blocks, control blocks and program blocks. Besides, several block
libraries that are not used frequently can also be called from the menu bar.

4.2 Names and Functions of Graphic Blocks

4.2.1 Actuator Blocks

Actuator blocks include all electronic components that can perform certain
motions in case that they receive certain commands from a related controller.
Main commands from controller consist of DO (Digital Output) startup and
shutdown, DC (motor) rotation, voice, display, etc. Below is a list of detailed
blocks:
S.N. Icon Name Function
DC ports on the controller: DC0~DC3; Check
then become valid;
1. Start motor Speed variation: -100~100; if motor is
closed-loop motor, then have the option
Closed-loop selected;
DC ports on the controller: DC0~DC3; Once a
2. Stop motor DC port is selected, relevant motor will stop its
rotation;
It represents the LCD screen of the controller;
Ccon102 controller can display 8 lines of
3. Display
characters; numbers of characters in each line
cannot exceed 21.
It refers to the digital output function of I/O ports
on the controller; all on-off-type actuators can
use this function; Channel Number parameter
4. Digital output for this block corresponds to I/O port on the
controller, can select multiple options; Status
parameter corresponds to the DO on-off status
of the I/O port;

Page 24
Ccon102

It corresponds to the digital output function of


relative I/O port on the controller; generally
5. LED
used for colored LED in the robotics kit; refer to
digital output instruction to find more details;
It corresponds to the digital output function of
I/O ports on the controller; generally used for
6. Electromagnet
the electromagnet in the robotics kit; refer to
digital output instruction to find more details;
It refers to the buzzer inside the controller; with
this function, a song can be made; 2 IMP
7. Tone
parameters available for this block: Time and
Frequency;
Define integer variable or do mathematical
8. Calculate
calculation;
Wait for a certain period of time; within the
9. Wait pre-set time, controller doesnt make any
motion; unit of time is second;
Initialize the servo motor before using it; actual
function is to switch on the RS485 power;
10. Initialize servo Note: The program will pause for a second
when executes the block, so we suggest the
user to put it at the top of a program.
It corresponds to RS485 function of I/O ports;
used for controlling digital servo by RS485
function (different from DO and DC control
mode); each servo has a ID; selecting all
11. Digital servo servos will control all servos linked to the
controller; speed refers to the rotary speed;
speed varies from 0 to 1023; position refers to
destination position angle; position angle varies
from -150 to 150; 0 refers to the position

Page 25
Ccon102

where the notch on the driving plate and notch


on the servo case can align each other;
Note: DC motor related blocks used in flow chart equal to motors
provided in robotics kits.

4.2.2 Sensor Blocks

Sensor blocks include all collection modules that can gather environment
data for the controller. Controller collects environment data via functions such
as AI, DO, counter, etc. Below is a detailed list of sensor blocks:
S.N. Icon Name Function
Read analog input value from relative I/O port on
the controller; AI Channel Number corresponds
to I/O port number on the controller; Clicking AI
Analog Var1 can help you rename the variable; Clicking
1.
input Convert it to be a Compare block after
detection can switch the block to be a judgment
block; Condition loop block will be referred in
control blocks in detail;
Read analog input value from relative I/O port on
Light the controller; generally used by light sensor for
2.
detection data collection; refer to Analog input instruction
to find more details of its usage;
Read analog input value from relative I/O port on
Temp the controller; generally used by temp sensor for
3.
detection data collection; refer to Analog input instruction
to find more details of its usage;
Read analog input value from relative I/O port on
Greyscale the controller; generally used by greyscale sensor
4.
detection for data collection; refer to Analog input
instruction to find more details of its usage;

Page 26
Ccon102

Read analog input value from relative I/O port on


Flame the controller; generally used by flame sensor for
5.
detection data collection; refer to Analog input instruction
to find more details of its usage;
Read analog input value from relative I/O port on
Voice the controller; generally used by voice sensor for
6.
detection data collection; refer to Analog input instruction
to find more details of its usage;
Read digital input value from relative I/O port on
the controller; DI Channel Number corresponds
to I/O port number on the controller; Clicking DI
Var1 can help you rename the variable; Clicking
7. Digital input
Convert it to be a Compare block after
detection can switch the block to be a judgment
block; Condition loop block will be referred in
control blocks in detail;
Read digital input value from relative I/O port on
Switch the controller; generally used by switch sensor for
8.
detection data collection; refer to Digital input instruction
to find more details of its usage;
Read digital input value from relative I/O port on
Magnetism the controller; generally used by electromagnet
9.
detection for data collection; refer to Digital input
instruction to find more details of its usage;
Read button status info of the controller; Start
key on Ccon102 can be read; Enter key, Left
Button
10. key and Right key of the controller can be read;
status
With this block, keys on the controller can be
used as a button in the software;
System Read current time of the system timer inserted in
11.
time the controller; unit of return value is second;

Page 27
Ccon102

12. Reset time Clear system time, and start timing again;

Start the counting function of related I/O port on


the controller; Counter channel of this block
corresponds to relative I/O port number on the
controller; Before counting , make sure the right
Start
13. port has been started; After rotating counter starts
counter
counting, the controller will record pulse signal of
the port and store in System variable (the
system variable should be assigned for the
relative port);
Clear the recorded value of the port that is linked
Clear
14. to the rotating counter; (empty value in system
counter
variable)
Get the accumulated value from the port; (Assign
Get
15. the value in the system value to a user-defined
counter
variable, such as Counter Var1)
End the counting function of relative I/O port on
the controller; Counter channel of this block
Stop corresponds to the relative I/O port on the
16.
counter controller; After closing this port, the System
variable area assigned for the rotating counter
will be drawn back;

4.2.3 Control Blocks

In user program, return value from each port generally has either of the
below two functions: data storage or judgment making. And judgment making
is used more frequently. As to VJC software, three judgment modes are
available, they are: while sentence, ifelse sentence, for sentence.
If a program needs to make a judgment, there should be an object and
reference value. The object for comparison is often the return value of a certain

Page 28
Ccon102

sensor or updated variable value. So each block that is capable of reading


function in sensor blocks can be converted to a Condition judgment block.
Below is a detailed list of control blocks:
S.N. Icon Name Function
The block works as for sentence in C language.
Loop number parameter in this block means
1. Multiple loop
how many times the block will loop. Exact loop
number is specified by users
The block works as while (1) sentence in C
2. Infinite loop language. It repeats the body inside the sentence
infinitely.
The block works as while sentence in C
language. Parameters are the conditions that can
Condition be set by users. As long as the loop condition is
3.
loop met, the loop will continue, or the loop will be
terminated and the program will run below
sentences.
The block works as ifelse sentence in C
language. Parameters can be set by users. If the
4. Compare condition is met, the program will implement the
Y branch, or the program will implement the N
branch.
The block works as Break sentence in C
language. It is used inside a certain loop. When
5. Break
the program implements to this block, the quit the
current loop.

Condition expression
Condition mentioned above is an expression including three parts: left
part, middle part and right part. Left and right part can be formulas, variables or
numerical values, while the middle part can be ==, !, =, >, <, >=, etc. Return

Page 29
Ccon102

value of such condition sentence only has two possibilities, they are 0 and 1. If
return value is 0, the condition is not met. If return value is 1, then the condition
is met.
When setting condition loop and condition judgment, you can find
Condition 1 and Condition 2. Usually we only use Condition 1. Condition
2 will become valid if Valid option on tab Condition 2 is selected. After
valid on tab Condition 2 is selected, other parameters for Condition 2 will
be activated (refer to below picture).
Detailed description:
Only when Valid selected will parameters for Condition 2 become
activated;
Logic relation means the relation between Condition 1 and Condition
2. Three logic relations are available, they are AND, OR and NOT (for C
language, &&, || and &&! instead). Parameters for AND, OR and NOT
can be formulas or values. Three results are available for the calculation:
Condition 1 AND Condition 2: when both conditions are met, result is 1,
or result is 0;
Condition 1 OR Condition 2: result will be 1 if one condition is met at
least, or result is 0;
Condition 1 NOT Condition 2: If return values for both conditions are
different, result is 1, otherwise result is 0;

Page 30
Ccon102

4.2.4 Program Blocks

S.N. Icon Name Function


This block can be used to build a new
subprogram. Users can also reference a
subprogram of another program. Subprogram
New
1. can be taken as a package of many blocks for
subprogram
realizing a certain function. Subprogram can
be used easily in later operations and can
keep the main program relatively brief.
This block is used to end a certain
Subprogram subprogram and keep the flow chart of the
2.
return subprogram complete. There is no practical
function for the block.
This block is used to end the main program
3. End block and keep the flow chart of the main program
brief. There is practical function for this block.

Page 31
Ccon102

With this block used, users can write C code


to make a program by themselves. Be sure
grammars used are right, or errors will appear
4. Customize
when compiling the program. Users without a
C language background are not suggested to
use this block.

4.3 Variables Box

For graphic blocks, you may find Variable option or sensor variable option.
After clicking that option, you will find a pop-up dialogue box as shown below.
The dialogue box is the variables box.

Variables box integrates all variables used in flow charts. Users can switch
types of variables by clicking icons of different sensors or others in the picture
as shown above. Then users can choose a serial number from 10 options
above icons on the picture as shown above. Highlighted option (yellow
Page 32
Ccon102

background) means the option is selected. There is also a key icon after the
selected option. In the area of icons, gray box means the variable type is
unavailable.

4.4 Other Block Libraries for Flow Chart Programming

For advanced users, we have developed several


special blocks. To use these blocks, you should list them
on the left panel of the flow chart programming area. You
can find these special blocks in Tools of the main menu.
After clicking the specific blocks, they will be listed on the
panel left to the flow chart programming area.

4.4.1 Line Tracing Blocks

Line Tracing Blocks are the blocks library


specially added for line tracers with grayscale sensors. It
is required that the grayscale sensors should be lined in
a row in the front of the line tracer. The number of grayscale sensors can be 5
or 7.
We suggest new users to learn 6.4 Line Tracing Principle of Grayscale
Sensors as the first step.

*Initialize*
This block is for setting the properties of line tracer. It determines which
port the motor or the grayscale sensor will be connected, output power of the
motor etc.

Page 33
Ccon102

Closed-loop Motor: If the motor that you use is a closed-loop motor, you
need to check this item. However, if your motor isnt, do not check this
item; otherwise, your motor will rotate at the max speed.
(Motor) Port: Two motors on the line tracer. One for the left wheel, one
for the right wheel. The user can decide which port the motor will be
connected to.
Power: The actual speed the motor generates is the speed value that
the user programs multiplies by the power value. If the power values are
positive but the robot moves backwards, the user can set the power
values negative. In this case, the user wont consider about turning
while setting the motor speed.
Number of Grayscale Sensors: If your robot is a line tracer with 7
grayscale sensors, please select 7 Grayscale Sensor; If yours is one
with 5 greyscale sensors, please select 5 grayscale sensors. If yours
is the one with neither 7 nor 5 grayscale sensors, then the Line Tracing
Blocks are not applicable, the user needs to customize by him/herself.
(Grayscale) Port: It determines which I/O port should one grayscale
sensor connects to.

Page 34
Ccon102

Types of Lines If the line is black (white ground), choose Black Line. If
the line is white (black ground), choose White Line. The user needs to
note that the white and black are concepts to grayscale sensors, for
example, glass is colorless, but the grayscale sensor will identify it as black.
Turn on DO?: This item determines whether to turn on the Digital Output. Select
Yes to switch on all the grayscale sensors.
Deviation of Threshold Value: The threshold value (i.e. critical value) usually refers
to (Minimum value + Maximum value)0.5. However, under some particular
circumstances, you may need the threshold value to deviate toward the minimum value by
decreasing the 0.5. The user needs to note that the threshold value shouldnt be too
small, like (2+8)0.5equals 5, if the user changes 0.5 into 0.1, the threshold value
will be invalid, because its even smaller than the minimum value.
Notices: The block of Initialize is for setting properties of the robot. No matter the line
tracing programs or threshold value of the grayscale sensor, the user needs to use this
block to start with. Usually, the block is at the beginning of a program. However, if types of
the lines change while the line tracer is moving, for example, black line on white ground
changes into white line on black ground, then the user needs to add another Initialize
block.
Initialize block can be seen as a block that stores information of the necessary robot
properties.
*Environment Gathering*

This block is used to gather the value of the ground grayscale. If the robot only
moves on one type of the ground, you only need to select
one type accordingly. If the robot moves on both types, you
need to check them both.
In the flow chart program, an Initialize block must be put
before the Environment Gathering block.
After being operated on the controller, the user can operate by

Page 35
Ccon102

instructions displayed on the controller. Take selecting both types as an example, the user
will go through some steps as following.
A. Move the arrow to select Yes by pressing Left or Right button, then press
ENTER to enter the interface of environment gathering. An instruction on the screen tells
you to put the grayscale sensors on the BLACK LINE.
B. Put the grayscale sensors on the BLACK LINE (refers to the black line on the
white ground that deviates to white the most), then press ENTER and wait until an
instruction appears on the screen telling you to put the grayscale sensors on the
WHITEGROUND.
C. Put the greyscale sensors on the WHITE GROUND (the blackest white ground
with black line on it), then press ENTER and wait until an instruction appears on the
screen telling you to put the grayscale sensors on the WHITE LINE.
D.Put the grayscale sensors on the WHITE LINE (the blackest white line on the
black ground), then press ENTER and wait until an instruction appears on the screen
telling you to put the grayscale sensors on the BLACK GROUND.
E. Put the grayscale sensors on the BLACK GROUND (the whitest black ground with
white line on it), then press ENTER and wait until an instruction appears on the screen
telling you that the environment gathering is OK (done).
F.If the block is followed by other program blocks, the program will go on after Step E
is complete.
Notices: There should be an Initialize block before the Environment Gathering block,
otherwise, the correct threshold value will not be gathered. The values will be stored in
EEPROM10-23 in turn, in which the values gathered from white ground with black line
will be stored in EEPROM10-16, and the values gathered from black ground with white
line will be stored in EEPROM17-23. If EEPROM is occupied in the program, do not use
EEPROM10-23; the user can change the threshold value directly in EEPROM10-23
instead of using Environment Gathering block.
*Intersection*

Page 36
Ccon102

Type of Intersection: The offset orientation of the intersections in one block. Two tips
for users to select the type of intersections. .
The same direction where the robot needs to turn to.
If the robot neednt to turn, choose one direction that has the less offsets.
Speed of Line Tracing: When the grayscale sensor in the middle is over the line, this
speed value is the speed of the motor that rotates faster.
Left Turn Speed Difference: When the grayscale sensor in the middle is over the line,
this difference value equals to Speed of Line Tracing minus speed of the left wheel(the
slower wheel).
Right Turn Speed Difference: When the grayscale sensor in the middle is over the line,
this difference value equals to Speed of Line Tracing minus speed of the right wheel (the
slower wheel).
Times of loops: This refers to how many intersections the line tracer will pass. A loop will
be complete when the line tracer passes one intersection. The Times of Loops is the
same as how many intersections needed to pass.
Time after Passing Intersection: How long the line tracer will move after passing the
intersection.
Car Stops after Completed: Whether the line tracer stops after the block is complete.
*Time*

Page 37
Ccon102

When theres no intersection or referential point on the way to destination, the line tracer
can be controlled by time. However, the distance the robot moves is determined by its
speed and time. The user can set time, not the speed which is affected by voltage,
frictional resistance etc. These factors cannot be controlled, so the distance/destination
the line tracer will move to cannot be precisely controlled.
*Advanced*

Page 38
Ccon102

This block will end with the return value of one sensor meeting the preset value, for
example, if an IR sensor is plugged into the NO.7 I/O port, the returning value when no
object is detected is 3000; when an object is detected, the returning value will be less than
500. The user can therefore set the line tracer to stop by AI(7)<500.
Sensor Port: The sensors I/O port number that responds to the termination of this
block.
Symbol: Mathematical notation that determines the relation of the return value and the
preset value.
Reference Value: The threshold value of the sensor that responds to the termination
of this block.
*Turn*

The robot motion is controlled by two motors, and turns are made by speed difference of
the two motors. If we think speed as pure numerical value (speed on the counter direction
will be represented as negative values), then the robot will turn to the side with smaller
speed value. This block will be complete for one time after the greyscale sensor crosses a
line.
Crossed Lines: Refers to the lines that itd crossed, for example, the line tracer needs
to turn 180 degrees by crossing 2 lines at a crossroad.
Stopped Position: It determines where the line tracer would stop over the
lineMiddle, Deviate to left or Deviate to right. The line tracer usually turns a little too
much because of inertia, so when the line tracer turns left at a relatively high speed, the

Page 39

Вам также может понравиться