```python
# picture from Jeremy Blum's book "Exploring Arduino" 2nd edition Page 50
from IPython.display import Image
from IPython.core.display import HTML 
Image(url= "https://i.imgur.com/K6pJCwd.png")
```









```python
# through trial and error we find that 5*sin(0.5*x)**2 is very close to Blum's graph
# the problem is that I could not figure out how to get the same amount of steps.
# But with 7*sin(0.5*x)**2 then making the digital signal graph starts looking like Blum's
from sympy import *
x = symbols('x')
eq0 = 5*sin(0.5*x)**2 
p = plot(eq0,legend = True,xlim = (0,4),ylim = (0,5),title="Analog Signal", xlabel = "Time(s)",ylabel = "Voltage (V)",size = (7,7),steps=1,show=False,line_color = 'r')
p.show()
```


```python
# What is unique here to my work was reverse engineering the graphs of Jeremy Blum that he also made with MATLAB
#
# Languages: Python Object Oriented Programming Language, Sympy (symbolic mathematics) Python external library
#       and Jupyter Notebook web-based Integrated Development Environment (IDE)
# https://docs.sympy.org/                      
# https://python.org/                          
# https://jupyter.org/
# 
# referencing Jeremy Blum's "Exploring Arduino" - 2nd edition P.50 for the idea
# thank you Andrew F. Rich for help with digital function notation
eq = 7*sin(0.5*x)**2 
p = plot(eq,legend = True,xlim = (0,4),ylim = (0,7),title="Analog Signal", xlabel = "Time(s)",ylabel = "Voltage (V)",size = (7,7),steps=1,show=False,line_color = 'r')
p.show()

# here we continually guessed values for some sine equation to look similar to Page 50 of Blum's "Exploring Arduino"
# The differing aspect ratios of the images can make the sine wave function look distorted
# 
# notice our y-axis is different (mine has 7 versus  versus Blum's 5)
#     this is because I don't know how to get digital function to graph the 7 or 8 steps in the next part)
```


```python
# notice here we use the previous 7*sin(0.5*x)**2 (variable: eq) as an input for the digital signal graph
eq2 =  ((7 - Abs(floor((eq+0.6)) - 7))) 

p = plot(eq2,legend = True,xlim = (0,4),ylim = (0,7),title="Digital Signal", xlabel = "Time(s)",ylabel = "Digital Value",size = (7,7),steps=1,show=False)
p.show()

# here we also reverse engineered Blum's digital value graph approximately


```


```python
Digital Value of range [0,7] translated to 3-bit ADC would be
    7 == 111
    6 == 110
    5 == 101
    4 == 100
    3 == 011
    2 == 010
    1 == 001
    0 == 000

 also important to note that 3-bit ADC means the ADC can quantize analog signals into 2**n where n = number of bits. 
 so a 10-bit ADC can do 2**10 or 1024 representations. In these 3-bit graphs, you see we have 2**3 or 8 representations 
 from a 5 volt supply. (although I had to use 7 volts to graph Blum's digital signal graph)
 
 In my personal case using the Arduino Metro microcontroller, 
     a 5V regulator can supply peak ~800mA as long as the die temp of the regulator does not exceed 150*C
     using https://www.rapidtables.com/calc/electric/ohms-law-calculator.html
     that means we have:
         
         Resistance (R) = 6.25 ohms
         Current (I) = 800 milliamps (mA)
         Voltage (V) = 5 Volts (V) 
         Power (P) = 4 watts(W)
```


```python
eq # Analog Signal Function

```




$\displaystyle 7 \sin^{2}{\left(0.5 x \right)}$




```python
eq2  # Digital Signal Function

```




$\displaystyle 7 - \left|{\left\lfloor{7 \sin^{2}{\left(0.5 x \right)} + 0.6}\right\rfloor - 7}\right|$




```python
in conclusion, with 5*sin(0.5*x)**2 I had trouble getting the stepwise function to have 8 steps (0-7)
but with 7*sin(0.5*x)**2 the digital graph looks more like Blum's. So in reverse engineering these graphs,
I was able to get either the Analog graph correct and Digital graph incorrect or the Analog graph incorrect
and digital graph correct.

```


```python
special thanks to Robin R Mitchell for ideas about low level binary machine translations of summations

written by    Nicholas Caudill           NSCaudill2020@manchester.edu           github.com/NSC9
```

9178035be86d2f09703d477bd99f48b335045776
ipynb
Jupyter Notebook
Personal_Projects/Reverse_Engineering/Reverse_Engineering_Analog-to-Digital_Graphs_v0.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Personal_Projects/Reverse_Engineering/Reverse_Engineering_Analog-to-Digital_Graphs_v0.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Personal_Projects/Reverse_Engineering/Reverse_Engineering_Analog-to-Digital_Graphs_v0.3.ipynb
NSC9/Sample_of_Work
8f8160fbf0aa4fd514d4a5046668a194997aade6
MIT
Qwen/Qwen-72B
1. YES
2. YES