Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Contents
Chapter 0 Preface .......................................................................................................................... 3
Chapter 1 Brief Intro of the Controller ......................................................................................... 4
1.1 Hardware & Parameters of the Controller .................................................................... 4
1.2 Power Supply, Startup and Shutdown .......................................................................... 6
Chapter 2 Controller Interface and Operation ............................................................................ 8
2.1 Main Interface................................................................................................................... 8
2.2 Program Interface ............................................................................................................ 9
2.3 Port Interface .................................................................................................................... 9
2.3.1 AI (Analog Input) ................................................................................................. 10
2.3.2 DO (Digital Output) ............................................................................................. 10
2.3.3 DI (Digital Input) .................................................................................................. 10
2.3.4 Servo Motor ......................................................................................................... 11
2.3.5 Counter ................................................................................................................ 11
2.4 Motor Interface ............................................................................................................... 12
2.5 Configuration Interface.................................................................................................. 13
2.5.1 EEPROM (Electrically erasable programmable read-only memory) .......... 14
2.6 Controller Update ........................................................................................................... 14
Chapter 3 Installation and Use of VJC4.2 ................................................................................ 15
3.1 Installation of VJC4.2 .................................................................................................... 15
3.2 First Start ......................................................................................................................... 16
3.3 Menu Bar and Toolbar ................................................................................................... 16
3.3.1 Selections of Menu Items under Flow Chart Interface .................................. 16
3.3.2 Selections of Menu Items under JC Code Interface ..................................... 18
3.3.3 Toolbar.................................................................................................................. 19
3.3.4 Shortcut Keys ...................................................................................................... 20
3.4 Program Download ........................................................................................................ 20
3.5 Software Online Update ................................................................................................ 21
Chapter 4 Programming Interface ............................................................................................. 23
4.1 Introduction of Flow Chart Interface ............................................................................ 23
4.2 Names and Functions of Graphic Blocks ................................................................... 24
4.2.1 Actuator Blocks ................................................................................................... 24
4.2.2 Sensor Blocks ..................................................................................................... 26
4.2.3 Control Blocks ..................................................................................................... 28
4.2.4 Program Blocks .................................................................................................. 31
4.3 Variables Box.................................................................................................................. 32
4.4 Other Block Libraries for Flow Chart Programming .................................................. 33
4.4.1 Line Tracing Blocks ...................................................................................... 33
4.4.2 Advanced Blocks .......................................................................................... 40
4.5 Writing a Flow Chart Program...................................................................................... 41
4.5.1 Mouse Operation ................................................................................................ 41
4.5.2 Add, Link and Insert Blocks............................................................................... 41
4.5.3 Move Blocks ........................................................................................................ 43
Page 1
Ccon102
Page 2
Ccon102
Chapter 0 Preface
This manual introduces the usage of Ccon102 controller and VJC 4.2
programming software. Meanwhile, it offers several simple program examples
for helping you better understand and use the robotic kit. We suggest you to
scan over this manual before using the robotic kit.
Ccon102 is the second generation of controller designed by us. Compared
with the first generation, main aspects listed below are improved. We believe
the new generation will bring you a complete new, more convenient and
efficient experience. Main functions of Ccon102 are listed as below:
Performance of ports are improved greatly: Sensor interfaces can be
inserted more firmly and conveniently; Each port has multiple functions such
as analog input, digital output, digital output, RS 485; Both DC motor and
closed-loop motor are supported by DC ports;
Dot-matrix LCD: 128*64. Much richer content display;
4 buttons available on the controller. Much richer UI and user modules;
Controller equipped with a dedicated lithium battery (8.4V, 1500MAH);
Battery easy to assemble and disassemble;
Multiple programs can be saved in the controller. Program storage
space reaches 3.96M;
Much richer operation menus; Sensor values can be displayed on the
LCD by menu operation; executor output controllable by menu operation;
EEPROM value can be read and configured; LCD backlight and buzzer can be
set;
Versions of Software:
Main Features of VJC 4.0:
Suitable for Econ101
Test Online is added. This function block can test & control each one of the ports
Digital Input (DI) and Analog Input (AI); control DC motor (DC), Digital Output (DO)
and Digital Motor Output (i.e. angles and rotation speed) on-line.
Multithreading supported.
Online check & update.
Page 3
Ccon102
Add new line tracing blocks for 7 grayscale sensors, line tracing blocks for 5
grayscale sensors and communication blocks.
Main Features of VJC 4.1:
Suitable for Econ101 and Ccon102. The user can switch between them by
selecting Select Controller function in the software.
The Test Online function is removed from VJC software, but can be realized by
the interface of the controller.
Multithreading isnt supported under Ccon102, but is supported under Econ101.
Check for update automatically.
Line tracing blocks for 7 grayscale sensors and communication blocks are
removed from Ccon102.
Main Features of VJC 4.2:
Only applicable for Ccon102. Released at the same time with the hardware
version 2.4.
Multithreading supported.
In order to avoid unnecessary disturbance, Check for Update Automatically is
removed. The user needs to check for update online him/her-self now.
Line tracing blocks are added, which support 5 grayscale sensors, 7 grayscale
sensors and some other advanced functions.
Users can make notes to line tracing blocks in the Flow Chart interface.
Users can call the parameter block by double-clicking on the C-code line in the
JC code window.
Function of closed-loop motor is added. Now user can control speed of the motor.
Combine 4 calculator related blocks into 1 block and 2 system time related blocks
into 1 block.
Move the EEPROM blocks into the newly added Advanced blocks library.
Have fun!
Page 4
Ccon102
port and buzzer at the bottom. Besides, LCD and 4 keys are on the front, while
10 extension slots, 5mm length each, are on left, right, top and back side. More
details are as below:
CPU: ARM 32-byte STM32F103VET6, 72MHz, 512 FLASH, and 64 K
SRAM;
I/O ports: 12 ports; each one of them supports functions, like analog
input, digital input, digital output, counter, RS485 communication1; all
electronic components except motor can be plugged in the I/O ports; Users
can also make their own sensors or actuators according to pins as described in
below table.
Code Definition Code Definition
Motor port: 4 ports; can control rotation speed and direction; support
general DC motor and closed loop motor; output voltage means battery
voltage; Maximum current of per port is 1.5A;
Power supply: 8.4V 1A power adaptor; feed the controller by
connecting to the power port of the controller; dedicated lithium battery can be
used (8.4V 1500MAH, maximum discharge current 6.5A, with protection
circuit);
LCD: Dot-matrix LCD 128*64; with backlight; graphs and characters
can be displayed;
Interface: Values such as analog input value, digital input value,
counter input value, servo angle value, and closed-loop motor input value can
be read by the operation interface of the controller; digital output status of
single I/O port, motor rotation direction and speed on each DC port, target
angle of servo motor can be configured; EEPROM value can be read and
revised by the operation interface; LCD backlight and status of the buzzer can
be set by the operation interface;
Page 5
Ccon102
Page 6
Ccon102
turned on.
Page 7
Ccon102
Ccon102 offers a much richer operation interface. Almost all input and
output tests can be done directly by key operation of the controller. Besides,
EEPROM, backlight and sound can be configured simply by key operation.
This helps to lower the download frequency of programs and improve the
debug efficiency of projects.
During operating the interface of the controller, left and right key are
generally used to select a certain option in a horizontal menu list and adjust
certain values. ESC means quitting current revision or returning to an upper
menu list. Enter means entering a certain menu or validating a certain
operation. There may be a slight difference in menu operation based on a
specific purpose.
Icon
Main menu includes 4 items. You can switch between them by left and right
key. Framed item means the selected item. By pressing the Enter button, you
can enter the submenu of the selected item. Icons and what they represent are
listed in below table:
Icon
Page 8
Ccon102
After entering the port interface, you can switch among AI, DO, DI,
Servo and Counter by left and right key. Characters of AI, DO, DI,
Servo and Counter will be displayed on the left bottom side of the LCD
screen. Port here means I/O port. All I/O ports on Ccon102 controller can be
linked to AI/DI sensors, revolving counters, DO actuators and servo motors. All
electronic components can be operated by key operation on the controller.
Tips: Among key operation of the displayed LCD interface, Enter
generally means entering the submenu of the selected item, left and right key
mean the switching among horizontal items of a menu or revision of
parameters, and ESC means returning to its previous menu.
Page 9
Ccon102
Page 10
Ccon102
2.3.5 Counter
Page 11
Ccon102
Page 12
Ccon102
cancel the selection of a certain motor, you can also press ESC key.
Once you exist from a certain DC motor mode or the overall control mode,
the motor on the related DC port will stop its operation.
Page 13
Ccon102
memory)
Page 14
Ccon102
Page 15
Ccon102
Similar to MS Office, the menu bar and toolbar of VJC should be familiar to
users. In this manual, we will have a detailed intro of related items on the menu
bar and toolbar.
Page 16
Ccon102
EditNew
Subprogram:
A dialogue box
will pop up for
creating a new
subprogram
(See right
picture). Users
can create a System Subprogram or call a subprogram from another program,
and then name the new subprogram by filling the blank behind Subprogram
Name. Behind the Author Name, users can write down their own name for
the convenience of the other users to find the author if they find out some
problems.
EditDelete Subprogram: Users can delete the subprogram they are
editing. This function only works when the displayed interface is the
subprogram interface. Please note that a subprogram couldnt be deleted in
case that the subprogram has been used in a main program.
ViewShow JC Code: In the right panel of the flow chart area is the zone
for displaying JC code. You can unfold or fold the panel at will.
ViewBlock Mark: On the top right corner of the flow chart area is the
parameter prompt window. You can hide it or display it at will.
ViewLine Tracing Blocks: The line Tracing Blocks will be added on the
left after being checked. These blocks are specially designed for line tracers
with 5 grayscale sensors or 7 grayscale sensors.
ViewAdvanced Blocks: Advanced Blocks will be added on the left after
being checked.
ToolsDownload Current File: Download current file to the controller.
You can use shortcut key F6 to download current flow chart (F5 is for
downloading JC program). Please note that USB cable need to be linked
before downloading.
ToolsScreenshot: Grab the image of current flow chart window. When
the function is activated, a pop-up dialogue box will suggest you to select a
Page 17
Ccon102
There are some slight differences in menu bar and toolbar between flow
chart interface and JC code interface.
EditGo to Line: When you click this item, a dialogue box for line setting
will pop up. Under JC code interface, each line of JC code has a serial number.
ViewInteractive Window: Interactive window refers to the window on
the bottom side of the JC code interface. In general, compile error, cautions,
progress errors, etc will be displayed in this area. The position of the
interactive window can be reset by dragging.
ViewMultifunction window: On the left side of JC code area is the
default area for the multifunction window. Multifunction window can be divided
into two sub windows: User Program, Find in File. User Program window
displays the main program, subprogram, variables of the current program.
Users can easily position any of these items (such as a variable) in the JC
code area by double clicking the item in the multifunction window. Select an
item in the JC code area and then right click your mouse, you will see a pop-up
Page 18
Ccon102
menu list. Click Find All, then you will find the results are listed in the Find in
All window on the left side of the JC code area.
3.3.3 Toolbar
Ccon102 controller can save more programs in its storage space. To make
programs more recognizable, we can define their names by ourselves.
Page 19
Ccon102
Three methods are available for downloading the present flow chart
Page 20
Ccon102
program or JC program:
Click Download program button on the toolbar;
Click ToolsDownload Current File in the menu bar;
Press shortcut key F5 to download current JC program, F6 to download
current flow chart program;
Before downloading the program, make sure USB cable is linked. When
Ccon102 controller is linked to the computer via USB cable, the controller will
beep. If no beeps heard, the controller may not be well linked to the computer
or the controller driver not be installed. When Ccon102 controller is linked to
the computer via USB cable, the LCD screen of the controller will enter
program interface automatically. In case that USB cable is not well connected,
downloading dialogue box of VJC software will also pop up while downloading.
If grammar mistakes exist in the program, compile process will be
terminated, and download process cannot be complete. In general, grammar
errors of flow chart program appear in the Customize block. As to JC
program, grammar errors will be displayed in the Interactive window. Double
clicking the error will lead you to the error in the program, and thus is
convenient for error correction.
Please do not pull off the USB cable during downloading, since this may
lead to machine crash.
After downloading the program, please pull off the USB cable firstly, then
run the program.
VJC supports online update. We will provide solutions for bugs found. On
one hand, the one-click update will help you get everything done. Its very easy
and simple. On the other hand, we will also provide new functions, tutorial
programs, etc to users by online update. Click HelpUpdate in the menu bar,
the dialogue box as shown below will pop up. Make sure you have saved your
program before closing for update.
Page 21
Ccon102
Click OK, and the dialogue box as shown below will pop up.
Click Start installation to install new updates. After the installation, click
Quit to close the dialogue box.
Page 22
Ccon102
As show above is the flow chart programming interface. Block libraries are
on the left panel, programming area is the central area, and right panel
displays JC code (can be hidden, code generated automatically, code cannot
be revise manually, convenient for learning C language grammar structure,
parameters of various blocks can be read here).
A robot mainly consists of below parts: a controller, sensors, actuators and
user program. Sensors and actuators are linked to various ports on the
controller, while user program runs in the controller. We can see a robot in this
way: User program read sensor values via controller ports, and then sends
commands to various actuators via related ports after various calculations.
Then actuator will make certain motions after receiving these commands from
the controller.
Ccon102 controller also has RS485 communication function, so it supports
sensors, actuators and communication which are RS485 based.
In VJC 4.2, block libraries are reclassified. They include actuator blocks,
Page 23
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.
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
Page 25
Ccon102
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
Page 27
Ccon102
12. Reset time Clear system time, and start timing again;
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
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
Page 31
Ccon102
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.
*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 LinesIf 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
Ccon102
user needs to select Deviate to left here to make the line tracer stop right in the middle
over the line.
*Start Motor*
This block, divided into time control and sensor control, is mainly used to control
motors. If it is controlled by time, the robot will stop after the time being consumed. If it is
controlled by the sensor, the user can select whether the robot should stop or not after the
block is complete. The return value and the preset value should meet a certain condition
to complete the block.
*Button*
While the program is running, itll pause when gets to the block. Press ENTER on the
controller to proceed to run the program after it.
Page 40
Ccon102
Users can introduce a block to the flow chart by clicking that block on the
panel left to the flow chart area, and then click the mouse again to release the
block after its dragged to the right position in the flow chart area.
Double click the block inside the flow chart area, and then you will see a
pop-up dialogue box.Then you can set the parameters of this block in the
dialogue box.
Right click the mouse on a certain block inside the flow chart area, and
then you will see a pop-up menu list. Items on the menu list are Copy, Paste,
Property, Delete, Copy to clipboard. Right click the mouse on the blank
area inside the flow chart area, you will find Paste from clipboard. Whats
notable is that VJC supports cross-window copy-and-paste function.
Adding a block is easy. Users just need to drag a block into the flow chart
area from the panel left to the flow chart area. To make the block effective,
users should link the block to the flow chart. Besides, inserting of blocks is also
frequently used. Below are some FAQ:
FAQ 1: Why blocks in flow chart area should be linked together?
Reply: If these blocks are not linked together with the Main block (on the
top of the flow chart area), they are not part of the program and will not play
any function for the program. When programming with VJC, you should drag
blocks which you need to the flow chart area and then link them to the Main
block (on the top of the flow chart area).
After these blocks are linked to the flow chart, their corresponding JC code
will be generated automatically. You can see these JC code on the code zone
Page 41
Ccon102
right to the flow chart area. JC code (right to the flow chart area) is also a mark
to check whether the program is valid. If blocks are not linked to the flow chart,
no code related to this will be generated, and of course you cant find the
related JC code of this block on the code zone. In this circumstance, the block
means nothing to the program.
FAQ 2: How to link a block to the bottom of the flow chart?
Reply: To add a block to the end point of the flow chart, users should
select a block on the panel left to the flow chart area by clicking the mouse,
and then users should drag the block to the end point of the flow chart. When
the cursor is at the end point of the last block in the flow chart, click the mouse,
and then you will find the new block is linked to the main body of the program.
Notice: Red point on each block can be hidden by clicking Block joint in
View of the main menu.
FAQ 3: How to make sure a block is linked to the flow chart?
Reply: When the new block is linked:
an arrow appears between the new block and the block above it.
Red point on the block which is above the new block disappears.
New JC code corresponds to the new block is generated in the
code zone.
FAQ 4: How to insert a new block in the flow chart?
Reply: Steps for adding a new block between block A and block B:
Click block B to move away block B and following blocks from the
flow chart. And then click the mouse again to free them from the cursor (See
picture 2);
Drag a new block to the flow chart area and link it to block A (See
picture 3);
Click block B to link Block B and parts below it to the newly added
block (See picture 4);
Check: Observe the JC code zone to see whether new JC code of
the new block is generated or not.
Page 42
Ccon102
Basic operation: Once you click your mouse on a certain block, the block is
picked up. Then you can drag it to any position inside the flow chart area. You
click the mouse again, the block is put down.
Follow below steps to switch the position between block B and block C:
Flow chart can be copied and pasted. Copy & paste operation can be
classified into two types: copy & paste in the same window; copy & paste in
different windows. Below are the detailed operation steps:
Page 43
Ccon102
Page 44
Ccon102
If you want to copy in one flow chart window and paste to another window.
Then Please use Copy to clipboard and Paste from clipboard. Please be
notified that subprogram cannot be copied and pasted.
Page 45
Ccon102
Page 46
Ccon102
comments can improve the readability of the program. When defining variables,
subprograms or making calculations, users are strongly suggested to make
comments. Before programming, user should have a basic grasp of the library
functions. Users are suggested to follow below ways:
Refer to the JC code generated by each block. This method is relatively
simple, and users dont need to learn JC code intentionally. They can grasp the
code while using. And as time passes, they will pile up their knowledge in JC
code gradually. But be notified that some functions not used commonly cannot
be found in graphic blocks for flow chart.
Open main.txt in the installation path of VJC software. You can find all
library functions of Ccon102 controller in the text file.
Page 47
Ccon102
S.N Description
Name Fig. Block
.
Analog sensor;
Detect the light intensity of
1. Light sensor or ambient environment;
The brighter the light is, the
larger the value will be;
Analog sensor;
Detect the temperature of the
2. Temp sensor or ambient environment;
The higher the temperature is,
the larger the value will be;
Analog sensor;
Detect the grayscale by
Grayscale reflection principle; may be
3. or
sensor affected by ambient light;
The darker the ground is, the
larger the return value will be;
Page 48
Ccon102
Analog sensor;
Detect the strength of the
thermal light source; infrared light
4. Flame sensor or
is detected;
The larger the light intensity is,
the larger the return value will be;
Analog sensor;
Detect the volume of the sound
(loudness of general sound source
5. Sound sensor or
is not stable);
The larger the sound is, the
larger the return value will be;
Analog sensor;
Detect the distance between
obstacle and sensor; realized by
Infrared
6. reflection principle;
sensor
The larger the obstacle-sensor
distance is, the larger the return
value will be;
Digital sensor;
Detect whether the touch
switch is turned on;
7. Touch switch or
when switch turned on, return
value is 1; when switch turned off,
return value is 0;
Digital sensor;
Detect whether a magnet is
Magnetic approaching;
8. or
switch When magnet detected, return
value is 1;
When magnet not detected, return
Page 49
Ccon102
value is 0;
To collect return value of a certain analog sensor, we can use Analog
input block instead of the analog sensor block. Correspondingly, we can use
digital input block to replace all digital sensor blocks. As to sensors designed
and made by yourself, you can also use analog input or digital input instead
of relative sensor blocks depending on the types of sensors (analog or digital).
Return value of analog sensor varies within a certain range. We often
select a critical value to compare with the value collected by the related sensor
(>, >=, or <=, <), and then we will add certain execution blocks based on the
comparison results. Critical value here is defined by users. Take light
controlled switch as an example, the operation logic is as below: when the
light strength is not larger than a certain degree (analog input value<= critical
value), the light will be turned on. In this example, critical value is the analog
input value.
Return value of digital value has two possibilities, they are 0 and 1. When
using digital sensors, we often use == or != to compare return values of
digital sensors with 0 or 1. Then the robot built will make certain motions
based on the comparison result.
For Ccon102 controller, we offer 32 EEPROM in which critical values can
be saved. We can have the critical value compared with actual return value of
a certain sensor. And if critical value of a certain sensor needs to be revised
since changes of ambient environment, users just need to revise the value via
controller operation, instead of revising the program by VJC software.
In the panel of graphic blocks for flow chart programming, there are also
uncommon sensors such as system clock, controller keys, revolving counter,
etc. System time block is used for logging time. Controller keys refer to keys
on the controller, while revolving counter is a kind of sensor for calculation
which can be taken as a simplified encoder.
Page 50
Ccon102
For Ccon102 controller, keys available are ENTER key, Left key, Right
key and ESC key. Button status block in sensor blocks, detects one of
Enter key, Left key and Right key. You should choose which key to
detect in the Button status block. Similarly, when button pressed, return value
is 1; when button not pressed, return value is 0. However, please note that
long press of Enter key will power off the controller. So dont long press the
Enter key. But long press of Left key and Right key is OK.
Page 51
Ccon102
5.3 Actuators
Page 52
Ccon102
Please note that closed loop option should be selected in case that the
motor used is closed-loop motor (if not selected, the motor will be taken as DC
motor). However, do not select closed loop option, if the motor is not a
closed-loop motor.
Digital servo has several features such as high precision, large torture,
convenient for connecting, etc. Digital servo should be linked to I/O port and
controlled by RS 485 communication protocol. Before using a certain digital
servo, make sure the relevant RS 485 power supply is powered on. After the
digital servo is on, dont forget to initialize/reset it. Initialization of the servo
motor takes about 1 second, so dont send any execution command to the
servo within this period of time. In VJC software, you can find Initialize servo
block in actuator blocks. Its function is to power on the RS 485 power supply.
Generally this block is put in the beginning of the program.
Notice: For making the controller more user-friendly, RS 485 power supply
for I/O 11 is powered on by default in case that a certain program is running.
So users dont have to add Initialize servo block in the beginning of the
program if the servo is linked to I/O 11. If you use DO function of I/O 11, be
sure that you know the DO function is started by default.
Page 53
Ccon102
Each digital servo has its own ID with which controller can send command
to the servo more accurately. Commands frequently used are rotation speed
and target position, which you can find easily in Digital servo block under flow
chart programming mode. Besides, attention should be paid to the fact that the
running of the digital servo to its target angle takes some time. So be sure you
have left enough time for the servo to move to its target angle. Only after this,
can you add another target angle command.
Reading and revising of digital servo ID can be done by key operation on
the Ccon102 controller. Communication frequency between Ccon102
controller and digital servo is 1M. If Ccon102 controller cant communicate with
digital servo by key operation on the controller, then you can revise the
communication frequency following below steps: find the file 500K to 1M.bin
or 1M to 500K.bin, then copy it to Ccon102 controller; After this step, link
digital servo to I/O 11, and then run the program to revise the communication
frequency of digital servo. If the program is 500K to 1M.bin, then the
communication frequency of the digital servo will be revised to be 1 M
(available for Ccon102 controller). Similarly, the communication frequency will
be revised to be 0.5 M (available for Econ101 controller), If the program is 1M
to 500K.bin.
Page 54
Ccon102
Page 55
Ccon102
Read are those with the shapes of parallelograms. While reading, the
related sensor has it return value updated.
The last block Delay time is used to reduce the refresh rate of the
LCD screen, or people cant see data on the LCD clearly.
With this program, its difficult for a sound sensor to read its return value.
You can refer to program Display maximum sound.flw in FileExample of
the main menu.
Users can find the program revolving counter controlled motor motion.flw
in FileExample of the main menu.
Function: Motor linked to DC 0 will stop its rotation after rotating for 100
circles;
Program: DC motor linked to one of the four DC ports; revolving counter
linked to I/O 0; DC motor linked to revolving counter;
Analysis:
Before using the revolving counter to record the rotation numbers of the
motor, make sure Start Counter block has been added and the counter
channel is correctly selected.
In this example, make sure the counter has been reset (start from 0)
before recording rotation numbers.
When the condition in the Condition Loop is met, the program
implements the code inside the loop body. If condition not met any more, the
program will end the loop and execute later code. The condition in this
program is Counter Var1 < 100. If Counter var1 is smaller than 100, then
the counter keeps recording rotation numbers. And when the condition is not
met any longer, the program will stop recording the rotation numbers and
execute Stop Motor block that follows.
Before using the return value of a certain sensor, the sensor, in general,
has to be read. So the first Get Counter block is used for reading data before
entering the loop body, while the Get Counter block inside the loop body is
Page 56
Ccon102
used to read data for determining whether the loop continues. Take the Get
Counter block from the loop body, you will find the motor never stops. Why?
Think about it.
The last Stop Counter block is not necessary, you can take it away.
You can find the program Light & mechanical controlled lamp.flw in
FileExample of the main menu.
Function: The lamp will light up if light intensity is weak or mechanical switch
is pressed.
Program: Light sensor linked to I/O 0; Touch/mechanical switch linked to I/O 1;
Red LED linked to I/O 2;
Analysis:
Either of the below two conditions is met, the lamp will be turned on:
Light intensity is week; touch switch is pressed. According to this logic, the
relation between above two conditions should be ||, meaning or relation.
How to define Light intensity is weak in this example? We all know
that, to a light sensor, the larger light intensity is, the larger the return value will
be. So here in this example, Light is weak can be defined as Return value of
I/O 0 < certain critical value. To read critical value, we can use example 6.1, or
Ccon102 controller itself (via AI function in Port interface).
In programs that may use critical values, we often define a variable
(use of Calculate block) to store the critical value, thus making it convenient
for revision. In this example, critical value 800 is saved in variable Integer
Var1 of the Calculate block.
Before using the variable, make sure the variable has been read first.
Then the program can continue for condition judgment. In this example,
Condition 2 of the Condition Judgment block should be kept valid. And logic
relation between Condition 1 and Condition 2 should be or.
Page 57
Ccon102
This chapter takes the line following principle of an automatic guided car as
an example, and introduces you to the programming of an automatic guided
car. The automatic guided car is two-wheel driven. Rear wheels are driving
wheels, while front wheels are driven wheels with 5 grayscale sensor equipped.
Left motor (motor for left rear wheel) is linked to DC 0, while right motor (motor
for right rear wheel) is linked to DC 1 port. Five grayscale sensors are linked to
I/O 0 to I/O 4 separately in this order. Users can refer to building of
5-grayscale AGV.pdf in FileExample of the main menu to finish the
building of the automatic car. The AGV (automatic guided vehicle) should
follow black lines on the white ground. (Notice: Parameters referred below and
parameter used in the program may need revision, subject to actual
situations.)
First step: Make clear driving wheels move forward or backward when
speed values are positive or negative respectively. For better knowing the
relation, you can use the motor interface of Ccon102 controller to test the
relation. Conclusion: When the speed value of left motor (DC 0) is positive, left
wheel moves forward; when the speed value of right motor (DC 1) is negative,
right wheel moves forward.
Second step: Measure critical values of grayscale sensors. Users can use
AI function of Ccon102 controller to test the analog-type return values of ports
ranging from I/O 0 to I/O 4, and have these values recorded. After calculation,
we find that return value of white ground is about 1,800, return value of black
line 3,100 more or less, and real critical value 2,700. Calculation of the critical
value: (3100+1800)/2 = 2450; Conclusion: When return value of a certain
value is larger than 2,500, the sensor is on the black line. To reduce the
interference caused by stains on the white ground, we can set the final critical
value to be higher (such as 2,700). But please note that the higher the value is,
the more difficult it is for the AGV to find black lines.
Third step: Design the line following logic of the AGV (automatic guided
vehicle) on the white ground (1 strip of black line is simpler).
Page 58
Ccon102
So as not to deviate from the black line, we hope that I/O 2 grayscale
sensor is always on the black line when the AGV is moving;
When grayscale sensor (I/O N, N may be 0, 1, 3, 4) on either side is on
the black line, the AGV goes astray from its forward direction. The larger the N
is, the more the AGV deviates. And if the AGV deviates, it should be adjusted
quickly.
Three adjustment modes are available for the AGV in terms of their
adjustment efficiency: One wheel at a much larger speed, while the other at a
much smaller speed; one wheel stops, while the other moves forward; one
wheel moves backward, while the other moves forward. Please note that
wheels mentioned here are driving wheels. Its obvious that the third mode has
the highest adjustment efficiency, while it makes the average line following
speed lower. Also obvious is that the first mode has the lowest adjustment
efficiency, while it has the highest line following speed in average. When I/O 0
or I/O 4 is on the black line, users are suggested to use the third adjustment
mode. When I/O 1 or I/O 3 is on the black line, users are suggested to use the
first adjustment mode.
Fourth step: Write the program. Users can refer to program 5-grayscale
line following(easy).flw in FileExample for reference. For simple following
path, 2 grayscale sensors outermost are not used in general and 3 grayscale
sensors can have that work done well. As the line following path becomes
more complicated, the two sensor outermost will play their functions gradually.
In this program, EEPROM is used. You can use keys on the controller to revise
the value of EE 0 to be 2,700.
Fifth step: Analyze the solution for much more complex following paths.
Complicated paths may include acute-angle crossing, direct-angle intersection,
crossroad, T road, curved line, etc. We can divide a complicate following path
to be below parts: simple path (lines without a large radian, 3 grayscale sensor
are enough for line following), crossing (3 grayscale sensors are not enough;
extra 2 are needed for detecting the black line in another direction)
Sixth step: Design the mode of motion of the AGV (automated guided
vehicle). This step designs the line following sequence from the starting point
Page 59
Ccon102
Page 60
Ccon102
(crossing) when the AGV starts turning left. But we can make sure that
grayscale sensor linked to I/O 0 is not on a black line, so we will have
grayscale sensors ranging from I/O 0 to I/O 2 detecting black line one by one in
above sequence. Then when grayscale sensor linked to I/O 2 finds the target
black line, the turning process is finished.
Line following by time: When the AGV follows a simple line, time is the
only parameter. Since subprogram cant pass parameters, users should define
a float variable before using the line following by time subprogram to control
the line following time. When the time is over, the AGV should stop its
movement. (Notice: The float variable cant be defined inside the subprogram.
If the float variable is defined in the subprogram and the subprogram is used
for multiple times in the main program, then one revision of time will change all
the subprograms of this type in the main program.)
Eighth step: Debug the AGV. Download the program to the controller of
the AGV, then debug on the white ground for line following.
Adjust the speeds of left and right driving wheels to make the AGV walk
more smoothly;
Adjust the value of EEPROM 0 to adjust the AGV to different grounds;
Increase the delay time to improve the line following speed of the AGV;
Add weights properly to avoid wheel skid;
Ninth step: Debugging of the AGV finished;
Page 61
Ccon102
Chapter 7 Others
FAQ: How to tell a controller crashed, and what to do after the controller
crashed?
Reply: If long pressing of all keys receives no response, the controller is
seen as crashed. After the controller crashed, cut off the power supply (pull out
the power adaptor, take out the lithium battery inserted), then plug in and turn
on the controller.
FAQ: When running a user program, why light on I/O 11 is lighted on?
Reply: For better use of digital servos, we have the DO function of I/O 11
switched on by default when a program is running, so 485 power supply of I/O
11 is switched on automatically. When using a certain digital servo in the
program, users dont have to add Initialize servo block anymore. If users
want to use DO function of I/O 11, just remember that its opened by default.
But you can still control the on-off status of the DO function.
FAQ: Why digital servo should be linked to I/O 11?
Reply: This is optional, not mandatory. Users can also link digital servo to
other ports. But when digital servo linked to other I/O port, an Initialize servo
block should be added. However, no Initialize servo block is needed if the
servo is linked to I/O 11.
Page 62
Ccon102
FAQ: After the building is done and successfully downloading the program,
it will get back to the main interface whenever I try to run it.
Reply: Base on the description, it should be caused by some
short-circuited I/O components. Please pull off all the wire that is connected to
the I/O ports at first, adjusting the controller to the AI interface, then plug the
wire back to the I/O ports one by one. While plugging, the controller will turn to
the main interface whenever you plug the component that is short-circuited.
Then change it.
Page 63