Help understanding a ASCII over RS485 protocol for Australian Monitor Sound Amp controller

I have been working on this off and on for over a year and am nearly ready to give up, then thought the massed expertise of the forum might be able to help. I am making a sound level controller using a mobile phone focused html/website for the AMD200 Amplifier by Australian Monitor. I'm using an ESP8266 as the micro and a RS485 converter connected to the tx/rx pins on the ESP8266. All this works fine and I can happily send messages to a USB RS485 dongle on my laptop.

The Problem is getting the AMD200 to understand/react to the messages I am sending. This is the extract from the manual on the protocol.

" The protocol is an ASCII protocol – all characters in the string are ASCII chars.
A binary value ranging between hexadecimal 00 and FF is transmitted as two
ASCII chars. All command strings start with the % character and end with a
carriage return – shown as in this document and equal to the single
ASCII value of 13 (0x0D).

  To adjust the virtual volume control of the mic/line inputs, BGM source or
  Master.  %PVAL:xxyy<CR>
  “xx” represents the parameter ID to be adjusted and “yy” is the new value.
  Parameter ID’s
  01 = Mic/Line 1 Volume
  02 = Mic/Line 2 Volume
  03 = Mic/Line 3 Volume
  04 = Mic/Line 4 Volume
  05 = Mic/Line 5 Volume
  06 = Mic/Line 6 Volume
  07 = Mic/Line 7 Volume
  08 = Mic/Line 8 Volume
  09 = Stereo BGM Volume
  0C = Master Volume
  
  The value of yy can range between 0x00 (off) and 0xE1 (225 = +12 dB of
  gain). 
  
  This allows half dB steps throughout the range where for example:
  0x00 = Off
  0x01 = -100 dB
  0xC9 = 0 dB
  0xE1 = +12 dB
  
  To request the current level of a source:
  %PVAL:xx??<CR> where “xx” is the source.
  
  When a volume is adjusted from another source e.g. ICON-CP the
  AMD100/200 will send: %PVAL=xxyy<CR> where “xx” is the source and “yy” is the
  current value."

So now I am into second guessing myself, do I send ASCII codes, binary codes, something else? I have tried multiple options and nothing works.

I am happy to post my code but don't want to make this a huge post as it is my first time posting. The section that is relevant is this:

'''
// Line 7 which is Lecturn (for now)
// Message should be %PVAL:05 actiually going for Line 7 for now
// = 25 50 56 41 4c 3a 30 35 0D
// = 25 50 56 41 4c 3a 30 37 0D

void slider1 (Control *sender, int type) {
if (sender->value.toInt() != vol1) {
vol1 = sender->value.toInt();
uint16_t vol_conv = vol1 * 2.25;
char tbs[30];
sprintf(tbs, "25 50 56 41 4c 3a 30 37 %02X 0D", vol_conv); //converts to Hex and pads to make sure there are 2 characters
Serial.println(tbs);
}
'''
All thoughts woud be most welcome

Welcome to the forum

The first thing to understand that an ASCII value is nothing more than a series of bytes and that it is how the bytes are interpreted that matters

This seems quite clear that ASCII characters representing the value should be sent

So, to set the Mic/Line 1 Volume to a value of 23 you would do something like this

Serial.print("%PVAL:0123\n");  //SEE CORRECTION BELOW

CORRECTION
The string should be terminated with a Carriage Return rather than a Newline so should be

Serial.print("%PVAL:0123\r");

How do you mean multiple options ? those are basically the same.
i would do something like this using the String class (it's all in a sub function so all objects will be destroyed when the function is exited.)

String tbs = "%PVAL:";
String xx = String(5, HEX);
while (xx.length() < 2) xx = "0" + xx;
tbs += xx;
String yy = String(vol_conv, HEX);
while (yy.length() < 2) yy = "0" + yy;
tbs += yy;
tbs += "\r";
Serial.print(tbs);

eh... '\r' the terminator is a CR not NL

Well spotted. I will add a note to that effect to my post

1 Like

Thank you both, I will try this tonight and over the weekend and let you know how it goes. I did try just hard coding

Serial.println("%PVAL:05C9");

But that gets no reaction either, although the lack of CR might be the problem there?

for sure ! no terminator no message.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.