How to make Raspbian recognize SPI input from ADC as a soundcard - raspberry-pi

I have an analog to digital converter (ADC) MCP3008 connected to Raspberry PI 4 via SPI interface.
I need to process the signal from ADC in ODAS library (Open embeddeD Audition System).
ODAS is capable to process signal from a device in real time, but requires the device to be a soundcard.
Therefore I need to make Raspbian recognize SPI input from ADC as a soundcard.
After googling I found out that I need to write a device tree overlay to describe the soundcard.
I read about device tree overlays and viewed the device tree specification, but still can't figure out, which nodes and properties should I describe in the overlay?

Related

How to send data from STM32 USB port to Raspberry PI USB port?

I want to send data through USB between STM32 and Raspberry Pi. I don't want to use USB to Serial convertor, but instead have a actual USB Connection (maybe CDC class). I have to send data at high rate (Full speed). Please guide on how to achieve this?
A USB-serial connector is simply a microcontroller implementing a USB CDC/ACM virtual COM port and bridging to a UART which you would connect to a microcontroller's UART interface.
In your case you can simply implement the CDC/ACM directly on the STM32 using either of its USB device controller peripherals (USB support varies depending on the specific device https://www.st.com/resource/en/application_note/dm00296349-usb-hardware-and-pcb-guidelines-using-stm32-mcus-stmicroelectronics.pdf).
How you actually implement that will depend on what specific part, and what library or framework ecosystem you are using (e.g. SPL, CubeMX, Mbed). There are reference implementations, examples, drivers and libraries for all of these.
Your milage may vary, but I have measured ST's own USB library and example CDC/ACM virtual COM for STM32F1xx on a 72MHz MCU achieving 700kbits/s. Note that the performance is independent of the baud rate you might set on the host when you open the he VCP. Setting the baud rate simply sends a control packet to the device that can be used to set the baud rate of a UART in bridging applications. In your case such control packets can be ignored. There are similar packets for modem control signals such as DTR, RTS, CTS and RI, which you might choose to us for flow control or other signalling.

Application design recommendations for embedded Raspberry Pi with screen reading GPIO & i2c

I am creating a simple car dashboard cluster using a Raspberry Pi 4 with a 7in screen and using an 8 channel ADC hat and the GPIO pins for sensor input.
The GPIO pins will be used to read the state of various switches in the car using a step down converter so that when a switch is on 12v from that switch will be converted to 3.3V and send to a GPIO pin so it will be high.
The ADC will be used to read the values of various 5V sensors in the car like oil pressure, coolant temp etc.
The screen is a basic HDMI 7in screen with the Pi mounted behind it and I plan to 3D print a new gauge cluster bezel to fit everything into the stock location. I have a Mausberry power controller so that the Pi will turn on with key on and turn off again with key off. I have modified the Pi so it boots from SSD and starts up pretty quickly.
I have used simple Python programs to read the data from the ADC over i2c and the GPIO pins and output it, no issues there. I have found a nice Javascript based library called Justgage which looks like a great way to display my data in a simple HTML page and have designed my page layout with the various gauges and lights that will eventually have the data read from the ADC or GPIO pins.
What I need some advice on is how best to architect the overall solution, I have all the various parts but need to integrate them. I want to minimise the amount of software running on the Pi so it boots quickly.
At the moment when the Pi boots it auto loads Chromium and opens my page I have created but I need a method to be able to read the i2c and GPIO data and then refresh the elements in the HTML page. The Justgage library supports refreshing the data so that I don't have to refresh the page and would like a method to read the data every second or so and then call the Justgage refresh function.
All the examples of this sort of model I can see online use a webserver running on the Pi but as the screen is directly connected to the Pi I don't actually need a webserver and would like to minimise the amount of software running for reliability and boot times.
Sorry for the long first post and appreciate any guidance. Happy to post the HTML if that would be of any help.
Cheers
Matt.

How to make Raspberry Pi to be a VoIP ATA Device

I want to make a VoIP ATA (Analog Telephone Adapter) Device using Raspberry Pi, furthermore, I also want to add FXS ports to the Raspberry Pi. Kindly, tell me whether it is possible or not. If Yes, then how?
Here is the
Reference Link
This is probably possible, but not with the Pi alone.
You will need to design and build some external circuitry to convert between telephone line audio (which apparently runs at 48 volts) and audio signals which the Pi can produce. Also it looks like the Pi has no audio input, so you might need to either add a USB audio device or use an analog to digital converter that the Pi has to read the audio signal coming in from the phone line, if it can be polled fast enough.
You might have better luck with a board that has a real microphone jack on it already, instead of the Pi.
Then on the software side you need to attach the audio out, whatever you are using to get audio in, and any circuitry you need to open/close the circuit or send special ring voltages to your VoIP software of choice. Working out how to write that driver code is going to depend heavily on what physical circuit you actually build and what VoIP software you want to have talk to it.
That link above has a design for a line-level audio to phone audio conversion circuit which may help you get started. You could also take the circuitry part of the project over to the Electrical Engineering StackExchange site.

Coding Raspberry Pi with an ADC - SPI

I am trying to connect an analogue to digital converter to the raspberry pi. As far as I am able to understand, the RPi doesn't support Bi-directional SPI mode. The adc I am using says it is SPI compatible but only has the inputs SCLK, CNV and outputs CLKOUT+ and CLKOUT- and SD0+ and SD0-. This leads me to understand that it will only work with bi-directional SPI as there is only the serial data out. I am thinking of using a PWM for CNV (which I think CE), GPIO clock for SCLK and then an interrupt on the falling edge of the GPIO clock to just digitally read each bit from the adc. I don't understand SPI in detail but from what I've read quite often it requires sending data in order to receive it. Do you know if the setup I mentioned (without using SPI) will work? Or am I missing something about SPI and the adc will work with that while not in bi-directional mode?
We are using the Raspberry Pi 3 b
adc - http://cds.linear.com/docs/en/datasheet/232316fa.pdf
Thanks for any help you can provide.
Read the data sheet carefully, in particular pages 8 and 9. I suggest that you tie CMOS/LVDS pin to ground to enable CMOS mode. Then use only the "+"-pins. Use the SCK for SPI clock, SD01+ for SPI data input to the Rpi. Connect a GPIO pin to CNV.
Also observe that the RPi runs at 3.3V, and the ADC's max rating is also 3v3, that is running the IC right to the edge.

arduino +odroid (linaru ubuntu with eclipse and opencv) + usb camera

I hope you can help me. I am trying to build a robot but I am kind of stuck. The Arduino Mega is controlling the stepper motors drivers of the robot. The odroid-x is a single board computer that has installed linaro ubuntu and eclipse c++. All the programming is done in C++ and OpenCV is an image processing library.
The odroid-x has only as input a color camera. Therefore, the information from the camera is received and is processed in eclipse. Then, according to the information that is received, the odroid-x should send different integers to the arduino. The arduino should have a program already uploaded in itself, so it will be waiting for an integer and that integer is going to determine what the arduino is going to send to the drivers.
My questions are the following:
How can I do a serial communication between the arduino and the odroid-x?
How can I send information from eclipse to the arduino with a serial connection?
Thanks so much for any guide you can give me
First, be very, very, very careful. The ODROID boards use 1.8V signalling, so hooking up your 3.3V or 5V Arduino to the pins that expect no more than 1.8V will give you a burnt ODROID-X. It is possible to hook these two boards together if you put a level converter between them, and Sparkfun and Adafruit have some of those converters available. There is even a 1.8V reference voltage pin available... one of the pins that go to the LCD panel RGB-to-LVDS converter board puts out a constant 1.8V.
You could use either the four pins of the little white connector, or UART1, as a serial port, or you can use some of the pins in the 50-pin GPIO block as UART4. There are board schematics available on Hardkernel's website. These two UARTs show up as /dev/ttySAC0 (UART1) and /dev/ttySAC3 (UART4).
I don't know how to talk to those UARTs from a program, personally, but I know there are serial communications libraries available for python from watching threads pop up on the ODROID forums.