Latency of Serial.println() with Arduino UNO

As a part of my current experiment, I’m running following piece of code:

   if (digitalRead(pinDeviceReadReady) == HIGH) {
    Serial.println("DATA READY");
    spiSend(0x20); // command "read request"
    readBuffer.deviceId = spiReceive();
    Serial.println(readBuffer.deviceId);
    readBuffer.wireId = spiReceive();
    Serial.println(readBuffer.wireId);
    readBuffer.length = spiReceive();
    Serial.println(readBuffer.length);
    for (int i = 0; i <= readBuffer.length; ++i) {
       readBuffer.data[i] = spiReceive();
       Serial.println(readBuffer.data[i]);
    }
  }

where

inline void spiSend(uint8_t data)
{
  // wait for device ready to write
  while (digitalRead(pinDeviceWriteReady) == LOW);
  SPI.transfer(data);
}

inline uint8_t spiReceive()
{
  while (digitalRead(pinDeviceReadReady) == LOW);
  uint8_t data = SPI.transfer(0);
  return data;
}

Phase one experiment

Continued from this article.  I’ve done with the phase one experiment.

The goal of phase one experiment is to implement end-to-end application with minimum struggle for hardware design and implementation.

What does the application do?

I am sure there will be a lot of testing work before I put the communication device in real applications.  So I first want a tool to test the driver and protocol.  Thus, the application for the first phase is a protocol tester that provides command line interface and several diagnostic commands / functions.

Inter Module Communication

I’m going to try making a digital communication bus for synthesizer modules.

Analog synth has a very simple control language which is voltage.  Any message is translated to voltage that can be read by any modules that accept voltage input. So for example, VCO output is basically audio output but also can be used as control voltage of some other modules, such as VCO cross modulation.

This simple data exchange methodology makes analog synthesizer very versatile and flexible.  However, as a drawback, patch wiring would become too complicated as you make complex module network.

One solution for making the wiring simple is to use a single common data bass where all modules are connected, and exchange data selectively using some software.  Apparently, making such a bass for analog signals is impossible or extremely difficult. So I’m going to try making it using a digital bass.