Friday, March 31, 2006

ST-1700C Upload Cable Pinout




This is a wiring diagram for the Cresnet upload cable for an ST-1700C, STX-1700C, ST-1550, ST-1550C or STX-1700CXP touchpanel.

Wednesday, March 29, 2006

Parsing RS-232 Serial Data in Crestron SIMPL - Volume for Denon AVR-3805

I'm starting this blog as a forum for posting examples of Crestron SIMPL Windows programming techniques, as well as other Crestron discussions. I encourage criticism and suggestions about the techniques I present, or questions about examples you'd like to see.

The first question is one that was actually asked by cwbowen2000 on the Crestron Yahoo! group. I'm replying here so I can use images, unlike in the text-email-only forum.

OK, here we go. A brief tutorial on parsing serial response strings for volume, using only SIMPL Windows (no SIMPL+).

The example is a Denon AVR-3805 receiver. I don't have this device in front of me, so none of this is tested. This is conceptual only. The document used as a reference is "AVR-3805_SerialProtocolv4-0UpdCV_serialprotocol.pdf"

The protocol states that when the master volume changes, you will be sent the following string:

MV80

"80" is the volume in ASCII, ranging from 00 to 98.

Here is some basic guidance on how you would parse this for display on a touchpanel (on a full-range (0% - 100%) gauge):

1. On the COM port rx$ port, put a signal denon_rx$



2.Insert a GATHER (Serial Gather) symbol in your program. Place the denon_rx$ signal on the in$ of the GATHER. Place a new signal, denon_gather_rx$, on the out$. The delimiter should be 0Dh. The length parameter should be longer than the longest string you'd expect to get from the receiver. For this example, use 50d. The purpose of the GATHER symbol is to collect all of the traffic from the receiver, waiting until it sees the CR (which is Carriage Return = 0D hex)


3. Insert a STOA (Serial to Analog) symbol in your program. Place the denon_gather_rx$ on the serial input. You then need to set up your maskwords in the parameter fields. Highlight the parameter field and hit ALT-Plus until you have 5 maskwords showing. This is because the string you are receiving is five characters long.

In the first field, put 014Dh. The "01" indicates that the character MUST match this character in order for parsing to proceed. The "4D" is the hex value of the character the first character must match, which in this case is M (4D hex).

In the second field, put 0156h. (The second character must match V, which is 56 in hex)

In the third and fourth fields, put 0200h. These characters are the volume payload, which you want to extract to use to determine the volume.

In the fifth field, put 010Dh. This field must be a carriage return, which is 0D in hex.

Highlight the analog output and hit ALT-Plus once to get a second analog signal. The two characters you specified with 0200h a>s the maskword will be sent to these analog signals. Name the top one "denon_volume_tens_ascii" and the second one "denon_volume_units_ascii"



4. Now we need to convert your data from ASCII to Decimal, and scale the tens value up. I had originally suggested using a more cumbersome method, but Lindsay made the following great recommendation, so I'm updating the post.

Insert two ASCALELs (Analog Scaler with I/O Limts) into your program. The first will be for the tens, the second will be for the units. These will be configured to not only convert the values from ASCII to decimal, but also scale up the tens so that 1d = 10d, etc. Both will have the lower limit of 48d (decimal equivalent of 0 in ASCII) and the upper limit of 57d (decimal equivalent of 9 in ASCII). The output lower limit of each will be 0d. The format will be 0d, as the values are all unsigned. The upper limit of the tens will be 90d, and the upper limit of the units will be 9d.



6. The next step is to add the scaled tens to the units. Insert another ASUM (Analog Sum). Ain1 will be "denon_volume_tens_scaled" and ain2 will be "denon_volume_units" Aout will be "denon_volume_decimal" You will now have a decimal value, ranging from 0d to 98d, which provides the volume of the receiver.


7. The final step is to scale the value from it's current range of 0d to 98d, up to 0% to 100% so you can use a gauge on the touchpanel. Insert an ASCALEL (Analog Scaler with I/O Limits). Ain1 should be denon_volume_decimal. Aout1 should be denon_volume. This is the signal you will run to your touchpanel. InputLowerLimit is 0d. InputUpperLimit is 98d. OutputLowerLimit is 0%. OutputUpperLimit is 100%. Format is 0d, because your values are all unsigned.

Needless to say, this can be done a lot quicker in SIMPL+, but this will accomplish your goal in SIMPL Windows only.