
Ryan Poethke (Customer) asked a question.
integer to DMX translation
I have a V-memory address that contains the position of a machine, measured in 10ths of inches. The decimal is implied.
Value will be 0-3720 or 372.0"
I need to represent that data by tying two consecutive DMX channels together for a 16-bit value. Problem is, I have absolutely no idea how to do it :)
Two adjacent DMX channels will give me 2^16, or 65,536 but I don't know how to parse that data across two unsigned bytes, say DMXOUT1 and 2.
I'm sure it will be obvious once I know where to look.
Thanks,
Ryan Poethke
If the locations were WORD aligned and in the right byte order, you could use an aggregation cast DMXOUT2:W would access DMXOUT2 and DMXOUT3.
Or you can use the PUBLISH/SUBSCRIBE instructions, which we created to move data for just this purpose.
It seems its possible. What does :U and :UW mean? I don't understand how casting works... at all.
Don't I want to use bytes and not words, as each DMX value is an 8-bit value, 0-255?
This type of data manipulation has always eluded me.
Thanks,
Ryan Poethke
Casting is just a way to reinterpret the underlying memory. The help topic DMD0309 goes into detail. The Cast Builder in the Element Browser dialog may also help.
It's a big strength of Do-more.
Hi Ryan,
This post will explain casting in the Do-More:
https://accautomation.ca/brx-plc-numbering-systems-and-addressing/
It will talk about the cast builder that BobO has mentioned.
Regards,
Garry
https://accautomation.ca/series/brx-do-more-plc/
Hi Ryan,
Take a look at the MEMCOPY instruction.
Regards,
Garry
https://accautomation.ca/series/brx-do-more-plc/
If the DMX BYTE ID is WORD aligned (i.e. it is EVEN), just use cast in a MOVE instruction:
MOVE V13 DMX8:UW
If it needs to be on an ODD byte (e.g. 1), use PUBLISH for unaligned assignment.
If you are able change the ID and align it on a WORD boundary, i.e. an EVEN ID, casting makes it MUCH easier in Do-more Designer, e.g. DMX8:UW. PUBLISH can do it (misaligned), but then you can't look at the DMX mis-aligned WORD in Designer Data View (for example), you'd have to look at the raw bytes.
OK. After watching Gary's video, I think I've got it.
It takes two MOVE commands per position I want to covnert. The :B denotes Byte, and there are two bytes in the V-mem word I need to cast.
MOVE
Source: V3000:B0
Destination: DMXOUT[Base_Add]
MOVE
Source: V3000:B1
Destination: DMXOUT[Base_Add+1]
Do I have it right?
Is your DMX device really needing a 16 bit value, with a range 0..65535?
The Endianness of your Device may require you to swap the Sources (or swap the Destinations), depending upon if it wants the MSByte first (Big Endian) or the LSByte first (Little Endian). What you have is Little Endian
Sorry that this is so confusing, but this is why many devices use ASCII instead of relying upon their clients knowing things like microprocessor Endian-ness.
Try the values 255 and 256. If you get HUGE differences on the remote device, it's Big Endian and you need to swap the Source (or Destination - but not BOTH the Source AND Destination), e.g.
MOVE Source V3000:B1
Dest: DMXOUT[Base_Add]
MOVE Source V3000:B0
Dest: DMXOUT[Base_Add+1]
The Video guys want a 16-bit DMX value (so-called "coarse/fine" in the lighting industry) that represents the position of some scenery so they can map video projection to it. I have 31ft of travel, expressed as 10ths of inches. That's 372" or 3720 tenths of inches. I didn't see a way to fit that into an 8-bit DMX channel (0-255) with anywhere the resolution they wanted.
Lighting consoles marry pairs of DMX channels together all the time to get finer control of moving light functions like pan and tilt.
I'll have to see what they want Big or Little data format. Changing that will be easy, now that I understand casting. Thanks for the help!
Ryan Poethke