Sei sulla pagina 1di 63

Ccon102

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

4.5.4 Copy and Paste Blocks ..................................................................................... 43


4.5.5 Delete Blocks ...................................................................................................... 45
4.6 C Language Interface.................................................................................................... 46
4.7 VJC Library Functions ................................................................................................... 46
Chapter 5 Electronic Components Related to Ccon102 Controller ...................................... 48
5.1 Analog Sensor and Digital Sensor .............................................................................. 48
5.2 Other Sensors ................................................................................................................ 50
5.2.1 Keys on the Controller ....................................................................................... 51
5.2.2 Revolving Counter .............................................................................................. 51
5.3 Actuators ......................................................................................................................... 52
5.3.1 DO Controlled Actuator ...................................................................................... 52
5.3.2 DC Motor and Closed-loop Motor .................................................................... 52
5.3.3 Digital Servo ........................................................................................................ 53
Chapter 6 Programming Examples ........................................................................................... 55
6.1 Display Return Value of an Analog Port ..................................................................... 55
6.2 Control the Motor via Revolving Counter ................................................................... 56
6.3 Light & Button Controlled Lamp................................................................................... 57
6.4 Line Tracing Principle of Grayscale Sensors ............................................................. 58
Chapter 7 Others .......................................................................................................................... 62
7.1 Common Failures and Solutions ................................................................................. 62
7.2 Improvements and Suggestions .................................................................................. 63

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!

Chapter 1 Brief Intro of the Controller

1.1 Hardware & Parameters of the Controller

As shown in the right picture, Ccon


102 has I/O ports on both sides, motor
ports on the upper side, power port, USB

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

A Power supply +/Battery voltage D AI/DI

B +5V power supply E RS485 D-

C Power supply -/Ground/DO output F RS485 D+

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

Others: Ccon102 controller adopts USB flash disk download mode,


maximum storage space reaching 3.96M; You can run any of downloaded
programs just by pressing the buttons on the controller;

1.2 Power Supply, Startup and Shutdown

Working voltage of Ccon102 controller ranges from 7V to 8.4V. Both power


adaptor and dedicated lithium battery can be used to feed the controller. For
making sure the controller will not break down, please dont feed the controller
with voltage over 9V.
Output voltage of the dedicated lithium battery is 8.4V after the battery is
fully charged. The battery has functions of overcharge protection and over
discharge protection. So when the working voltage of the battery is lower than
5.5V, the battery will enter over discharge protection status, and stop its output.
The over discharge protection status will be stopped immediately once a
charger is linked to the battery for charging, and then the charging status starts.
The suitable configuration of the power adaptor for the dedicated lithium
battery is 8.4V 1A. You can simply insert the plug of the power adaptor in the
batterys charge port for charging, or insert the battery in the controller and link
the plug of the power adaptor with the power port of the controller. The working
status of the controller wont affect battery charging. If the light on the power
adaptor is red, the charging status is ongoing, if the light is green, the charging
status is finished.
Long press the Enter key for about 2 seconds, the controller will be started
or shut down (opposite to its previous status). When battery of power adaptor
linked to the controller, you can turn on the controller by long pressing the
Enter key. When the controller is turned on, you can shut it down by long
pressing the Enter key regardless of which interface the LCD displays.
If no response after long press of any key, its for sure the controller
crashed. When the controller crashes, just cut off all power supply to the
controller (take out the battery and pull out the adaptor). Then when battery
inserted or power adaptor is linked, the controller can work well again after

Page 6
Ccon102

turned on.

Page 7
Ccon102

Chapter 2 Controller Interface and Operation

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.

2.1 Main Interface

After the controller is turned on, the LCD will display


the interface as shown in the right picture including the
main menu and battery indicator.
We can roughly tell the battery level by the battery indicator. The battery
indicator differs as voltage of the battery varies. The relation is shown as
below:

Icon

Voltage 8.46V>BV>7.8V 7.8V>BV7.7V 7.7V>BV>7.6V 7.6V>BV>7.1V

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

Items Program Port Motor Settings

Page 8
Ccon102

2.2 Program Interface

Ccon102 controller adopts USB flash disk download


mode, with maximum storage space reaching 3.96 M.
When no program is stored in the controller, you cant
get access to the program interface. As shown in right picture, there are two
programs stored, they are PROGRAMA and PROGRAMB. Numbers before
programs are their serial number for sorting purpose. With these serial
numbers, users can easily find the program they are looking for.
Users can switch among programs under this interface by left and right key.
Selected program will show a different background. In this condition, when the
Enter key is pressed, the program will be loaded to the memory card of the
controller and start running.
When a certain program is running, you can end its running status by
pressing the ESC key. And when the ESC key is pressed, the displayed
interface will return to the main interface.

2.3 Port Interface

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

2.3.1 AI (Analog Input)

The picture on the right is the AI testing interface.


0~11 represent I/O ports, while the following figure 0
means collected real-time input value. 0 as shown in
the right picture means there is not a sensor connected
to corresponding port. Returned AI value of the Ccon102 varies between 0 and
4095.
AI function of port each port can play the role of testing sensor input status.
Values can be read, but no additional operation available.
Attention: Each I/O port of Ccon102 controller has multiple functions. So
the circuit is multiplex. Since the specified sensor should be powered with 5V
power supply when AI function is used, the DO function of the port linked to the
sensor opened.

2.3.2 DO (Digital Output)

The picture on the right is the DO testing interface.


0~11 represent I/O ports, while following figures show
the startup or shutdown status of the DO port. 0 means
switched off, while 1 means switched on.
Users can control the DO status of one port separately by the combination
of Enter, Left and Right keys. To secure the project model, DO port will
return to switched off status automatically when DO control is finished.

2.3.3 DI (Digital Input)

The picture on the right is the DI testing interface.


0~11 represent I/O ports with following figure 0
representing collected real-time DI input values. Return
values from digital sensors have only two statuses, 0
and 1. When displayed value is 0, there are 2 possibilities. Possibility 1: No

Page 10
Ccon102

sensors connected to the relevant port. Possibility 2: Connected digital sensor


is switched off.
DI function of all ports plays the role of digital sensor testing. Apart from
reading the digital value, there is no further operation available.

2.3.4 Servo Motor

The picture on the right is the testing interface for


servo motor. Please be noted that you can only detect
one motor at one time. On the lower right corner of the
picture are parameters that can be configured.
IO means the port to which the servo motor is linked. It aims at opening
the RS 485 power supply on this port. Default value of the IO is --. After
revising the value and then having the Enter key pressed, the setting
becomes valid and the RS 485 power supply is turned on.
ID represents the ID number of the controlled servo motor. Default value
is --. The controller will read the ID of the servo motor 1 second after the 485
power supply is turned on. Users can change the ID number on the interface.
After revising and making it valid, the ID of the servo motor which is actually
connected will also be changed.
A means the position angle of the servo motor. Default value is --. The
controller will read the position angle of the servo motor 1 second after the 485
power supply is turned on. After pressing Enter key, uses can revise the
angle by left and right key. Then press Enter key for confirmation, the servo
motor will move to the target angle.

2.3.5 Counter

The picture on the right is the counter testing


interface. This function can only read the return value of
one revolving counter. Since revolving counter should
be driven by motor, there is also motor parameter in the

Page 11
Ccon102

counter testing interface. Control parameters of the revolving counter is shown


in the right picture.
IO means the port to which the revolving counter is linked.
DC means the port number to which the motor that drives the counter is
linked.
S: Used to control the rotation of a motor. When S is highlighted, press
Enter key to enter motor control mode. After entering the mode, you can
change the speed and rotation of the motor via left key and right key. Speed
will be displayed after the S character.
CNT: The value after CNT is the return value of the specified revolving
counter. When the value is highlighted, you can press Enter key to clear the
value (reset the counter).

2.4 Motor Interface

The picture on the right is the DC Motor testing


interface. In the column that DC characters are listed,
M0~M3 corresponds to DC0~DC3 respectively. In the
column that Speed is listed, numeral values represent
motor speed (-100~+100) of each motor. In the column that Encode is listed,
numeral values represent return values from all closed-loop motors (available
only when closed-loop motors are linked to motor ports, value ranging from 0
to 65535; As the closed-loop motor rotates CW or CCW, the values increases
or reduces, ranging from 0 to 100)
After entering the DC motor testing interface, the DC characters are
highlighted. Press Enter key, the interface will switch to overall control mode.
Then you can control the output speed of all motors at the same time with left
and right keys. You can also choose a specific motor with left and right keys.
After one specific motor being selected, press Enter key to enter the
submenu of that specific motor. Then you can adjust the motor speed of that
specific motor. Real-time speed value of that specific motor will be displayed
on the LCD screen as you adjust. If you want to return to the previous menu or

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.

2.5 Configuration Interface

Configuration interface includes several sub interfaces such as EEPROM,


sound interface, backlight interface, language interface, contrast interface,
Host ID interface, communication interface, About interface, etc. Users can
enter the item they want to select with the left key and right key. Enter key will
help users get access to its interface, while ESC helps users exist from that
interface.
EEPROM: please refer to 2.5.1
Sound: switch of the buzzer; once selected, it will be valid; when buzzer
switched off, pressing keys will not produce any sound, but Voice block inside
a program still works.
Backlight: Switch on or switch off the backlight by key operation. In bright
environment where the interface can be seen clearly, you can turn off the
backlight for saving electricity.
Language: Users can switch languages by this function. For now, only
Chinese and English are supported.
Contrast: Used to adjust the contrast of the display. While adjusting, levels
of the contrast will be displayed on the screen. Press ENTER to save and quit;
press ESC to quit without saving (return to the condition before adjusting).
Host ID: When multiple controllers are used, this parameter needs to be
configured. It assigns the host address in RS485. It should be set properly
before doing multi-controller communication.
Communication: Used when a controller is linked with others. This function
can be used to set the controller as the affiliated controller. Quit the mode of
Affiliated controller by pressing ESC.
About: System version of the controller will be displayed here. This file is
for v2.4.

Page 13
Ccon102

2.5.1 EEPROM (Electrically erasable programmable read-only

memory)

Ccon102 has assigned 32 EEPROM, each one capable of storing


integer variable ranging from 0 to 65535. In case of sudden shutdown of the
controller or electricity outage, data will not be lost. Users can read or revise
data inside each EEPROM though user program. Its also available for users to
revise or read data stored in each EEPROM via the operation interface of the
controller.
By revising EEPROM data with key operation, users dont have to
re-download programs when debugging. What they can do instead of
re-downloading programs is to revise some parameters by key operation on
the controller.

2.6 Controller Update

The version of Ccon102 can be seen by pressing About in Settings on


the controller. After the version of 3.0, users can update the controller
themselves. Well share the new VJC patch to users when there is a new
version. After the VJC update is completed, youll find a file named
Update.bin in the Example folder. Copy the file and paste in the controller
folder, pull out the data cable and the controller starts to update automatically.
The controller will only update to a version for 1 time. The user needs to
notice that the name of the file, Update.bin, should not be changed,
otherwise, the controller wont update automatically. Also, if you copy the
previous version file into the controller that has been updated into the latest
version, the controller will start to update as well.

Page 14
Ccon102

Chapter 3 Installation and Use of VJC4.2

VJC stands for Graphic interactive C language. It supports standard flow


chart programming and standard C language programming. Beginners can
learn it quickly, while advanced users can fully use it to develop much more
complicated projects.

3.1 Installation of VJC4.2

Users can get VJC4.2 software on our website (http://vjc.xpartner.cn) or


download from our website directly. After downloading the software, follow
installation tips to finish the installation. During the installation, you can select
an installation address by yourself. Details are list as below:
Firstly, the software will install the driver of Ccon102. If the driver is not
installed correctly, you cant download programs to Ccon102 controller. If you
wont use Ccon102 in later projects, you can skip the installation step of
Ccon102 controller driver. Users can also install the controller driver manually.
The controller driver is listed in the below catalog: \\VJC40CH\superdriver\.
The name of the controller driver is as below:
CP210x_VCP_Win_XP_S2K3_Vista_7.exe.
When installing the software, the software will verify whether your
computer has installed .NET2.0 (or more advanced version). If .NET2.0 is not
installed, the software will install .NET2.0 firstly. If .NET2.0 already installed,
you can directly install the VJC software.
Default save path for VJC software is the root directory of partition C.
Users can revise the save path by themselves. After the installation, a shortcut
named VJC_4.2_CH will appear on the desktop and quick launch bar
automatically. Double click the shortcut, then the software will be started.
Attention: suggested operating environment for VJC4.2 is Win XP and
WIN7.

Page 15
Ccon102

3.2 First Start

When running the software for the


first time after the installation, users
can find a pop-up option box for
selecting a controller. As shown in
the right picture, you can choose the
right controller based on the real
controller you have. After clicking the
icon of that controller, you can enter the main interface for flow chart
programming.
If you are not running the software for the first time, you wont see the
controller option box. But you can switch the controller by clicking
ToolsSelect controller. After the controller type is switched, the software will
restart automatically. So dont forget to save your program.
Since Ccon102 has some new functions compared with Econ101 controller,
programs for different controllers are not universal.

3.3 Menu Bar and Toolbar

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.

3.3.1 Selections of Menu Items under Flow Chart Interface

FileExport JC File: Save current flow chart as JC program.


EditMain Program: Back to main program interface from subprogram
interface. This function only works when the present interface is subprogram
interface.

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

save path. If you want screenshots to be in a white background, you can


remove the confirmation mark before Background in the View.
ToolsSave flow chart in real time: When this item is confirmed, the
program in editing will be saved automatically. To make this function valid, you
should save your file manually for one time. Automatic saving function can help
you improve the security of the file you are editing in case of power outage or
that you forget to save the file.
HelpHelp Topics: Users can call the help docs of the software by
clicking the function key. Of course, users may also find updated information,
which generally appear in the end of the texts.
HelpCheck for Update: VJC4.0 and more advanced versions support
online update. This function helps you check whether there are updates. If so,
then the update will proceed automatically. For updating online, make sure the
computer you are using can get access to the internet.

3.3.2 Selections of Menu Items under JC Code Interface

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.

ToolsCompile in real time: When this function is confirmed to use,


just-in-time compile result will be displayed in the Interactive Window for
better helping you find grammar errors or cautions.
Window: Under JC code interface, multiple program windows can be
opened. Users can sort these program windows manually.

3.3.3 Toolbar

Toolbar under JC code interface:

Toolbar under flow chart interface:

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

3.3.4 Shortcut Keys

Shortcut keys under flow chart programming interface


F2: Full screen display
ESC: Quit full screen display mode. When more dialogue boxes are
opened, the key works as cancel key.
F6: Download flow chart program
F1: Open help document
F9: Make highlights on graphic blocks of the flow chart
F12: Switch between flow chart interface and JC code interface.
Please note that the switch wont convert flow chart to JC code.
Shortcut keys under JC code interface
F2: Look for marks
Ctrl ++: Enlarge JC code
Ctrl + -: Narrow JC code
Ctrl + w: Search all
Ctrl + F3: Search down
Shift + F3: Search up
Ctrl + F: Open the search dialogue box
Ctrl + A: Select all
Ctrl + H: Replace
Ctrl + Z: Repeat
Ctrl + C: Copy
Ctrl + V: Paste
Ctrl + X: Cut
F5: Download JC program

3.4 Program Download

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.

3.5 Software Online Update

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

Chapter 4 Programming Interface

4.1 Introduction of Flow Chart Interface

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.

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 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.

4.4.2 Advanced Blocks

Therere also some not-often-used functions stored in Advanced Blocks. Blocks in


this block library will be added in accordance with the update of functions and hardware.
*Read EEPROM*
Read the EEPROM value of a certain address inside the controller; key parameter of
EEPROM is its address, which ranges from 0 to 31; generally critical values of programs
are stored in EEPROM.
*Write EEOROM*
Revise the EEPROM value of a certain address inside the controller; for Ccon102
controller, this operation can be done by key operation of the controller.

Page 40
Ccon102

4.5 Writing a Flow Chart Program

4.5.1 Mouse Operation

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.

4.5.2 Add, Link and Insert Blocks

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

4.5.3 Move Blocks

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:

4.5.4 Copy and Paste Blocks

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

Right click the mouse


while the cursor is on the
first block of the block
group you want to copy.
Then you will see a
pop-up menu listing
below options: Copy,
Paste, Property, Delete,
Copy to clipboard. The
picture on the right shows
the options, you can take
it as a reference.
After you click Copy on
the pop-up menu, the
selected block group will
be highlighted by a green
frame, indicating the
blocks inside are copied..

If you want to cancel


copy operation, just press
ESC or click your
mouse on a blank area
inside the flow chart
window.

Right click the mouse on


the Red point where
you want to place the
copied block group firstly.
Then click Paste in the
menu that popped up.

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.

4.5.5 Delete Blocks

Two ways are available for deletion:


First way: right click the mouse on the block or first block of a certain block
group to attribute a menu, then select Delete to delete the block or block
group;
Second way: Drag the block or block group to the delete bin on bottom
panel left to the flow chart area.
While deleting the block or certain block group, please be aware of below
problems:
If the block to be deleted is not the last block or last blocks of the flow
chart, then some moving operations are necessary for separating the block or
blocks to be deleted from the flow chart. After this, you can delete the block or
blocks related.
Main program block (first block of flow chart) cant be deleted.
Before deleting a certain subprogram in the Program blocks, make
sure the subprogram is not used in the main program. If the subprogram is use
in the main program, a warning box will pop up.

Page 45
Ccon102

4.6 C Language Interface

C language interface is the one as shown in above picture. To be more


specific, C language interface can be divided into 3 parts: Multifunction prompt
window, Interactive window, Programming window. In above picture, the panel
that takes the largest space on the right side is the programming window.

4.7 VJC Library Functions

VJC code (generally named as JC language) is a subset of C language in


initial versions of VJC software. When it comes to VJC4.2, it has developed to
be standard C language format. So users familiar with C language can use C
language as the development language directly. When using C language
directly, uses should think about below suggestions:
Users are not suggested to revise the hierarchical structure of the
program. Users are not suggested to revise the indent, alignment of program
code that is automatically indented or aligned.
Keep the habit of making comment when programming, since

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

Chapter 5 Electronic Components Related to Ccon102


Controller

Electronic components include sensors, actuators and controller. Generally,


sensors can be divided into two types: digital sensor and analog sensor.
Theres also a kind of sensor that transmit signals by certain communication
protocol, but we will only introduce digital sensor and analog sensor here.
Actuators, as per control mode, can be grouped in to 3 kinds including DO
control, PMW control, and RS485 control. Of course, display LCD screen and
buzzer of the controller are also actuators.

5.1 Analog Sensor and Digital Sensor

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.

5.2 Other Sensors

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

5.2.1 Keys on the Controller

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.

5.2.2 Revolving Counter

Key parts of a revolving counter are a magnetic


switch and a magnet inserted in a rotor. When the
rotor rotates for 1 circle, the magnet will be detected
for 1 or 2 times (distance between magnetic switch
and rotor smaller, possibility of being detected for 2 times larger). Controller
will record how many times the magnet is detected. The final record is the
return value from the revolving counter.
In Abilix robotics kit, revolving counter should be assembled before using.
A finished revolving counter consists of magnetic switch, rotor, cube and short
bolt as shown in the right picture. Be sure that magnetic switch should be
inserted properly (magnetic switch doesnt touch the rotor; magnetic switch
can detect the magnetism of the magnet inserted in the rotor). Inserted
properly and only keeping a short distance from the rotor, the magnetic switch
can sense the magnetic signal for 2 times when the rotor rotates for 1 circle.
Before using the revolving counter to record data, make sure it has been
initialized (reset). In general, the counter needs to be reset (adding Counter
clear) before using its return value (adding Get counter block). The reset
operation will clear data recorded. After using the counter, you can stop the
counter (not compulsory).

Page 51
Ccon102

5.3 Actuators

Frequently used actuators are components such as DO controlled


actuators, DC motor, Digital servo, closed-loop motor, LCD of the controller,
buzzer, etc.

5.3.1 DO Controlled Actuator

DO controlled actuators include colored lights, electromagnets, etc. We


can add LED block and Electromagnet block in Actuator blocks to control
their corresponding real objects. We can also use Digital output blocks
instead. Actuators of this kind only have two statuses: switched on and
switched off. You can add one block to control the on-off status of multiple
ports (multiple I/O ports can be selected at one time; represented by
hexadecimal value)

5.3.2 DC Motor and Closed-loop Motor

Corresponding to Start motor and Stop motor blocks, DC ports on the


controller control the rotation speed and direction of motors by PWM mode. As
shown in the picture below, main parameters for motors are port number,
speed value, closed loop.

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.

5.3.3 Digital Servo

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

Chapter 6 Programming Examples

As we have mentioned before, handling of a certain sensor or actuator is


actually the handling of the I/O port to which the sensor or actuator is linked.
So be clear which electronic component corresponds to which I/O port. Then
write some program notes illustrating the wiring of all electronic components.
This will help yourself and others in understanding the program afterwards.
If Customize block is not used in a certain program, generally there will
not be grammar errors in the program. Under C programming interface, errors
will appear in the bottom inactive window in case that there are grammar errors.
As to grammar errors of C language, we will not discuss in detail here.
Below are several programming examples.

6.1 Display Return Value of an Analog Port

As shown in the right picture is a sample of flow


charts. You can find this file in FileExample of the
menu bar.
Function: Display the return value of I/O 0 in the bottom line

of the controller LCD;

Application: This program can be used to collect


critical value of analog sensors;
Analysis:
In general, an infinite loop will be added to
include all other blocks added in the program. If not so,
the program will only implement for one time (you
wont see the result most of the time).
The corresponding sensor should be linked to
I/O 0, since the program reads the analog value of I/O 0.
The program keeps looping, and displays updated values repeatedly.
When programming, make sure that return value of each I/O port have been
read before using that value. In flow chart programming, blocks can be

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.

6.2 Control the Motor via Revolving Counter

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.

6.3 Light & Button Controlled Lamp

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

6.4 Line Tracing Principle of Grayscale Sensors

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

to the end point.


Start the AGV;
Run simple line following until the AGV finds a crossing. After
detecting a crossing, the AGV crosses the crossing.
The AGV judges whether making a turn is necessary. If necessary, then
the AGV turns its direction until the centered grayscale sensor is detected on
the next black line for following.
Repeat the second and third operation to finish the path following.
Stop the AGV. If there is a crossing for the end point, then its very easy
to stop the AGV. If no crossing available for the end point, then stop the AGV
by time control.
We can see, from this step, that the modes of motion for the AGV can be
divided into three parts: Line following for finding a crossing; make a turn; Line
following by time. Correspondingly, we can make the three modes of motion
into three subprograms.
Seventh step: make three subprograms on the
basis of the conclusion of step six. Users can refer to
5-grayscale line following.flw and 5-grayscale line
following.jc in FileExample for reference.
Line following for finding a crossing: The AGV
keeps following the line until finding a crossing. After
moving across the crossing for a short distance, the AGV stops. Since
subprogram defined in flow chart cannot pass parameters, so we can define
two subprograms: line following for finding the left crossing, line following for
finding the right crossing.
Make a turn: The AGV should make a turn to switch to another black
line after moving across a certain crossing. The finishing of the turning is
decided by the grayscale sensor linked to I/O 2. When this grayscale sensor
detects the target black line, the turning should be terminated. Since
subprogram in flow chart cannot pass parameters, so we define Turn left and
Turn right in two subprograms instead. Take Turn left as an example, we
cant guarantee grayscale sensor linked to I/O 2 is not on the black line

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

7.1 Common Failures and Solutions

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: How to tell a lithium battery is fully charged?


Reply: Please use the power adaptor to charge the lithium battery in the
robotic kit. There are indicators on the adaptor. Red light means charging,
while green light means battery is fully charged. After the battery is charged,
please remember to pull out the power adaptor. For security reasons, please
dont charge the battery over 12 hours.

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.

7.2 Improvements and Suggestions

We keep improving product performance consistently. Any update will be


found on our website www.abilix.cn. Besides, you can also use the update
function of VJC 4.1 to keep your software the latest version.
If you meet some troubles in using this software, or you have some
suggestions for us, just feel free to let us know.
Phone number: +86 21 64952827 2073
Email: cuiyq@abilix.com

Page 63

Potrebbero piacerti anche