tag 标签: vector

相关博文
  • 2025-1-16 10:19
    97 次阅读|
    0 个评论
    基于Vector工具进行CAN协议错误帧的分析实践
    引言 CAN(Controller Area Network)协议是当前使用最普遍的车载通信协议之一,其优点不只体现在多主并行、最高达1Mbit/sec的传输速率(针对标准CAN)、基于优先级的仲裁机制以及广播发送的短帧结构,还体现在其错误检测机制上。通过总线数据以及总线波形来分析总线故障时,CAN协议错误检测机制中丰富的错误帧类型能让定位问题的效率更高。错误帧是CAN协议进行错误报告的方式,可以将总线上任何一个节点发现错误的信号通知给其他节点。作为一名总线测试工程师,在日常测试过程中不可避免的会接触到错误帧,因此了解错误帧的作用、类型与产生原因,对于测试工作的顺利开展有很大的帮助。 CAN错误帧格式 图1 错误帧通用格式 CAN错误帧通用格式如上图1所示,主要包括错误标志和错误界定符两个部分,其形成的原理以及作用如下: 错误标志 :出现错误后若CAN节点处在主动错误阶段则发送6个连续显性位,在被动错误阶段则发送6个连续隐性位。由于6个连续相同的位违背了位填充规则会引发填充错误,会使其他节点也发送错误标志,因此,一个错误标志通常由两个连续6位的信号组成,由于会存在错误标志的重叠,所以错误标志的长度会在6-12位的范围。 错误界定符 :错误界定符由8个连续隐性位组成,所有节点在发送错误标志后,都会向总线发送1个隐性位,若检测到总线上该位为隐性,则发送剩下的7个隐性位。 CAN错误帧分类 CAN错误帧根据产生错误的节点类型可以分为发送错误和接收错误两大类,根据错误产生的原因则可以分为位错误、填充错误、ACK错误、格式错误以及CRC错误,下图2为各类错误帧所检测范围的分布。 图2 错误检测分布 位错误:回读总线位状态与自身发送的位不同,发送节点发送错误帧,需要注意仲裁段和ACK位发送隐性位但是回读到显性位除外。 填充错误:违反位填充规则,发送节点在发送报文时遇到5个相同极性位后需要插入1个极性相反的位,接收节点再接收报文时则需要删除填充位。如果接收到的报文存在6个相同极性的位,则第6个位便是出现了填充错误,需要在该位后发送错误帧。 ACK错误:当发送节点发送报文后,在ACK位没有在总线上检测到其他节点发送的显性电平。 格式错误:固定格式位场(如CRC界定符、ACK界定符、EOF等)与协议标准定义的显隐性不同则会被检测为非法位触发格式错误,发送和接收节点都会发送错误帧。 CRC错误:接收节点计算的CRC序列与接收到报文中的CRC序列不同。 错误帧的表现形式 图3 实验环境配置 为了更直观的展示各种错误帧类型,搭建了如图3所示的实验环境,以VN1630为发送节点,VH6501为接收节点,结合VH6501的报文干扰功能制造各类错误帧。 1. 发送错误 位错误 如图4所示,用VH6501干扰发送节点仿真报文的SOF位后,SOF位出现位错误,在Bit0开始发送错误帧,接收节点在Bit5检测到存在6个连续的隐性位,触发填充错误。 图4 位错误报文示例 ACK错误 按照CAN协议的规定,在一帧报文发出之后,如果接收节点成功接收了该帧报文,则接收节点需要在该帧报文ACK段内向总线上发送一个显性位来对发送节点的报文进行应答,此时发送节点会在ACK段内从总线上回读到一个显性位。如图5所示,通过配置关闭接收节点的ACK应答功能,此时发送节点在ACK位没有收到其他节点应答,触发ACK错误。 图5 ACK错误报文示例 格式错误 如图6所示,分别干扰EOF的第一位和第六位都会导致发送和接收节点出现格式错误,是由于发送节点发送隐性位EOF,回读到总线为显性位,在该位后发送格式错误帧。 图6 EOF格式错误报文示例 2. 接收错误 填充错误 如图7所示,干扰报文0x210,使Bit7隐性变为显性,总线出现6个连续显性位,使得发送节点和接收节点都检测到填充错误,发送错误帧。 图7 报文填充错误 CRC错误 如图8所示,通过VH6501直接发送报文序列,并篡改数据场使其与CRC序列不匹配,触发接收节点检测到CRC错误,错误位置是100(ACK DEL),ISO 11898-1中规定检测到CRC错误后,应该在ACK界定符之后发送错误标志。 图8 CRC错误报文示例 格式错误 : 如图9所示,Position 98和Position 100分别为CRC界定符和ACK界定符,干扰发送报文固定格式位后,接收节点检测到格式错误帧。 图9 界定符格式错误报文示例 错误标志重叠 由于错误标志为6个极性相同的位,因此错误标志会导致填充错误,引起其他节点发送错误标志,或在发送错误标志时将原本个,从而使其他节点紧跟着发送错误标志,当引起全局错误时,所有节点都会同时发送错误标志,使得错误标志为6个位。以下为三种典型错误标志重叠范例。 重叠部分为6个位时: 如图10所示,在固定格式ACK界定符发送后,总线获取到的信号为显性位,由此发送节点和接收节点同时检测到格式错误,都在ACK界定符后发送6个连续显性位。 图10 错误标志完全重叠 重叠部分为5个位时: 如图11所示,当接收节点B出现CRC错误时,在ACK DEL后发送主动错误标志,发送节点和接收节点A监测到EOF的第一位被显性位覆盖,发送格式错误帧,总线上表现为7位长度的错误标志。 图11 错误标志部分重叠 重叠部分为0时: 如图12所示,发送节点回读总线监测到位错误,发送错误标志,当错误标志的6个连续显性位发送完毕之后,总线上出现填充错误,引起其他节点发送错误标志,从而使错误标志达到12个位。 图12 错误标志不重叠 总结 CAN总线在几十年的使用和发展下,被使用在几乎每一台车辆上,可以说是车辆行业不可或缺的存在,是现如今国际上应用最广泛的现场总线之一。而错误帧是CAN总线用于错误报告的报文,丰富的错误帧类型有助于迅速排查定位总线故障,因此错误帧的理解和使用也是作为总线测试工程师的必修课,希望这篇简介能够帮助了解错误帧的相关内容。 北汇信息是一家专注于汽车电子测试领域的企业,对网络测试有着丰富经验,并可提供相关培训、咨询服务以及测试解决方案,帮助汽车制造商和零部件供应商确保其车载网络的可靠性和安全性。如果需要具体的测试服务或了解更多信息,欢迎大家来联系我们。 参考文献 【1】《ISO11898-1 - 2015》,Road vehicles - Controller area network (CAN) - Part 1:Data link layer and physical signalling 【2】《CAN入门书》瑞萨科技RCJ05B0027-0100
  • 热度 16
    2016-3-15 21:01
    1184 次阅读|
    0 个评论
    Vector是C语言里面没有的概念。 Vector是Container(容器)的一种,有关容器更多的留在后面再说。 要使用Vector,首先要包含头文件,并且声明命名空间: #include using std::vector; Vector是一个类的模板(template)。 C++有类的模板,也有函数的模板。以后会学习怎样创建模板,现在只需要了解如何使用它。 模板自身并不是类或者函数,它们是用来创建类或者函数的指令。这个过程称为实例化。 为了将模板实例化,我们需要提供额外的信息。 为了将Vector实例化,我们需要提供的额外信息是Vector持有的对象类型: vector ivec; vector sales_vec; vector file;  //旧版的C++需要写成 我们可以创建任何类型的Vector,整型、类或者Vector自身。 引用并不是对象,因此不能为引用创建Vector。 有很多种方法可以初始化Vector: vector v1 vector v2(v1) vector v2 = v1 vector v3(n, val) vector v4(n) vector v5{a,b,c...} vector v5 = {a,b,c...} vector v1;//它定义了一个空的向量 空向量看起来没什么用,但是我们可以动态的往向量里面添加内容。 实际上,大部分使用都是这么做的。 Vector初始化的时候,使用括号(parentheses)和使用大括号(curly braces), 有非常有意思的区别。编译器会聪明的配置它们。 ---------------- 如何为Vector增加元素? 使用push_back增加新的最后一个。 先来一个整型数的例子: vector v2; for (int i = 0; i != 100; i++)     v2.push_back(i); 再来一个string的例子: string word; vector text; while (cin word)     text.push_back(word); 由于Vector的长度可变,因此在使用range for的时候,不要在循环里面增加它的长度。 ---------------- v.empty() v.size() v.push_back() v v1 = v2 v1 = {a,b,c...} v1 == v2 v1 != v2 ,=,,= 这些操作和string类似。 size_type的用法也和string类似,除了vector必须指定元素类型: vector::size_type 同string一样,vector也可以使用下标来访问元素; 同string一样,vector的下标越界也是不会被检查的。
  • 热度 14
    2011-3-14 16:44
    2910 次阅读|
    0 个评论
      A 3×3 matrix class? It's this character flaw that keeps me from being able to show you a completed 3×3 matrix class. Until recently, I've been stuck in one of those while-loops, and this time the ex-wife isn't here to assert the interrupt. I wasn't able to exit the loop until I began writing this column. I'd like to tell you what I have, and see what you think.   Clearly, a 3×3 matrix is not just any old matrix, even any old matrix with one dimension of three. It's a square matrix, and square matrices have special properties. For one thing, they have well-defined diagonals. A square matrix might, in fact, be diagonal. That is, its off-diagonal elements may all be zero. That's important, because a diagonal matrix has a trivial inverse: A square matrix might also be symmetric. If so, it can easily be transformed to a diagonal matrix. When I'm doing arithmetic with 3×3 matrices, they're almost always associated with coordinate rotations. For example, to convert a vector from a rotating coordinate system to a fixed one, I might write:   The matrix T is even more specialized than most. It's a rotation matrix , also called an orthonormal matrix . It has two very important attributes: Its determinant is 1, and its inverse is the same as its transpose:   This is very important, because a transpose of a 3×3 matrix is trivial to generate, whereas an inverse takes a lot longer. Also, because the determinant is known, we don't have to worry about the matrix being singular.   Finally, there exist more than one way to represent a rotation. The matrix is one choice, but not the only one, or even the best one. Other choices include Euler angles and quaternions. Euler angles are useful because people tend to be able to visualize the rotations better. But they're terrible choices for computations. Quaternions are the best and most compact, but good luck trying to visualize them.   Side Comment: You know you've arrived as a guru when you realize you can visualize a quaternion. Since it's a four-dimensional vector, that takes a little practice.   Decisions, decisions Now that I've given you the background, I can tell you why I was stuck in the while-loop. I know that I want to use 3×3 matrices mostly to effect coordinate rotations. But is that always going to be the case? Maybe not. And if it is, may I include constructors to convert a set of 3-vectors to a matrix? Or a set of Euler angles, or quaternions? If I demand that the matrix must be orthonormal, I'd better not try to create one from vectors.   For that matter, if I'm dealing exclusively with rotation matrices, maybe I need a function to make sure they stay orthonormal.   Here's why. When we're writing dynamic simulations involving rotations, we have to numerically integrate the elements that make up the state vector. If one of those elements is a rotation matrix (or equivalent structure), numerical roundoff errors can cause the matrix to drift away from its nominally orthonormal state. Those of us who write such simulations often include functions to re-normalize the matrix. It's not an easy thing to do, and doing it in an optimal way is even harder.   So a re-normalizing function is going to be almost a necessity for rotation matrices, but it's going to look really, really strange in a general-purpose matrix package—even one specialized to 3×3 matrices.   Of course, you know the conceptual solution to problems such as this: inheritance. Write a C++ base class for 3×3 matrices. Then define a derived class that specializes the class even further, to rotation matrices. Most of the operations will be the same, but a few functions, such as re-normalization, can be added, and the inverse function can be changed to invoke the simpler transpose function.   There's only one problem with this approach. A rotation in 3-space is a very unique thing, and the function that it performs is vastly different from the more generic matrix product. Heck, the member data for a "rotation matrix" need not even include a matrix. Rotations can also be described by a quaternion or a set of Euler angles.   And because there are three possible ways to describe the rotation, we're also going to need conversion functions to transform one set of descriptors to another.   FYI, a couple of years ago I wrote a library of Matlab functions capable of converting between angle, matrix, and quaternion representations. In doing so, I even surprised myself, coming up with killer algorithms that resulted in code that was tight, accurate, and bulletproof. I'll be sharing the algorithms with you soon.   Most people who work every day with rotation-related problems choose the quaternion, because it's more efficient to do so (no angles involved, and fewer elements to store). One has to ask: what's the point having a rotation matrix be a derived class of the 3×3 matrix, if it doesn't even hold a matrix anywhere in its structure?   Off and on, I've wrestled with questions like this many times. I can't say that I've ever come up with the definitive solution. More often, I find myself in need of that priority interrupt.   But this time, I've finally got the structure I need. The trick is, there should be no class called RotationMatrix . Instead, there's a class called Rotation . When applied to a vector or another matrix (or Rotation ), the operation may look like a matrix product, but the appearance is only superficial. Internally, a Rotation should be a separate type of object, worthy of its own class. Heck, it may not—and probably won't—even have a matrix as part of its member data. And in the best tradition of object-oriented programming, the way the rotation class is implemented should be transparent to the user. If I decide to change the internal representation from matrix to quaternion, that decision shouldn't matter one iota to users of the class.   When you think about it, the fact that I can define a rotation operation that looks like a matrix product is no different than defining products of integers or real numbers. I can declare:   int i, j, k; double x, y, z; Vector X, Y; Matrix A; Rotation R;   and write:   k = i*j; z = x*y; Y = A*X; Y = R*X;   Yes, the statements look the same and mean much the same. That's the elegance of operator overloading, and it makes life incredibly easy for the programmer. But we have no particular reason for a rotation object to inherit the '*' operator from a matrix, any more than we might have it do so from class int . Separating the class Rotation into a full-blown separate class is beginning to make a lot of sense.   Wrapping up I'm glad we had this little talk. So often in life, I've found that as I try to explain a knotty problem to someone else, I realize that I suddenly know the solution. That seems to be what has happened here. Thanks for listening.    
相关资源
  • 所需E币: 0
    时间: 2022-9-1 19:28
    大小: 614.51KB
    Bayesiansupportvectorregressionusingaunifiedlossfunction
  • 所需E币: 0
    时间: 2022-5-27 09:52
    大小: 383.55KB
    DSPBasedImplementationofFuzzyPrecompensatedPISpeedControllerforVectorControlledPMSMDrive
  • 所需E币: 1
    时间: 2022-4-25 09:46
    大小: 13.76MB
    VectorControlofThree-PhaseACMachines-SystemDevelopmentinthePractice
  • 所需E币: 5
    时间: 2019-12-25 15:29
    大小: 3.64MB
    上传者: wsu_w_hotmail.com
    ARM指令集……
  • 所需E币: 4
    时间: 2019-12-25 02:43
    大小: 157.93KB
    上传者: 2iot
    ARMVectorFloatingPointInstructionSetQuickReferenceCardVectorFloatingPointInstructionSetQuickReferenceCardKeytoTables{cond}SeeTableConditionField(onARMside).{E}E:raiseexceptiononanyNaN.WithoutE:raiseexceptiononlyonsignalingNaNs.S(singleprecision)orD(doubleprecision).{Z}Roundtowardszero.OverridesFPSCRroundingmode.Asabove,orX(unspecifiedprecision).AcommaseparatedlistofconsecutiveVFPregisters,enclosedinbraces({and}).Fd,Fn,FmSd,Sn,Sm(singleprecision),orDd,Dn,Dm(doubleprecision).……
  • 所需E币: 5
    时间: 2019-12-24 23:07
    大小: 744.37KB
    上传者: givh79_163.com
    本应用笔记介绍了如何使用LPC32x0矢量浮点协处理器(VFP)。AN10902UsingtheLPC32xxVFPRev.01―9February2010ApplicationnoteDocumentinformationInfoContentKeywordsVectorFloatingPoint(VFP)coprocessor,LPC32x0,LPC3180AbstractThisapplicationnotedescribeshowtouseLPC32x0VectorFloatingPoint(VFP)coprocessor.NXPSemiconductorsAN10902UsingtheLPC32xxVFPRevisionhistoryRevDateDescription0120100209Initialversion.Contactinformati……
  • 所需E币: 5
    时间: 2019-12-24 22:04
    大小: 145.27KB
    上传者: 2iot
    Abstract:Tamperingwithelectricenergymeasurementcausessignificantrevenuelosstotheenergyproviders.TheMAXQ3183polyphaseAFEprovidescurrentvectorsummeasurementsfortamperdetection.ThisapplicationnotedescribeshowtoconfiguretheMAXQ3183forthree-currentvectorsum.Testresultsgeneratedwithareferencedesignmeterareprovided.Maxim>AppNotes>ASICsEnergyMeasurement&MeteringMicrocontrollersKeywords:MAXQ3183,vectorsum,tamperdetection,energymeterOct27,2010APPLICATIONNOTE4664HowtoConductThree-CurrentVectorSumMeasurementsBy:KennethTangAbstract:Tamperingwithelectricenergymeasurementcausessignificantrevenuelosstotheenergyproviders.TheMAXQ3183polyphaseAFEprovidescurrentvectorsummeasurementsfortamperdetection.ThisapplicationnotedescribeshowtoconfiguretheMAXQ3183forthree-currentvectorsum.Testresultsgeneratedwithareferencedesignmeterareprovided.Downloadassociatedsoftware(ZIP).IntroductionTamperingwiththemeasurementofelectricenergyoccursinavarietyofformsandcauses……
  • 所需E币: 5
    时间: 2019-12-24 17:55
    大小: 145.27KB
    上传者: rdg1993
    摘要:篡改电能计量的能源供应商造成重大的收入损失。MAXQ3183多相AFE提供篡改检测和电流矢量测量。本应用笔记介绍了如何配置MAXQ3183三个电流的矢量和。提供参考设计计生成的测试结果。Maxim>AppNotes>ASICsEnergyMeasurement&MeteringMicrocontrollersKeywords:MAXQ3183,vectorsum,tamperdetection,energymeterOct27,2010APPLICATIONNOTE4664HowtoConductThree-CurrentVectorSumMeasurementsBy:KennethTangAbstract:Tamperingwithelectricenergymeasurementcausessignificantrevenuelosstotheenergyproviders.TheMAXQ3183polyphaseAFEprovidescurrentvectorsummeasurementsfortamperdetection.ThisapplicationnotedescribeshowtoconfiguretheMAXQ3183forthree-currentvectorsum.Testresultsgeneratedwithareferencedesignmeterareprovided.Downloadassociatedsoftware(ZIP).IntroductionTamperingwiththemeasurementofelectricenergyoccursinavarietyofformsandcauses……
  • 所需E币: 4
    时间: 2020-1-13 19:33
    大小: 386.08KB
    上传者: rdg1993
    PINDiodeVectorModulators-FundamentalsandDriveRequirementsAN3001ApplicationNotePINdiodeVectorModulatorsFundamentalsandDriveRequirementsV3.00IntroductionM/A-COM’sChipScalePackage(CSP)vectormodulatorplatformoffersameansofvaryingattenuationandphaseinasinglesurfacemountpackage.Thesevectormodulatorsofferlinearphaseandminimalamplituderippleintheirbandsofoperation.DuetousingPINdiodesastheactivedevices,thesevectormodulatorshavehighinterceptpoints.Thesevectormodulatorsoperateintandemwithaduallinearizer,MADRCC0002thathasbeendevelopedbyM/A-COM.Case2.IfthediodesinthetopVVAaresettoanimpedanceof50ohms,thetopVVAwillbeinahighlossstate.TheoutputofthebottomVVAwillhaveaphaseof-90°or90°,dependingontheimpedanceoftheterminatingdiodes……