おもちゃ、家電、もろもろの修理の足跡と備忘録

色々と忘れるので、趣味のメモ

1Hz-50MHz周波数カウンタ

2020-02-09 15:30:14 | その他工作
2020年の正月休みに、ebayをさまよっていたら、安い周波数カウンタのキットを見つけたのでポチリ。いつもだと2週間ほどで到着するのだけれど、今回は最長1ヶ月かかるかも、とのお達し。
この日までには届くと思う、と言う日が過ぎ、連絡しようかな、と思ってた次の日に到着。今回の物は台湾からの出荷だったけれど、このご時世(肺炎騒ぎが大騒ぎになる前だったと思うけど)、届いただけ良かったと思います。

さて、この周波数カウンタのキット、なんと送料込みで387円。1ヶ月待っても、オーダしたのを忘れちゃっても大丈夫なくらいです。国内で部品を集めるとこの3倍から5倍位(プリント基板は当然無し)掛かりそうです。しかし、部品しか入っておらず、マニュアルも何も無し。プチプチに包んで国際メール便で到着。

とりあえず、部品はあることを確認して、シルクの通りハンダ付け。小一時間のお仕事でしたが、電源を入れても動かず、ドキッとしましたが、DC電源コネクタが不良なだけだったのでとりあえず動作確認のために、手持ちのXtalを計測。(このキットはXtalの周波数カウンタ、として作ってあります。)これも48MHzのXtalもきちんと動きましたので、50MHzは十分計測できそうです。

調べてみると、秋○電子で同じものを扱っており、日本語での丁寧なマニュアルがありました。もう少し調べてみると、このキットは、DL4YHF さんが作ったもののコピー品(正確には、Xtal計測部分をDL4YHFさんの回路に追加したもの)のようで、PICのプログラムもそこにありました。
Xtalの計測ではない、外部の信号の計測用の端子がありますが、PICに直接入っているようで、PICのHigh/Low検出電圧が必要なようなので、一般的な周波数カウンタとして使うときにはトランジスタで信号を増幅する必要がありそうです。
プリスケーラ(1/10で十分)とアンプを入れてお遊びツールとして準備したいと思います。

LEDランタンの修理(液漏れ)

2020-02-09 15:06:49 | 修理
会社の同僚からLEDランタンの修理の依頼。
主訴?としては「つかない」。
会社でばらしてみると、液漏れのようなので、持ち帰りで修理。

中を開けてみると、やはり液漏れで、制御基板?がやられていました。
基板自体は、レジストがやられていましたが、まだ電極は大丈夫そう。半田は腐食しているので、腐食している部分を清掃、磨いて基板とチップの端子を再度ハンダ付け。
あとは、本体とつながっている電線の交換(毛細管現象で、電解液が入り込んですぐにだめになります)、とタクトスイッチの中にも電解液が入り込んでこれは、修理できず交換。タクトスイッチは、たまたまほぼ同等なものがジャング箱の中にあったので外して取り付け。
また、表と裏の基板の配線をつなぐスルーホールがやられていて、表裏を電線でつないでハンダ付け。

とりあえず、これくらいまで修理して、本体に接続。無事動作しました。↓


お客様?には、長時間使わない場合は、電池は外して一緒に保管してくださいとお伝えしました。微小電流が流れ続けると、液漏れを起こしやすい、とのことです。内圧が高まって、たいていマイナス側に制御弁?があるので、そこから電解液が漏れるようです。この電池の電解液は結構強いので、まだ濡れている場合は手などにつけないようにご注意ください。

帰宅後の二時間ほどのお楽しみでした。
2020/2/5

%後日美味しいコーヒーを飲ませて頂きました。

ESP8266DEVkit, nodeMCU, LUAで温度と気圧をInternetで送る(software編5-souce)

2020-02-09 12:05:51 | ESP8266DEVkitで遊ぶ
Luaで書いた、NodeMCU用のsource codeです。
 あちこちの先人達の知恵を頂いて作りました。とりあえず動いておりますがソフトは素人なので、try and errorの結果のcodeです。deep sleepは使っていません。実際のpasswordやtest用のcodeを消して、commentを入れました。
 これを動かすハードウェアについては、前の記載の通りです。
プログラムをコピペするとindentなどが飛んでしまうので、見ずらいですが、ご参考までに。
2020/2/9

-----------------------------------------------------------
-- Send Baro and Temp with NodeMCU over wifi connection using mqtt
-- writen in lua language.
-- tomoharika 2020/2/9 last update..
-----------------------------------------------------------
-- Connection:
-- [mqtt_server]--(wifi)--[NodeMCU]--(i2c)--[bmp280]
--
-- It will send status and messages on your serial line.
-- If it meets some errors, NodeMCU will restart from
-- begining of the source again.
-- So you can find the status by checking the access LED
-- on your NodeMCU, many flushes will be occured error
-- somewhere. Check the serial messages.
-- It goes no error, the access LED flushes every
-- main_loop_interval.
-----------------------------------------------------------

-- initial setting..
alt=50

--for i2c
sda=2 ---D2, GPIO04
scl=1 ---D1, GPIO05
--for main measurement loop timer
main_loop_interval = 300 --[sec]

--set your mqtt server address
mqtt_server_address = "aa.bb.cc.dd"

--for access LED indicator
ledpin = 0 --for D4

--for wifi retry counter
error_count = 0
error_max = 4

--set wifi environment
station_cfg.ssid="set_your_wifi_ssid"
station_cfg.pwd="set_your_wifi_password"

-----------------------------------------------------------------------------
m = mqtt.Client(node.chipid(), 120) -- clientID, keepalive, username, password, cleansession, max_message_length)

m:lwt("/lwt", "offline", 0, 0)
m:on("connect", function(client) print ("connected") end)
m:on("offline", function(client) print ("offline")
print("Restart..")
node.restart()
end)
m:on("message", function(client, topic, data)
print(topic .. ":" )
if data ~= nil then
print(data)
end
end)

-- on publish overflow receive event
m:on("overflow", function(client, topic, data)
print(topic .. " partial overflowed message: " .. data )
end)

function mqtt_loop()
gpio.write(ledpin, gpio.LOW)
P = bme280.baro()
T = bme280.temp()
print(string.format("QFE=%d.%03d Temp=%d.%02d", P/1000, P%1000, T/100, T%100))
m:publish("room1/temp", T/100, 0, 0, function(client) print("sent") end)
m:publish("room1/baro", P/1000, 0, 0, function(client) print("sent") end)
gpio.write(ledpin, gpio.HIGH)
mqtt_timer:start()

end
-----------------------------------------------------------------------------
--when wifi connected..
wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
print("\n\tSTA - CONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
T.BSSID.."\n\tChannel: "..T.channel.."\n")
wifi_Up = 1
wifi_timer:start()
end)

--when wifi disconnected..
wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
print("\n\tSTA - DISCONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
T.BSSID.."\n\tReasone: "..T.reason.."\n")
wifi_Up = 0
wifi_wait_ip()
end)

--when get ip address over the wifi
function wifi_wait_ip()
if wifi.sta.getip()== nil then
print("IP unavailable, Waiting.", error_count)
if error_count > error_max then
print("Error_max exceeded. Wifi reconnecting.")
error_count = 0
wifi.sta.connect()
else
error_count = error_count + 1
end
wifi_timer:start()
else
wifi_timer:stop()
print("\n====================================")
print("ESP8266 mode is: " .. wifi.getmode())
print("MAC address is: " .. wifi.ap.getmac())
print("IP is "..wifi.sta.getip())
print("====================================")
error_count = 0

--after getting ip address over the wifi, then connecting to mqtt server
print("Connecting to Mqtt server with ".. mqtt_server_address )
m:connect( mqtt_server_address, 1883, 0, function(client)
print("Connected to Mqtt server @"..mqtt_server_address)
mqtt_loop()
end,
function(client, reason)
print("Mqtt failed. reason: " .. reason)
print("Restart..")
node.restart()
end)
end
end
--------------------------------------------------------------------------------
-- Start main routine here...
--------------------------------------------------------------------------------
print("### Start Measurement at every "..main_loop_interval.."[sec] ###")

-- for access indicater
gpio.mode(ledpin, gpio.OUTPUT)
gpio.write(ledpin, gpio.HIGH)

-- i2c initializing
print("i2c initializing.")
if i2c.setup(0,sda,scl,i2c.SLOW) == 0 then
print("i2c initializing error. Check i2c connection. Restart.")
node.restart()
end

-- bmp280 initializing
print("bme280 initializing.")
if bme280.setup() == nil then
print("BME/P280 initializing error. Restart.")
node.restart()
end

-- wifi initializing
print("Wifi initializing.")
wifi.setmode(wifi.STATION)
station_cfg={}
-- station_cfg.ssid="xxxxxx" -> set at top of this source program..
-- station_cfg.pwd="xxxxxx" -> set at top of this source program..
station_cfg.auto=false -- true for wifi auto connect mode
station_cfg.save=false
wifi.sta.config(station_cfg)
wifi.sta.connect()
print("Connecting to wifi.")

-- ip connection timer set
wifi_timer = tmr.create()
wifi_timer:register( 3*1000, tmr.ALARM_SEMI, wifi_wait_ip)

-- mqtt connection timer set
mqtt_timer = tmr.create()
mqtt_timer:register( main_loop_interval * 1000, tmr.ALARM_SEMI, mqtt_loop )

wifi_timer:start()
-- end of program lua..