Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node-RED Controller #40

Open
pdawcewicz opened this issue Dec 2, 2022 · 3 comments
Open

Node-RED Controller #40

pdawcewicz opened this issue Dec 2, 2022 · 3 comments

Comments

@pdawcewicz
Copy link

Hi Matt.

I'm looking for way to control my DMX decoder using RS485 hat on Rpi. I'd love to control it in Node-RED environment.
Shield's manufacturer supplied a sample python code, sending a simple test string over RS485, and it works, but I'm wandering how can I modify this code, making it send DMX frames. Maybe you could give me some tips how to do it, because unfortunately, I don't know python.

Here is the code which I've simplified a little bit, and original one in the link below.

import serial
import os
import sys
import logging

logging.basicConfig(level=logging.INFO)
libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(file))), 'lib')
if os.path.exists(libdir):
sys.path.append(libdir)

import RPi.GPIO as GPIO
import time
from waveshare_2_CH_RS485_HAT import config

TXDEN_1 = 27
TXDEN_2 = 22

ser = config.config(dev = "/dev/ttySC0")
data = ''
GPIO.output(TXDEN_1, GPIO.LOW)
ser.Uart_SendString('Waveshare 2-CH RS485 HAT\r\n')
time.sleep(0.005)#Waiting to send
GPIO.output(TXDEN_1, GPIO.HIGH)

https://www.waveshare.com/wiki/2-CH_RS485_HAT

Regards,
Paweł

@MattIPv4
Copy link
Owner

MattIPv4 commented Dec 9, 2022

Hey! it sounds like this is a serial device? If so, the serial controller in the project might be what you want?

https://github.com/MattIPv4/PyDMXControl/blob/master/PyDMXControl/controllers/_SerialController.py

If it isn't a true serial device, you might be able to use that controller as a basis for implementing your own controller that makes the right calls to send each DMX frame

@pdawcewicz
Copy link
Author

Hey.
Thanks. That is what I was looking for. I was wandering how to get this >88 usec break and >8 usec idle before sending the pocket, and you are doing it at the very end of the code:

    self.__device.send_break(100e-6)
    sleep(10e-6)
    self.__device.write(data)

It seems I will be able to handle DMX protocol this way, using your python code, but maybe you could give me some ideas how to achieve that in Node-RED, if you have any experience with this environment.

@MattIPv4
Copy link
Owner

Unfortunately, I'm not familiar with Node-RED, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants