{"id":1728,"date":"2021-02-18T19:56:36","date_gmt":"2021-02-18T19:56:36","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1728"},"modified":"2021-02-18T19:56:37","modified_gmt":"2021-02-18T19:56:37","slug":"my-first-lego-dmx-fixture","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2021\/my-first-lego-dmx-fixture","title":{"rendered":"My first LEGO DMX fixture"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 3 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>probably also first LEGO DMX fixture ever in the multiverse \ud83d\ude42<\/p>\n\n\n\n<p>So my <a href=\"https:\/\/www.cameolight.com\/en\/solutions\/dj-musicians\/lighting-control\/dmx-controllers\/2086\/control-6\">Cameo Control 6<\/a> DMX controller is not probably full DMX compliant &#8211; I can only read 6 channels and even so only when cutting one of the data wires off. But who cares? (I do, but this month&#8217;s budget is already exceeded so I will only get a more decent DMX controller for Easter).<\/p>\n\n\n\n<p>But using PyFtdi on EV3 works:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip3 install ftdi<\/pre>\n\n\n\n<p>I could not confirm my FTDI url  with &#8216;ftdi_urls.py&#8217; like I did on my laptop but used same url (&#8216;ftdi:\/\/ftdi:232:FT4NMHF6\/1&#8217;) and it worked:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"LEGO MINDSTORMS DMX Fixture\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/zdJG_xdE8hY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env python3\n\nfrom ev3dev2.motor import MediumMotor, LargeMotor, DcMotor, OUTPUT_A, OUTPUT_B, OUTPUT_C,  SpeedPercent\nfrom ev3dev2.port import LegoPort\nfrom time import sleep\n\nlights_port = LegoPort(OUTPUT_C)\nlights_port.mode = 'dc-motor'\n\nsleep(1.5)\n\nimport pyftdi.serialext\nport = pyftdi.serialext.serial_for_url('ftdi:\/\/ftdi:232:FT4NMHF6\/1', baudrate=250000)\nport.timeout=0\n\nport.reset_input_buffer()\nport.read(8)\n\nchannels = &#91;0]*6\n\npan = MediumMotor(OUTPUT_A)\npan.position = 0\npan.speed_sp = 90\n\ntilt = LargeMotor(OUTPUT_B)\ntilt.position = 0\ntilt.speed_sp = 90\n\nlights = DcMotor(OUTPUT_C)\nlights.run_direct()\nlights.duty_cycle_sp = 0\n\nwhile True:\n    port.reset_input_buffer()\n    dmx_data = port.read(8)\n    sleep(0.01)\n    port.reset_input_buffer()\n    port.read(8)\n\n    print(dmx_data)\n    i = 0\n    error = False\n    for b in dmx_data:\n    #    print(b)\n        if i == 0 or i == 1:\n            if b != 0:\n                error = True\n        else:\n            channels&#91;i-2] = b\n        i = i + 1\n    if error:\n        print(\"Error!\")\n    else:\n#        print(\"Channels:\", channels)\n        pan.on_to_position(SpeedPercent(25), channels&#91;0] * 90\/255 - 45)\n        tilt.on_to_position(SpeedPercent(25), 45 - channels&#91;1] * 90\/255)\n        lights.duty_cycle_sp = channels&#91;2] * (100\/255)\n\n\n<\/code><\/pre>\n\n\n\n<p>Now it&#8217;s time to plan a few DMX fixtures: a bubble machine, a fog machine, a spark machine, a confetti cannon, a flamethrower&#8230; \ud83d\ude00<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 3  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>probably also first LEGO DMX fixture ever in the multiverse \ud83d\ude42 So my Cameo Control 6 DMX controller is not probably full DMX compliant &#8211; I can only read 6 channels and even so only when cutting one of the data wires off. But who cares? (I do, but this month&#8217;s budget is already exceeded &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2021\/my-first-lego-dmx-fixture\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;My first LEGO DMX fixture&#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-1728","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-rS","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1728","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=1728"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1728\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1728"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}