400 likes | 417 Views
Tiny EPICS CAS in NetBurner MOD5282. National Synchrotron Radiation Research Center ( NSRRC ) Te-Hui Lee, lee.robert@nsrrc.org.tw 2009/11/11. Preface. This is an incomplete but workable CAS solution. (ShanZhai EPICS) The cheapest EPICS CAS. For MOD5270, USD 79 ~ USD 59 (1000)
E N D
Tiny EPICS CAS in NetBurner MOD5282 National Synchrotron Radiation Research Center (NSRRC) Te-Hui Lee, lee.robert@nsrrc.org.tw 2009/11/11
Preface • This is an incomplete but workable CAS solution. (ShanZhai EPICS) • The cheapest EPICS CAS. • For MOD5270, USD 79 ~ USD 59 (1000) • Good CA protocol tutorial material. • Small code size for low-end microcontroller porting.
Limitation • Only DOUBLE and STRING PV are supported so far. • Alarm is not correctly specified. • Severity is not correctly specified.
NetBurner MOD5282 • uC/OS Multitask RTOS • Freescale MCF5282 ColdFire Microcontroller @ 66 MHz • 8 10-bit on-chip analog inputs, 0 ~ 3.3 volts • 4-digit 7 segment LED display • 8-bit DIP SW digital input • 8-bit LED display digital output • 2 RS-232 serial ports • SD card FAT32 file system • RTC chip on board
NetBurner NNDK-MOD5282-KIT • www.netburner.com
NNDK-MOD52XX-KIT • Network in 1 day: easy to learn • Well documented • Good technical support • Plenty sample codes • Plenty network support. HTTP, email, FTP…
How To Change Code • Hardware PV control code is located at ioc.cpp and pv.h. • Three wrapper functions need to be maintained to accommodate different hardware. • IOC_Init(): PV initialization • IOC_GetData(): get new value from hardware • IOC_SetData(): set new setting to hardware
On Board Signal Converter • EPICS to DIO converter • EPICS to A/D, D/A converter • EPICS to RS-232 converter
IP Address • DHCP will be used if initial IP is 0.0.0.0. • Assigned fixed IP will be used if it is not 0.0.0.0. • Netmask is used for beacon broadcast • Default is 255.255.0.0, broadcast address is 172.16.255.255
Time • NTP client function • NTP server IP is assigned in configuration file. • NTP server synchronization interval is configurable in configuration file. • If NTP server time correction fails, on board RTC chip time will be used. • NTP server compatibility • PresenTense Time Server, Meinberg NTP server
EPICS PVs Test • Analog input • #caget nbcas255ai0 • … • #caget nbcas255:ai7 • Digital input • #caget nbcas255:di • Digital output • #caput nbcas255:do x55 • #caput nbcas255:do 85 • 7-segment 4-digit LED display • #caput nbcas255:seg 1234 • RS-232 serial port #0 • #caput nbcas255:s0 abcdefghijk • RS-232 serial port #1 • #caput nbcas255:s1 abcdefghijk
Parameter Initialization • Configuration file cassetup.iniis stored at the root directory of SD card • The configurations parameters are loaded during power on process. • Parameters include • Device name • NTP server IP address, sync interval • Authorized access IP group • Authorized access host and user group • Log format (None, binary, text) • Log Interval • Log file auto deletion function.
Example cassetup.ini • DeviceName=nbcas255 //device name • NTP=172.16.1.201 //NTP server IP address • NTPInterval=1440 //NTP sync interval in minutes • NetMask=255.255.0.0 • LogFormat=1 //log format: binary, 0:none,1:binary,2:test • LogInterval=1 //log interval 1 s • //RW 1:read,2:write,3:read/write • AuIP1=172.16.1.201 • AuRW1=3 • AuIP2=172.16.1.210 • AuRW2=3 • AuIP3=172.16.255.210 //172.16.xxx.210 group are allowed • AuRW4=3 //access read and write • Host1=host1:user1,user2 //user1 and user2 at host1 have access rights • Host2=host2:user1,user3 //user1 and user3 at host2 have access rights • TimeZone=480 //Taipei, Beijing. Unit in minutes • SOUT=0 //continuous serial output to RS-232 • AutoDel=1 //Auto deletion for log file enabled
Security Control by IP • Only authorized IP or IP group can access the device. • The authorized IPs are loaded from NOR flash during power on process. • If the authorized IPs in module are different from those in cassetup.ini, they will be updated from the card and then saved into NOR flash. • Security privileges include • Read only access • Read and write access
Security Control by User and Host Name • Host1=host1:user1,user2 • user1 and user2 at host1 can read and write the device. • Case sensitive
Log File System • The log data will be saved in the SD card • Log format: binary or text • Log interval is configurable by initialization file cassetup.ini on SD card. • If AutoDel flag is enabled, device will delete the oldest directory automatically when disk data is full. • Filename • Text: \YYYYMM\YYMMDD.txt • Binary: \YYYYMM\YYMMDD.bin
Binary Log File Format Timestamp is saved as unsigned long. It is equal to the second since 1990/1/1 12:00:00.Data are saved as 4-byte float.
Text Log File Format Timestamp is saved as unsigned long. It is equal to the second since 1990/1/1 12:00:00.Data are saved as 4-byte float.
FTP Log File Access Log file and directory in SD card are read-only through FTP transfer.
CA Server CA Client Channel Access in One Slide “connection request” or “search request” “get” or “caGet” “put” or “caPut” “set a monitor” Who has a PV named “S1A:H1:CurrentAO”? Change its value to 30.5 Notify me when the value changes What is its value? Channel Access Client Channel Access Server I do. 25.5 AMPS OK, it is now 30.5 It is now 20.5 AMPS It is now 10.5 AMPS It is now -0.0023 AMPS Process Variables: “put complete” “post an event” or “post a monitor” S1A:H1:CurrentAO S1:P1:x S1:P1:y S1:G1:vacuum 30.5 is too high. It is now set to the maximum value of 27.5. or You are not authorized to change this value or
CA Protocol Analyzer - Wireshark • Where is it? Extension Wireshark • http://www.aps.anl.gov/epics/extensions/index.php • CA protocol document • http://epics.cosylab.com/cosyjava/JCA-Common/Documentation/CAproto.htm • Wireshark CA plugin support • http://www-linac.kek.jp/cont/epics/wireshark/
CA Protocol Example for caget CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
CA Protocol Example for caput CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
CA Protocol Example for camonitor CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
Payload Data Structure • \base-3.14.9\include\db_access.h • /* structure for a double time field */ • struct dbr_time_double { • dbr_short_t status; /* status of value */ • dbr_short_t severity; /* severity of alarm */ • epicsTimeStamp stamp; /* time stamp since 1990/1/1 12:00 AM*/ • dbr_long_t RISC_pad; /* RISC alignment */ • dbr_double_t value; /* current value */ • };
MEDM Test Program 7-seg LED display LED display DIP SW status Serial0 Output Serial1 Output
Channel Archive Compatibility • DBE_LOG data processing for CA_PROTO_EVENT_ADD
UDP Port 5066 • GETDATA • GETNAME
Next Step • Hardware module development • DIO, A/D, D/A • Photon BPM controller • Archive viewer • smarter and user-friendly GUI • PV correlation analysis • Galil motor controller • X-ray detector controller