福彩3D走势图

技术天地

IEEE1588协议驱动分布式系统高精度同步触发    发布时间:2019-8-1 11:40:01    被阅览数:次

  IEEE1588SHIJINGQUEWANGLUODUISHIXIEYI,JIANCHENGPTP。TATONGGUOYINGJIANSHIXIANDESHIJIANBIAOQIAN(hardware time stamp),SHIDUISHIJINGDUDADAOYAWEIMIAOJI(< 1us),DADAGAOYUCHANGGUIDEWANGLUODUISHIXIEYI(NTP)。PTPXIEYIDELINGYIGETESESHITAKESHUCHUJINGQUESHIJIANTONGBUDEYINGJIANMAICHONG,TONGCHANGCHENGWEIPPSMAICHONG。ZAIWANGLUOHUADEQIANRUSHIXITONGZHONG,LIYONGPTPDEYINGJIANPPSMAICHONG,KEDUICHUYUBUTONGWEIZHIDEDUOTAISHEBEISHIXIANTONGBUCHUFADEGONGNENG。ZHEIDUIFENBUSHIXITONGDESHUJUCAIJI、SHISHIKONGZHIDOUJUYOUFEICHANGDEYIYI。


  YINGCHUANGGONGSIDEDUOKUANQIANRUSHIZHUBAN,ESM7000、ESM6802HEESM6800,QIWANGLUOJIEKOUJUNZHICHIPTPXIEYI,QIEKESHUCHUPPSMAICHONG,YINCISHIFENBUSHIZHINENGSHEBEIDELIXIANGQIANRUSHIPINGTAI。YIXIAJIANGYIESM7000WEILI,JIESHAOSHIXIANFENBUSHITONGBUCHUFADERUANYINGJIANFANGAN。


基于PTP的同步触发软件流程


  福彩3D走势图ESM7000预装的Linux平台文件系统中,已包含了PTP对时及硬件时间同步的完整工具,即ptp4l和phc2sys,同时可方便的控制PPS脉冲的使能。在这个基础上,按照图1所示流程就可实现同步触发的功能。


基于IEEE1588协议实现分布式系统的高精度同步触发.png

图1 同步触发软件流程


  在实际的测试中发现,PTP的对时精度与网络环境有密切关系。在单一的100M网络环境所获得的设备间的同步精度在±200ns;而在1000M网环境,同步精度就下降到±1us;混合网络环境,同步精度可差至±15us。


同步触发脉冲的硬件方案


  福彩3D走势图所谓硬件方案,是指图1中触发脉冲生成器的实现方案。以PTP协议生成的周期性PPS脉冲为基础,由应用程序生成触发使能信号,再通过一个简单的D触发器生成最后的触发脉冲。硬件方案涉及3个信号如下:

  ● PPS_OUT:ZHENGMIAOMAICHONGSHUCHU,JIZHOUQIGUDINGWEI1MIAO,ZAIESM7000SHANG,PPSDEMAICHONGKUANDUWEI10ns,SHANGSHENGYANYOUXIAO。

  ● TRG_EN:CHUFASHINENG,TONGCHANGYONGYIWEIGPIOLAISHIXIAN,QIGAODIANPINGYOUXIAO。

  ● TRG_PULSE:CHUFAMAICHONG,SHANGSHENGYANYOUXIAO;ZAITRG_ENWEIDISHI,JIANGQIANGZHITRG_PULSEWEIDI;DANGTRG_ENWEIGAOSHI,HOUXUDEPPS_OUTMAICHONGSHANGSHENGYANJIANGSUOCUNGAODIANPING,CONGERSHITRG_PULSEBIANGAODIANPING。TRG_PULSEMAICHONGSHANGSHENGYANJIANGJIANGZUOWEIXITONGCAIJIKONGZHIYINGJIANDANYUANDECHUFASHURU,CHUFAGEGEQIANRUSHISHEBEITONGBUDONGZUO。


基于IEEE1588协议实现分布式系统的高精度同步触发.png

图2 同步触发脉冲生成电路原理图


  在图2中,TRG_PULSE还可反馈给ESM7000主板,通知同步触发已发生。但不是必须的。


  DABUFENESMARCZHUBANJUNKEZHICHIPTPTONGBUCHUFAGONGNENG。DUIBUTONGXINGHAODEZHUBAN,PPSMAICHONGSHUCHUGUANJIAOYOUSUOBUTONG,RUXIABIAOSUOSHI:


主板型号PTP网口PPS信号管脚备注
ESM7000系列eth0CN2.GPIO0 
ESM6802系列eth0CN2.GPIO24V2.4版才支持
ESM6800系列eth1CN2.GPIO22不能使用SD卡
ES6801eth0CN1.GPIO0不能使用CAN1


福彩3D走势图  DUIXUANZENAYIWEIGPIOGUANJIAOZUOWEITRG_EN,BENFANGANMEIYOUXIANZHI。KEGENJUSHEBEIDEJUTIQINGKUANGLAIQUEDING。


对同步触发从设备测试


  本测试用从设备的“当前时间+ 偏移量”来代替主设备发布的触发时间TRGTIME,就可用简单的脚本测试整个触发过程,具体的脚本如下:



#!/bin/sh

# trg_en_3 $1 [$2] [$3]

# $1 = 0, off ptp; = 1: on ptp

# $2 = number of seconds to delay from cuurent time

# $3 = ip:port

 

PATH="/usr/bin:$PATH"

E_NOARGS=85

re='^[0-9]+$'

TRG_EN_GPIO="gpio1"

TRG_EN_DIRECTORY="/sys/class/em_gpio/em_gpio/$TRG_EN_GPIO"

PHC2SYSLOG="/tmp/phc2syslog.txt"

DELAY=10

 

# if no arg, exit

if [ -z "$1" ]

then

       echo "Usage: `basename $0` filename"

       exit $E_NOARGS

fi

 

# if $1 != 1, off ptp and exit

if [ "$1" -ne 1 ]

then

    echo 0 > /sys/class/ptp/ptp0/pps_enable

    pkill phc2sys

    pkill ptp4l

       exit 0

fi 

 

# get trigger delay is available, default = 10(s)

if [ $# -ge 2 ]

then

       DELAY="$2"

fi

 

# now we start to make trg_en step by step

 

echo "step 1: setup gpio1 as trg_en"

if [ ! -d "$TRG_EN_DIRECTORY" ]

then

       echo "config $TRG_EN_GPIO as trg_en"

       echo 1 > /sys/class/em_gpio/em_gpio/export

fi

echo out > /sys/class/em_gpio/em_gpio/$TRG_EN_GPIO/direction

echo 0 > /sys/class/em_gpio/em_gpio/$TRG_EN_GPIO/value

 

echo "step 2: start ptp"

phc2sys -s eth0 -c CLOCK_REALTIME -w -m -u 4 > $PHC2SYSLOG &

sleep 1

ptp4l -i eth0 -s &

 

echo "step 3: wait phc2sys sync convergence"

num_rms=0

while [ "$num_rms" -lt 3 ]

do

       RMS_ARRAY=$(cat $PHC2SYSLOG | tail -n 3 | sed -r 's/.*rms[ ]+([0-9]+).*/\1/g')

       # echo "$RMS_ARRAY"

 

       for rms in $RMS_ARRAY

       do

              if ! [[ $rms =~ $re ]]

        then

            echo "$rms is NOT an integer!"

                     break

              fi           

 

              echo "$rms"

              if [ "$rms" -lt 350 ]; then

                     let "num_rms += 1"

              fi

       done

      

       # clear log file if rms is convergence

       if [ "$num_rms" -ge 3 ]; then

              echo "rms is convergence ($num_rms)"

              cat /dev/null > $PHC2SYSLOG

       else

              let "num_rms = 0"

              sleep 2

       fi

done

 

echo "step 4: enable pps, and setup trigger time"

echo 1 > /sys/class/ptp/ptp0/pps_enable

TRGTIME=$(date +%s)                                       # get current date in seconds

let "TRGTIME = $TRGTIME + $DELAY"

PPSTIME=$(cat /sys/class/pps/pps0/assert | cut -d '.' -f 1)

echo "TRGTIME = $TRGTIME PPSTIME = $PPSTIME"

 

echo "step 5: wait pps time reach trigger time"

while [ "$PPSTIME" -lt "$TRGTIME" ]

do

       sleep 0.1

       PPSTIME=$(cat /sys/class/pps/pps0/assert | cut -d '.' -f 1)

done

 

echo "step 6: now PPSTIME = TRGTIME, set trg_en"

echo 1 > /sys/class/em_gpio/em_gpio/$TRG_EN_GPIO/value

 

echo "step 7: wait pps time reach trigger time + 1"

let "TRGTIME = $TRGTIME + 1"

while [ "$PPSTIME" -lt "$TRGTIME" ]

do

       sleep 0.1

       PPSTIME=$(cat /sys/class/pps/pps0/assert | cut -d '.' -f 1)

done

 

echo "step 8: clear trg_en"

echo 0 > /sys/class/em_gpio/em_gpio/$TRG_EN_GPIO/value

echo "basename $0 done"


福彩3D走势图  CONGSHIBOQIKEGUANCHADAO,SHANGSHUJIAOBENCHANSHENGDETRG_ENXINHAO,ZHUNQUESHINENGPPSMAICHONGCHANSHENGYUZHISHANGSHENGYANWANQUANTONGBUDECHUFAMAICHONGTRG_PULSE。


  DUIFENBUSHIXITONGTONGBUCHUFAGONGNENGGANXINGQUDEKEHU,KETONGGUOYOUJIANsupport@emtronix.comYUYINGCHUANGGONGSIJISHUBUMENLIANXI,YILEJIEXIANGXIDESHIXIANDAIMA。

Go Top
澳门AG 澳门AG 狗万足彩app 3d捕鱼 3d捕鱼 神扑克 万人斗地主 万人棋牌