Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Login


4 Pages123>»
Options
View
Go to last post Go to first unread
Possum  
#1 Posted : Saturday, June 9, 2018 1:24:32 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
My Arduino class library for the ES9028/38 chip is now available here at Github

If you want to configure the ES9028/38 in dual mono, quadrophonic, implement a 2, 3, or 4 way digital x-over, or control multiple DACs, then this is for you - and of course, the Arduino allows you to easily add remote control, LCDs, etc to your project.

Example code snippet for quadraphonic configuration (see the example programs for a more complete overview of programming with the library):

// map DAC channels 1-4 to inputs 1 & 2 (first I2S right/left data input),
//and DAC channels 5-8 to inputs 3 & 4 (second I2S right/left data input)
dac.mapInputs(ES9028::Input_1, ES9028::Input_2, ES9028::Input_1, ES9028::Input_2, ES9028::Input_3, ES9028::Input_4, ES9028::Input_3, ES9028::Input_4);


Note that the code example above will not work with stereo boards such as the BIII SE PRO but works a treat for chips transplanted onto the old BIII 8-channel board

(There is also a completely rewritten version of my ES9018 library there as well)

Enjoy!

Poss

Edited by user Tuesday, June 12, 2018 1:17:30 AM(UTC)  | Reason: Not specified

meo  
#2 Posted : Monday, June 11, 2018 11:27:36 PM(UTC)
meo

Rank: Member

Groups: Member
Joined: 2/17/2016(UTC)
Posts: 5

Thanks: 1 times
Sounds interesting! I'l have a look at it.
Very nice of you to make your library public.
Marcel
Possum  
#3 Posted : Tuesday, June 12, 2018 12:39:07 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
I started playing around with Arduino control a few years back when I wanted to play with the bandwidth register setting on a BII. Now I do all of my builds with Arduino as it opens up heaps more build possibilities - e.g.: ir/bluetooth/wifi control - and is easy to debug issues real-time using a PC and the Serial Monitor interface (applying updates is easy too).

I managed to learn the requisites based on DimDim's Arduino code (as well as from Russ's on-board firmware code) - however, it was still a heap of work transforming those solutions into something custom when you're dealing with registry bits 'n bytes - even for an IT pro like myself.

DimDim's Arduino projects combined user interface code for the LCD and remote control with the DAC control code into one large code base - fine if you want to build a similar project, but not so great if you had to unravel the code because, for example, you didn't want to use an LCD, or had a different number of DACs (or even a mixture of ES9018/28/38s!). So I decided to write an object-oriented library that separates and encapsulates all the DAC-specific behaviour - thus completely abstracting the user from all those pesky registry addressing and bitwise settings, and separating that code from the UI-specific code.

Hopefully the library makes it easy enough for even a novice programmer to use.

Another big advantage of this coding approach is that it is easy to create user interface libraries that interact with the DAC classes - such as DAC remote control, LCD, and indicator light libraries - so anyone with basic programming skills can quickly program a custom build by plugging together the various DAC user interface libraries they need for their build (you can tell I have an OO software background :-) )

Here's an example of the main code to control 3 different DACs in a 3-way xover, add support for a power button, lock, power, and input indicator LED, motorised volume control pot, and infra-red remote control:

#define NO_OF_ES9018_DACS 1
#define NO_OF_ES9028_DACS 2
ES9018 lowDAC = ES9018("Front Right Low", ES9018::Clock100Mhz, ES9018::MonoRight, ES9018::InPhase, 0x48);
ES9028 midDAC = ES9028("Front Right Mid", ES9028::MonoRight, 0x49);
ES9028 hiDAC = ES9028("Front Right High", ES9028::MonoRight, 0x47);

DACControl dacCtrl = DACControl(es9018dacs, NO_OF_ES9018_DACS, es9028dacs, NO_OF_ES9028_DACS);
DACPowerButton powerButton = DACPowerButton(&dacCtrl, DigitalPins::POWER_BTN);
LightControl indicatorLight = LightControl();
DACVolumeControl dacVolCtrl = DACVolumeControl(&dacCtrl, AnalogPins::POT_INPUT, DigitalPins::POT_MOTOR1, DigitalPins::POT_MOTOR2);
IRrecv irrecv(DigitalPins::IR_RECV);
DACRemoteControl dacRemoteCtrl = DACRemoteControl(&dacCtrl, &dacVolCtrl, &irrecv);


A lot of work went into this. Hope you find it useful!

Edited by user Tuesday, June 12, 2018 12:58:32 AM(UTC)  | Reason: Not specified

thanks 3 users thanked Possum for this useful post.
fred_com on 6/12/2018(UTC), MartinC700 on 6/15/2018(UTC), branko on 1/16/2019(UTC)
MartinC700  
#4 Posted : Friday, June 29, 2018 7:01:47 PM(UTC)
MartinC700

Rank: Advanced Member

Groups: Member
Joined: 9/7/2010(UTC)
Posts: 43
Location: San Diego

Thanks: 1 times
Hi Poss,

I love the idea of converting control of my 9038 to i2s but I'm currently running the modded onboard firmware that runs sync mode as well as allowing switching between serial and SPDIF modes. Any chance that you may be able to add those functions to the library in the future? (and I do know how much work that would be so apologies for even asking!)


Cheers
Possum  
#5 Posted : Tuesday, July 3, 2018 12:43:54 PM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Your ready to go - All the functions are already there! (not tested tho)

SPDIF functions and switching between modes:

bool setInputSelect(InputSelect val); // Configures the SABRE DAC to use a particular input decoder if auto_select is disabled.
bool setSPDIFUserBits(SPDIFUserBits val); // Setting user_bits will present the SPDIF user bits on the read-only register interface instead of the default channel status bits.
bool setSPDIFDataFlag(SPDIFDataFlag val); // Configures the SPDIF decoder to ignore the ‘data’ flag in the channel status bits.
bool setSPDIFValidFlag(SPDIFValidFlag val); // Configures the SPDIF decoder to ignore the ‘valid’ flag in the SPDIF stream.
bool setAutoSelect(AutoSelect val); // Allows the SABRE DAC to automatically select between either serial, SPDIF or DSD input formats
bool setSPDIFInput(SPDIFInput val); // Selects which input to use when decoding SPDIF data. Note: If using a GPIO the GPIO configuration must be set to an input.


Sync/async functions:

bool enableMasterMode(); // Enables master mode which causes the SABRE DAC to derive the DATA_CLK and DATA1 signals when in I2S mode
bool disableMasterMode(); // Disables master mode
bool setMasterDiv(MasterDiv val); // Sets the frame clock (DATA1) and DATA_CLK frequencies when in master mode.
bool enable128fsMode(); // Enables operation of the DAC while in synchronous mode with a 128*FSR MCLK in PCM normal or OSF bypass mode only.
bool disable128fsMode(); // Disables operation of the DAC while in synchronous mode with a 128*FSR MCLK in PCM normal or OSF bypass mode only.
bool setLockSpeed(LockSpeed val); // Sets the number of audio samples required before the DPLL and jitter eliminator lock to the incoming signal.
bool setSPDIFInput(SPDIFInput val); // Selects which input to use when decoding SPDIF data. Note: If using a GPIO the GPIO configuration must be set to an input.
SCompRacer  
#6 Posted : Monday, October 15, 2018 4:03:01 PM(UTC)
SCompRacer

Rank: Member

Groups: Member
Joined: 1/6/2012(UTC)
Posts: 305
Location: Plainfield, IL

Thanks: 11 times
Was thanked: 26 time(s) in 21 post(s)
Wow, very nice of you to share!

Myself, I just need working code for simple BIIIse 9028 Pro in stereo.

First off, high marks to Dimitris, or dimdim, for providing a shield and code for the 9028/9038 boards. But I cannot get it to work with my BIIIse 9028 Pro. He is using a BIII 9018 board with 9028 chip installed. I don't know if that has anything to do with it.

I've tried a new shield with professionally installed chips to remove me as a possible problem attaching chips, still no go. He has been very helpful via email to try and get it to work. Using scanner code, dimdim shield will connect and identify 9028 from Arduino side, but not from shield isolator side powered by BIII. I get no dac or error with address. Using scope I get same SDA/SCL signal on isolator side as Arduino non isolated side.

My previous DAC is a dual mono BIII with Corpius code and shield and it works great.

I am code challenged so I am stuck with my BIIIse 9028 Pro on cookie sheet.

Edited by user Monday, October 15, 2018 4:08:14 PM(UTC)  | Reason: Not specified

Possum  
#7 Posted : Monday, October 15, 2018 5:05:38 PM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
I use a 2nd arduino running as an I2C slave to test isolator. Lets u see whts going on. Can send u tbe sketch if u want
branko  
#8 Posted : Wednesday, January 16, 2019 11:17:44 AM(UTC)
branko

Rank: Member

Groups: Member
Joined: 3/23/2010(UTC)
Posts: 53
Location: Germany

Thanks: 1 times
Hi, tried to read through your code. But unfortunately I am to noob.

I want to set a BIIIpro 9038 in stereo mode and use the spdif and I2S input for sources.

How would I have to use your library and how would I make the connections from an Arduino to the BIIIpro.
Would like to set the "default" values for the 9038 registers. But would like to "play" with different settings after.

I have an Arduino due with Dimdims shield which is working fine with BIIIse.

Would like to set up a DAC with small LED-Matrix display (I build a small 8x64 Matrix display which should only display source and sampling rate) and remote control (optional). Did that before with the original Hifiduino code.

thank you in advance

Branko
Possum  
#9 Posted : Wednesday, January 16, 2019 10:51:27 PM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
The I2C connections to BIIIpro are the same as for BIIIse - and you need to use an I2C isolator like on DimDims shield

However, in addition you will need to pull the DAC reset pin high to enable it. I use an optocoupler to do this (don't know if DimDims board has something similar). Please read the description on my githuib page here: https://github.com/possum64/BuffaloDAC

The I2S connections are also the same as on the BIIIse - however, you can configure the DAC to use any of 13 possible SPDIF inputs via the setSPDIFInput() func (eg: dac.setSPDIFInput(ES9028::DATA8) makes data input 8 the SPDIF input). You can even use GPIO pins. So its possible to simultaneously have I2S connected and also have multiple SPDIF inputs connected to the unused data and GPIO pins and use the setSPDIFInput() func to switch between them via the Arduino (no Sidecar needed).

I will have to check Russ's firmware code to see which input the BIIISEpro board is using for the SPDIF in (I never use SPDIF so I don't know off the top of my head..).

You can switch input select via the setInputSelect() function - e.g.: switch to SPDIF input by calling dac.setInputSelect(ES9028::InputSelect_SPDIF) or select I2S via dac.setInputSelect(ES9028::InputSelect_Serial)

I have not included the sampleRate() function in the ES9028 library yet but can do so if you need it.

The code to initialise the DAC in stereo I2S is straightforward:

#include <ES9028.h>

ES9028 dac = ES9028("My Stereo DAC", ES9028::Stereo);

void setup() {
// initialize digital pin LED_BUILTIN as the DAC lock light.
pinMode(LED_BUILTIN, OUTPUT);
// wait for SR trident regulators to ramp up to full voltage
delay(1500);
// put code here to pull DAC Reset Pin high to enable the DAC
//...
if (dac.initialise())
{
dac.mute();
// default to I2S input
dac.setInputSelect(ES9028::InputSelect_Serial);
// init GPIOs 1 and 4 to same as BIII
dac.setGPIO1(ES9028::GPIO_Automute);
dac.setGPIO4(ES9028::GPIO_Lock);
//play with settings
dac.setSerialBits(ES9028::Bits_24); // set 24 bit I2S source
dac.setDpllBandwidthSerial(ES9028::DPLL_Lowest);
dac.setFilterShape(ES9028::Filter_Hybrid);
dac.setAutoMute(ES9028::AutoMute_MuteAndRampToGnd);
dac.setAutomuteTime(100);
dac.unmute();
}
}


void loop() {
if (dac.getInitialised())
digitalWrite(LED_BUILTIN, dac.locked()); // turn the LED on if both DACs locked
delay(100);
}

Edited by user Thursday, January 17, 2019 5:21:32 AM(UTC)  | Reason: Not specified

branko  
#10 Posted : Thursday, January 17, 2019 8:01:57 PM(UTC)
branko

Rank: Member

Groups: Member
Joined: 3/23/2010(UTC)
Posts: 53
Location: Germany

Thanks: 1 times
Thank you very much for responding that fast and friendly :)

to make things clear: just bought the Arduino cookbook for beginners (here in Germany).
So there maybe lots of questions coming up. As in my surrounding nobody is into programming I do not have lot of help here.
If you do mot mind I would like to ask for your kind help in getting started (and ready).

My goals are: stereo Dac BIIISEpro with two I2S inputs and two Spdif inputs.Thoose inputs should be selected with a pushbutton on front panel (maybe "revolving"). The display should be a small LED Dot matrix Display 8x64 dots (which have build already with I2C, will post picture later).
this display should show in short only the source i.e. CD, TV, BBB and the sampling rate of the played music--->

CD____44.1kHz TV____48kHz BBB___DSD64 and so on.

Also I would like to store the setting for filters, DPLL etc. per input.

Sorry if I bother you too much.

BR

Branko
Possum  
#11 Posted : Thursday, January 17, 2019 9:03:03 PM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
2 I2S inputs is easy - a TPA OttoII board will do the job. You can control it from Arduino via another optocoupler.

From the ES9028 manual:

"An SPDIF source multiplexer allows for up to 13 SPDIF sources to be connected to the data and GPIO pins selectable via
Register 11: SPDIF Mux and GPIO Inversion. SPDIF input mode can be manually selected by input_select in Register 1:
Input selection or automatically selected if auto_select in Register 1: Input selection is set to a mode allowing automatic
SPDIF selection."

Selecting the standard SPDIF is also easy - as per the BIIISE pro manual it is connected to DATA3:

"The SPDIF input accepts consumer level or CMOS level SPDIF - the SPDIF signal is level shifted to CMOS and sent to the DATA_3 pin on the DAC Controllers switching between Serial and SPDIF should select DATA_3 as the SPDIF source."

Please note consumer level SPDIF is shifted to CMOS. The BIIISE pro board does not expose DATA 4-8, so you will have to use one of the GPIO pins exposed on the new header for your second SPDIF input and you will need to build/buy a similar consumer level-to-CMOS circuit for it.

I have companion libraries for pushbutton and remote control interfaces you can use/adapt

I'd suggest you use DimDim's isolator board as I believe it includes a flash rom you can use to save your settings to (you will need some kind of a user interface to select, change, and save settings of course)
cdeveza  
#12 Posted : Sunday, July 14, 2019 2:32:21 AM(UTC)
cdeveza

Rank: Member

Groups: Member
Joined: 5/12/2016(UTC)
Posts: 66
United States
Location: Concord

Thanks: 6 times
Hi,

Can you please check if this is correct? for single BIIISE pro, input SPDIF? I tried it and its not locking. So I just to make sure that the code is correct.

#include "ES9028.h"

ES9028 dac = ES9028("Stereo DAC", ES9028::Stereo);

void configureDAC(ES9028 dac)
{
dac.mute();
dac.setSerialBits(ES9028::Bits_24);
dac.setInputSelect(ES9028::InputSelect_SPDIF);
dac.setSPDIFInput(ES9028::SPDIF_Data3);
dac.setFilterShape(ES9028::Filter_Hybrid);
dac.setAutoMute(ES9028::AutoMute_MuteAndRampToGnd);
dac.setAutomuteTime(100);
dac.setGPIO1(ES9028::GPIO_Automute);
dac.setGPIO2(ES9028::GPIO_StandardInput);
dac.setGPIO3(ES9028::GPIO_StandardInput);
dac.setGPIO4(ES9028::GPIO_Lock);
dac.setDpllBandwidthSerial(ES9028::DPLL_Lowest);
dac.setVolumeMode(ES9028::Volume_UseChannel1);
dac.setAttenuation(25);
}

void setup() {
// initialize digital pin LED_BUILTIN as the DAC lock light.
pinMode(LED_BUILTIN, OUTPUT);
delay(1500);
dac.mute();

configureDAC(dac);

delay(500);
dac.unmute();
}

void loop() {
if (dac.getInitialised()){
digitalWrite(LED_BUILTIN, dac.locked());
delay(500);
}
}

Thanks,
Alex
Possum  
#13 Posted : Sunday, July 14, 2019 2:45:18 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Is the Arduino communicating with the DAC ok? (check the serial monitor window)
cdeveza  
#14 Posted : Sunday, July 14, 2019 4:43:39 AM(UTC)
cdeveza

Rank: Member

Groups: Member
Joined: 5/12/2016(UTC)
Posts: 66
United States
Location: Concord

Thanks: 6 times
Originally Posted by: Possum Go to Quoted Post
Is the Arduino communicating with the DAC ok? (check the serial monitor window)


Hi,

Thanks again, yes I do have a an I2S source, I just have to move my stuff in my living room, but my code is for spdif?
Not sure I understand. Shall I change my code?

Sorry for my ignorance, but what do you mean text in the serial monitor? will it show something in there.

Thanks,
Alex
Possum  
#15 Posted : Sunday, July 14, 2019 4:50:35 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Plug your PC into the Arduino board via USB and open up the Arduino IDE - go to Tools->Serial Monitor

It will show detailed diagnostic trace of comms between Arduino and DAC (built into the code library)

I want to see if the Arduino is properly communicating via I2C
cdeveza  
#16 Posted : Sunday, July 14, 2019 4:56:51 AM(UTC)
cdeveza

Rank: Member

Groups: Member
Joined: 5/12/2016(UTC)
Posts: 66
United States
Location: Concord

Thanks: 6 times
Hi Possum,

When I ran the scanner, here is what I get.

ScannerRstAlex.jpg (76kb) downloaded 12 time(s).

Thanks,
Alex
cdeveza  
#17 Posted : Sunday, July 14, 2019 5:02:13 AM(UTC)
cdeveza

Rank: Member

Groups: Member
Joined: 5/12/2016(UTC)
Posts: 66
United States
Location: Concord

Thanks: 6 times
Originally Posted by: Possum Go to Quoted Post
Plug your PC into the Arduino board via USB and open up the Arduino IDE - go to Tools->Serial Monitor

It will show detailed diagnostic trace of comms between Arduino and DAC (built into the code library)

I want to see if the Arduino is properly communicating via I2C



Ok, I reloaded the code above, and ran it, but the serial monitor is not showing anything?

The scanner sees the dac, but the codes could not??

Alex
Possum  
#18 Posted : Sunday, July 14, 2019 6:21:55 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
Likely a baud rate setting - but the following line as the first line in setup():

Serial.begin(115200);


and change the baud rate in Serial Monitor Accordingly (you can use another baud rate if you wish but faster is better :-) )
Possum  
#19 Posted : Sunday, July 14, 2019 8:12:50 AM(UTC)
Possum

Rank: Member

Groups: Member
Joined: 8/5/2012(UTC)
Posts: 208
Australia

Thanks: 4 times
Was thanked: 16 time(s) in 14 post(s)
- that's

PUT the following line as the first line in setup():

Serial.begin(115200)

You can set the baud rate to 9600 but my library has very verbose diagnostics and the higher speed is recommended - change your I2C network sniffer to use the higher baud rate

BTW What Arduino are you using?


Clearly you have I2C comms with the DAC (its address is 48) - so there's no reason why we cant get this puppy to behave :-)
cdeveza  
#20 Posted : Sunday, July 14, 2019 8:34:43 AM(UTC)
cdeveza

Rank: Member

Groups: Member
Joined: 5/12/2016(UTC)
Posts: 66
United States
Location: Concord

Thanks: 6 times
Originally Posted by: Possum Go to Quoted Post
- that's

PUT the following line as the first line in setup():

Serial.begin(115200)

You can set the baud rate to 9600 but my library has very verbose diagnostics and the higher speed is recommended - change your I2C network sniffer to use the higher baud rate

BTW What Arduino are you using?


Clearly you have I2C comms with the DAC (its address is 48) - so there's no reason why we cant get this puppy to behave :-)


Ok, will do. I am using the very latest one. I got it from the arduino website itself. Is there anything I should be doing on the dac side? switches maybe? but my understanding is that once the onboard controller is out, switches on the dac no longer works.

ok, let me try that one.

Alex
Rss Feed  Atom Feed
Users browsing this topic
GuestUser (7)
4 Pages123>»
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.