Changing the Strategy for Analog3

I’ve been trying for a year to make my own serial interface protocol to exchange data among synth modules.  Though it showed some progress, I kind of giving up this approach.  The problem is complexity of serial interface controller.  A controller for multi-master serial interface is complex.  Implementing using a generic device is more costly in many sense than I expected.  I started with Arduino.  This was the easiest approach but channel was too slow.  I could only achieve 50kbps.  Then I tried implementing it into AVR using assembler language.  It went 100kbps but it was about the limit.  The most serious problem with MPU was that the processing is always on single thread.  Some data processing has to be done in parallel during data reception, but it was pretty inefficient to run such concurrent tasks on 8-bit simple processor.  Overhead for such multi-tasking killed the speed.  Then, I moved onto PSoC.  It achieves bit rate 400kbps easily and it might go higher if it’s tuned well.  However, the logic to handle collision is so complex that I eventually am suffered from lack of resources in PSoC.

So at this point, it seems more practical to use a ready-made implementation of an existing protocol, which is CAN.

The reason I didn’t go for CAN at first was speed.  I wanted to use the interface even for synching oscillators.  I was not sure if 44bit-at-shortest message from at 1 Mbps is short enough for that usage.  (I’m not sure yet.  It’s about 22kHz rate if you keep repeating shortest CAN message at the highest rate.  That’s pretty close to audio frequency.  If an oscillator keeps sending such messages, the communication channel would be pretty much occupied.)  So probably I need to give up some usage of the common data bus.  I will go with following approach:

  • Use cheap CAN controller and transceiver: MCP2515 and MCP2551.
  • MCP2515 is controlled by SPI.  Most processors can use it.
  • I’ll use Raspberry Pi for the master synth controller module.
  • Synth modules can be based on PSoC or AVR.  These two are ones I am familiar with.
  • I’ll give up some features such as oscillator sync network.

SPI / RX 衝突試験

spi_rx_collision_test通信ドライバでの SPI と RX の衝突試験をしました。通信ドライバはいつでも RX 信号を受け取る可能性があります。それはホストがデータの受け渡しをするため SPI 通信をしている最中でも起こります。RX 信号の処理は他の処理を中断して即行わなくてはいけないので外部入力割り込みハンドラで実施しています。このハンドラの処理がやや複雑なので、バグによりもう一つの複雑な処理である SPI 通信で使われているレジスタを壊してしまう可能性があり、実際にそういうバグがいくつか出ました。バグは全て修正されて、負荷試験が通せるようになりました。試験では、負荷生成ドライバがシリアルデータを送り続けている一方、受信ドライバのホストのタイミングを調整して RX 信号と SPI が頻繁に衝突するようにしました。パケット一個おきに衝突が発生しています。負荷試験は10時間走り続け、通信エラーなし、セッションは固まったり暴走したりすることなく続いています。