Transcript Document

Tiny EPICS CAS in
NetBurner MOD5282
National Synchrotron Radiation Research Center (NSRRC)
Te-Hui Lee, [email protected]
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.
Ethernet Module
CPU
SW
URL
Arcturus
Networks
Inc. uC5282
Freescale
MCF5282
uClinux
http://www.arcturusnetworks.
com/products/uc5282/
Netburner
MOD5282
Freescale
MCF5282
USD 200 ~ 220
uCOS
http://www.netburner.com/p
roducts/core_modules/mod5
282.html
USD 145 ~105 (100) ~ 89 (1000)
RabitCore
RCM4300
RabbitCore Dynamic
4000
C
http://www.rabbit.com/prod
ucts/rcm4300/
USD 99 ~ 81 (100)
Netburner Performance
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-MOD5282-KIT
NNDK-MOD5282-KIT
NNDK-MOD52XX-KIT





Network in 1 day: easy to learn
Well documented
Good technical support
Plenty sample codes
Plenty network support. HTTP, email, FTP…
Firmware Architecture
Main Task
UDP Listening Task
CA_SERVER_PORT
TCP Listening Task
CA_SERVER_PORT
UDP2 Listening Task
Port 5066
Beacon Server
CA_REPEATER_PORT
PV Check Task
camonitor, channel archiver
response
Serial0 Task
Serial1 Task
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




Digital input



#caput nbcas255:seg 1234
RS-232 serial port #0


#caput nbcas255:do x55
#caput nbcas255:do 85
7-segment 4-digit LED display


#caget nbcas255:di
Digital output


#caget nbcas255ai0
…
#caget nbcas255:ai7
#caput nbcas255:s0 abcdefghijk
RS-232 serial port #1

#caput nbcas255:s1 abcdefghijk
Parameter Initialization



Configuration file cassetup.ini is 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
NTP=172.16.1.201
NTPInterval=1440
NetMask=255.255.0.0
LogFormat=1
LogInterval=1
//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
AuRW4=3
Host1=host1:user1,user2
Host2=host2:user1,user3
TimeZone=480
SOUT=0
AutoDel=1
//device name
//NTP server IP address
//NTP sync interval in minutes
//log format: binary, 0:none,1:binary,2:test
//log interval 1 s
//172.16.xxx.210 group are allowed
//access read and write
//user1 and user2 at host1 have access rights
//user1 and user3 at host2 have access rights
//Taipei, Beijing. Unit in minutes
//continuous serial output to RS-232
//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

Host and Client Name in Windows
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
Offset
Data
0 ~ 127
Contents
Header, Device name, PV1 name\tPV2 name\t…
128 ~ 131
Data 1
TimeStamp (unsigned long)
132 ~ 135
Data 1
PV1 (float)
136 ~ 139
Data 1
PV2 (float)
…
Data 1
…
132 + (N-1)*4
Data 1
PVN(float)
132 + N*4 = A
Data 2
TimeStamp (unsigned long)
A+4
Data 2
PV1 (float)
A+8
Data 2
PV2 (float)
…
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
Line
Contents
1
2
Device name
PV1 name,PV2 name,…\r\n
TimeStamp,PV1,PV2,PV3..\r\n
3
TimeStamp,PV1,PV2,PV3..\r\n
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.
Channel Access in One Slide
“connection request” or
“search request”
“get” or
“caGet”
Who has a PV named
“S1A:H1:CurrentAO”?
“put” or
“caPut”
“set a
monitor”
Change its
value to 30.5
Notify me
when the
value changes
What is its
value?
Channel Access
Client
CA Server
Channel Access Server
Process Variables:
I do.
25.5
AMPS
“put complete”
S1A:H1:CurrentAO
CA Client
S1:P1:x
or
S1:P1:y
S1:G1:vacuum
OK, it is
now
30.5
or
30.5 is too high. It
is now set to the
maximum value of
27.5.
You are not
authorized to
change this value
It is now
20.5 AMPS
It is now
10.5 AMPS
It is now 0.0023 AMPS
“post an event”
or
“post a monitor”
CA Protocol Analyzer - Wireshark

Where is it? Extension  Wireshark


CA protocol document


http://www.aps.anl.gov/epics/extensions/index.php
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
CA Protocol
CID
SID
CSID
IOIO
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
broadcast
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_CLIENT_NAME
CA_PROTO_HOST_NAME
CA_PROTO_CREATE_CHAN
TCP
 CAS 5064
CA_PROTO_VERSION
CA_PROTO_ACCESS_RIGHTS
CA_PROTO_CREATE_CHAN
TCP
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x01
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x01
0x01
 CAS 5064
0x01
0x01
0x01
CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
#caget Process Captured by
Wireshark
CA Protocol Example for caput
CA Protocol
CID
SID
CSID
IOIO
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_CLIENT_NAME
CA_PROTO_HOST_NAME
CA_PROTO_CREATE_CHAN
TCP
 CAS 5064
CA_PROTO_VERSION
CA_PROTO_ACCESS_RIGHTS
CA_PROTO_CREATE_CHAN
TCP
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x01
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x01
CA_PROTO_WRITE
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x01
0x01
0x02
CA_PROTO_READ_NOTIFY
TCP
 CAS 5064
0x01
0x02
0x01
 CAS 5064
0x01
0x01
0x01
CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
#caput Process Captured by
Wireshark
CA Protocol Example for camonitor
CA Protocol
CID
SID
CSID
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
broadcast
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_CLIENT_NAME
CA_PROTO_HOST_NAME
CA_PROTO_CREATE_CHAN
TCP
 CAS 5064
CA_PROTO_VERSION
CA_PROTO_ACCESS_RIGHTS
CA_PROTO_CREATE_CHAN
TCP
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x01
0x01
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x01
0x01
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x01
0x01
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x01
0x01
IOIO
0x01
 CAS 5064
0x01
0x01
0x01
CID: Channel ID, SID: Server ID, CSID: client provided subscription ID, IOID: client provided IO ID
#camonitor Process Captured by
Wireshark
CA Protocol Example for MEDM (2 PVs)
CA Protocol
CID
SID
CSID
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
broadcast
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_SEARCH
UDP
Response
 CAS 5064
0x01
0xFFFFFFFF
CA_PROTO_VERSION
CA_PROTO_CLIENT_NAME
CA_PROTO_HOST_NAME
CA_PROTO_CREATE_CHAN
CA_PROTO_CREATE_CHAN
TCP
 CAS 5064
CA_PROTO_VERSION
CA_PROTO_ACCESS_RIGHTS
CA_PROTO_CREATE_CHAN
CA_PROTO_ACCESS_RIGHTS
CA_PROTO_CREATE_CHAN
TCP
CA_PROTO_READ_NOTIFY
CA_PROTO_EVENT_ADD
CA_PROTO_READ_NOTIFY
CA_PROTO_EVENT_ADD
TCP
CA_PROTO_EVENT_ADD
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x0e
0x10
CA_PROTO_EVENT_ADD
TCP
 CAS 5064
0x0e
IOIO
0x1d
0x1e
 CAS 5064
0x1d
0x1d
0x1e
0x1e
 CAS 5064
0x01
0x02
0x01
0x01
0x02
0x02
0x0d
0x0e
0x0f
0x10
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;
dbr_short_t
severity;
epicsTimeStamp
stamp;
dbr_long_t
RISC_pad;
dbr_double_t
value;
};
/* status of value */
/* severity of alarm */
/* time stamp since 1990/1/1 12:00 AM*/
/* RISC alignment */
/* 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
Thank you for your attention.