Connecting to a Goldmund audio processor

Hi,

I am trying to use an Aduino Uno + ARCELI USB Host Shield to send serial commands to a Goldmund audio processor.

These commands when I use a C++ program on Windows 10 with code like:

WriteFile(hSerial, dataToSend.data(), dataToSend.size(), &bytesWritten, nullptr)

work well.

I had to use a driver from:

My Arduino program uses:


#define ENABLE_UHS_DEBUGGING 1
#include <cdcacm.h>
#include <usbhub.h>                                                                                                            
// Global objects for USB communication
USB Usb;
CDCAsyncOper AsyncOper;
ACM Acm(&Usb, &AsyncOper);

void setup()
{

  Serial.begin(115200);

  while(Usb.Init() == -1)
   { Serial.println("OSC did not start.");
     delay(250);
   }
}
void loop()
{
  Usb.Task(); // Required to maintain USB functionality
  USB_DEVICE_DESCRIPTOR desc_buf;
  if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
   { uint8_t rcode = Usb.getDevDescr(1, 0, 0x12, (uint8_t *)&desc_buf);
     if (rcode)
      { Serial.print(F("\r\nError reading device descriptor: "));
        Serial.println(rcode, HEX);
      }
     else
        Serial.print(F("\r\nDevice descriptor: "));
     delay(10000);
   }
  else
     Serial.println(Usb.getUsbTaskState());
..............
 
Usb.Task();
if (Acm.isReady())
   Acm.SndData(len_serial, buff_serial);
else
   Serial.println("Acm is not ready);
..............
}

With this:

  1. Usb.Init() works.

  2. Usb.getUsbTaskState() return 18.

  3. Acm is not ready.

What can I do to debug this?rtl+W>

FTDI is not CDC ACM. Look for the USB host shield library ftdi example.

Ah, great.

I am very new to using USB, and did not know that there were 2 protocols.

That's just the information I needed, thank you very much.

You should clarify how you have things connected.
To me this sounds like to have connected a FTDI USB-to-TTL-adapter this way

Windows_10_PC---------->-------FTDI-Adapter----->-----Audio-processor

Do you use an external FTDI USB-to-TTL-adapter?
or
are you plugging in a USB-cable directly into your PC like this

Windows_10_PC---------->-------normal USB-cable----->-----Audio-processor

The PC reference was just to show how the processor reacts to USB commands.

I am trying to replicate what works from a PC using an Adruino Uno + USB shield, with the USB Host Shield Library 2.0.

There is one cable from the Shield to the Processor.

During debugging phase, there is one cable from the PC to tje Arduino, but that's just to upload the program and debug it.

With the help of grok 2, I am trying now:

#include <Usb.h>
#include <cdcftdi.h>
 
USB Usb;
FTDI *Ftdi = NULL; // Use a pointer to handle dynamic allocation
 
void setup() {
  Serial.begin(115200);
 
  // Initialize USB
  while (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
    delay(200);
  }
 
  // Manually find and initialize FTDI device
  Serial.println("Line 17");
  Usb.Task();
  Serial.println("Line 18");
  uint8_t devCount = Usb.getUsbTaskState();
  //if (devCount == 0)
      Serial.println(devCount);
  Serial.println("Line 23");
  for (uint8_t i = 0; i < devCount; i++) {
    USB_DEVICE_DESCRIPTOR devDescr;
    if (Usb.getDevDescr(i, 0, 0x12, (uint8_t*)&devDescr) == 0) {
      Serial.println("Line 27");
      // Check if this device is an FTDI device by its VID/PID
      if (Usb.getUsbTaskState() == USB_STATE_RUNNING) {
        if (devDescr.idVendor == 0x0403 && devDescr.idProduct == 0x6001) { // Example VID and PID for FTDI FT232R
          Ftdi = new FTDI(&Usb, i); // Assuming FTDI constructor takes USB instance and device index
          if (Ftdi == NULL) { // Check if allocation failed
            Serial.println("Failed to allocate FTDI instance.");
          } else {
            break; // Found FTDI device
          }
        }
      }
    }
  }
 
  if (Ftdi == NULL) {
    Serial.println("No FTDI device found.");
    while (1);
  }
 
  // Set baud rate to 115200
  if (Ftdi->SetBaudRate(115200) != 0) {
    Serial.println("Failed to set baud rate.");
    while (1); // Halt if baud rate cannot be set
  }
  Serial.println("USB FTDI Initialized");
}
 
void loop() {
  Usb.Task(); // Maintain USB functionality
 
  if (Ftdi->isReady()) {
    const char* cmd = "DE4212";
    uint16_t len = strlen(cmd);
 
    // Write the command string to the FTDI device
    uint8_t rcode = Ftdi->SndData(len, (uint8_t*)cmd);
 
    if (rcode) {
      Serial.print("Send Data Error: ");
      Serial.println(rcode, HEX);
    } else {
      Serial.println("Data sent successfully.");
      delay(1000); // Wait a bit before sending again or looping
    }
  } else {
    Serial.println("FTDI device not ready.");
  }
}

that goes straight to:

Serial.println("No FTDI device found.");

Any idea?

clarifying how the connection between Windows10-PC and Audio-processor was done.

Windows-10-PC-----normal-USB-cable----Audio-processor

or

Windows-10-PC-----FDTI-USB-to--TTL-adapter---SERIAL-Cable----Audio-processor

You are working on an informatc project and what is most needed in an informatic project is detailed information.

Post a link to that exact USB-shield that you have lying on the table
Post a picture how you have connected the USB-shield to the arduino-uno

So:

Windows PC to Arduino UNO using an USB cable B on the Arduino side an A on the PC side.

This Shield:

Connected to the processor, using USB A on the shield and USB B on the audio processor.

The Shield is plugged in on top of the Arduino. My project uses some pins like A0 that still work going through the shield.

Here:

The green cable goes to the PC, the white to the audio processor.

It looks prettier in the dark. :slight_smile:

Did you try this example-code from the USB-host-shield-library?

What results do you get using the hubdemo?

Try this example code gives:

GoldCont.ino: 4:10: fatal error: pgmstrings.h: No such file or directory
   #include "pgmstrings.h"
   ^~~~~~~~~~~~~~

I'll try the hubdemo next.

Edit: same error of course, this include does not exists in

'C:\Users\m1\Documents\Arduino\libraries\USB_Host_Shield_2.0-master

I did a quick search and found the file pgmstrings.h in multiple of the demo-codes

The include has double-hyphens which indicates in most (not all) cases that the file is located in the sketchfolder

I should have made a search of course!
I found it in several places, so I just used:
include "C:\Users\m1\Documents\Arduino\libraries\USB_Host_Shield_2.0-master\examples\USB_desc\pgmstrings.h"
At first, I got "OSC did not start.", so I added this retry loop:

  while(start)
   { if (Usb.Init() == -1)
      { Serial.println("OSC did not start.");
        delay(200);
      }
     else
      { Serial.println("OSC started.");
        start = 0;
      }

   }

Now it does start, but all I get is:

Port open
VS%�5E���5
OSC did not start.
OSC started.

and in the output window:

     Millis is currently 28720.
13:58:50.827 [up:28s:971ms perf:247ms]   GoldCont.ino, line 103		millis()=28971
     Millis is currently 28971.
13:58:51.075 [up:29s:221ms perf:246ms]   GoldCont.ino, line 103		millis()=29221
     Millis is currently 29221.

So there is no communication.

I tried your previous example with the same mods, but setup() is not called, it goes directly into loop()!

I don't believe this.
I would do an immidiate serial print like this

void setup() {
  Serial.begin(115200);
  Serial.println("Setup-Start");
  delay(5000);
  Serial.println("delay done");

@Bob8K How do you know it is an FTDI device? Run the USB_desc example to find the Vendor ID and Product ID. Search the web for "USB Vendor ID code" to determine the manufacturer.

This could be due to mismatch of Vendor ID and/or Product ID.

The following might help.

I would debug the USB host shield without all those wires connected. One misplaced wire can prevent this from working. Also if there are any other shields in the stack, remove them.

It's an FTDI device because on Windows I had to use this driver:

That made it visible as an USB com port.

I'll try your other suggestions and get back.

Thanks.

Can you get the same control functions via the Audio Processor's RS232 interface as are available via USB? I imagine using RS232 would be considerably simpler.

I was using it, but the processor got a problem with it, it's not working anymore!

The USB port does work (with a PC), so until it's fixed, I wanted an alternative...

Are USB and RS232 different interfaces?

I was assuming that the FTDI-chip does the conversion from USB to real TTL-serial

Do you have a real D-SUB9-socket or something like that for serial
plus a USB-socket?

From https://goldmund.com/mimesis-168-processor/:

Yes, there is a real RS232 socket.

Goldmund doc does not say that the USB socket can be used the same way as the RS232 one, it's usually used to set up the processor with a specific software.

But I tried with exactly the same C program with Visual Studio, and it does work.

I can from the PC control the volume, input and balance exactly the same it was working before using the RS232 socket. For the PC, it's just a different COM port once I set up the driver mentioned above,