# Equations and Formulas

Hello everyone,

I am a hobbyist whose weakness is Math and calculation.

So it's difficult for me to start a code from scratch. This is why I resorted to already available codes. Thanks to Arduinos, this has been available.

1. The first problem I need a solution to is converting the following eqation in Arduino code. I have tried but I got errors:

(Vmax / v )² (4.9 V / 7.5)²
Pmax = -------------- = --------------------- = 8,53 mW = 0.6533 V (vrms)

1. The other problem is that I want to add some protection to the AD8313 or so chip
once the voltage exceeds a certain threshold a relay cuts off power or connection to the input.

I wrote this code but as soon as the program runs I get the warning and the protection no matter the input signal

// if (Watts >10)// if the signal is higher than 10 Watts, then block signal.
// digitalWrite (4,HIGH);// drives a relay of so to block signal
// lcd.clear();
// lcd.setCursor(0,0);
// lcd.print("Warning");
// lcd.setCursor(0,1);
// lcd.print("OverVoltage");
// delay(5000);

I'd appreciate it if you wrote me the conversions and formulas concerning 1: Vrms to Watt, 2: Watt to dBm, and 3: dBm to Vrms.

Here's another eqation for the ADL5513, I was not sure of the results in Arduino:
Output power = the signal from the ADL5513 at the input A0 divided by 47 minus -89 from the result.

I wrote as such in arduino Pout= (Vin(A0)/47)/-89;

In languages one can't improvise, it's copy and imitate.

I wanted to try this one detector:

https://pa0rwe.nl/?page_id=356

it's luxurious but I don't have a rotary encoder. I looked for a more convenient one and I found this one:

http://www.darc-husum.de/pegelmesser-10ghz.html

and I've already built it as it is what I want and tried to adapt it to the ADL5513 but all my efforts in vain I didn't know how to change the math. Replacing the slope and intercept values wouldn't solve the problem. The measurement is counterclockwise the higer the input the lower the power and dB!!!!

I found this one:

https://www.changpuak.ch/electronics/Arduino-Shield-NRVD.phpbut

it's complicated as it usese double ADL5513

1. Show us some code you tried, then we can fix it.

Was this it? Where did 47 and 89 come from? which is Vmax and which is v?

I wrote as such in arduino Pout= (Vin(A0)/47)/-89;

You are missing the square.

``````float temp = Vmax / v;
temp = temp * temp;
float result = temp / 50.0;
``````
1. What happens if power is connected before the Arduino has started up?

Thank you, sure here I enclosed the program I am trying to adapt to different chips.
Note please the uncommented lines that wouldn’t work, you’ll see what I mean.

there are two equations one for the

I am tackling another job which is the warning routine how can I get the program to react only after the threshold exceeds the limit.

In the code I enclosed it reacts as soon as power on no matter the signal strength!

I have been struggling to express this formula in arduino:

result1=(pow(Vrms,2)/50/0.001);

result=10*log(result1);

dBm=(result);

the result and log*10 part doesn't work, I get wrong numbers.

for example I have 0.66 Vrms I should get 9.4 dBm, but I get 21.85 dBm instead.

Why do you use pow() just to multiply a number by itself? That will invoke extra run time and code size. Your stated problem might be because you use log() instead of log10(). I say, "might" because I don't know if you are calculating Vrms correctly. Also, you are using "magic numbers", 50 and 0.001 in this case. That hides the derivation and/or the meaning. You know that 50 is Rload, why not just create a constant named "Rload" and use it instead? Especially, if math is a self-avowed weakness?

Also,

1. The other problem is that I want to add some protection to the AD8313 or so chip
once the voltage exceeds a certain threshold a relay cuts off power or connection to the input.

Forget about that right now. In most overload scenarios, any damage to the internal circuitry of the IC would happen thousands of times faster than any practical relay could operate.

Here's another eqation for the ADL5513, I was not sure of the results in Arduino:
Output power = the signal from the ADL5513 at the input A0 divided by 47 minus -89 from the result.

Where are you digging up this stuff? It seems very amateurish. You should be looking at the data sheets to find the right values to integrate with your program.

aarg:
Why do you use pow() just to multiply a number by itself? That will invoke extra run time and code size. Your stated problem might be because you use log() instead of log10(). I say, "might" because I don't know if you are calculating Vrms correctly. Also, you are using "magic numbers", 50 and 0.001 in this case. That hides the derivation and/or the meaning. You know that 50 is Rload, why not just create a constant named "Rload" and use it instead? Especially, if math is a self-avowed weakness?

Also,Forget about that right now. In most overload scenarios, any damage to the internal circuitry of the IC would happen thousands of times faster than any practical relay could operate.
Where are you digging up this stuff? It seems very amateurish. You should be looking at the data sheets to find the right values to integrate with your program.

Thanks for popping in and helping.

Well Arduino is a personal language and I am learning, one can't always improvise.

I thought pow() is better well developed than simply multiplying temp*temp.
OK, as for the relay I gave it up.

I found some help in the arduino reference but I got 0.94 dBm or something close so I multiplied that with 10 as you see.

dBm=10*(log10(result1));

but I am not sure if thats OK.

The numbers I got are there in the datasheet of the AD8361 page 15.

when there are 5 Volts they should be divided by 7.5 = .66Vrms.

I used 50 instead of creating constants because I found that more intelligible as constants and variables add more confusion.

I'm digging everywhere, engineer stuff is also indicipherable sometimes!

I have been working on the project for months but the tedious task is simply to calculate dBm, Vrms, Watts, and the next task calculate attenuators.

Ok, hold on a minute. To clarify what you already stated above, the ADL5513 has a log converter built in. The AD8361 has a linear response, so the linear formula would apply. So which one are you using? What dynamic range are you trying to measure?

aarg:
Ok, hold on a minute. To clarify what you already stated above, the ADL5513 has a log converter built in. The AD8361 has a linear response, so the linear formula would apply. So which one are you using? What dynamic range are you trying to measure?

I am an amateur and hobbyist using part of my energy and hobby for fun and knowledge!

Never mind what chip I might be using! I am asking about formulating and converting formulas and equations in arduino.

I got the feeling people here are grudging on a piece of information for such trivial questions like dB to mW to mV_rms in arduino! Is that so bad!

Correct me if I'm wrong.

If people are not ready to cooperate and help they should say it!