{"id":1726,"date":"2021-02-18T08:19:26","date_gmt":"2021-02-18T08:19:26","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1726"},"modified":"2021-02-18T08:19:45","modified_gmt":"2021-02-18T08:19:45","slug":"dmx-slave","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2021\/dmx-slave","title":{"rendered":"DMX slave?"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 2 of 6 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/lego-and-dmx\" class=\"series-363\" title=\"LEGO and DMX\">LEGO and DMX<\/a><\/div>\n<p>Controlling DMX fixtures with EV3 is cool but what I really want is creating my own LEGO  fixtures &#8211; like the bubble maker.<\/p>\n\n\n\n<p>The USB DMX adapter is great for generating DMX messages but I was in doubt if it could be also used to receive DMX messages since most DMX interfaces that allow TX\/RX make use of some kind of microcontroller to reduce overhead.<\/p>\n\n\n\n<p>Nevertheless I decided to give it a try. The cable uses a FTDI FT232R chip that is supported by <a href=\"https:\/\/eblot.github.io\/pyftdi\/index.html\">PyFtdi<\/a> for speeds up to 3 Mbps and the DMX &#8220;only&#8221; requires 250 kbps.<\/p>\n\n\n\n<p>First attempts on my laptop with the very cheap 6-channel controller I have look promising:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pyftdi.serialext<br>port = pyftdi.serialext.serial_for_url('ftdi:\/\/ftdi:232:FT4NMHF6\/1', baudrate=2500000)<br>port.timeout=0.002<br>port.reset_input_buffer()<br>port.read(8)<\/code><\/pre>\n\n\n\n<p>With channels 1, 3 and 5 at maximum and channels 2, 4 and 6 at minimum I get:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">b'\\x00\\x00\\xff\\x00\\xff\\x00\\xff\\x00'<\/pre>\n\n\n\n<p>and with the opposite (channels 1, 3 and 5 at minum and channels 2, 4 and 6 at maximum) I get:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">b'\\x00\\x00\\x00\\xff\\x00\\xff\\x00\\xff'<\/pre>\n\n\n\n<p>The second byte always being &#8216;\\x00&#8217; is expected &#8211; the first frame or Start Code is &#8216;0&#8217; for most common DMX usages.<\/p>\n\n\n\n<p>And the first byte is the practical result of &#8220;<a href=\"https:\/\/www.element14.com\/community\/groups\/open-source-hardware\/blog\/2017\/08\/24\/dmx-explained-dmx512-and-rs-485-protocol-detail-for-lighting-applications\" data-type=\"URL\" data-id=\"https:\/\/www.element14.com\/community\/groups\/open-source-hardware\/blog\/2017\/08\/24\/dmx-explained-dmx512-and-rs-485-protocol-detail-for-lighting-applications\">the start-of-packet procedure is a logic zero for more than 22 bit periods,followed by a logic 1 for more than 2 bit periods<\/a>&#8220;.<\/p>\n\n\n\n<p>Now the problem is that if I read more than 8 bytes I will get a the same results repeated &#8211; for instance if I read 514 bytes (start-of-packet + start code + 512 channels) with all 6 channels at maximum I will get:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">b'\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\xff\\xff\\xff\\xff\\xff\\xff'<\/pre>\n\n\n\n<p>So is it my cheap 6-channel controller really sending just 6 channel data instead of full 512 channel data (so 6 &#8216;FF&#8217; followed by 506 &#8217;00&#8217;) or am I doing something wrong when reading? Most probably the second option, of course.<\/p>\n\n\n\n<p>The timeout = 0.002 was just an attempt, I probably need to use 0.023 (514 frames at 250 kbps take 22.616 ms).<\/p>\n\n\n\n<p>And I also need a 3 pin XLR male to male adapter to assure connections are stable. But if this works I expect to have a DMX BUBBL3R before Easter.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 2  of 6 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/lego-and-dmx\" class=\"series-363\" title=\"LEGO and DMX\">LEGO and DMX<\/a><\/div><p>Controlling DMX fixtures with EV3 is cool but what I really want is creating my own LEGO fixtures &#8211; like the bubble maker. The USB DMX adapter is great for generating DMX messages but I was in doubt if it could be also used to receive DMX messages since most DMX interfaces that allow TX\/RX &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2021\/dmx-slave\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;DMX slave?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[],"series":[363],"class_list":["post-1726","post","type-post","status-publish","format-standard","hentry","category-sem-categoria","series-lego-and-dmx"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-rQ","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1726"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1726\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1726"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}