Car project

A place to showcase LattePanda creations!
User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Sun Sep 25, 2016 4:34 pm

So, as many people I wanted to do the pc in car.
but I never used an arduino etc... however I used to programming and got intermediate knowledge of electronics.
So project is to put LP as heart of multimedia, My car is an audi a3 from 2005 year with single din concert II (2) radio. I wanna to pin LP as cd changer (got connector with analogical audio input + clk + signal in and out and V+) with possibility to use signal code to communicate between radio and LP (play pause next etc...). Then need to implement some battery as temporary power source for cranking time, and as psu when is without power from car that need to last at least in sleep mode for 1-2 days (the LP will go to sleep mode instead of power on/off any time I use car).
Before I used the 2connects device to emulate the cd changer and use usb drives for playing mp3 songs.
Meanwhite I'm looking if with arduino on LP I can use it like programmer for get the codes to and from radio for each command. this device using STM32F102C8T6 to interface radio and USB reader chip (bu9458kv). Or if not implement an code to listen binary code with freq. of 16kHz and just plug it to radio and then from codes read use them as commands to LP.
So for this I need to know if I can look inside it and see commands codes, how i can control the windows player with LP and then if LP can generate clock of around 16kHz?
About programming, meanwhile I didn't got LP I've done simple c++ program that simulate impulse from radio to LP and viceversa:

Code: Select all

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <wmp.h>

int pin1; // pinout of arduino for see if the power is from battery or if its from car

void Play (void);
int a
void main (void){
	pin1 = 1;
	system("color f9");
	if(pin1==0){
		Sleep(2000);
//		 system("%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby");
		return;
	}
	else Play();
	return;
}

void Play (void){
	char p='0';
	while (pin1!=0){
		printf ("enter char:\n");
		char b; b = getch();
		if (b=='0'){
		  return;
		}
		if ((b=='p')&&(p=='0')){
//			m_BackgroundPlayer.GetControls().play();
			printf ("\nplay\n");
			p='1';
			b='1';
		}
		if ((b=='p')&&(p=='1')){
//		    m_BackgroundPlayer.GetControls().pause();
			printf ("\npause\n");
		    p='0';
			b='1';
	    }
		if (b=='s') printf ("\nstop\n"); //b=='s' is as code sent form radio on button press and printf is as action to do in player
		if (b=='n') printf("\nnext\n"); //effective code should be like if(b=='0101010010110') WMPlayer(next);
		if (b=='b') printf("\nback\n");
		if (b=='j') printf("\nnext playlist\n");
		if (b=='h') printf("\nback playlist\n");
		if (b=='q') printf("\nforward\n");
		if (b=='w') printf("\nrewind\n");
//		itoa(pin1,b,10);
	}
	return;
}

After all I will need to stepdown and stepup the signal as I think that signal from radio coming in 12v

User avatar
LattePanda
Site Admin
Posts: 2472
Joined: Wed Jan 20, 2016 9:09 am

Wed Sep 28, 2016 7:33 am

marek196c wrote:So, as many people I wanted to do the pc in car.
but I never used an arduino etc... however I used to programming and got intermediate knowledge of electronics.
So project is to put LP as heart of multimedia, My car is an audi a3 from 2005 year with single din concert II (2) radio. I wanna to pin LP as cd changer (got connector with analogical audio input + clk + signal in and out and V+) with possibility to use signal code to communicate between radio and LP (play pause next etc...). Then need to implement some battery as temporary power source for cranking time, and as psu when is without power from car that need to last at least in sleep mode for 1-2 days (the LP will go to sleep mode instead of power on/off any time I use car).
Before I used the 2connects device to emulate the cd changer and use usb drives for playing mp3 songs.
Meanwhite I'm looking if with arduino on LP I can use it like programmer for get the codes to and from radio for each command. this device using STM32F102C8T6 to interface radio and USB reader chip (bu9458kv). Or if not implement an code to listen binary code with freq. of 16kHz and just plug it to radio and then from codes read use them as commands to LP.
So for this I need to know if I can look inside it and see commands codes, how i can control the windows player with LP and then if LP can generate clock of around 16kHz?
About programming, meanwhile I didn't got LP I've done simple c++ program that simulate impulse from radio to LP and viceversa:

Code: Select all

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <wmp.h>

int pin1; // pinout of arduino for see if the power is from battery or if its from car

void Play (void);
int a
void main (void){
	pin1 = 1;
	system("color f9");
	if(pin1==0){
		Sleep(2000);
//		 system("%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby");
		return;
	}
	else Play();
	return;
}

void Play (void){
	char p='0';
	while (pin1!=0){
		printf ("enter char:\n");
		char b; b = getch();
		if (b=='0'){
		  return;
		}
		if ((b=='p')&&(p=='0')){
//			m_BackgroundPlayer.GetControls().play();
			printf ("\nplay\n");
			p='1';
			b='1';
		}
		if ((b=='p')&&(p=='1')){
//		    m_BackgroundPlayer.GetControls().pause();
			printf ("\npause\n");
		    p='0';
			b='1';
	    }
		if (b=='s') printf ("\nstop\n"); //b=='s' is as code sent form radio on button press and printf is as action to do in player
		if (b=='n') printf("\nnext\n"); //effective code should be like if(b=='0101010010110') WMPlayer(next);
		if (b=='b') printf("\nback\n");
		if (b=='j') printf("\nnext playlist\n");
		if (b=='h') printf("\nback playlist\n");
		if (b=='q') printf("\nforward\n");
		if (b=='w') printf("\nrewind\n");
//		itoa(pin1,b,10);
	}
	return;
}

After all I will need to stepdown and stepup the signal as I think that signal from radio coming in 12v
thanks for sharing, please keep us updated!
Enjoy Tinkering with LattePanda ! :lol:

User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Wed Sep 28, 2016 10:27 am

Hi, little update (as still waiting for more parts cables etc...) got the gps module GY-NEO6MV2, and power bank 10000mah (is with usb c, model yn-037t) by the way the usb c could be implemented to LP instead of micro usb as power port, about programming nothing new as can't do nothing w/o getting all parts. By the way will need help with programming interface (commands to use).

User avatar
LattePanda
Site Admin
Posts: 2472
Joined: Wed Jan 20, 2016 9:09 am

Wed Sep 28, 2016 10:31 am

marek196c wrote:Hi, little update (as still waiting for more parts cables etc...) got the gps module GY-NEO6MV2, and power bank 10000mah (is with usb c, model yn-037t) by the way the usb c could be implemented to LP instead of micro usb as power port, about programming nothing new as can't do nothing w/o getting all parts. By the way will need help with programming interface (commands to use).
USB c has been suggested a few times on here, and it is a valid suggestion. assuming it is implemented in a board revision, it will be some time before it is pushed out to market. sorry! is there no alternative?
Enjoy Tinkering with LattePanda ! :lol:

User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Wed Sep 28, 2016 9:14 pm

Hi, I mean (about usb c) that should be a good idea to use it as support much more power (i mean current). The power bank that actually I got uses also usb charge but up to 2.1A (however booted LP without problems) now the psu for car will be approx. DC to DC converter 5V 3A + power bank for shut down + capacitor for cranking, capacitor will need to last about 10 sec, so assuming that LP consuming an average of 2.5A on boot (prefer to excess with values for margin) and it need to hold for 10 sec. so 0.7mah would be fine. That converting to Farad scale would be 0.5F, but is better to find more popular 1F, 1,5F on 5.5V. taht will be charged in instance when key turned to accessory and keep LP booting or working for (incase of 1,5F) 30 sec.
And what about some conversion pcb from flat display cable to normal cable? or longer cable? as in my case will need around 1,5m of it.

User avatar
LattePanda
Site Admin
Posts: 2472
Joined: Wed Jan 20, 2016 9:09 am

Thu Sep 29, 2016 3:29 am

marek196c wrote:Hi, I mean (about usb c) that should be a good idea to use it as support much more power (i mean current). The power bank that actually I got uses also usb charge but up to 2.1A (however booted LP without problems) now the psu for car will be approx. DC to DC converter 5V 3A + power bank for shut down + capacitor for cranking, capacitor will need to last about 10 sec, so assuming that LP consuming an average of 2.5A on boot (prefer to excess with values for margin) and it need to hold for 10 sec. so 0.7mah would be fine. That converting to Farad scale would be 0.5F, but is better to find more popular 1F, 1,5F on 5.5V. taht will be charged in instance when key turned to accessory and keep LP booting or working for (incase of 1,5F) 30 sec.
And what about some conversion pcb from flat display cable to normal cable? or longer cable? as in my case will need around 1,5m of it.
good idea, your suggestion is noted.
as for the cable, we are collecting information about this and have plans for an adapter, but there is no firm timescale for it right now. i will open a thread about it so we can have more focused feedback
thanks for your feedback
Enjoy Tinkering with LattePanda ! :lol:

User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Thu Sep 29, 2016 8:19 pm

Ok, about lcd / touch cable, there is no possibility to buy the spare fpc connectors and male to male cables to do my own the pcb?

User avatar
LattePanda
Site Admin
Posts: 2472
Joined: Wed Jan 20, 2016 9:09 am

Fri Sep 30, 2016 8:46 am

marek196c wrote:Ok, about lcd / touch cable, there is no possibility to buy the spare fpc connectors and male to male cables to do my own the pcb?
yeah thats also possible. i will find part numbers and names and get back to you
Enjoy Tinkering with LattePanda ! :lol:

User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Sat Oct 01, 2016 10:05 pm

ok, some progress in here, after some hours of searching on internet I found code needed without any oscilloscope to measure bits on it (thx to google) so if anyone will need code to do something like this click here. now will elaborate it to arduino on LP and interface it to windows.

User avatar
marek196c
Posts: 20
Joined: Thu Sep 08, 2016 6:37 pm

Sun Oct 02, 2016 9:10 pm

A bit of update about the coding:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using LattePanda.Firmata;

#define CDC1 0x53
#define CDC2 0x2C

#define END_CMD 0x14
#define PLAY 0xE4
#define STOP 0x10
#define NEXT 0xF8
#define PREV 0x78
#define SEEK_FWD 0xD8
#define SEEK_RWD 0x58
#define CD1 0x0C
#define SCAN 0xA0
#define SFL 0x60
#define PLAY_NORMAL 0x08

#define MODE_PLAY 0xFF //random off
#define MODE_SHFFL 0x55 //random on
#define MODE_SCAN 0x00 // play until 5 sec of song and skip

#define byte unsigned char

byte *b1;

namespace CDC;
{
	class Program 
	{
		static Arduino = new Arduino();
		static void Main(string[] args)
		{
// note 1
			arduino.wireBegin(0);
			arduino.wireRequest(CDC1, CDC2, 4, Arduino.I2C_MODE_READ_ONCE);
			arduino.wireRequest(CDC1, CDC2, CD1 END_CMD, Arduino.I2C_MODE_WRITE);
			arduino.wireRequest(CDC1, CDC2, PLAY END_CMD, Arduino.I2C_MODE_WRITE);//note 2
			void Loop()
			{
				arduino.wireRequest(CDC1, CDC2, b1, Arduino.I2C_MODE_READ_CONTINOUSLY);//note 3
				if(b1==PLAY)//note 4
			}
		}
	}
}

/*
P.S. the code is resoult of my understanding of page posted before with codes to radio and LP docs page about I2Cs
Notes:
note 1: till now initialize program and communication with Arduino + declaring global variables
		program starts here
note 2: cdc1 and cdc2 should be address and header of device as they repeat continuously
		so only 3rd byte interested me as they are 8bit ones
		so 2 of them are 16bit and matching perfectly the variable.
		However here I just initializing/sending info to enable audio.
note 3: here we start to read input from radio per each byte incoming
note 4: triggering byte if interesting us,
		then will implement command to open player or play if opened and paused
		next if and elses will be about all actions such pause etc...
*/
someone can check and explain better functions wirerequest and tell me if I can use normal ones such provided on arduino forum (bcs is bigger is much faster find answers without loosing time) and how i can check addresses?

Post Reply