{"id":1736,"date":"2021-02-24T23:01:03","date_gmt":"2021-02-24T23:01:03","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1736"},"modified":"2021-02-24T23:01:04","modified_gmt":"2021-02-24T23:01:04","slug":"lego-dmx-fire-machine","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2021\/lego-dmx-fire-machine","title":{"rendered":"LEGO DMX Fire Machine"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 6 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>Second LEGO DMX fixture: a Fire Machine \ud83d\ude42<br>Similar script on EV3, listening to DMX channel 1 and reacting to just two values:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>255 turns the BIC lighter ON<\/li><li>0 turns it OFF again<\/li><\/ul>\n\n\n\n<p>Working quite good with QLC+ as a DMX controller (at 9 Hz DMX frame rate) and other DMX fixtures on the loop (in this video a Fonestar PAR-18L set to DMX channel 2):<\/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 DMX Fire Machine Fixture\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/U6C1iknyegk?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>&#8216;DMXfire.py&#8217; script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/env python3\n\nfrom ev3dev2.motor import MediumMotor, OUTPUT_A, SpeedPercent\nfrom time import sleep\nimport pyftdi.serialext\n\nport = pyftdi.serialext.serial_for_url('ftdi:\/\/ftdi:232:AG0KAEQB\/1', baudrate=250000)\n\n#works good with QLC+ at 9 Hz\nport.timeout = 0.0226\n\n# clear input buffer (not sure if everything needed)\nport.reset_input_buffer()\nport.read(514)\nport.reset_input_buffer()\n\nchannels = &#91;0]*512\nCH_FIRE = 1\n\nfire = MediumMotor(OUTPUT_A)\nfire.reset()\nfire.position_sp = 0\nfire.speed_sp = 1560\n\nfireON = False\n\nwhile True:\n    port.reset_input_buffer()\n    dmx_data = port.read(514)\n\n    i = 0\n    error = False\n    for b in dmx_data:\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        # first 2 bytes should be zero (\"start-of-packet procedure\" and \"start frame\") \n        print(\"Error!\")\n    else:   \n        if channels&#91;CH_FIRE -1] == 255:\n            if fireON == False:\n                # turn Fire ON\n                print('Fire triggered ON')\n                fireON = True\n                fire.position_sp = 3050\n                fire.run_to_abs_pos()\n        elif channels&#91;CH_FIRE -1] == 0:\n            if fireON == True:\n            # turn Fire OFF \n            print('Fire triggered OFF')\n            fireON = False \n            fire.position_sp = 0\n            fire.run_to_abs_pos() \n    print(\"FireON: \", fireON)\n    sleep(0.1)<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 6  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>Second LEGO DMX fixture: a Fire Machine \ud83d\ude42Similar script on EV3, listening to DMX channel 1 and reacting to just two values: 255 turns the BIC lighter ON 0 turns it OFF again Working quite good with QLC+ as a DMX controller (at 9 Hz DMX frame rate) and other DMX fixtures on the loop &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2021\/lego-dmx-fire-machine\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;LEGO DMX Fire Machine&#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-1736","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-s0","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1736","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=1736"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1736\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1736"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}