zarino / netballs

Wireless light-up netballs
1 stars 0 forks source link

Get Raspberry Pi to read PWM output from DMX Decoder #2

Closed zarino closed 5 years ago

zarino commented 5 years ago

Our DMX decoder outputs PWM on 4 channels, corresponding to the 0–255 data it receives on the 4 incoming DMX channels.

We need to read the PWM output from a Raspberry Pi, so that it can forward the message on to the ESP32s in the balls via MQTT.

The DMX decoder runs on 12V – can the Raspberry Pi GPIO withstand that? Or will we need to step it down somehow?

zarino commented 5 years ago

We’re now going to do this via an Arduino Uno. So the flow is something like:

DMX input -> DMX shield -> Arduino Uno -> (I2C) -> Raspberry Pi

Outstanding questions right now:

paulgeering commented 5 years ago

The Arduino Uno receiving DMX and sending out via serial, is showing some unwanted glitching/instability.

DMX Masters tested: Mac + uDMX cable: Glitchy Arduino Uno + DmxSimple library: Glitchy Cheap RGB Disco light DMX output: Rock Solid Stran 100 Professional Lighting desk: Glitchy

More investigation needed, but the current solution probably shouldn't be used as the core of our system till we know what's up. (I'll bring my work's oscilloscope to MakerNight)

It only needs to work with the Lighting desk that will be used for the event, (Although having a test setup is fairly essential for us to be confident of the solution we develop), so any details we can get on that would be great.

paulgeering commented 5 years ago

DMXSerial might be worth another look, as an alternative DMX receiving library.

paulgeering commented 5 years ago

DMXSerial might be worth another look, as an alternative DMX receiving library.

I ported our test code over to using the DMX Serial Library.

Once again, the output from the DMX Disco Light was read fine, but the DMX from the lighting desk was not being received correctly.

DMXSerial

If the receiving was correct, we should see: 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0 10 20 40 80 0

paulgeering commented 5 years ago

If we decide to go back to the DMX to PWM hardware decoder, then we have a few options for reading the PWM into the Arduino/Raspberry Pi (EDIT: For the record, I still prefer direct digital decoding of the DMX on the Arduino,as we'll loose some fidelity, but this is backup talk)

We could use an Arduino to read the PWM and send values over serial to the Pi Overview of PWM decoding Simple method if we don't need many updates per second Some other library.

Or we could attempt PWM decoding on the raspberry Pi itself PWM decoding in C on RPi PWM decoding in Python on RPi

Each of these would still likely require some level conversion given the output of the decoder box was in the region of 12-15 volts.

EDIT: Internally the MOSFETs driving the PWM outputs are being controlled by a nice 0-5v (Also PWM) So if we're happy soldering some wires and bringing them out of the box, we could use those and GND straight into an Arduino.

Decoder

paulgeering commented 5 years ago

DMX512 is a very a standard that allows a very broad range of timings.

Investigations on Thursday showed the Arduino DMX decoding libraries could cope with DMX that had its slots and frames well spaced out. This seemed to give the Arduino time to buffer and decode the signal.

The disco light had spaced out signals (and also a non-compliant DMX Break period) The DMX simple library was sending bursts of tightly packed slots The uDMX ,and the presumably the lighting desk, were sending the DMX slots and frames with little to no spacing between them.

DMX-rate

zarino commented 5 years ago

The legendary @paulgeering has submitted a pull request to fix these timing issues, at the level of the Arduino, rather than the Raspberry Pi, which works great, but just needs to be reviewed and merged: https://github.com/zarino/netballs/pull/8

Closing this ticket now, though, since the code we wrote for the Pi works fine.