# Shenzhen I/O: Control Signal Amplifier

In our second assignment we are asked to build a signal amplifier as a replacement for a control signal amplifier factory module that got eeeehhhh smashed…. but don’t worry, no one was hurt much. This task is in my opinion still as close as we get to a tutorial in this game as we ever will. The signal amplifier is pretty simple. We will take the input signal from a simple input, multiply it by 2 and send it to the simple output pin.

In order to do that we need two new concepts. The first is that we need to use a new instruction

mul R/I – which will multiply the acc register with the given input from either an integer or a register.

The second concept is that we need to know that all these arithmetic instructions work on acc.

With that in mind we can set up a MC4000 micro controller as shown here

and write the code as

```  mov p0 acc
mul 2
mov acc p1
slp 1
```

The programs reads the input from p0 and puts it in acc. Then it multiplies it by two inside acc and moves the result in acc to the output p1. Finally we sleep until the next cycle. And tadaa a control signal amplifier that meets  the specifications we need to move on.

## Optimizing the lines of code and energy usage

If we start studying the input signal, we will see that we only have values of 0, 25 and 50. Which means that the output values always needs to be either 0, 50 or 100. Therefore we should be able to make use of a logic gate to make a solution that is more expensive, since we use more components, but that should reduce the lines of code as well as reduce the energy consumption.

For the case of 50 as an input. We can use the LC70G32  OR gate to boost the signal. For the 0 case we just need to make sure that we do not send any output.

For the last case of 25 as input the logic gate will provide no output, therefore we can use the mc4000 microcontroller to test if the value of p0 is larger than the output at p1, and in that case send 50 as the output. I thought I could just check if p0 was equal to 25, but I realized I needed to read from p1 as well, as that will reset sending an output signal to it. And therefore implicitly also reset the output to 0 in case nothing should be sent.

The solution will look like this.

It is a solution that you should not be able to do at the time you reach that level for the first time. But it is something you can come back and do.