Shenzhen I/O – Harmonic Maximization Engine

By now we are veterans in making cheap electronic gadgets for the company. And now they want us to make a Harmonic Maximization Engine! That sounds cool.

When we look at the specifications we are supposed to copy the audio-in to audio out as long as the maximize is not high.

If the maximize input is high then we should apply the following algorithm

AUDIO_OUT = (AUDIO_IN – 50) x 4 + 50

As it is given to us in the manual. This gives us the following signals for verification

Shenzhen IO - harmonic maximization engine - signals

 

First design

The first thing that becomes apparent is that we have 3 simple inputs to deal with, and only micro controllers to handle 2. My first solution is therefore to use a micro controller to transform the maximize signal from a simple input to an xbus output.

That xbus input can then we read from the main microcontroller and used to apply the other algorithm.

The second thing we should note is that if we apply the algorithm directly to the harmonic maximization engine we need to do it with the following steps assuming the audio in is already in acc

  sub 50
  mul 4
  add 50

As you can see the sub is a new instruction I haven’t used before. It works just like add, but subtracts from the acc and stores the result there.

However, we can rewrite the algorithm and move the

AUDIO_OUT = (AUDIO_IN – 50) x 4 + 50

AUDIO_OUT = AUDIO_IN  x 4 – 200 + 50

AUDIO_OUT = AUDIO_IN  x 4 – 150

and thus we will need only two instructions to apply the algorithm.

  mul 4
  sub 150

This gives us the following first solution

Shenzhen IO - harmonic maximization engine - solution 1
This solves the problem in

Cost: 6
Energy: 430
Lines of code: 8

which is sort of bang in the middle, and probably the solution most people would arrive at

An improved solution to the Harmonic Maximization Engine

After I made the first solution I learned that the DX300 is your friend when it comes to changing between simple and xbus inputs. For this application it doesn’t matter what the xbus value that comes out is. As long as it is different from 0 when we need to apply the algorithm. Therefore we can interchange the first microcontroller with the DX300 and get the following solution

Shenzhen IO - harmonic maximization engine - solution 2

This solves the problem in the improved stats

Cost: 4
Energy: 310
Lines of code: 6

Which means that it improves the solution on all three parameters! Based on the scoreboard diagram, I don’t think anyone has derived a better design so far.

 

Posted by Kristian

1 comment

MÉHÉSZ GYÖRGY ÁKOS

Just one line longer but uses less energy. 😉

tgt x0 0
– mov p0 p1
+ mov p0 acc
+ mul 4
+ sub 150
+ mov acc p1
slp 1

Leave a Reply