永发信息网

bh1750的输入输出关系

答案:4  悬赏:70  手机版
解决时间 2021-04-08 00:52
bh1750的输入输出关系
最佳答案
环境光传感器
【性能 参数】
  BH1750环境光传感器内置16位的模数转换器,它能够直接输出一个数字信号,不需要再做复杂的计算。这是一种更精良的和容易使用简易电阻器的版本,通过计算电压,来获得有效的数据。这款环境光传感器能够直接通过光度计来测量。光强度的单位是流明"lx"。当物体在均匀的光照下它能够在每平方米获得1lx的。

BH1750环境光传感器内置16位的模数转换器,它能够直接输出一个数字信号,不需要再做复杂的计算。这是一种更精良的和容易使用简易电阻器的版本,通过计算电压,来获得有效的数据。这款环境光传感器能够直接通过光度计来测量。光强度的单位是流明"lx"。当物体在均匀的光照下它能够在每平方米获得1lx的光通量,它们的光强度是1lx。有时为了充分利用光源,你可以增加一个光源的反射装置。那样在某些方向就能获得更多的光通量,以增加被照表面的亮度。
技术规格:
供电电压:+3-5V
接口:I2C
量程和精度:1~65535 lx
可以选择I2C地址的两种形式
微小的测量变化(+/-20%)
尺寸:0.85x0.63x0.13"(21x16x3.3mm)
光亮度数据参考:
晚上: 0.001-0.02;
月夜: 0.02-0.3;
多云室内: 5-50;
多云室外: 50-500;
晴天室内: 100-1000;
夏天中午光照下: 大约10*6能量;
阅读书籍时的照明度: 50-60;
家庭录像标准照明度:1400
全部回答
不懂
程序如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity adc is
Port ( adc_out : out STD_LOGIC_vector(15 downto 0);
SCL : out STD_LOGIC;
SDA : inout STD_LOGIC;
clk50MHz : in STD_LOGIC;
adc_en : in STD_LOGIC);
end adc;
architecture Behavioral of adc is
constant slaveaddress : std_logic_vector(7 downto 0):=x"46"; ------------write address-----------------
constant slaveaddress2 :std_logic_vector(7 downto 0) := x"47"; ---------read address---------------
constant h_resolution_mode :std_logic_vector(7 downto 0) := x"10";
constant poweron : std_logic_vector(7 downto 0) := x"01";
signal delay5us : std_logic_vector(7 downto 0);
type state is (step1,step2,step3,step4,step5,step6,step7,step8,step9,step10,step11,step12,step13,step14,
step15,step16,step17,step18,step19,step20,step21,step22,step23,step24,step25,step26,step27,step28,step29,step30,
step31,step32,step33,step34,step35,step36,step37,step38,step39,step40,step42,step43,step44,step45,step46,step47,
stepplu1,stepplu2,stepplu3,stepplu4,stepplua1,stepplua2,stepplua3,stepplua4,stepplub1,stepplub2,stepplub3,stepplub4,
steppluc1,steppluc2,steppluc3,steppluc4,stepplud1,stepplud2,stepplud3,stepplud4);
type state_send is(a1,a2,a3,a4);
signal state2 : state_send ;
signal state1 : state;
signal counter : integer range 0 to 7;
signal delay180ms : std_logic_vector(23 downto 0);
type state_receive is (b1,b2,b3,b4,b5);
signal state3 :state_receive ;
signal counter2 : integer range 8 to 15;
signal temp : std_logic_vector(15 downto 0);
signal delay5ms :std_logic_vector(7 downto 0);
signal counter3 :integer range 0 to 7;
begin
process(clk50MHz,adc_en)
begin
if adc_en='1' then
if clk50MHz' event and clk50MHz='1' then
case state1 is
when step1 => ---------start-------------
SDA<='1';
SCL<='1';
state1<=step2;
when step2 => -----------delay-----------------
if delay5us=x"FA" then
state1<=step3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;------------------------------------------
when step3 =>
SDA<= '0';
state1 <=step4;
when step4 =>
if delay5us=x"FA" then
state1<=step5;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step5 =>
SCL<='0';
state1<=step6; -----------over--------------------
when step6 => ----------send slaveaddress+write signal-------
case state2 is
when a1 =>
SDA<=slaveaddress(counter);
SCL<='1';
state2<=a2;
when a2 =>
if delay5us=x"FA" then
state2<=a3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when a3 =>
SCL<='0';
state2<=a4;
when a4=>
if delay5us=x"FA" then
if counter = 0 then
state1<=stepplu1;
counter<=7;
state2<=a1;
delay5us<=x"00";
else
counter<=counter-1;
state2<=a1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; -----------over---------------------
when stepplu1=> -----------receive ACK--------------
SCL<='1';
state1<=stepplu2;
when stepplu2=>
if delay5us=x"FA" then
state1<=stepplu3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when stepplu3=>
SCL<='0';
state1<=stepplu4;
when stepplu4=>
if delay5us=x"FA" then
state1<=step7;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------over----------------------
when step7 => -------------send power on signal--------------
case state2 is
when a1 =>
SDA<=poweron(counter);
SCL<='1';
state2<=a2;
when a2 =>
if delay5us=x"FA" then
state2<=a3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when a3 =>
SCL<='0';
state2<=a4;
when a4=>
if delay5us=x"FA" then
if counter=0 then
state1<= stepplua1;
counter<=7;
state2<=a1;
delay5us<=x"00";
else
counter<=counter-1;
state2<=a1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; ------------------over--------------------
when stepplua1=> -----------receive ACK--------------
SCL<='1';
state1<=stepplua2;
when stepplua2=>
if delay5us=x"FA" then
state1<=stepplua3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when stepplua3=>
SCL<='0';
state1<=stepplua4;
when stepplua4=>
if delay5us=x"FA" then
state1<=step8;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------over----------------------
when step8 => ---------------stop----------------------
SDA<='0';
SCL<='1';
state1<=step9;
when step9 =>
if delay5us=x"FA" then
state1<=step10;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step10 =>
SDA<='1';
state1<=step11;
when step11 =>
if delay5us=x"FA" then
state1<=step12;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------------over------------------------
when step12 => -----------------start---------------------
SDA<='1';
SCL<='1';
state1<=step13;
when step13 =>
if delay5us=x"FA" then
state1<=step14;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step14 =>
SDA<= '0';
state1 <=step15;
when step15 =>
if delay5us=x"FA" then
state1<=step16;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step16 =>
SCL<='0';
state1<=step17; -------------------over---------------------
when step17 => ----------------send slaveaddress+write signal-------
case state2 is
when a1 =>
SDA<=slaveaddress(counter);
SCL<='1';
state2<=a2;
when a2 =>
if delay5us=x"FA" then
state2<=a3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when a3 =>
SCL<='0';
state2<=a4;
when a4=>
if delay5us=x"FA" then
if counter = 0 then
state1<= stepplub1;
counter<=7;
state2<=a1;
delay5us<=x"00";
else
counter<=counter-1;
state2<=a1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; -------------------------over---------------
when stepplub1=> -----------receive ACK--------------
SCL<='1';
state1<=stepplub2;
when stepplub2=>
if delay5us=x"FA" then
state1<=stepplub3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when stepplub3=>
SCL<='0';
state1<=stepplub4;
when stepplub4=>
if delay5us=x"FA" then
state1<=step18;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------over----------------------
when step18 => ----------send H- resolution mode signal-------
case state2 is
when a1 =>
SDA<=h_resolution_mode(counter);
SCL<='1';
state2<=a2;
when a2 =>
if delay5us=x"FA" then
state2<=a3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when a3 =>
SCL<='0';
state2<=a4;
when a4=>
if delay5us=x"FA" then
if counter=0 then
state1<= steppluc1;
counter<=7;
state2<=a1;
delay5us<=x"00";
else
counter<=counter-1;
state2<=a1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; -----------over-----------------
when steppluc1=> -----------receive ACK--------------
SCL<='1';
state1<=steppluc2;
when steppluc2=>
if delay5us=x"FA" then
state1<=steppluc3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when steppluc3=>
SCL<='0';
state1<=steppluc4;
when steppluc4=>
if delay5us=x"FA" then
state1<=step19;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------over----------------------
when step19 => -------------stop--------------
SDA<='0';
SCL<='1';
state1<=step20;
when step20 =>
if delay5us=x"FA" then
state1<=step21;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step21 =>
SDA<='1';
state1<=step22;
when step22 =>
if delay5us=x"FA" then
state1<=step23;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; ------------------over----------------
when step23 => -------------delay 180 ms ----------
if delay180ms=x"895440" then
state1<=step24;
delay180ms<=x"000000";
else
delay180ms<=delay180ms+1;
end if; ------------over-----------------
when step24 => ---------start-----------------------
SDA<='1';
SCL<='1';
state1<=step25;
when step25 =>
if delay5us=x"FA" then
state1<=step26;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step26 =>
SDA<= '0';
state1 <=step27;
when step27 =>
if delay5us=x"FA" then
state1<=step28;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step28 =>
SCL<='0';
state1<=step29; -----------over-----------------
when step29 => -----------send slaveaddress+read signal---------
case state2 is
when a1 =>
SDA<=slaveaddress2(counter);
SCL<='1';
state2<=a2;
when a2 =>
if delay5us=x"FA" then
state2<=a3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when a3 =>
SCL<='0';
state2<=a4;
when a4=>
if delay5us=x"FA" then
if counter=0 then
state1<= stepplud1;
counter<=7;
state2<=a1;
delay5us<=x"00";
else
counter<=counter-1;
state2<=a1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; ------------over-----------------
when stepplud1=> -----------receive ACK--------------
SCL<='1';
state1<=stepplud2;
when stepplud2=>
if delay5us=x"FA" then
state1<=stepplud3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when stepplud3=>
SCL<='0';
state1<=stepplud4;
when stepplud4=>
if delay5us=x"FA" then
state1<=step30;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------over----------------------
when step30 => ------------------receive h data------------------------
SDA<='1';
state1<=step31;
when step31 =>
case state3 is
when b1 =>
SCL<='1';
state3<=b2;
when b2 =>
if delay5us=x"FA" then
state3<=b3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when b3 =>
temp(counter2)<=SDA;
state3<=b4;
when b4 =>
SCL<='0';
state3<=b5;
when b5 =>
if delay5us=x"FA" then
if counter2=8 then
state1<=step42;
counter2<=15;
delay5us<=x"00";
state3<=b1;
else
state3<=b1;
counter2<=counter2-1;
delay5us<=x"00";
end if;
else
delay5us<=delay5us+1;
end if;
end case; ----------------over----------------
when step42 => ----------------Ack=0------------------------------
SDA<='0';
SCL<='1';
state1<=step43;
when step43 =>
if delay5us=x"FA" then
state1<=step44;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step44 =>
SCL<='0';
state1<=step45;
when step45 =>
if delay5us=x"FA" then
state1<=step46;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; ----------------over--------------
when step46 => -------------receive low data----------------
SDA<='1';
state1<=step47;
when step47 =>
case state3 is
when b1 =>
SCL<='1';
state3<=b2;
when b2 =>
if delay5us=x"FA" then
state3<=b3;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when b3 =>
temp(counter3)<=SDA;
state3<=b4;
when b4 =>
SCL<='0';
state3<=b5;
when b5 =>
if delay5us=x"FA" then
if counter3 = 0 then
state1<=step32;
counter3<=7;
delay5us<=x"00";
state3<=b1;
else
counter3<=counter3-1;
delay5us<=x"00";
state3<=b1;
end if;
else
delay5us<=delay5us+1;
end if;
end case; -----------------over-------------------
when step32 => -----------------ACK=1------------------
SDA<='1';
SCL<='1';
state1<=step33;
when step33 =>
if delay5us=x"FA" then
state1<=step34;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step34 =>
SCL<='0';
state1<=step35;
when step35 =>
if delay5us=x"FA" then
state1<=step36;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step36 => --------------stop--------------
SDA<='0';
SCL<='1';
state1<=step37;
when step37 =>
if delay5us=x"FA" then
state1<=step38;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if;
when step38 =>
SDA<='1';
state1<=step39;
when step39 =>
if delay5us=x"FA" then
state1<=step40;
delay5us<=x"00";
else
delay5us<=delay5us+1;
end if; -----------------over------------------
when step40 => ---------------delay 5 ms------------
if delay5ms=x"64" then
state1<=step1;
delay5ms<=x"00";
else
delay5ms<=delay5ms+1;
end if; --------------over-----------------
end case;
end if;
adc_out<=temp;
else
state1<=step1;
state2<=a1;
counter<=7;
delay180ms<=x"000000";
state3<=b1;
counter2<=15;
counter3<=7;
delay5ms<=x"00";
temp<=x"0000";
SDA<='1';
SCL<='1';
delay5us<=x"00";
adc_out<=X"0000";
end if;
end process;
end Behavioral;
BH1750是数字式串行输出的环境光照度传感器,输出直接就是检测到的数字量(以lx为单位),又不是模拟输出要有什么换算……所以你提的这个问题是没有意义的。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我非常喜欢一个女生我向她表白了但她说我不了
淘宝免费试用有什么要求?
发酵鸡床好不好呢
我是2015年买的社保月交890元15年后我一个月
新农庄酒店在什么地方啊,我要过去处理事情
开幼儿园除了不能用实验来当园名还有别的没
镀金纯银唐草芝宝打火机怎样区分k几
身高170女的是不是偏高
logx^10与10lgx是同一个函数吗
登陆和聚会出现接口异常2100是什么意思
书包两字田子本怎么写
我妈管她叫大婶我管她叫什么?
喜欢穿超高跟鞋的女人是很骚的吗
he carried the bed on to the roof of his h
亚马逊主题风情餐厅这个地址在什么地方,我要
推荐资讯
为什么中国非要与美日英法等国敌对,却不能像
指出康有为,梁启超和严复的维新思想侧重点在
今天我得到一个消息,就是阿姨怀上了第二个小
人死后要不要打开窗户
His camera is more expensive than .A. ours
利用平方差公式计算:20132-2012×2014.
朱自清的背影名句,朱自清的背影最出名的两句
8.53中的“5”在________位上,表示5个______
42与24的和乘以它们的差的积是多少?
我应该感谢母亲,她教给我与困难作斗争的经验
大峨村地址有知道的么?有点事想过去!
神舟笔记本和戴尔笔记本哪个好?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?