📜 ⬆️ ⬇️

We collect CarPC on Android: unfinished unfinished



My car suits me almost everything. There is almost everything you need. In the configuration bluetooth phone, push-button climate control, electric windows on all doors, heated seats, heated, adjustable and folding mirrors, chip key, CD-changer for 6 discs, but without MP3 and line-in. It was this unfortunate fact that led me to the idea of ​​starting to assemble my CarPC on the basis of android. Began to consider the options and rolled ... there were a lot of ideas.


There are many different variants of CarPC based on Windows, Androids, Linux, and even Macs on the thematic forums, but like most fans of picking up pieces of iron, I wanted to build my own unique one. For my CarPC, I put forward several requirements:

I chose Android because there is a lot of high-quality navigation, a lot of useful software, a lot of suitable devices and firmware for them, open source and it’s easy to write your code for it. I met ready-made solutions that satisfy certain requirements, but, to be honest, I did not really consider them, because Immediately did not like anything, and the price is often high with poor functionality. Therefore, I leave the problems of choice and move on to the custom version, which should be almost perfect for me.
')
Article review. The system is presented in general form and for each component of the system I want to show my vision of its implementation. Our carpc can consist of several devices. Separate modules, I tried to portray the connections between them like this:



All blocks are divided by degree of reliability:


Controller


The heart of the system is the “controller”. Its tasks include obtaining data from devices and sensors, processing this data and, if possible, managing it. If a controller and an Android tablet are connected, the controller transfers the collected data to the more “intelligent” Android program, and then it allows you to change controller settings, control other devices via the controller.

A little running ahead, I will give an example:
Let's say the android has hung, it reboots or the control program falls on it. At this time, an incoming call is being sent to the Bluetooth module from the phone. There is an opportunity to answer it with a button on the steering wheel. And it is implemented by the controller without the participation of the android. Since the controller is available information about the status of the steering wheel buttons and he sees that there is no connection with the android, he can implement such a primitive function as receiving a call by a short press, hang up for a long time. If everything is in order and the management program responds to it, then it will transmit information about the incoming call to the android, the android will draw a beautiful window and it will be possible to implement a more convenient functionality by means of the android itself. On the buttons on the steering wheel, android, too, will know accordingly. The same goes for the radio. Channel switching and volume control can be performed from the steering wheel without the participation of the android.

The basis of the controller, I suggest to take the stone STM32 . I mess around with the STM32F4-Discovery board, but of course it is possible to use other options. Personally, I find it somewhat harder to write C code under STM32 and not so conveniently than, say, python or node.js under Raspberry Pi. But the device on the STM32 is more suitable for these tasks. The logic is relatively simple and the code must be written, roughly speaking, to connect devices and handle simple commands. Plus, I think the STM32 based controller will be initialized much faster than the Raspberry Pi.

The tablet


I chose the first generation Amazon Kindle Fire as a tablet. I have been lying around for a long time, and its visible area of ​​the screen fits well in size in 2DIN. The dimensions of the case allow you to stick it without significant rework of the panel in the car. Relatively cheap, has a high-quality screen, a fairly powerful percentage and graphics. He has no extra buttons! In this case, it is rather a plus! There is a USB host, but I think you should not use it. Since it is supported only in custom firmware and when connecting several devices various floating glitches occurred. Stable work is not achieved ...
I think everyone knows that in the old Kindle Fire there is neither 3G, nor GPS, nor bluetooth, so I use the TP-LINK MR3020 for 3G and connecting external USB drives. This option is somewhat redundant, but for now let it be so.

Firmware


I think it is not worth much to cut the firmware itself, otherwise it will be problematic to update it. I would like to implement all the functionality purely by the application. But still, if it is convenient to do, then you can remove the battery icon (or show them the level of fuel in the tank, battery charge). The bluetooth icon is shown when connected to the bluetooth module of our CarPC phone and / or A2DP player, and also shows the level of the network of the cellphone connected via the bluetooth. It would also be nice to pick up a standard android dialer to your bluetooth module.

Communication controller with the tablet


Communication with the tablet on the android can be implemented in different ways. If there is a USB host on board, then you can use USB <-> UART , Ethernet . You can also via Wi-Fi , but I would like to have a reliable wired connection. I consider the use of the ADK to be the best way to implement the connection, the support of which has long been implemented even in the most recent versions of the android. In this case, fit any tablet and even a mobile phone on which you can put control software, connect the wire from the carpc to it, plug it into the holder. In addition, for the STM32F4 there is an implementation of the ADK protocol. Collected and checked. A test case worked with a tablet and a mobile phone. There are glitches, but you can figure it out. On Habré there is already material on a similar topic:
Android + Arduino = ♥
An old Android radio
USB devices for Android
Work with COM port in Android applications
COM port on Android

Just the other day I came across an FT311D chip from FTDI , which implements the ADK- based Android <-> interface (GPIO, UART, PWM, I2C Master, SPI Slave, SPI Master).
image
This solves a bunch of problems! I ordered, I wait. Allows you to use any device on the android and is quite cheap. So I decided to use it. As an interface, I like the good old UART . FT312D will also be out soon for similar tasks.

GPS


I would like to have a permanently enabled GPS with the ability to record tracks to a memory card, and their periodic synchronization with dropbox ... many opportunities for creativity appear! Tracks with good quality would be useful for the project OpenStreetMaps . To get accurate tracks, I would like to use a GPS module with support for Dead Reckoning technology. Uses additional data from the gyroscope, temperature sensor and speed to clarify the position in space, is calibrated while the signal is there, calculates the position of the sensors when the GPS signal is lost.

There is already a very worthy project based on the UBLOX LEA-6R chip.
image

It gives very good results compared to conventional GPS:
image
Comparison with conventional GPS tracks


Video of work with such GPS.

More pictures!
image
TC "Bela Dacha"

image
Several parking floors

image
After 2.5km Tonel took 7.5 meters

image
More parking

With such accuracy on the accuracy of tracks in OSM, soon and the number of bands can be calculated)
At the moment, the project seems to be podzagloh ...
I'd love to find a similar open source project. I bought the same UBLOX LEA-6R chip, tried to connect. Simple GPS data is obtained simply, with a gyroscope and odometer did not understand.
Noticed that on Habré there are fans of the Kalman filter . Perhaps this article will encourage those interested in realizing this on the basis of a controller and a conventional GPS chip, articles will help with the mat. part)

It would be nice to save the accelerometer data. In the future, according to the array of such data, one could try to automatically map bumps, dangerous pits, etc.

Phone


There is no Bluetooth in the tablet, and in the presence of little sense. When I started to address this issue, I did not find the implementation of the HFP profile under the android. You can connect with the headset, but the Android device could not act as a headset. You can use the Bluegiga WT-32 external module for this task.
image
Allows you to make / receive calls, monitor network settings, get call history, address book, supports A2DP , AVRCP and much more. Some developments are described here . This solution completely suits me: it can be controlled by the controller using buttons from the steering wheel without using a tablet, it works with all the phones I checked (modern HTC One X, HTC Desire, grandfather HTC Hero, some ancient Samsung, great-grandfather Qtek 8310, stub of the last generation)

Sound


With the sound at the moment, some uncertainty ...
Need to pick up the necessary components. I hope for your help!
There are several analog sources of stereo sound. It is necessary to mix them into one stereo channel and control both the overall volume and the volume of each channel separately via a digital interface. Plus, there can be a lot of speakers in the car (front / rear, etc.). It is necessary to take this into account somehow ... I found some ready-made microcircuits for these tasks, but I could not make up my mind with the solution.
The channels are approximately as follows:

Also the signal from the microphone from the car should go to the WT32 Bluetooth module and to the tablet (skype, hangouts, voice notes, etc.). It is advisable to somehow make an echo cancellation between the sound output to the amplifier and the microphone. Surely there is some ready-made solution.

FM Radio


So far I have used the primitive TEA5767 . There are enough examples of using the network ... instead of a boring and boring datasheet, you can start reading here FM STEREO Receiver on the TEA5767 module
As I wrote, I would like it to connect to the controller and not depend on the work of the android, but could be controlled and configured through the android.

There is also an interesting opportunity to use the famous RTL2832U .

Who will be interested in this chip will discover a lot of opportunities for the implementation of many cool ideas. There are already several topics about it:
Radio receiver 60-1700 MHz on RTL2832 for 20 bucks or SDR for beginners
USB TV tuners on rtl2832 - or how to hear everything on the radio for 600 rubles
The truth is the question with its connection. Since In my version of the usb tablet port is already taken. Then it is not entirely clear how and where to connect it. But if a USB hub is connected to the android and the exchange with the controller goes through some USB <-> UART module, then the problem is solved. However, I did not achieve stable operation of several devices via a usb-host on the Kindle Fire ...

Video Recording


Flew in from Korea BlackVue DR500GW-HD . He has GPS, accelerometer, WiFi and no screen! This is a significant advantage for me.
image
The skilled firmware for it is actively sawed by the custom firmware here , but the policy of distributing the firmware is not very pleasant, somehow everything is quiet, mail, there are no sources ... but the guys are great! Strongly pumped the functionality of this wonderful device.
By WiFi, live video from the camera and recorded videos can be watched through the android, save them. I think it is not very difficult to write software to automatically download GPS tracks, accelerometer data and even video from the recorder if WiFi speed allows.

Even a webcam can be adapted for the rear view camera. Connect via Raspberry Pi or some DIR320, MR3020 to the network. In the simplest case, look through the browser)

In general, it would be very nice to have a good mechanism for connecting several DVRs to your system for recording video directly to the hard disk. Something like an industrial video recorder for video surveillance.
In this regard, the Virt2real project is very encouraging to me . It seems to me that it is not quite suitable for such a task, but once there is some groundwork, it is possible that someone will write a more specific device with the specific task of collecting video from several remote cameras (met with remote HDMI cameras in DVRs) on the HDD, accessing the archive and managing via Ethernet, its API and / or SDK for third-party applications, open firmware and at a reasonable price! In general, there is something to work)

Another thought was to do something like an SD card proxy, i.e. connect the DVR instead of the SD card to the FPGA or a processor that would implement the interface of the memory card, but wrote the data over the network to a shared folder or via SATA on the HDD. But it is not so easy and he did not dare to do it himself. From the finished options almost nothing came across. There is www.eye.fi , but in this case it will not work. The connection is preferably wired, not the fact that it will stably hold a stream of 10-15Mb / s. With the help of such devices it would be possible to direct the recording from several DVRs to one Vinci.

We also have a topic “Car Satellite Alarm on STM32F1” , there are a lot of interesting ideas. And the idea about cameras based on the STM32F4 was very impressive.

Autostart


I would like to provide for the possibility of autorun. Solutions are different for each car, but in my case the Fortin EVO-ALL immobilizer tracker is suitable.
image
Small box with multiple connectors and three LEDs. It supports a lot of auto models from different manufacturers. It clings to several wires and allows you to start the machine without a key. Those. there is no need to leave one key in the car, which is required by many alarm systems with autorun and many insurance systems do not allow in the basic hull insurance contract.
Although autorun is separately separated from the CarPC functionality, I don’t have an alarm with autorun and don’t want to install it. This is not convenient, but in terms of protecting the car, I hope more for CASCO from theft. Therefore, the controller should send a signal to start by sms with an encrypted command, or by a call from a certain number in the simplest case. Many different options you can come up with. For this, it would be better to screw the GSM module to the controller. I think it is more reliable than a communication channel through the Internet. You can store the config in the controller’s memory or on the SD card, which will determine the sequence of actions after a successful launch. In the summer we turn on the condo, in the winter blowing the windshield, heated windows / mirrors, steering wheel, driver's seat, etc. This config Android can change and save to the memory of the controller. I would like to send the config to the dropbox and upload it to the controller with an automatic program on the tablet.

Tire Pressure Monitoring - TPMS


I haven’t followed the topic for a long time, but I remember that there were some developments that allow to get data into your device from the systems already existing on the market:
Tire Pressure Monitoring (USB TPMS)
Custom USB tire pressure monitoring interface
Stumbled upon an interesting piece from TI .

A small specialized module for these tasks TX-Module TPIC82000 Series , promise “Over 10 year life with 550mAhr Li-Coin battery” did not find on sale, but I would like to tinker.

Additional buttons, connectors


Honestly, there is a very big desire to avoid them altogether ... those regular buttons that are on the steering wheel and the console will most likely be enough, no additional homemade twists and buttons do not want to, because they can hardly be done qualitatively. The Kindle Fire has just one button, and that one is not always needed. In each car there is some inconspicuous panel, there you can install “service” buttons and connectors. They are extremely rarely needed. If, nevertheless, there is a need to use hardware buttons, then in my opinion it is better to make them touch-sensitive and position them right under the plastic of the panel. You can use specialized controllers Atmel QTouch , QMatrix . There are buttons, sliders, circles, and it seems to be fine through the plastic panel should work.
image
However, this issue is solved individually in each case, perhaps in some cars there are suitable spins and a place under the display.

Voice control


For the most part, this task is already being solved in android, there is already some functionality there, and also saw some third-party engines for speech recognition, creating voice commands. Honestly, if it were not for the Google voice search, I especially would not want to mess around with it. According to my tests, he recognizes quite well even a variety of arbitrary commands. But ideally, I would like a good offline recognizer. I want to remind you that we have a very interesting topic “Speech Recognition on STM32F4-Discovery” , so you can try to do the same with the microcontroller.
It is not quite clear how to catch the team itself from the whole stream of speech, music, noise and extraneous sounds. In my opinion, the system must be given a name. Suppose there is any Johnny :) Then next to the name that skipped over in the general flow of speech, you can search for the keywords of the command. Write to the buffer, say, 5–10 seconds of sound, detect a given name with some effective offline algorithm, and if it is caught, then process a piece before the name and a little after. The calculated “fingerprint” of the phrase is sent to the Google server, we get the phrase string and look for keywords, analyze the request. You can implement something like control wheelbarrow, navigation, etc. phrases in the style of "Johnny, close the windows", "Johnny, open the trunk", "Johnny, let's go to work ...", "Drive home, Johnny!".
If you have implemented or have plans for a smart home, then you can try to combine and process the commands, taking into account the fact that you can make a request to the house from the car and vice versa. For example, to find out if electrical appliances are turned off at home or to immediately de-energize the circuit of all sockets, turn on heated floors before arrival, condos, etc.

It may be necessary to implement the issuance of any messages by voice (for example, reading incoming SMS). Unfortunately, I did not deal with this issue closely, but the readers seemed to be able to recite the text for a long time ... you can pick up something for such a system.

Nutrition


Regarding the issue of powering all this zoo devices, we have a great topic "Solder an" intelligent "car BP ..." . For our devices, you also need to get 3.3V, but as it says “by default the KIS-3R33S module is set to 3.3V”. And having a stable and reliable power supply in 5V is not difficult for us to get 3.3 directly on the board, using some economical and reliable DC-DC Step-Down converter or 78L33 roll . Of course, if a car battery sits down, the devices need to be turned off, system control is needed. Perhaps it makes sense to put a small battery backup power for critical systems such as autorun.

Various buns


Since we have the ability to connect to the machine, we can receive data from it and partially manage it. You can implement things that are not in every car. For example:


Web access


Of course, it is desirable to pick up the system on any server. Collect statistics, tracks, update the state of the machine, allow editing settings, watching camera images (if installed), etc. It can even make an API for a mobile application on it. But I will not dwell on this, because this is a familiar topic for 99% of the habrids and in the topic “Automotive satellite signaling on STM32F1” this question has already been raised.

Not saying goodbye...


It seems that this is all I wanted to talk about. At the moment this project exists in the form of separate demos, a handkerchief, notes with pieces of code and parts hanging on the welded wires. For each item, it would be nice to write a small separate topic more seriously, with technical details, examples of commands, links to github, divorced printed circuit boards, etc. So far, unfortunately, no. Hopefully, things will move on and something similar will appear!

PS I apologize for the hells of photoshop in the header of the topic ... drew as I could)
Write your ideas, comments, leave useful links ...

Source: https://habr.com/ru/post/181996/


All Articles