HUD速度计-从构思到结果

大家好!
我已经很长时间没有写任何东西了,现在它比实际的新闻资源更多。我将尝试解决这种情况。我将向您介绍HUD速度计的发展。尽管不是激光投影,但价格实惠且结构紧凑。
引言
, 3.3" . , . 4 , 5, . , — . , . , , ( ) — 1800. ( ):
1. — , , , - . , — . .
2.您不能粘胶膜,然后数字(它们很小)加倍,在阳光下看不到任何东西。
对于初学者来说,结果是在玻璃杯中甚至在白天都没有胶卷:


在剪裁下,我保证会提供很多图片,平庸的视频,代码和文本-都是最好的传统。

理论
想法很简单-在固定的时间段内,我们计算来自速度传感器的脉冲数。作为CPU,简单而经济的ATMega8。
遇到的第一个困难是MK 5 V和指示器7.5 V的配合。Fantasy绘制了晶体管和电阻器堆栈的示意图(用于动态指示的7个元件)。在所有google中,只有一篇文章帮助我解决了更换手表中的指示器的问题,对不起,我失去了她的地​​址。我借此机会向作者表示感谢,感谢他使用TD62783的想法(每手5个)。实际上,这是晶体管组件内部的七段指示器驱动器。
接下来,一个DC / DC转换器。我有很多在MC34063上制造,并且有库存。我用计算器对它进行了计数,并用测试仪-7.5 V对其进行了检查。在现场测试中,结果显示亮度稍低,亮度不足,增至10V。
亮度是根据光传感器的读数进行调整的,光传感器是普通的中国光敏电阻。
结果,电路结果如下:

练习I
印刷TopoR印刷电路板。我使用自动放置,尽管我手动固定了大多数元素。但是进步必须对我有用,而不仅仅是我对进步有用。事实证明

,这很美:U4错过了车身的宽度,我不得不完成赛道,而不是焊接第11条腿。
在现实生活中的外观:



下一个意外的人爬上了软件(我不会告诉我如何忘记镜像2和5、4-没有什么值得骄傲的)。问题更加复杂:计数器对必要的脉冲数进行了太长时间的计数。例如,以60 km / h的速度计算来自速度传感器的60个脉冲需要花费一秒钟以上的时间。如此罕见的证词更新不适合我。
我必须将每个测量楼层乘以2。
与照明相比,亮度的线性变化不适合:当它稍微更暗时,亮度证明是不够的;当它几乎是暗时,亮度太大了。我启动了Excel,为不同的数学函数构建了图形。结果,我选择了一个正方形。


Bascom代码:
隐藏文字
'HUD-speedometer
'17/01/2016
'21/01/2016
'v1.1

$regfile = "m8adef.dat"
$crystal = 4000000
$hwstack = 40
$swstack = 16
$framesize = 32

Config Portb = Output
Config Portc = Output
Config Portd = Output
Config Portd.4 = Input
Portd.4 = 1
Config Timer0 = Counter , Edge = Falling
Config Timer1 = Pwm , Pwm = 8 , Compare_a_pwm = Clear_up , Compare_b_pwm = Clear_up , Prescale = 8
Config Timer2 = Timer , Prescale = 1024
On Timer2 Mytimer2
Enable Interrupts
Enable Timer2
Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc

Dim I As Byte '
Dim N As Byte '
Dim Pwm_value As Integer '
Dim Speed As Integer , Speed_half As Integer , First_symbol As Integer , Second_symbol As Integer
Dim A As Integer ' Speed Speed_half
Dim R1 As Word
Declare Sub Digit_indication(digit As Integer) '

Const P = 500
Const T = 5000 '
Const T1 = 1000 ' PWM
Pwm_value = 5
Tcnt0 = 0 '

Do
Incr I
If I = 25 Then '
R1 = Getadc(7)
R1 = Sqr(r1) '
R1 = R1 * 8
If R1 < 250 Then
Pwm_value = 250 - R1
Else
Pwm_value = 3 '
End If
I = 0
End If
Gosub Indication
Loop

Indication:
If Speed < 3 Then ' 0 - , 3 -
Pwm_value = 0
End If
While Speed > 99 '.. 2
Speed = Speed - 100
Wend
First_symbol = Speed / 10 '
Second_symbol = First_symbol * 10 '
Second_symbol = Speed - Second_symbol '
Pwm1b = 0
Pwm1a = 0
Waitus T1 '
Call Digit_indication(first_symbol) '
Pwm1b = Pwm_value
Waitus T
Pwm1b = 0
Pwm1a = 0
Waitus T1 '
Call Digit_indication(second_symbol)
Pwm1a = Pwm_value
Waitus T
Return

Sub Digit_indication(digit As Integer)
Select Case Digit
Case 0:
Portd.0 = 0
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
Portc.5 = 1
Case 1:
Portd.0 = 0
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
Portc.4 = 0
Portc.5 = 1
Case 2:
Portd.0 = 1
Portc.0 = 0
Portc.1 = 1
Portc.2 = 1
Portc.3 = 0
Portc.4 = 1
Portc.5 = 1
Case 3:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 0
Portc.3 = 0
Portc.4 = 1
Portc.5 = 1
Case 4:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 1
Portc.4 = 0
Portc.5 = 1
Case 5:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 0
Portc.3 = 1
Portc.4 = 1
Portc.5 = 0
Case 6:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
Portc.5 = 0
Case 7:
Portd.0 = 0
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 0
Portc.4 = 1
Portc.5 = 1
Case 8:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
Portc.5 = 1
Case 9:
Portd.0 = 1
Portc.0 = 1
Portc.1 = 1
Portc.2 = 0
Portc.3 = 1
Portc.4 = 1
Portc.5 = 1
End Select
End Sub

Mytimer2:
Incr N
If N = 26 Then
N = 0
Speed = Tcnt0 'Speed =
Tcnt0 = 0 '
End If
If N = 13 Then '.. ( )
Speed_half = Tcnt0 * 2 '
A = Speed - Speed_half
A = A And &B0111111111111111 '
If A > 2 Then
Speed = Speed_half
End If
End If
Timer2 = 135 ' 135
Return


在135的末尾-一个校正因子,为每台机器分别选择它(135用于Logan,对于Solaris则更小-每个人都有不同的速度传感器)。
承诺的视频。抱歉,我用一只手拍了张蓝色的电气胶带,而我滑行了另一只:



, 3 /. 99, .

:
ATMega8 — 200 5 — 40
— 825 10 — 165
TD62783 — 250 5 — 50
, , 500 .

. . . , . OBD2 ELM327.
.
!

Source: https://habr.com/ru/post/zh-CN393529/


All Articles