Easiest interface with an Arduino ? (I2C, Serial or SPI)


#1

Hi everyone,

I plan to use a little touch screen along with an Arduino Mega

The idea is to connect it to the Axoloti (needs a level adapter ?).

Is it easier, reliable to use a serial UART than the I2C or SPI to link the Arduino Mega to the Axoloti ?


#2

Arduino Mega 5v, Axoloti 3.3v, yes you will need a level converter.
If you use a 3.3v mcu, you won't need to convert, and it may give you extra options down the track.
Some options, Arduino Due or clone equivalent, Teensy.
And both these options are faster and have more memory etc..

As far as what type of coms, I guess it depends on your setup, are you planning on connecting any other devices, if you have an opportunity to try all three, would be interesting to see the differences. All three should be considered OK. I have never used I2C, but have never had any issues with Uart or SPI, Although I have never connected a Touch Screen either.
:grin:


#3

Thanks for the level converter advice. I don't want to fry my Axoloti !

The main interest of the Arduino Mega and this screen is that it is a shield and that the com ports are still available. I'm not sure the screen can work with 3.3V boards.

I think I will start with uart. I don't need tremendous data transfers (just synth parameters and maybe display some waveform / envelope...).

I'm not familiar with SPI but as far as i understand it is able to transfer data much faster but it seems more complicated to me.


#4

I don't know if it will help or not, but there is a popular shield for the Arduino Due that allows you to connect a screen for the Mega to a Due.
And on all the shields I have seen, they also have a micro SD card slot as well. There are no loose wires, its all on theww shield.
As an example, this is one of many on ebay..
Link to Shield Example.


#5

I'll begin with the Arduino Mega. I think it is nice for beginners. I've ordered all this... i will experiment with it next week :slight_smile:

Thanks to your suggestions, I browsed the internet a little more.

I'm really tempted by the teensy - it is powerful and is more compact than the Arduino Due and PJRC offers a comparable TFT with optimised libraries :
https://www.pjrc.com/store/display_ili9341_touch.html


Another option would be to use a bluetooth -> uart module and to implement a control software on a bluetooth device (tablet or phone). It can seem complicated at first, but there are many Arduino examples around and it can be more versatile that embedding an arduino+touch screen+power.


#6

I'm doing some experiments with an arduino and an axoloti with the help patch of the gpio/serial.axh helper.

@johannes, as far as I see, there is no mutexes.
As i plan to transfer some data sets/chunks, i'd like to know if there are some best practice involving mutexes or semaphores ?


#7

You can use mutexes:
http://chibios.sourceforge.net/html/group__mutexes.html
http://chibios.sourceforge.net/html/group__synchronization.html

But I'd avoid locking in the DSP thread, depending on what you want to do exactly, perhaps use "double buffering" and signalling the transmitting thread (chEvtSignal / chEvtWaitOne )

Comparing I2C, UART and SPI:

I2C is a well defined standard that includes a way to address multiple devices on one bus (if they have different addresses). Implementing an I2C bus master is easy. Implementing an I2C slave on a microcontroller is way harder since you have to be in ready in time to answer the master. Chibios only provides a I2C master implementation.

SPI is far less defined, multiple modes (clock polarity and phase) and addressing schemes exist. Again, Chibios only provides a SPI master implementation. I don't know how a generic SPI slave implementation would look like, as the packet size is unknown.

UART is the most friendly, as it is provides a stream interface on Axoloti/Chibios you can print formatted text strings etc. The downside is that encoding numbers into base-10 ascii text is inefficient, and there is a need to recognize the start of a message somehow. MIDI does this beautifully by using the most significant bit of every byte to separate header from data.


#8

FYI, I have a Teensy and they're great... PRCJ has done a good job supporting it and lots of power in such a small package. There is also the cheaper alternative to a Teensy... the Maple Mini... based around the STM32F103RC8T6 chip (received one 'knock off' tonight from eBay at a cost under $5 CAD delivered) and can be programmed through the Arduino IDE. Not as well supported but all open sourced... http://www.stm32duino.com


#9

Internet soures say that the Arduino IDE is not able to control I2C, Uart and SPI on the STM32 controllers. Its just basic GPIO control. But I suspect overtime things will change over time with the friendship between Arduino and STM, however easy availability of the Arduino Star is well overdue. Where on earth can you get one.. !!:tired_face:


#10

@Gavin first I've heard of this 'Star' board and it certainly looks interesting... http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-3rd-party-evaluation-tools/ard-otto-stm32.html

But I do believe there is some SPI and I2C support in the IDE currently...


#11

I achieved to make the Arduino Mega and the Axoloti to speak to each other through UART in a few minutes :smiley: (through a 3v3 <-> 5V level adapter

I think that MIDI is a good solution.
Instead of inventing my own obscure protocol, i can use MIDI.
MIDI with sysex can be an elegant solution to synth parametrization (much like the good old synth editors).

The main difference with the previous synths is that each patch is a new synth, with different parametrizations.

Basically, the arduino+screen is a dedicated MIDI controller.

Thus, we can imagine a protocol where the Axoloti sends a Sysex to the controller to inform it which parameters are available and how they should be presented (layout) and controlled (Sysex, CC...).

After this phase, the controller (Arduino + screen + pots... or a tablet through MIDI bluetooth...) adapts itself and controls the Axoloti as the Axoloti told it.


#12

Yes, I intend to transfer chunks of data that should be consistent during the processing (preset information).


#13

I have ordered a teensy 3.6...
@Gavin, whatever the situation is about UART support, i'll find some application for it :wink:
But i think that UART support is the strict minimum.


#14

@SmashedTransistors you might find interest in using digi-pots along with your rotary pots in your controller to help with preset management (or may have thought of this already). I'm currently diving into using some MCP4261 digi-pots this way - i.e. indication of current value compared to stored value and no change until physical pot crosses the preset value. A lot of good info in this write up I found... https://forum.arduino.cc/index.php?topic=480635.0


#15

Concerning the UART support, I've seen this:
https://www.pjrc.com/teensy/td_uart.html

Concerning the I2C:
https://www.pjrc.com/teensy/td_libs_Wire.html

and SPI:
https://www.pjrc.com/teensy/td_libs_SPI.html


#16

Thanks @SmashedTransistors, The Teensy is perfect for what you are doing and will work fine, but I was referring to controllers like that mentioned by @timeorspace, the STM32F103RC8T6 and or similar, STM32DUINO project has been working at porting many STM32 boards for use on the Arduino IDE, from all sorts of clones in the M3 to the M4 like the STM32F427 that the Axo uses (the chip only, not a board, but almost same thing) through to the STM32F7 disco board and even many Nucleo boards etc. Because of the work required to do this, mostly only the basics have been covered, (well from what I have read) so things like serial coms are left out for later porting.
Its interesting reading, the differences, how they work etc..
:grin:


#17

For example this board from Adafruit:


Is very interesting with it's 64MHz M4F and Bluetooth, but it does not havr UART support :slightly_frowning_face:


#18

I believe Adafruit is different,
My reference is only for STM32 series microchips.
If you google "STM32 development boards" and see the images, you'll see there are a lot of options, but they were never designed for the Arduino IDE, maybe there are others here who maybe able to comment on the Arduino IDE versus the Standard IDE used for STM32 chips, from what I understand it is far more complicated, that is why STM32Duino started.
It may not have uart support because it has Bluetooth.
:thinking:


#19

The chip itself nRF52832 has all the modern features (SPI I2C timers...), but the way it is reset/parametrized/configured certainly implies some adaptations.

By the way, does the SoftwareSerial Arduino library work with the STM microchips ?


#20

@SmashedTransistors and @Gavin my apologies if I sent this thread into a spiral suggesting an stm32f103... with hopes @SmashedTransistors can proceed with the teensy and the supported libraries it provides. Cheers.