# My "Rosetta Stone" Prop Controller.



## Hippie Crane (Sep 17, 2019)

Here is some information about how my prop controller works.

To start. I have always preferred storing data in time rather than storing it in fixed memory locations, the reason I prefer this is because in the long run, my data is embedded in the media file itself and doesn't take up any extra space.

*How is the show programming accomplished?*

Show programming is done through my own software which supports up to 128 channels, but you can use some clever tricks to double, triple, quadruple the amount of channels programmed.

You program in real time in front of your prop by assigning their movements and lights to keys on the keyboard. you can assign as many movements as you want to turn on/off when the key is pressed, and you can have up to 4 keys assigned to movements at a time.

Once the programming is complete for a particular sequence, you record the data stream from the UART modulator into audacity. Then line up the data stream with the audio to make sure the commands send exactly when they are supposed to. You apply a low pass filter to give the data a more sinusoidal form before exporting it to a wav format (This helps the operation of the wave shaper circuit).

You now have serial data stored in real time.

*How does the data get to the controller itself?*

Bytes are only sent if a channel turns on or off.

During show programming, serial data is modulated to "Biphase Mark Code" which is a line coding scheme that combines both the data and clock lines into a single data line.

There is a transition at the beginning of every bit of data. The presence of a second transition in the middle of the data bit represents a 1. The absence of a transition in the middle of the data bit represents a 0.










This Modulated data is what is stored on a DVD, CD, MP3 Player, Cassette Tape, VHS Tape, or any other media format.

In order for the microcontroller (atmega328) to detect and demodulate the data, it needs to be amplified by a single supply amplifier (LM358) to 0v and 5v levels, then shaped into a square wave by a 7414 schmitt trigger, in my case a 74lvc1g14 single channel schmitt trigger.

*How does the data tell the controller what outputs to turn on and off?*

There are 8 banks of 16 outputs to make up 128 outputs.

Setting outputs on and off is all just clever math with the 7-bit ascii table.

Let me introduce 2 variables of the byte datatype and a byte array:
byte bank
byte state
byte channel[128]

If the incoming ascii character has a value greater than 47 and less than 64, we will set the variable bank to ( (incoming - 48) / 2). We will also set the variable data to (incoming % 2) which gives us the remainder of division.

Here is a chart to represent that:
Ascii 48 = Bank 0 Data 0
Ascii 49 = Bank 0 Data 1
Ascii 50 = Bank 1 Data 0
Ascii 51 = Bank 1 Data 1
............................etc.
Ascii 62 = Bank 7 Data 0
Ascii 63 = Bank 7 Data 1

If the incoming ascii character has a value greater than 63 and less than 80, we can then set the state of an output at a certain index and shift out the data array. 
The state of the output is set using: channel[(bank * 16) + (incoming - 64)] = state;

The absence of the pilot tone for longer than half a second clears all of the outputs and the values in the array at the same time.

Here is an example of the data that is stored on the left audio channel. Your soundtrack is usually stored on the right audio channel.
Link To Audio
Please feel free to open it in audacity and look at the data itself.

Any Questions?


----------



## David_AVD (Nov 9, 2012)

Thanks for the write-up. Some questions:


Is the programming software available?


Is the code for the decoder available?


Have you done up a schematic for people to build the decoder?


Does the system support dimming (analog / PWM outputs)?


----------



## Hippie Crane (Sep 17, 2019)

David_AVD said:


> Thanks for the write-up. Some questions:
> 
> Is the programming software available?
> 
> ...


The programming software is currently experimental so I don't have a stable version to release yet (it still looks very edgy but is mostly functional)

I will upload code for the encoder (biphase generator) and code for the decoder and the wave shaper schematic soon.


----------



## Hippie Crane (Sep 17, 2019)

Here is a video of it working.


----------



## Nanorrock46 (Jan 17, 2017)

@Hippie Crane
This is awesome. I love the fact you have encoded the automation into a WAV file and that you can program in real time, that the file created is the playback of what you recorded.
Can't wait to see it evolve.


----------



## David_AVD (Nov 9, 2012)

Light-O-Rama use an event style data stream in their serial based lighting protocol. They signal on and off events like you do, but extend it to include commands to fade and flash channels too.


----------



## Hippie Crane (Sep 17, 2019)

David_AVD said:


> Light-O-Rama use an event style data stream in their serial based lighting protocol. They signal on and off events like you do, but extend it to include commands to fade and flash channels too.


I could do that as well, but it is a little more challenging.


----------



## Batbuddy (Sep 3, 2014)

This sounds very interesting! I hope you will share more detail soon.


----------



## pyroandy (Oct 22, 2019)

Interesting, very interesting


----------



## pshort (May 6, 2008)

Out of covid19-lockdown boredom I'm resurrecting an older, similar project that I've described in some very old postings. At the lowest level I'm using biphase-encoding, somewhat similar to the differential Manchester encoding that you're using. Above that I'm packetising the data using SDLC-line framing, allocating one byte for each output device (e.g. servo position or light brightness). The current board is about 0.75" x 2", set up for use with the AUS5121 board from MDfly. four servo channels and an optional PIR input.


----------



## Hippie Crane (Sep 17, 2019)

pshort said:


> Out of covid19-lockdown boredom I'm resurrecting an older, similar project that I've described in some very old postings. At the lowest level I'm using biphase-encoding, somewhat similar to the differential Manchester encoding that you're using. Above that I'm packetising the data using SDLC-line framing, allocating one byte for each output device (e.g. servo position or light brightness). The current board is about 0.75" x 2", set up for use with the AUS5121 board from MDfly. four servo channels and an optional PIR input.


I'm actually using biphase-mark code, way easier to do than D-Man encoding.


----------



## pshort (May 6, 2008)

How do they differ? It's been a long time since I've worked with those methods, but the WIkipedia article for biphase-mark redirects to differential Manchester. Also, your diagram looks just like what I consider to be differential Manchester, apart from the reversal of polarity of the decoded bits.


----------



## Hippie Crane (Sep 17, 2019)

pshort said:


> Out of covid19-lockdown boredom I'm resurrecting an older, similar project that I've described in some very old postings. At the lowest level I'm using biphase-encoding, somewhat similar to the differential Manchester encoding that you're using. Above that I'm packetising the data using SDLC-line framing, allocating one byte for each output device (e.g. servo position or light brightness). The current board is about 0.75" x 2", set up for use with the AUS5121 board from MDfly. four servo channels and an optional PIR input.


Biphase Mark Code is different than D-MAN in that there is a transition at the beginning of every single data bit, and there is a transition in the middle of the data bit when data is logic 1.

D-Man has a transition in the middle of every data bit, but only a transition at the beginning of the bit if the data is logic 0.

So basically D-Man encoding is inverted and shifted backwards half a bit. It can be decoded using a similar circuit biphase but you have to take the inverted data output.

There are 3 or so different type of biphase: biphase mark (the style im using), biphase space, and biphase level

biphase-level is basic manchester
biphase-space is the exact same as biphase mark but with flipped logic.


----------



## pshort (May 6, 2008)

Are you just using .wav files, or are you converting the samples into an mp3 file and then using some sort of mp3 player? I've been experimenting with the latter process, which seems to work fine at 9600 baud but not so good at 14400 (the mp3 encode/playback process seems to be introducing some nasty artifacts, as observed on an oscilloscope). If you are using mp3 files at some point in your implementations, which encoder and playback device are you using?


----------



## Hippie Crane (Sep 17, 2019)

pshort said:


> Are you just using .wav files, or are you converting the samples into an mp3 file and then using some sort of mp3 player? I've been experimenting with the latter process, which seems to work fine at 9600 baud but not so good at 14400 (the mp3 encode/playback process seems to be introducing some nasty artifacts, as observed on an oscilloscope). If you are using mp3 files at some point in your implementations, which encoder and playback device are you using?


.wav files, cd, dvd, or cassette tape, reel to reel all seem to work fine for me. wav files work the best using a digital media player.

You must also have a wave shaper circuit to amplify and schmitt trigger the signal into the decoder.

for the wave shaper you want to use a single supply op amp circuit with some resistors and a 4148 diode and a 74ls14.


----------



## pshort (May 6, 2008)

The MDfly player that I've been using (MOL-AU5121) only plays .mp3 files. On the possibility that playing .wav files is an undocumented feature, I tried just copying the file that you referenced to an SD drive, but no-go. What I've been doing is the .wav files to .mp3 files on a FreeBSD system. Which player are you using? And, for that matter, what sample rate are you using?


----------



## Hippie Crane (Sep 17, 2019)

pshort said:


> The MDfly player that I've been using (MOL-AU5121) only plays .mp3 files. On the possibility that playing .wav files is an undocumented feature, I tried just copying the file that you referenced to an SD drive, but no-go. What I've been doing is the .wav files to .mp3 files on a FreeBSD system. Which player are you using? And, for that matter, what sample rate are you using?


The sample rate I used to record it is 38.4k and I used a DFplayer. I was able to see all the text I recorded onto a wav file show up without error when I played it back. I think you can convert it to mp3 using audacity rather than some other alternative. mp3 shouldn't mess up the data from the several times I've done it. I notice it messed up usually if its youtube compressed or some other conversion software.


----------

