-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.json
1 lines (1 loc) · 17.5 KB
/
index.json
1
[{"categories":null,"contents":"CyberMatrix|赛博阵列是一个赛博朋克风格的桌面摆件,硬件采用嘉立创EDA设计,软件在platformIO上编写。代码开源在github上。\n功能 用ESP32为控制器。驱动5个7x11的方形点阵,背部有5个WS2812作为背光。板载加速度计和温度传感器。\n时间显示 5个点阵可以显示当前的小时和分钟。并且由于ESP32自带WiFi,所以可以连接到NTP服务器进行授时,省去了DS3231之类的实时时钟芯片。 不过这里有个字体的问题,因为为了能容易的实现print之类的方法,使用了Adafruit_GFX的库。这样可以把点阵当做一个屏幕来控制,但是因为像素非常的少,所以一定要精确控制字体中每个像素的亮灭。这样就需要自定义一个专用的字体。\n点阵过渡效果 为了让点阵有过渡的效果,我写了一个库。实现了在两个画面切换时,随机找到需要改变的一个像素进行切换。并且在不同的像素间加入很小的延迟,实现效果类似以前那种反应比较慢的电子产品的效果。\n背景灯光 背面有5个WS2812留在了PCB开孔和开槽的附近,当有反光的外壳背板时(暂时还没做)可以从背面透出灯光,实现一些待机和敲击唤醒的灯效。 这里为了呼吸灯效更自然一些,我用了电机控制里面常用的一个Sigmoid曲线。可以在启动和停止时更平滑一些。\n温度和加速度传感器 因为觉得只有时间的显示有点单调,为了增加一些交互,我在板子上做了一个温度传感器和加速度计,用加速度计可以识别到附近是否有桌面的敲击,并且双击时切换屏幕显示内容为当前温度。\n这里有个尴尬的地方是画PCB的时候我尽量的原理了ESP32和可能发热的器件,但是没想到和正面的TM1640距离过近了,导致现在测量的温度比环境温度高了一些。。。下次改版的时候再说吧\n识别敲击的实现是在上电的时候连续采样求平均得到一个基准的XYZ,然后读取实时的XYZ,看和基准值的差别。差别大于阈值时认为有敲击,这里有个去抖的问题,用类似按键的去抖逻辑写了一个状态机来识别双击和去抖。效果大概就没问题了。\n开源代码 代码可以在这里找到,如果喜欢的话可以STAR一下。\n原理图 实拍图 ","permalink":"https://swortain.wang/project/cybermatrix/","tags":["开源","自造","电子电路","Arduino"],"title":"CyberMatrix|赛博阵列"},{"categories":null,"contents":"其实很久以前就接触过TouchDesigner这个软件,但是当时对这种连线式的编程方式还是比较抗拒,所以只是大概了解了一下就没有继续看了。但是最近有一个项目用到了kinect azure,然后TD对这个东西的支持比较好,所以就用TD做了一次项目。发现和原来用processing写程序的感受还是挺不一样的。最近周围的人越来越多开始用td做项目。所以想开始写一些td的入门教程和防止自己后面会忘记,也给想要学td的人一些帮助。因为td的中文资源还不是很多,我学的时候主要还是只能看官方的wiki,辅助一些YouTube上面英文的视频教程。\n我还是用平常的方式来介绍,主要是解释几个概念,我的理解是搞懂了这些概念就可以知道题题是怎么样运行的。\nOP 首先这种连线式的编程方式基本都是由一个一个的块链接而来的,在td中这些块被称为op。OP主要有下面这几种 COMP、TOP、CHOP、SOP、MAT、DAT、Custom。\n其中TOP是对一个画面进行处理的,比如生成一个纯色的图片,或者一个渐变的图片,或者对几个输入的图片进行选择或者叠加什么的。\nCHOP会包含一个或者多个的数据,每个数据又可能有多个sample,可以理解为一个变量,可以存储很多数据每个数据可以是一个数也可以是一个数据包含很多个数,每一个数据被称为channel,数据如果由多个数组成,那么每个数被称为sample。不同的CHOP可以对输入或者自己产生的数据进行变化,比如constan CHOP会生成一个常亮,LFO CHOP会生成一个周期变化的数据等等。\nSOP会生成一个三维的模型或者对一个三维的模型进行变化\nMAT是材质的OP\nDAT有两种,一种是包含数据的,比如一个txt文本,或者一个table的表格。还有一种是作为一个脚本可以运行,因为TD是支持python脚本,所以可以在DAT里面写python的脚本来运行,不同的DAT可以在不同的情况下执行,比如CHOP execute可以在chop里面的数据发声变化时被调用\nCOMP可以理解为其他种类的OP。这个有点复杂估计要单独说。\n每个OP都会有参数可以调节,通常界面的右上角会有,如果没有的话可以按下p这个按键调出。\n数据流和引用 因为每一个op都只能实现特定的一些简单功能,所以一个程序通常来说是由很多op连接而成的。所以每一个op会有或者没有一个或者多个输入或者输出,取决于他的功能。OP之间的连接会有两种方式:第一种是由一个op的输出连接到另外一个op的输入;另外一种方式是一个op的参数引用,另外一个op。\n比如这个程序里面我先用一个constant CHOP来生成一个Channel的数据交值是0.3。然后用一个math CHOP把这个数据乘以二,让它变成0.6。然后用一个constant top,让他参数中的颜色的r通道引用math生成的这个数据。我们我们就会得到一个r的值为0.6的颜色。可以看到如果是用第一种的数据流方式的话,在touchdesigner里面会用一条实线来表示。线条的颜色是和数据流的种类有关的,比如如果是chop的话,那它就是绿色,和op的颜色是相同的。如果是参数引用的话,会用一条白色的虚线来表示。\npython 因为touchdesigner是支持python的,所以几乎所有参数的地方都可以是python的表达式,比如constant top的引用方式。\n看到这里,你应该去试着理解和记住一些常见的OP了。可以去看TD中文社区这个网站的初级教程,或者官方的wiki。 https://docs.derivative.ca/TOP https://docs.derivative.ca/CHOP https://docs.derivative.ca/SOP https://docs.derivative.ca/DAT 这些页面里每个都有一个sweet 16 xxxs下面列出了常用的16个这个种类的op\n脚本的运行 在TD里面是可以运行Python的脚本的。通常来说这样的脚本是放在不同的dat op里来执行的。而不同的dat op有不同的触发条件。 比如CHOP execute是当关联的CHOP里面的数据发生变化时被调用的,DAT execute则是当关联的DAT发生变化时被执行。execute可以在程序启动,或者退出,或者每一帧开始的时候运行特定程序\n搭建三维场景 TD中有一些固定模式,比如搭建三维场景就是其中最常用的一个。一个三维场景要有几个op来共同执行。 这里面geometry是一个场景,双击进去可以在里面放各种形状SOP,然后把每个SOP的render开关打开,这个SOP就可以被看到了,然后用一个cam去确定摄像机的位置和视角等,然后用一个light去照亮,最后用一个render TOP来渲染这个画面。 其中geo的参数是比较多的,他有一个instance的功能,是可以把里面SOP进行阵列,可以通过CHOP或者dat把每一个样本的信息给到,并且还可以在material里面给定这些sop的材质。\n参数设置 每个参数都有四种状态,第一种是常数,第二种是一个表达式,第三种是它可以输出给另外一个地方,第四种是可以和另外一个参数进行绑定。它使用的是Python inline的语法,类似这样:\nxxx if yyy else zzz #OP之间的转换 其实TOP的画面也是由一个个像素组成的,所以其实可以把一个TOP里的每一个像素都变成一个channel,然后组成一个CHOP。同理,也可以用一个这样呢的CHOP转成TOP。类似的道理,SOP和CHOP,DAT和CHOP都是可以互相转换的,用类似TOP to这样的OP就可以\n常用的几个OP 这个里面我想介绍几个我自己很常用的TD的结构,因为TD是图形化的连线式编程方式,所以其实一些OP之间的特定连接方式组成的特定结构其实就是代码里里面的算法,我们这里还是称为结构吧,更直观一些\nFeedback feedback是TD里面比较独特又很常用的一种结构,主要是用来实现拖尾和运动模糊的一些相关效果。 Geometry + Light + Camera + Render 这个主要是用来搭建三维场景和渲染的,Geometry里面可以放各种SOP(记得要打开每个SOP的render开关)。 Camera用来指定相机的位置,Light打光,然后render把他们组合的画面显示出来变成一个TOP的画面。从而可以实现实时的3维场景效果。并且还可以指定材质,实现类似unity里的一些效果 Instance 不过TD的Geometry的功能实在是比较简陋,所以我用的最多的还是他的instance功能,Geometry的这个开关打开后,会吧他里面的东西变成很多份,每一份的参数可以由Default Instance OP来指定。 这里的Default Instance OP可以是一个tale DAT,里面比如有tx、ty、tz这些,也可以是一个CHOP,里面的不同channel指定xyz坐标,甚至还可以是一个TOP。会把里面的每个像素的RGB映射到不同的地方,比如可以实现类似这样的一个效果 这个的教程可以看这里的第40讲:平面图像的立体化视觉处理\n恩。。。那么这个系列大概就到这里了,这几篇文章主要是给没接触过TD的人快速入门的,更复杂的效果可以多看看YouTube上的教程,现在TD用的人还不是很多,教程相对没那么丰富,但是同样的,教程的质量也会比较高,因为越是小众的一般来说厉害的人的比例也会越高。。\n","permalink":"https://swortain.wang/blog/touchdesigner-intro/","tags":["完结","TouchDesigner"],"title":"TouchDesigner入门教程"},{"categories":null,"contents":" insar-socket是我的第一个产品类的作品,主要的功能是支持Modbus-TCP的插座,可以让你在装置项目中集成一个220的电器,而不需要你懂任何的电子电路知识。 我还写了一写装置软件的库(目前位置仅支持了TouchDesigner)。这样你甚至不需要了解Modbus的相关知识,只需要配网,和软件内部的一些设置即可。\n参数 功率:额定功率2000w,长期负载建议不找过1500w。\n电压:由于接口采用国标规范,所以无法在国外使用,但是设计上采用100~240V,支持全球通用。\nPCB效果图 使用教程 配网 设备第一次链接WiFi时需要进行配网操作,让设备知道需要链接的WiFi的SSID和密码。这个操作如果不更换链接WiFi的名称和密码的情况下,只需要做一次,后面设备每次开机会自动连接最近一次设置的WiFi。\n先给设备供电,按钮处红色LED常亮,并且黄色LED缓慢闪烁,此时可以搜索到一个「insar_config_」开头的wifi热点。\n连接后会自动弹出一个页面(在iphone上通常会自动弹出)或者显示需登录/认证(在我的小米手机上是这样的)点击后弹出页面\n点击Configure WiFi\n点击要连接的WiFi名称,在密码行填入密码\n点击save后设备后自动重启后链接wifi。黄色LED闪烁几次后常亮,表示已经成功连上WiFi\nTouchDesigner库 首先电脑要和设备连入同一个wifi。打开insar-socket.toe这个文件,在insar_socket OP的参数里有一个search点击旁边的pulse会自动搜索局域网内所有的设备。\n搜索完成后会弹出一个窗口,点击ok后IP Address会列出所有局域网内所有的设备的IP地址。\n在左边连入一个CHOP,当里面任意一个channel从0变为非零的时候会打开插座,反之会关闭插座\n后台管理界面 在浏览器输入设备的IP地址,可以看到后台的管理界面,可以看到设备ID,固件版本,插座的通断以及可以控制插座的打开和关闭。\n基于其他平台实现二次开发 如果你只是想在已有库的软件(比如目前的Touchdesigner)里面使用本设备的话,这一部分是不需要看的,如果你需要集成到其他的环境中,比如单片机(需要设备能联网,比如使用ESP32、ESP8266或者Arduino UNO加Ethernet shield或者STM32加W5100这些)、openFrameworks、Processing(相关库在计划当中)、或者更底层的比如java、python,那么你需要看下面这部分,同时你需要懂一些TCP/IP通讯相关的知识以及Modbus相关的一些概念。\nModbus 通讯协议 设备是基于Mocbus-RTU TCP协议的,也就是说是基于二进制表示数据的方式,所以你需要知道一些指令的含义,关于Modbus-RTU的一些知识可以看我在简书的这里写一些简单的介绍。设备是作为TCP主机的,所以你需要用TCP客户端去连接\nModbus RTU是一种紧凑的,采用二进制表示数据的方式,Modbus ASCII是一种人类可读的,冗长的表示方式。\n维基百科 参数 从机地址:01 端口号:29779(这里不是默认的Modbus TCP端口,是为了方式搜索设备的时候搜索到网络中其他的Modbus设备) 继电器对应的线圈编号:100 校验:modbus标准的CRC16校验 控制例程 以下数字均为十六进制\n控制线圈 事务处理标识符 协议标识符 长度 从机地址 功能码 线圈编号 数据 CRC校验码 00 00 00 00 00 08 01 05 00 64 FF\u0026rsquo; 00 CD E5 数据位如果要打开继电器应为FF 00,如果关闭则是00 00\n返回数据与发送的是完全相同的\n查询线圈状态 发送 事务处理标识符 协议标识符 长度 从机地址 功能码 线圈编号 数据 CRC校验码 00 00 00 00 00 08 01 01 00 64 00 01 BC 15 其中事务处理标识符理论上可以是任意数字\n协议标识符Modbus都是00 00\n线圈编号开始线圈的编号,是100的十六进制,小端模式\n数据00 01表示读取一个线圈\n注意因为设备内只定义了100号线圈,所以查询其他编号比如99开头的两个线圈或者100开头的2个线圈都会返回错误信息。\n返回 事务处理标识符 协议标识符 长度 从机地址 功能码 后面bytes的数量 状态值 00 00 00 00 00 04 01 01 01 01 状态值当继电器打开时是01,关闭时是00\nCRC16校验示例代码(Python) 1 2 3 4 5 6 7 8 9 10 11 def crc16(data): crc = 0xFFFF for pos in data: crc ^= pos for i in range(8): if ((crc \u0026amp; 1) != 0): crc \u0026gt;\u0026gt;= 1 crc ^= 0xA001 else: crc \u0026gt;\u0026gt;= 1 return crc.to_bytes(2,byteorder=\u0026#39;little\u0026#39;,signed=False) 硬件的二次开发 设备出厂预制程序,如果只需要使用的话这一部分是不需要看的,如果想基于现有硬件二次开发,那么你需要了解ESP32的相关知识。\n设备是由ESP32开发的,预留了烧写接口如下图,排针是不焊接的,可以使用间距2.54mm的顶针烧写,或者焊接普通2.54mm间距的排针。内部预留了空间保证焊接后也可以装上外壳,\n烧写接口引脚定义 1 2 3 4 5 6 GND IO0 RST RXD TXD 3.3V 烧写过程 因为设备供电的时候PCB上是有220v强电的,所以建议用烧写器给设备供电3.3v,如果烧写器有ESP32的自动复位电路的话需要链接2、3号引脚,否则只需连接其他四个引脚,但是在上电前需要短接2号和GND引脚使设备进入烧写模式。\n引脚定义 设备内有两个LED,红色是电源LED无法控制,黄色连接了IO21,可以控制。继电器连接是的IO12引脚\n","permalink":"https://swortain.wang/project/insar-socket/","tags":["TouchDesigner","电子电路","商业项目"],"title":"insar-socket | 装置插座"},{"categories":null,"contents":"这是第一篇文章,不出意外的话这里主要是记录一些经过整理的文章(如果有的话。。。),主要的碎片文章还是会更新到简书上。 个人网站主要还是为了展示做过的项目,和作为个人项目经历的目的。\n","permalink":"https://swortain.wang/blog/first/","tags":["完结"],"title":"第一篇文章"},{"categories":null,"contents":"","permalink":"https://swortain.wang/pasted-image-20230323231004.png/","tags":null,"title":""},{"categories":null,"contents":"","permalink":"https://swortain.wang/pasted/","tags":null,"title":""},{"categories":null,"contents":"This file exists solely to respond to /search URL with the related search layout template.\nNo content shown here is rendered, all content is based in the template layouts/page/search.html\nSetting a very low sitemap priority will tell search engines this is not important content.\nThis implementation uses Fusejs, jquery and mark.js\nInitial setup Search depends on additional output content type of JSON in config.toml ``` [outputs] home = [\u0026ldquo;HTML\u0026rdquo;, \u0026ldquo;JSON\u0026rdquo;] ```\nSearching additional fileds To search additional fields defined in front matter, you must add it in 2 places.\nEdit layouts/_default/index.JSON This exposes the values in /index.json i.e. add category ``` \u0026hellip; \u0026ldquo;contents\u0026rdquo;:{{ .Content | plainify | jsonify }} {{ if .Params.tags }}, \u0026ldquo;tags\u0026rdquo;:{{ .Params.tags | jsonify }}{{end}}, \u0026ldquo;categories\u0026rdquo; : {{ .Params.categories | jsonify }}, \u0026hellip; ```\nEdit fuse.js options to Search static/js/search.js ``` keys: [ \u0026ldquo;title\u0026rdquo;, \u0026ldquo;contents\u0026rdquo;, \u0026ldquo;tags\u0026rdquo;, \u0026ldquo;categories\u0026rdquo; ] ```\n","permalink":"https://swortain.wang/search/","tags":null,"title":"Search Results"}]