tiny epics cas in netburner mod5282 national synchrotron radiation research center (nsrrc) te-hui...
TRANSCRIPT
Tiny EPICS CAS in Tiny EPICS CAS in NetBurner MOD528NetBurner MOD528
22National Synchrotron Radiation Research CenterNational Synchrotron Radiation Research Center
((NSRRCNSRRC))Te-Hui Lee, [email protected] Lee, [email protected]
2009/11/112009/11/11
PrefacePreface
This is an incomplete but workable CAThis is an incomplete but workable CAS solution. (ShanZhai EPICS)S solution. (ShanZhai EPICS)
The cheapest EPICS CAS. The cheapest EPICS CAS. For MOD5270, USD 79 ~ USD 59 (1000)For MOD5270, USD 79 ~ USD 59 (1000)
Good CA protocol tutorial material.Good CA protocol tutorial material. Small code size for low-end microcontSmall code size for low-end microcont
roller porting.roller porting.
LimitationLimitation
Only DOUBLE and STRING PV are Only DOUBLE and STRING PV are supported so far.supported so far.
Alarm is not correctly specified.Alarm is not correctly specified. Severity is not correctly specified.Severity is not correctly specified.
Ethernet ModuleEthernet Module
CPUCPU SWSW URLURL
ArcturusArcturusNetworksNetworksInc. uC52Inc. uC528282
Freescale Freescale MCF5282MCF5282
uClinuxuClinux http://www.arcturusnehttp://www.arcturusnetworks.com/products/utworks.com/products/uc5282/c5282/USD 200 ~ 220USD 200 ~ 220
NetburnerNetburnerMOD5282MOD5282
Freescale Freescale MCF5282MCF5282
uCOSuCOS http://www.netburner.http://www.netburner.com/products/core_mocom/products/core_modules/mod5282.htmldules/mod5282.htmlUSD 145 ~105 (100) ~ 89 USD 145 ~105 (100) ~ 89 (1000)(1000)
RabitCoreRabitCoreRCM4300RCM4300
RabbitCoRabbitCore 4000re 4000
DynamiDynamic Cc C
http://www.rabbit.com/http://www.rabbit.com/products/rcm4300/products/rcm4300/USD 99 ~ 81 (100)USD 99 ~ 81 (100)
Netburner PerformanceNetburner Performance
NetBurner MOD5282NetBurner MOD5282 uC/OS Multitask RTOSuC/OS Multitask RTOS Freescale MCF5282 ColdFire MicrocontrolleFreescale MCF5282 ColdFire Microcontrolle
r @ 66 MHzr @ 66 MHz 8 10-bit on-chip analog inputs, 0 ~ 3.3 volts8 10-bit on-chip analog inputs, 0 ~ 3.3 volts 4-digit 7 segment LED display4-digit 7 segment LED display 8-bit DIP SW digital input8-bit DIP SW digital input 8-bit LED display digital output8-bit LED display digital output 2 RS-232 serial ports2 RS-232 serial ports SD card FAT32 file systemSD card FAT32 file system RTC chip on boardRTC chip on board
NetBurner NNDK-MOD5282-KINetBurner NNDK-MOD5282-KITT
www.netburner.comwww.netburner.com
NNDK-MOD5282-KITNNDK-MOD5282-KIT
NNDK-MOD5282-KITNNDK-MOD5282-KIT
NNDK-MOD52XX-KITNNDK-MOD52XX-KIT
Network in 1 day: easy to learnNetwork in 1 day: easy to learn Well documentedWell documented Good technical supportGood technical support Plenty sample codesPlenty sample codes Plenty network support. HTTP, email, Plenty network support. HTTP, email,
FTP…FTP…
Firmware ArchitectureFirmware Architecture
UDP Listening TaskCA_SERVER_PORT
TCP Listening TaskCA_SERVER_PORT
UDP2 Listening TaskPort 5066
Beacon ServerCA_REPEATER_PORT
PV Check Taskcamonitor, channel archiver
response
Main Task
Serial0 Task Serial1 Task
How To Change CodeHow To Change Code
Hardware PV control code is located at ioHardware PV control code is located at ioc.cpp and pv.h.c.cpp and pv.h.
Three wrapper functions need to be maiThree wrapper functions need to be maintained to accommodate different hardwntained to accommodate different hardware.are. IOC_Init(): PV initializationIOC_Init(): PV initialization IOC_GetData(): get new value from hardwareIOC_GetData(): get new value from hardware IOC_SetData(): set new setting to hardwareIOC_SetData(): set new setting to hardware
On Board Signal On Board Signal ConverterConverter
EPICS to DIO converterEPICS to DIO converter EPICS to A/D, D/A converterEPICS to A/D, D/A converter EPICS to RS-232 converterEPICS to RS-232 converter
IP AddressIP Address
DHCP will be used if initial IP is 0.0.0.0.DHCP will be used if initial IP is 0.0.0.0. Assigned fixed IP will be used if it is noAssigned fixed IP will be used if it is no
t 0.0.0.0.t 0.0.0.0. Netmask is used for beacon broadcastNetmask is used for beacon broadcast
Default is 255.255.0.0, broadcast address iDefault is 255.255.0.0, broadcast address is 172.16.255.255s 172.16.255.255
TimeTime
NTP client functionNTP client function NTP server IP is assigned in configuration fNTP server IP is assigned in configuration f
ile.ile. NTP server synchronization interval is confNTP server synchronization interval is conf
igurable in configuration file.igurable in configuration file. If NTP server time correction fails, on boarIf NTP server time correction fails, on boar
d RTC chip time will be used.d RTC chip time will be used. NTP server compatibilityNTP server compatibility
PresenTense Time Server, Meinberg NTP serverPresenTense Time Server, Meinberg NTP server
EPICS PVs TestEPICS PVs Test Analog inputAnalog input
#caget nbcas255ai0#caget nbcas255ai0 …… #caget nbcas255:ai7#caget nbcas255:ai7
Digital inputDigital input #caget nbcas255:di#caget nbcas255:di
Digital outputDigital output #caput nbcas255:do x55#caput nbcas255:do x55 #caput nbcas255:do 85#caput nbcas255:do 85
7-segment 4-digit LED display7-segment 4-digit LED display #caput nbcas255:seg 1234#caput nbcas255:seg 1234
RS-232 serial port #0RS-232 serial port #0 #caput nbcas255:s0 abcdefghijk#caput nbcas255:s0 abcdefghijk
RS-232 serial port #1RS-232 serial port #1 #caput nbcas255:s1 abcdefghijk#caput nbcas255:s1 abcdefghijk
Parameter InitializationParameter Initialization Configuration file Configuration file cassetup.inicassetup.ini is stored at this stored at th
e root directory of SD carde root directory of SD card The configurations parameters are loaded dThe configurations parameters are loaded d
uring power on process.uring power on process. Parameters includeParameters include
Device nameDevice name NTP server IP address, sync intervalNTP server IP address, sync interval Authorized access IP groupAuthorized access IP group Authorized access host and user groupAuthorized access host and user group Log format (None, binary, text)Log format (None, binary, text) Log IntervalLog Interval Log file auto deletion function.Log file auto deletion function.
Example cassetup.ini Example cassetup.ini DeviceName=nbcas255DeviceName=nbcas255 //device name//device name NTP=172.16.1.201NTP=172.16.1.201 //NTP server IP address//NTP server IP address NTPInterval=1440NTPInterval=1440 //NTP sync interval in minutes//NTP sync interval in minutes NetMask=255.255.0.0NetMask=255.255.0.0 LogFormat=1LogFormat=1 //log format: binary, 0:none,1:binary,2:test//log format: binary, 0:none,1:binary,2:test LogInterval=1LogInterval=1 //log interval 1 s//log interval 1 s //RW 1:read,2:write,3:read/write//RW 1:read,2:write,3:read/write AuIP1=172.16.1.201AuIP1=172.16.1.201 AuRW1=3AuRW1=3 AuIP2=172.16.1.210AuIP2=172.16.1.210 AuRW2=3AuRW2=3 AuIP3=172.16.255.210AuIP3=172.16.255.210 //172.16.xxx.210 group are allowed//172.16.xxx.210 group are allowed AuRW4=3AuRW4=3 //access read and write//access read and write Host1=host1:user1,user2Host1=host1:user1,user2 //user1 and user2 at host1 have access rights//user1 and user2 at host1 have access rights Host2=host2:user1,user3Host2=host2:user1,user3 //user1 and user3 at host2 have access rights//user1 and user3 at host2 have access rights TimeZone=480TimeZone=480 //Taipei, Beijing. Unit in minutes//Taipei, Beijing. Unit in minutes SOUT=0SOUT=0 //continuous serial output to RS-232//continuous serial output to RS-232 AutoDel=1AutoDel=1 //Auto deletion for log file enabled//Auto deletion for log file enabled
Security Control by IPSecurity Control by IP
Only authorized IP or IP group can access the Only authorized IP or IP group can access the device.device.
The authorized IPs are loaded from NOR flash The authorized IPs are loaded from NOR flash during power on process.during power on process.
If the authorized IPs in module are different fIf the authorized IPs in module are different from those in cassetup.ini, they will be updaterom those in cassetup.ini, they will be updated from the card and then saved into NOR flash.d from the card and then saved into NOR flash.
Security privileges includeSecurity privileges include Read only accessRead only access Read and write accessRead and write access
Security Control by Security Control by User and Host NameUser and Host Name
Host1=host1:user1,user2Host1=host1:user1,user2 user1 and user2 at host1 can read and user1 and user2 at host1 can read and
write the device.write the device. Case sensitiveCase sensitive
Host and Client Name in Host and Client Name in WindowsWindows
Log File SystemLog File System
The log data will be saved in the SD cardThe log data will be saved in the SD card Log format: binary or textLog format: binary or text Log interval is configurable by initialization fiLog interval is configurable by initialization fi
le cassetup.ini on SD card.le cassetup.ini on SD card. If AutoDel flag is enabled, device will delete tIf AutoDel flag is enabled, device will delete t
he oldest directory automatically when disk dhe oldest directory automatically when disk data is full.ata is full.
FilenameFilename Text: \YYYYMM\YYMMDD.txtText: \YYYYMM\YYMMDD.txt Binary: \YYYYMM\YYMMDD.binBinary: \YYYYMM\YYMMDD.bin
Binary Log File FormatBinary Log File Format
OffsetOffset Data Data ContentsContents0 ~ 1270 ~ 127 Header, Device name, PV1 name\tPV2 name\Header, Device name, PV1 name\tPV2 name\
t…t…
128 ~ 131128 ~ 131 Data 1Data 1 TimeStamp (unsigned long)TimeStamp (unsigned long)132 ~ 135132 ~ 135 Data 1Data 1 PV1 (float)PV1 (float)
136 ~ 139136 ~ 139 Data 1Data 1 PV2 (float)PV2 (float)
…… Data 1Data 1 ……
132 + (N-132 + (N-1)*41)*4
Data 1Data 1 PVN(float)PVN(float)
132 + N*4 132 + N*4 = A= A
Data 2Data 2 TimeStamp (unsigned long)TimeStamp (unsigned long)
A+4A+4 Data 2Data 2 PV1 (float)PV1 (float)
A+8A+8 Data 2Data 2 PV2 (float)PV2 (float)
……Timestamp is saved as unsigned long. It is equal to the second since Timestamp is saved as unsigned long. It is equal to the second since 1990/1/1 12:00:00.1990/1/1 12:00:00.Data are saved as 4-byte float.Data are saved as 4-byte float.
Text Log File FormatText Log File Format
LineLine ContentsContents
11 Device nameDevice namePV1 name,PV2 name,…\r\nPV1 name,PV2 name,…\r\n
22 TimeStamp,PV1,PV2,PV3..\r\nTimeStamp,PV1,PV2,PV3..\r\n
33 TimeStamp,PV1,PV2,PV3..\r\nTimeStamp,PV1,PV2,PV3..\r\n
Timestamp is saved as unsigned long. It is equal to the second since Timestamp is saved as unsigned long. It is equal to the second since 1990/1/1 12:00:00.1990/1/1 12:00:00.Data are saved as 4-byte float.Data are saved as 4-byte float.
FTP Log File AccessFTP Log File AccessLog file and directory in SD card are read-only through Log file and directory in SD card are read-only through FTP transfer.FTP transfer.
Channel Access in One Channel Access in One SlideSlide
CA ServerCA Server
CA ClientCA Client
Process Variables:
Channel Access Server
S1A:H1:CurrentAO
S1:P1:x
S1:P1:y
S1:G1:vacuum
Channel Access Client
Who has a PV named
“S1A:H1:CurrentAO”?
I do.
What is its value?
25.5 AMPS
Change its value to
30.5
““connection connection request” or “search request” or “search
request”request”
OK, it is now 30.5
30.5 is too high. It is now
set to the maximum
value of 27.5.You are not
authorized to change this
value
Notify me when the
value changes
It is now 20.5
AMPS
It is now 10.5
AMPS
It is now -0.0023
AMPS
““put” put” or or
““caPutcaPut””
““get” get” or or
““caGetcaGet””
““set a set a monitor”monitor”
““post an event”post an event”
or or
““post a monitor”post a monitor”
““put complete”put complete”
oror
oror
CA Protocol Analyzer - WireshCA Protocol Analyzer - Wiresharkark
Where is it? Extension Where is it? Extension Wireshark Wireshark http://http://www.aps.anl.gov/epics/extensions/index.phpwww.aps.anl.gov/epics/extensions/index.php
CA protocol documentCA protocol document http://epics.cosylab.com/cosyjava/JCA-Common/Documentation/CAproto.http://epics.cosylab.com/cosyjava/JCA-Common/Documentation/CAproto.
htmhtm
Wireshark CA plugin supportWireshark CA plugin support http://www-linac.kek.jp/cont/epics/wireshark/http://www-linac.kek.jp/cont/epics/wireshark/
CA Protocol Example for cagetCA Protocol Example for cagetCA ProtocolCA Protocol CIDCID SIDSID CSIDCSID IOIOIOIO
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDPbroadcastbroadcast
CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDP CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_CLIENT_NAMECA_PROTO_CLIENT_NAMECA_PROTO_HOST_NAMECA_PROTO_HOST_NAMECA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 5064
0x010x01
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_ACCESS_RIGHTSCA_PROTO_ACCESS_RIGHTSCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 50640x010x010x010x01 0x010x01
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CIDCID: Channel ID, : Channel ID, SIDSID: Server ID, : Server ID, CSIDCSID: client provided subscription ID, : client provided subscription ID, IOIDIOID: : client provided IO IDclient provided IO ID
#caget Process Captured by Wi#caget Process Captured by Wireshark reshark
CA Protocol Example for CA Protocol Example for caputcaput
CA ProtocolCA Protocol CIDCID SIDSID CSIDCSID IOIOIOIO
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDP CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDP CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_CLIENT_NAMECA_PROTO_CLIENT_NAMECA_PROTO_HOST_NAMECA_PROTO_HOST_NAMECA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 5064
0x010x01
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_ACCESS_RIGHTSCA_PROTO_ACCESS_RIGHTSCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 50640x010x010x010x01 0x010x01
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_WRITECA_PROTO_WRITECA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY
TCPTCP CAS 5064CAS 5064 0x010x010x010x01
0x010x010x020x02
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFY TCPTCP CAS 5064CAS 5064 0x010x01 0x020x02
CIDCID: Channel ID, : Channel ID, SIDSID: Server ID, : Server ID, CSIDCSID: client provided subscription ID, : client provided subscription ID, IOIDIOID: : client provided IO IDclient provided IO ID
#caput Process Captured by Wi#caput Process Captured by Wireshark reshark
CA Protocol Example for camoCA Protocol Example for camonitornitor
CA ProtocolCA Protocol CIDCID SIDSID CSIDCSID IOIOIOIO
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDPbroadcastbroadcast
CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDP CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_CLIENT_NAMECA_PROTO_CLIENT_NAMECA_PROTO_HOST_NAMECA_PROTO_HOST_NAMECA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 5064
0x010x01
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_ACCESS_RIGHTSCA_PROTO_ACCESS_RIGHTSCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 50640x010x010x010x01 0x010x01
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD TCPTCP CAS 5064CAS 5064 0x010x01 0x010x01
CIDCID: Channel ID, : Channel ID, SIDSID: Server ID, : Server ID, CSIDCSID: client provided subscription ID, : client provided subscription ID, IOIDIOID: : client provided IO IDclient provided IO ID
#camonitor Process Captured #camonitor Process Captured by Wireshark by Wireshark
CA Protocol Example for MEDM (2 PVCA Protocol Example for MEDM (2 PVs)s)
CA ProtocolCA Protocol CIDCID SIDSID CSIDCSID IOIOIOIO
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDP UDP broadcastbroadcast
CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_SEARCHCA_PROTO_SEARCH
UDPUDPResponseResponse
CAS 5064CAS 5064 0x010x01 0xFFFFFFFF0xFFFFFFFF
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_CLIENT_NAMECA_PROTO_CLIENT_NAMECA_PROTO_HOST_NAMECA_PROTO_HOST_NAMECA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 5064
0x1d0x1d0x1e0x1e
CA_PROTO_VERSIONCA_PROTO_VERSIONCA_PROTO_ACCESS_RIGHTSCA_PROTO_ACCESS_RIGHTSCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHANCA_PROTO_ACCESS_RIGHTSCA_PROTO_ACCESS_RIGHTSCA_PROTO_CREATE_CHANCA_PROTO_CREATE_CHAN
TCPTCP CAS 5064CAS 50640x1d0x1d0x1d0x1d0x1e0x1e0x1e0x1e
0x010x01
0x020x02
CA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFYCA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADDCA_PROTO_READ_NOTIFYCA_PROTO_READ_NOTIFYCA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD
TCPTCP CAS 5064CAS 5064 0x010x010x010x010x020x020x020x02
0x0e0x0e
0x100x10
0x0d0x0d
0x0f0x0f
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD
TCPTCP CAS 5064CAS 5064 0x0e0x0e0x100x10
CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD TCPTCP CAS 5064CAS 5064 0x0e0x0e
Payload Data StructurePayload Data Structure \base-3.14.9\include\db_access.h\base-3.14.9\include\db_access.h /* structure for a double time field *//* structure for a double time field */ struct dbr_time_double {struct dbr_time_double { dbr_short_tdbr_short_t status;status; /* status of value *//* status of value */ dbr_short_tdbr_short_t severity;severity; /* severity of alarm *//* severity of alarm */ epicsTimeStampepicsTimeStamp stamp;stamp; /* time stamp since 1990/1/1 12:00 AM*//* time stamp since 1990/1/1 12:00 AM*/ dbr_long_tdbr_long_t RISC_pad;RISC_pad; /* RISC alignment *//* RISC alignment */ dbr_double_tdbr_double_t value;value; /* current value *//* current value */ };};
MEDM Test ProgramMEDM Test Program
DIP SW status
LED display
7-seg LED display
Serial0 Output
Serial1 Output
Channel Archive Channel Archive CompatibilityCompatibility
DBE_LOG data processing for DBE_LOG data processing for CA_PROTO_EVENT_ADDCA_PROTO_EVENT_ADD
UDP Port 5066UDP Port 5066 GETDATAGETDATA GETNAMEGETNAME
Next StepNext Step
Hardware module developmentHardware module development DIO, A/D, D/ADIO, A/D, D/A
Photon BPM controllerPhoton BPM controller Archive viewerArchive viewer
smarter and user-friendly GUIsmarter and user-friendly GUI PV correlation analysisPV correlation analysis
Galil motor controllerGalil motor controller X-ray detector controllerX-ray detector controller
Thank you for your Thank you for your attention.attention.