你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【设计分享】基于stm32f4的三维旋转显示平台  

[复制链接]
原来是他 发布时间:2015-7-27 10:33
给大家分享个基于stm32f4的设计,下面有硬件图和源程序。(不是我写的,只是分享而已)


摘要
   现实的世界是一个拥有宽度、高度和深度的三维立体世界。在平面二维显示技术已经成熟的今天,三维立体显示技术首当其冲的成为了当今显示技术领域的研究热点。
本作品搭建了基于stm32f4的三维旋转显示平台,它的显示原理属于三维显示中的体三维显示一类。它是通过适当方式来激励位于透明显示体内的物质,利用可见辐射光的产生三维体像素。当体积内许多方位的物质都被激励后,便能形成由许多分散的体像素在三维空间内构成三维图像。
体三维显示又称为真三维显示,因为他所呈现的图像在真实的三维空间中,展示一个最接近真实物体的立体画面,可同时允许多人,多角度裸眼观看场景,无序任何辅助眼镜。
本作品的特点在于,利用stm32f4的浮点运算能力,实现了低成本的体三维显示数据的生产,并利用类似分布式处理的系统结构,满足了体三维显示所需要的巨大数据吞吐量,等效吞吐量可达约300Mb/s
1.    系统方案
众所周知人眼在接收被观察物体的信息时,携带物体信息的光信号通过人眼细胞及神经传入大脑神经,光的作用时间只是一个很短暂的时间段,当光的作用时间结束后,视觉影像并不会立即消失,这种残留的视觉称“后像”,视觉的这一现象则被称为“视觉暂留”( duration of vision)物体在快速运动时, 当人眼所看到的影像消失后,人眼仍能继续保留其影像0.1---0.4秒左右的图像。在空间立体物体离散化的基础上,再利用人眼视觉暂留效应,基于LED阵列的“三维体扫描”立体显示系统便实现了立体显示效果。如图1所示,以显示一个空心的边长为单位1的正方体为例。LED显示阵列组成的二维显示屏即为正方体每个离散平面的显示载体,LED显示屏上的被点亮的LED即为正方体的平面离散像素。我们将该LED显示平面置于轴对称的角度机械扫描架构内,在严格机电同步的立体柱空间内进行各离散像素的寻址、赋值和激励,由于机械扫描速度足够快,便在人眼视觉上形成一个完整的正方体图像。图1(a)所示为立方体0度平面二维切片图,图1(b)所示为立方体45度平面二维切片图,图1(c)所示为立方体135度平面二维切片图,图1(d)所示为立方体180度平面二维切片图,图1(e)所示为观看者观察到的完整立方体显示效果。
1.png
1
系统方案如图2所示,整个系统由四个模块组成,其中数据获取单元主要由在PC上的上位机完成,利用3D-Max,OpenCV,OpenGL,将三维建模数据转化成三维矢量表述文件,传给由STM32F4Discovery开发板构成的控制单元,利用其上的角度传感器,结合wifi模块或以太网模块通过电力线模式传给LED旋转屏单元,其中的STM32F4负责将ASE文件解析成LED显示阵列所需的点云数据流,通过串行总线传输给由FPGA驱动的LED显示阵列,通过LED刷新速率与机械单元旋转速率相匹配,从而实现体三维显示的效果。
[tr]   [/tr]


2.PNG
2

2.    系统硬件设计
系统的机械部分如图3所示,显示面板的硬件结构如图4,图5所示。本系统的底部是直流电机和碳刷,直流电机主要负责带动上层的显示屏幕高速旋转,而碳刷则负责传递能量和通信信号。在显示屏幕的正面是由96*128构成的三色LED点阵,FPGA的PWM信号通过驱动芯片控制三色LED从而实现真彩显示。在屏幕背面由多块STM32F4,SD卡,FIFO构成,主要负责解析由控制单元传过来的ASE文件,并实时生成体三维显示数据,并传给LED灯板的驱动FPGA,并通过其实现最终的图像显示。
3.png
3
4.png
4
5.png
5

3.    系统软件设计
3.1软件控制流程:
6.png

3.2关于实时生成体三维显示数据的讨论:
一个瓦片64*32
LEDFPGA*8:每个16*16LED
中间层stm32*2:每个4LED层的FPGA,也即32*32
由于经过压缩,一个led数据为4bits
所以一个stm32每一帧所要生成的数据为32*32*0.5bytes = 512bytes
转速800转,一帧1/800s = 1.25ms = 1250000ns
stm32f4主频168Mhz,指令周期 = 5.93ns
约可执行20万多条指令
假设fsmc总线的速度为50Mhz,则每帧写入的时间大概在0.02ms
程序总体思路
事先算出所有电子帧上非零的点,以及连续0的个数,在每一个电子帧同步后,算出生成下一帧的数据,写入fifo
输入:线段端点的集合
  1. //input: endpoints of segments which formedthe outline of a 3D model
  2. //x position with range 0-95
  3. //y position with range 0-95
  4. //z position with range 0-128
  5. /******************************************/
  6. //from later discussion, one of the Qformat
  7. //type should replace the char type
  8. /******************************************/
复制代码

  1. struct Coordinate_3D
  2. {
  3.        _iqxPosition;
  4.        _iqyPosition;
  5.        _iqzPosition;
  6. };
  7. //after you get the intersection points in3d coordinate, you need to remap it into 2d coordinate on the very electricalplane,
  8. //and the conversion is quite simpleCoordinate_2D.yPosition = Coordinate_3D.zPosition; Coordinate_2D.xPosition =sqrt(xPosition^2+yPosition^2)
  9. struct Coordinate_2D
  10. {
  11.        charxPosition;
  12.        charyPosition;
  13. };
  14. struct Line
  15. {
  16.        structCoordinate_3D beginPoint;
  17.        structCoordinate_3D endPoint;
  18.        unsignedchar color;
  19. };
  20. //frame structure to store the visiblepoints in one electrical frame
  21. //need to be discussed
  22. //here's the prototype of the Framestructure, and basically the frame struture should contain the visible points,
  23. //and the zero points. As we have enclosedthe number of zero points after each visible points in their own datastructure,
  24. //only the number of zero points at the beginningof the whole frame should be enclosed in the frame struture
  25. struct Frame
  26. {
  27.        intzerosBefore;
  28.        PointQueue_tvisiblePointQueue;   
  29. };
  30. //we need a union structure like colorplane with bit fields to store the color imformation of every four FPGAs in onedata segment
  31. //actually, it's a kind of frustrateingthing that we had to rebind the data into such an odd form.
  32. union ColorPalette
  33. {
  34.        struct
  35.        {
  36.               unsigned char color1 : 4;
  37.               unsigned char color2 : 4;
  38.               unsigned char color3 : 4;
  39.               unsigned char color3 : 4;
  40.        }distributedColor;
  41.        unsignedshort unionColor;
  42. };
  43. //and now we need a complete pointstructure to sotre all the imformation above
  44. //here we add a weight field = yPosition*96+ xPosition, which will facilitate
  45. //our sort and calculation of the zero pointsnumber between each visible point
  46. //it's important to understand that, 4corresponding points on the LED panel
  47. //will share one visiblepoint datastructure.(一块stm32负责4块16*16的LED,每块对应的点的4位颜色信息,拼成16位的数据段)
  48. struct VisiblePoint
  49. {
  50.        structCoordinate_2D coord;
  51.        unionColorplane ColorPalette;
  52.        intweight;
  53.        intzerosAfter;
  54. };
  55. //as now you can see, we need some thing tostore the visible points array
  56. typedef struct QueueNode
  57. {
  58.        structVisiblePoint pointData;
  59.        structQueueNode * nextNode;
  60. }QueueNode_t, *QueueNode_ptr;

  61. typedef struct
  62. {
  63.        QueueNode_ptrfront;
  64.        QueueNode_ptrrear;
  65. }PointQueue_t;
  66. //finally, we will have 16*16 words(16bits)to write into the fifo after each electrial frame sync cmd.
  67. //it may hard for us to decide the framestructure now, let's see how will the work flow of the algorithm be.
  68. //firstly, the overall function will belike this
  69. void Real3DExt(struct Line inputLines[],int lineNumber, struct Frame outputFrames[])
  70. //then we need some real implementationfunction to calculate the intersection points
  71. //with 0 = no intersection points, 1 = onlyhave one intersection points, 2 = the input line coincides the given electricalplane
  72. //2 need to be treated as an exception
  73. //the range of the degree is 0-359
  74. //it's important to mention that each intersectionpoint we calculate, we need to
  75. //remap its coordinate from a 32*32 fieldto x,y = 0-15, as each stm32 only have a 32*32
  76. //effective field(those intersection pointsout of this range belong to other stm32), which can be decided by its address
  77. int InterCal(struct Line inputLine, structVisiblePoint * outputPoint, int degree)
  78. //so we will need something like this inthe Real3DExt function:
  79. for (int j = 0; j < 360; j++)
  80. {
  81.        for(inti = 0; i < lineNumber; i++ )
  82.               InterCal(struct Line inputLine, struct VisiblePointoutputPoint, int degree);
  83.               ......
  84. }
  85. /******************************************/
  86. //simple float format version of InterCal
  87. /******************************************/
  88. //calculate formula
  89. //Q = [-1,1,-1];
  90. //P = [1,1,-1];
  91. //V = Q - p = [-2,0,0];
  92. //Theta = pi/6;
  93. //Tmp0 = Q(1)*sin(Theta) - Q(2)*cos(Theta);
  94. //Tmp1 = V(1)*sin(Theta) - V(2)*cos(Theta);
  95. //Result = Q - (Tmp0/Tmp1)*V
  96. float32_t f32_point0[3] ={-1.0f,1.0f,-1.0f};
  97. float32_t f32_point1[3] ={1.0f,1.0f,-1.0f};
  98. float32_t f32_directionVector[3],f32_normalVector[3], f32_theta,
  99.               f32_tmp0, f32_tmp1, f32_tmp2, f32_result[3];
  100. arm_sub_f32(f32_point0,f32_point1,f32_directionVector,3);
  101. f32_theta = PI/6.0f;
  102. f32_normalVector[0] =arm_sin_f32(f32_theta);      
  103. f32_normalVector[1] = arm_cos_f32(f32_theta);
  104. f32_normalVector[2] = 0.0f;
  105. arm_dot_prod_f32(f32_point0,f32_normalVector, 3, &f32_tmp0);
  106. arm_dot_prod_f32(f32_directionVector,f32_normalVector, 3, &f32_tmp1);
  107. f32_tmp2 = f32_tmp0/f32_tmp1;
  108. arm_scale_f32(f32_normalVector, f32_tmp2,f32_normalVector, 3);
  109. arm_sub_f32(f32_point0, f32_normalVector,f32_result, 3);

  110. //and than we need to decide whether to adda new visible point in the point queue, or to update
  111. //the color field of a given point in thepoint queue(as 4 visible point share one data structure). from this point, youwill find that, it may be
  112. //sensible for you not to diretly insert anew point into the end of point queue but to insert it in order
  113. //when you build the pointqueue. it seemsmore effective.
  114. void EnPointQueue(PointQueue_t * inputQueue,QueueNode_t inputNode);
  115. //finally we will get an sorted queue atthe end of the inner for loop
  116. //than we need to calculate the number ofinvisible points between these visible points
  117. //and to store it in each frame structure.the main purpose to do so is to offer an quick generation
  118. //of the blank point(color field = 16'b0)between each electrical frame
  119. //the work flow will be like this:
  120. loop
  121. {
  122.        dmaoutput of the blank points;
  123.        outputof the visible points;
  124. }
  125. /******************************************/
  126. //some points need more detailed discussion
  127. /******************************************/
  128. //1.memory allocation strategy
  129. //a quite straight forward method will beestablishing a big memnory pool in advance, but the drawback of this method
  130. //is that it's hard for you to decide thesize of the memory pool. Another way would be the C runtime library method,
  131. // and you can use build-in function mallocto allocate the memory, but it will be a quite heavy load for the m3 cpu
  132. // as you need dynamic memeory allocationthroughout the algorithm.
  133. //2.the choice of Q format of the IQMATHlibrary
  134. //from the discussion above, the range ofthe coordnate is about 1-100, but the range of sin&cos is only 0-1,sothere's a large gap between them.
  135. //may be we can choose iq24?? Simultaneously,another big problem will be the choice between IQMATH and arm dsp library astheir q format is
  136. //incompatible with each other. as far asmy knowledge is concerned, we should choose IQMATH with m3 without fpu, andcmsis dsp library with m4 with fpu.

  137. //more detail discussion about the range ofthe algorithm
  138. //x,y range is -64 to 64
  139. //the formula is
  140. //Tmp0 = Q(1)*sin(Theta) - Q(2)*cos(Theta);
  141. //Tmp0 range is -128 to 128
  142. //Tmp1 = V(1)*sin(Theta) - V(2)*cos(Theta);
  143. //Tmp1 range is -128 to 128
  144. //Result = Q - (Tmp1/Tmp2)*V
  145. //because the minimal precision of thecoordinate is 1, so if the result of Tmp1/Tmp2 is bigger than 128, the Resultwill be
  146. //saturated. With the same reson, if(Tmp1/Tmp2)*V >= 128 or <= -127, the result will be saturated
复制代码

4.    系统创新
其一,由于高效解析算法的提出,大幅简化了真三维显示器显示数据的获取难度,只需在PC端获得当前较为标准化的三维图形的三角面顶点数据流文件,即可在真三维显示平台上显示出来,使得真三维显示器的整体显示流程大为简化。
其二,由于显示体的结构分为并行的若干区块,各个区块只显示自身的部分,因此显示屏幕的扩大并不会造成数据计算量的大幅增加,这就使得本显示器的扩展性大大增强,可以适用于多种多样的显示范围与领域。
其三,由于高效算法的优化与区块化显示的优势,并行结构的计算量相对较少,这就使得实时控制得以实现,大大增强了真三维显示器的应用领域。
其四,高效算法与区块化显示使得本三维体显示器不需要如国内外其他同类产品的中所需的高速传输方式,因此大大减少了从产品研发到材料再到加工中各个环节的成本。
5.    评测与结论
在作品的过程中,我们发现本作品虽然还不是很成熟,也同样具备较大的应用前景与价值。价格成本的极大降低,使得真三维立体显示的门槛很低,那么在一些对清晰度要求不高,但是希望多层次全角度呈现三维图像的应用领域,我们的真三维立体显示器能发挥较大的作用。

附录  
7.png
8.PNG

9.PNG 10.PNG

原理图.pdf (1.2 MB, 下载次数: 440)
收藏 13 评论39 发布时间:2015-7-27 10:33

举报

39个回答
Paderboy 回答时间:2015-7-27 11:06:29
不懂,帮顶。。。
JackieLaura 回答时间:2015-7-27 11:29:23
这效果太铉了。。。
moyanming2013 回答时间:2015-7-27 11:39:56
1.jpg
Tension 回答时间:2015-7-27 11:44:36
期待楼主传个视频观摩下。
stary666 回答时间:2015-7-27 12:18:30
学习一下,,
lkl0305 回答时间:2015-7-27 12:28:11
牛,多谢分享
watershade 回答时间:2015-7-27 13:41:20
没看懂,这数据量都用到FPGA了。
丁南 回答时间:2015-7-27 13:47:49
MouseCat 回答时间:2015-7-27 13:56:52
好NB啊啊啊
1234下一页

所属标签

STM32团队

意法半导体微控制器和微处理器拥有广泛的产品线,包含低成本的8位单片机和基于ARM® Cortex®-M0、M0+、M3、M4、M33、M7及A7内核并具备丰富外设选择的32位微控制器及微处理器


最新内容

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版