Aus RN-Wissen.de
Wechseln zu: Navigation, Suche
Balkonkraftwerk Speicher und Wechselrichter Tests und Tutorials

 
(Eine dazwischenliegende Version von einem anderen Benutzer wird nicht angezeigt)
Zeile 1: Zeile 1:
 
<!-- be kind, this is just a test -->
 
<!-- be kind, this is just a test -->
<script language="JavaScript">
 
 
var form;
 
 
var win_ubrr, fosc, baud;
 
var row, ubrr, err;
 
 
function init()
 
{
 
form = document.forms["data"];
 
 
form.fosc.value="1.000000";
 
}
 
 
function round (x, n)
 
{
 
n = Math.pow (10, n);
 
x = Math.round (n*x)/n;
 
return x;
 
}
 
 
function get_ubrr (baud, m)
 
{
 
var f = 1000000*fosc;
 
var ubrra, bauda, erra;
 
var ubrrb, baudb, errb;
 
 
ubrr = f/(m*baud)-1;
 
ubrra = Math.floor (ubrr);
 
ubrrb = Math.ceil  (ubrr);
 
bauda = f/(m*(ubrra+1));
 
baudb = f/(m*(ubrrb+1));
 
erra = bauda/baud-1;
 
errb = baudb/baud-1;
 
 
if (Math.abs (erra) < Math.abs (errb))
 
{
 
err = erra;
 
ubrr = ubrra;
 
}
 
else
 
{
 
err = errb;
 
ubrr = ubrrb;
 
}
 
 
err = round (err*100, 1);
 
if (ubrr >= 10)
 
ubrr += "=0x" + ubrr.toString(16);
 
 
if (Math.abs (err) < 0.21)
 
{
 
err = "<b>"+err+"</b>";
 
ubrr = "<b>"+ubrr+"</b>";
 
}
 
else if (Math.abs (err) > 10)
 
{
 
err = "&#150;";
 
ubrr = err;
 
}
 
}
 
 
function get_row (baud)
 
{
 
var color = ((row & 1) == 0) ? "#ffffff" : "#f0f0ff";
 
var html = "<tr bgcolor=\""+color+"\">";
 
var baudstr = baud;
 
var ubrr0, err0;
 
var ubrr1, err1;
 
 
row++;
 
 
if (baud > 9600)
 
{
 
baudstr = "" + (baud / 1000) + "k";
 
}
 
 
if (baud > 250000)
 
{
 
baudstr = "" + (baud / 1000000) + "M";
 
}
 
 
get_ubrr (baud, 16);
 
ubrr0 = ubrr;
 
err0 = err;
 
 
get_ubrr (baud, 8);
 
ubrr1 = ubrr;
 
err1 = err;
 
 
html += "<td>"+baudstr+"</td>";
 
html += "<td align=\"center\">"+ubrr0+"</td>";
 
html += "<td align=\"center\">"+err0+"</td>";
 
html += "<td align=\"center\">"+ubrr1+"</td>";
 
html += "<td align=\"center\">"+err1+"</td>";
 
html += "</tr>\n";
 
 
return html;
 
}
 
 
function write_ubrr_table ()
 
{
 
var html = "<center>";
 
row = 0;
 
 
html += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n";
 
html += "<tr><td rowspan=3><b>Baud<br>Rate<br>(bps)</b></td>";
 
html += "<td colspan=4 align=\"center\"><b>f<sub>osc</sub> = "+fosc+" MHz</b></td></tr>\n";
 
html += "<tr><td colspan=2 align=\"center\"><b>U2X = 0</b></td><td colspan=2 align=\"center\"><b>U2X = 1</b></td></tr>\n";
 
html += "<tr><td align=\"center\"><b>UBRR</b></td><td align=\"center\"><b>Error (%)</b></td>";
 
html += "<td align=\"center\"><b>UBRR</b></td><td align=\"center\"><b>Error (%)</b></td></tr>\n";
 
html += get_row (2400);
 
html += get_row (4800);
 
html += get_row (9600);
 
html += get_row (14400);
 
html += get_row (19200);
 
html += get_row (28800);
 
html += get_row (38400);
 
html += get_row (57600);
 
html += get_row (76800);
 
html += get_row (115200);
 
html += get_row (230400);
 
html += get_row (250000);
 
html += get_row (500000);
 
html += get_row (1000000);
 
html += "</table></center>\n";
 
 
// alert (html);
 
 
win_ubrr.document.writeln (html);
 
}
 
 
function open_ubrr_window (val)
 
{
 
fosc = parseFloat (val);
 
 
if (win_ubrr)
 
win_ubrr.close();
 
win_ubrr = window.open ("about:blank", "ubrr", "toolbar=no, menubar=no, width=400");
 
win_ubrr.focus();
 
win_ubrr.document.close();
 
// win_ubrr.document.open();
 
// win_ubrr.document.location.href = "about:blank";
 
 
var html = "<html>\n";
 
html += "<head>\n"
 
html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
 
html += "<meta name=\"Author\" content=\"Georg-Johann Lay\">\n";
 
html += "<title>ATMega8 Baudrate, fosc = "+fosc+" MHz</title>\n";
 
html += "</head>\n"
 
win_ubrr.document.writeln (html);
 
 
html = "<body bgcolor=\"white\" text=\"black\">\n";
 
win_ubrr.document.writeln (html);
 
write_ubrr_table (fosc, baud);
 
html = "</body>\n";
 
html += "</html>\n";
 
win_ubrr.document.writeln (html);
 
win_ubrr.document.close();
 
}
 
 
function write_freq_button (frq)
 
{
 
html = "<input type=submit onclick=\"open_ubrr_window("+frq+")\" SIZE=\"120\" VALUE=\" "+frq+" MHz \">";
 
 
document.writeln (html);
 
}
 
 
 
</script>
 

Aktuelle Version vom 4. Dezember 2005, 02:02 Uhr


LiFePO4 Speicher Test