直接买个这种云台
这个帖子主要是更控制,软件相关的内容,每一次重大进展单独一层。
进度更新1:
2019年4月19日10时50分许,远程控制LED灯的测试取得圆满成功,特发帖纪念。——题记
如果在荒郊野岭里建了一个天文台,又不能远程控制,那对于爱好者而言基本就是废物。所以,自SORT项目上马以来,远程控制就确定为一定要突破的技术。但是,我们管着写代码(也是唯一一个懂网络)的程序员小哥哥@FanceStudio被生物地理中考这只可怕的魔鬼抓走了,而我的编程水平撑死也就写一个HelloWorld,所以,我选用了曲线救国的方案——
使用“向日葵远程控制”控制一台计算机,由这台计算机再发出指令控制设备。
所以就有三部分工作需要完成:搞明白远程控制软件咋用,写一个控制设备的上位机,写arduino的程序。
远程控制软件直接从网上下载就可以了,在座的各位都是牛人,我就不介绍了。
这次制作的目标仅仅是控制arduino板载的LED的亮灭,所以程序的思路很简单,收到‘1’点亮,收到0‘熄灭’。其程序代码为:
<code class="hljs cpp"><span style="background-color:rgb(245, 245, 245); color:rgb(51, 51, 51); font-family:monospace, monospace; font-size:1em;"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword">void</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"> </span></span></span></span></span></span></span></span></span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">setup</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">()</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"> </span></span></span></span></span></span></span></span></span></span>{</span></code><code class="hljs cpp"> <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">// put your setup code here, to run once:</span></span></span></span></span></span></span></span></span></span></span> pinMode(<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">13</span></span></span></span></span></span></span></span></span></span></span>,OUTPUT); Serial.begin(<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">9600</span></span></span></span></span></span></span></span></span></span></span>); } <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">char</span></span></span></span></span></span></span></span></span></span></span> num; <span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-keyword">void</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"> </span></span></span></span></span></span></span></span></span></span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">()</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"><span class="hljs-function"> </span></span></span></span></span></span></span></span></span></span></span>{ <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">// put your main code here, to run repeatedly:</span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span>(Serial.available()><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span>)num=Serial.read(); <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//Serial.print(num);</span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span>(num==<span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string">'1'</span></span></span></span></span></span></span></span></span></span></span>) digitalWrite(<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">13</span></span></span></span></span></span></span></span></span></span></span>,HIGH); <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span>(num==<span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string">'0'</span></span></span></span></span></span></span></span></span></span></span>) digitalWrite(<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">13</span></span></span></span></span></span></span></span></span></span></span>,LOW); }</code>
写完之后传进去就可以了。
然后是用VB写上位机。首先要做一些简单的设置:工程-部件-控件-选择Comm……那一个,把他勾上,就要用这个控件实现串口通信。
拖进两个按钮来,再拖进一个串口控件来。一定要把串口控件的CommPort设置成Arduino所在的端口号,我这个是照着Com7设的,对应我电脑的左上USB口。然后说一下程序的大概思路:启动时开启串口,按左边的按钮发送1,按右边的按钮发送0,大家一看就能看明白。下面是源代码。
<code class="hljs vbnet"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Private</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span> Command1_Click() MSComm1.Output = <span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string">"1"</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">End</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Private</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span> Command2_Click() MSComm1.Output = <span class="hljs-string"><span class="hljs-string"><span class="hljs-string"><span class="hljs-string">"0"</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">End</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Private</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span> Form_Load() MSComm1.PortOpen = <span class="hljs-literal"><span class="hljs-literal"><span class="hljs-literal"><span class="hljs-literal">True</span></span></span></span> <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">'打开串口</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">End</span></span></span></span> <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">Sub</span></span></span></span></code>
连接好arduino,启动远程控制,远程操作上位机软件,就可以控制小灯的亮灭。如此,即使我们在十万八千里外,远隔重洋,也能控制家里(天文台里)的一盏小灯的亮灭了。
@2019_0419_105059.wmv
emmmm因吹斯听
[修改于 5年7个月前 - 2019/05/03 21:13:56]
进度更新2:在原程序的基础上加了一个文本框,一个按钮,可以在程序运行阶段改端口了。并且实现了对小灯状态的检测
代码:
<code class="hljs vbscript"><p>Private Sub Command1_Click() <br>MSComm1.Output = "1" <br>End Sub <br> <br>Private Sub Command2_Click() <br>MSComm1.Output = "0" <br>End Sub <br> <br>Private Sub Command3_Click() <br>MSComm1.CommPort = Text1.Text <br>If MSComm1.PortOpen = False Then <br>MSComm1.PortOpen = True '打开串口 <br>End If <br>End Sub <br> <br>Private Sub MSComm1_OnComm() <br>Dim num As Integer <br>num = 0 <br>num = CInt(MSComm1.Input) <br>Form1.Caption = num <br>If num = 1 Then <br>Command1.BackColor = RGB(0, 255, 0) <br>Command2.BackColor = RGB(255, 255, 255) <br>Else <br>Command1.BackColor = RGB(255, 255, 255) <br>Command2.BackColor = RGB(255, 0, 0) <br>End If <br>End Sub <br></p></code>
我感觉花生壳的东西稳定性欠佳,路由器绑了花生壳普通专业版的穿透,还没免费的ngrok来的稳定,up能力可以的话,可以买个便宜服务器开ngrok
我感觉花生壳的东西稳定性欠佳,路由器绑了花生壳普通专业版的穿透,还没免费的ngrok来的稳定,up能...
先这么搞着吧,其实在调试中已经出现过死机了,如果出现在正式的观测任务甚至发射跟踪中那么不可设想。
@信仰は儚き人間の為に 其实不是荒郊野岭,在一个小村子里,架设点附近500米左右有一家全羊店,有WiFi,我单独架一口反射面接受WiFi信号。
直接买个上海合宙的4G dtu,用中国移动或者阿里云的mqtt服务器进行转发,成本200元,稳定性超高,工业级物联网监控就是用这种方案的.
不用拉通信线,有手机信号的地方就可以.
手机卡用中国移动的物联网流量卡一个月100m一年30元
动态域名稳定性极低,正规项目没有用的,阿里云mqtt服务器有免费额度一个月100w条,应该够你用的了
如果为了省钱就自己买GPRS的模块画板,成本全套最多70块,.....
现在GPRS模块中国移动/合宙的也就16块
对望远镜的话可以用串口摄像头.....真正拍照可以用单反改制的专用拍照设备......
经过今天下午与@怪咖0121,@FanceStudio的探讨,还是老老实实找个高可靠性的远程联机吧……我们的程序员小哥哥也办不了啊
这个想法很不错,不过中学生时间确实比较紧张啊,如果要远程控制的话比较推荐贝壳物联,一些控制方面的做的挺不错的,话说需要控制什么呢,只是主动打开开始测量的话比较简易,想要有数据反馈就很麻烦了
重大进展,首次实现家中-邢家东庄村观测站的远程控制,明后天有时间具体汇报到这一层楼中
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |
200字以内,仅用于支线交流,主线讨论请采用回复功能。