Video tutorial: http://www.zmotion.com.cn/support_info_69.html
Today, Zheng Motion Technology will share with you "Quick Start Guide to VPLC Series Machine Vision Motion Control All-in-One Machine (Part 2)".
In the last lesson, we discussed the principles, advantages, application areas, and the hardware and software environments required to implement machine vision solutions.
In this course, we will share with you the first step in implementing a machine vision solution—the basic use of a camera.
The camera's interface determines the transmission method and output efficiency of the image data. Industrial cameras can be classified according to different interface methods into USB interface cameras, IEEE1934 interface cameras, CamLink interface cameras, and Gigabit Ethernet interface cameras.
Due to its high transmission speed, low cost, and easy connection, the Gigabit Ethernet interface is widely used in machine vision selection solutions. This course will use Hikvision's Gigabit Ethernet camera as an example.
The camera's acquisition modes include free acquisition mode and triggered acquisition mode. Triggered acquisition mode is further divided into software trigger mode and hardware trigger mode depending on the trigger source.
In ZDevelop software, different acquisition modes need to be selected using the SET_MODE(mode) command. The specific programming implementation will be explained in detail later.
To ensure the camera captures clear images that highlight the features of the target, it's necessary to adjust relevant camera parameters such as exposure and gamma values. In situations where high detection speed isn't critical, the frame rate can be appropriately reduced to minimize motion blur caused by moving targets.
Commonly used camera settings are as follows:
This course uses the Hikvision MV-CE050-30GM 5-megapixel 1/2.5” CMOS gigabit Ethernet industrial area scan camera as an example.
When connecting the camera to the device, simply use a network cable to connect the camera's network port to the LAN2 port of the VPLC516E controller, and then connect the camera's power adapter and the power and GND interfaces of the 6-pin Hirose I/O cable. The power adapter plug can then be directly inserted into the socket for normal use.
'Functions responding to pressing the free capture button on the HMI interface'
GLOBAL SUB btn_con_grap()
if (grap_switch=1) then 'If already in free-capture mode, print a prompt message
"Free data collection in progress, please do not repeat the operation."
return
endif
if (cam_num=0) then 'If no camera has been scanned, prompt the user to scan the camera first.'
"Please scan the camera first"
return
endif
'*************Initialize camera operations*********************
CAM_SEL(0) 'Select the first camera
CAM_SETMODE(-1) 'Select camera for free acquisition mode
'*************End camera initialization*********************
grap_switch=1 'Set free-sampling state to 1, start the looping sampling task.'
if (1 = grap_switch) then
if (0 = PROC_STATUS(grab_task_id)) then
RUNTASK grab_task_id, grab_task
endif
endif
END SUB
'Free Gathering Mission'
grab_task:
while(1)
if (0 = grap_switch) then
exit while
endif
CAM_GRAB(image) 'Captures a single frame of image in free-capture mode.
ZV_LATCH(image,0) 'Displays the captured image into the image element.'
wend
END
'Function to respond when the stop acquisition button is pressed on the HMI interface'
GLOBAL SUB btn_stop_grab()
if (grap_switch = 0) then
"Continuous data collection is not enabled"
return
endif
grap_switch = 0
END SUB
ZDevelop software supports obtaining image data from local files for simulation debugging, which requires the use of the image reading function.
Implementing the image reading function is relatively simple; it only requires calling the ZV_READIMG instruction and inputting the path to the image in the parameter pass. As shown below:
That concludes this article, "Quick Start Guide to VPLC Series Machine Vision Motion Control All-in-One Machine (Part 2)". For more exciting content, please follow "Zheng Motion Assistant".
This article is original content from Zheng Motion Technology. We welcome everyone to reprint it for mutual learning and to jointly improve China's intelligent manufacturing level. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.