Hi there,
looking on the schematics of the RevPi Core 3+ module i have seen, that the Bridge-Connector uses SPI to communicate with other modules.
Now i wonder if it is possible to connect a SPI-Sensor like mentioned below, to connect via the bridge to my Core3+ module?
I hope somebody has experienced the same problem or could help me..
Kind Regards
(https://www.amazon.de/Beschleunigungsse ... 6QYD2SKQWB
RevPi Core 3+ - SPI Connection
Re: RevPi Core 3+ - SPI Connection
On the RevPi Core, the SPI bus of the Raspberry Pi is not exposed on the PiBridge. Rather, there are two SPI Ethernet chips which expose a physical Ethernet port on the PiBridge ("pileft" and "piright" Linux network interfaces, implemented by two ks8851 chips).
However on the RevPi Connect, we do expose the spi0 bus on the ConBridge (righthand side of the Connect, see schematics), so it is possible to connect the sensor there.
You can obtain a maker-set from our shop in which you can house the sensor. However the maker-set is for the PiBridge, whose sockets and plugs are shaped slightly differently than on the ConBridge. We could add a ConBridge maker-set to the shop if this is of interest for you?
Driver support for this sensor is missing in the 4.9 kernel which we're currently shipping in our image, but we're working on a 4.19 kernel which will be made available soon and that one does include a driver. You can use the kernelbakery tooling which we've put on GitHub to build your own 4.19 kernel based on our current revpi-4.19 branch.
You will also have to create a devicetree overlay similar to the one for the RevPi Con CAN to tell the kernel that an adxl345 is attached. See the documentation for details. The overlay then needs to be added to /boot/config.txt to activate it.
However on the RevPi Connect, we do expose the spi0 bus on the ConBridge (righthand side of the Connect, see schematics), so it is possible to connect the sensor there.
You can obtain a maker-set from our shop in which you can house the sensor. However the maker-set is for the PiBridge, whose sockets and plugs are shaped slightly differently than on the ConBridge. We could add a ConBridge maker-set to the shop if this is of interest for you?
Driver support for this sensor is missing in the 4.9 kernel which we're currently shipping in our image, but we're working on a 4.19 kernel which will be made available soon and that one does include a driver. You can use the kernelbakery tooling which we've put on GitHub to build your own 4.19 kernel based on our current revpi-4.19 branch.
You will also have to create a devicetree overlay similar to the one for the RevPi Con CAN to tell the kernel that an adxl345 is attached. See the documentation for details. The overlay then needs to be added to /boot/config.txt to activate it.
Re: RevPi Core 3+ - SPI Connection
Update: The ConBridge maker-set can be ordered via our sales department. It hasn't been added to the online shop yet, but is readily available.
Re: RevPi Core 3+ - SPI Connection
@lukas
So if i build the 4.19 kernel and activated the devicetree in the boot-config i can directly plug my sensor to the Core3+ Bridge Adapter (in accordance to the pinout)?
If so, how can i access my sensor data? Can i configure it via Pictory or access the data via piTest?
Many thanks for your help!
Und viele Grüße
So if i build the 4.19 kernel and activated the devicetree in the boot-config i can directly plug my sensor to the Core3+ Bridge Adapter (in accordance to the pinout)?
If so, how can i access my sensor data? Can i configure it via Pictory or access the data via piTest?
Many thanks for your help!
Und viele Grüße
Re: RevPi Core 3+ - SPI Connection
Again, the SPI bus is only exposed on the RevPi Connect. Not on the Core3+. But other than that, yes, it is possible to place your sensor in the maker kit case, attach it to the right hand side of the Connect, and with a 4.19 kernel and addition to the devicetree it will be usable.
There are actually two drivers in the kernel for this sensor: An older one in the input subsystem and a newer one in the iio (Industrial I/O) subsystem. Actually I realize now that the input driver is already in our 4.9 kernel. Only the iio driver requires 4.19:
The input driver is in this directory in the adxl34x* files:
https://git.kernel.org/pub/scm/linux/ke ... input/misc
The iio driver is in this directory in the adxl345* files:
https://git.kernel.org/pub/scm/linux/ke ... /iio/accel
I'm not familiar with accelerometers and their drivers, but the iio driver will expose a directory in /sys/bus/iio/devices/ with a bunch of files to access the sensor. Search for the string "accel" in this file to get an overview of the data that is made available:
https://git.kernel.org/pub/scm/linux/ke ... fs-bus-iio
I don't know how the input driver is supposed to be used. I suppose it sends input events to user space when something happens. I notice it requests an interrupt for that. There's an interrupt pin available on the ConBridge which you may use for this purpose. We use it on the Con CAN module to attach the interrupt of the hi3110 chip. The iio driver on the other hand does not seem to make any use of the chip's interrupt.
Something else I notice in the input driver is that adxl34x-i2c.c contains a "struct of_device_id" array which is referenced by a MODULE_DEVICE_TABLE() macro as well as in the struct i2c_driver. But adxl34x-spi.c is missing that. Thus, if you want to use the input driver, you need to hack adxl34x-spi.c to also contain those strings, otherwise it's not possible to bind the driver to the DeviceTree node. Hm, now we're firmly in kernel hacker territory...
If you want to be able to control the sensor via piControl/piTest, you'd have to extend the piControl source code to access the sensor via the iio driver and expose it in the process image. That's possible, but it's another piece of kernel-level code you'd have to touch. We're doing this on the upcoming RevPi Compact: It has an ADC and a DAC which are under the control of iio drivers. piControl uses the in-kernel iio API to access the sensors and expose them in the process image. So piControl is kind of like a shim between the iio drivers and the process image on the Compact:
https://github.com/RevolutionPi/piContr ... _compact.c
I'm sorry if all of this sounds complicated. But it's doable if you're willing to get your hands dirty and we're right here to answer your questions.
Re: RevPi Core 3+ - SPI Connection
Okay, that's a pitty, cause i already have two Core 3+ in use and need to equip my automation structure with accelerometers...
So the only possible and affordable way for a student would be an additional arduino, right?
Like in your blog-post (https://revolution.kunbus.de/blog/maker-herz/) described i don't need any additional parts or is the Modbus RTU USB-Adapter mandatory?
Thank you very much lukas for your detailed explanation!
All the best
So the only possible and affordable way for a student would be an additional arduino, right?
Like in your blog-post (https://revolution.kunbus.de/blog/maker-herz/) described i don't need any additional parts or is the Modbus RTU USB-Adapter mandatory?
Thank you very much lukas for your detailed explanation!
All the best
Re: RevPi Core 3+ - SPI Connection
Yes, the Arduino is supposed to be attached to the RevPi via an RS485 USB adapter (such as this one) and communicate with Modbus RTU. There's an Arduino Modbus RTU library available in the Downloads section of our support area (search for "Arduino Coupling" on that page). See this forum answer for some more details.
A relatively affordable ready-made USB accelerometer based on the ADXL345 is available on Tindie.
With some googling I've also found an interesting master thesis which lists multiple other product options, such as the industrial grade (but pricey) Digiducer 333D01.
http://jultika.oulu.fi/files/nbnfioulu-201705041660.pdf
http://www.modalshop.com/digiducer-333D01?ID=1168
A relatively affordable ready-made USB accelerometer based on the ADXL345 is available on Tindie.
With some googling I've also found an interesting master thesis which lists multiple other product options, such as the industrial grade (but pricey) Digiducer 333D01.
http://jultika.oulu.fi/files/nbnfioulu-201705041660.pdf
http://www.modalshop.com/digiducer-333D01?ID=1168