// script for operating a toggle pushbutton switch var switch_off = new Image(); switch_off.src = "gifs/red_button_up.gif"; var switch_on = new Image(); switch_on.src = "gifs/red_button_dn.gif"; var rled_off = new Image(); rled_off.src = "gifs/red_off.gif"; var rled_on = new Image(); rled_on.src = "gifs/red_on.gif"; var switch_state = 0; var output_no = 0; function not_toggle(){ // if (switch_state == 0 ) { switch_state=1; document.images.red_btn.src = switch_on.src; document.images.power_led.src = rled_on.src; rebuild_all() power_on(); } else { switch_state=0; document.images.red_btn.src = switch_off.src; document.images.power_led.src = rled_off.src; } //end } //script for 555 flasher circuit var gled_off = new Image(); gled_off.src = "gifs/green_off.gif"; var gled_on = new Image(); gled_on.src = "gifs/green_on.gif"; var yled_off = new Image(); yled_off.src = "gifs/yellow_off.gif"; var yled_on = new Image(); yled_on.src = "gifs/yellow_on.gif"; var ra_value = 5000; //4.7K Ra Value var rb_value = 100000; //100K Rb value var ct_value = 0.000001; //1uF Ct value //var period_555 =1000*(((ra_value+(2*rb_value))*ct_value)/1.44); //period t = 1/f of the pin 3 of 555 1/frequency f=1.44/(Ra+2(Rb))Ct var charge_t = 1000*(0.693*(ra_value + rb_value)*ct_value); //charge time is t1 = 0.693(Ra + Rb)Ct the output is high. var discharge_t = 1000*(0.693*(rb_value)*ct_value); //discharge time is t2 = 0.693(Rb*Ct) the output is low. var period_t = (charge_t+discharge_t)/1000; //as charge_t and discharge_t was in mS var freq_h = 1/period_t; var duty_c = 100*((discharge_t/1000)/period_t); //as discharge_t was in mS function power_on() { document.images.lo_led.src = gled_off.src; document.images.hi_led.src = yled_on.src; window.setTimeout('turn_off()',charge_t); //end } function turn_on() { document.images.lo_led.src = gled_off.src; document.images.hi_led.src = yled_on.src; window.setTimeout('turn_off()',charge_t); //end } function turn_off() { if (switch_state == 1) { document.images.lo_led.src = gled_on.src; document.images.hi_led.src = yled_off.src; window.setTimeout('turn_on()',discharge_t); } else { document.images.lo_led.src = gled_off.src; document.images.hi_led.src = yled_off.src; } //end } //the below code for a pot for Ra resistor var ra_pot=5; var range_ra=1000; function dec_ra(speedy) { if (ra_value > 5000) { //limit to 4.7K or discharge pin 7 transistor goes. ra_pot = ra_pot-(1*speedy); if (ra_pot < 1){ ra_pot=1; } ra_value = ra_pot*range_ra; } rebuild_all(); document.ra_set.ra_dsp.value = ra_pot; //end } function inc_ra(speedy) { if (ra_value < 10000000) { //limit to 10M due to leakage ra_pot = ra_pot+(1*speedy); ra_value = ra_pot*range_ra; } rebuild_all(); document.ra_set.ra_dsp.value = ra_pot; //end } function rebuild_all() { charge_t = 1000*(0.693*(ra_value + rb_value)*ct_value); discharge_t = 1000*(0.693*(rb_value)*ct_value); var period_t = (charge_t+discharge_t)/1000; //as charge_t and discharge_t was in mS var freq_h = 1/period_t; var duty_c = 100*((discharge_t/1000)/period_t); //as discharge_t was in mS document.freq_f.freq.value = freq_h; document.period_f.period.value = period_t; document.duty_f.duty.value = duty_c; //end } //the below code for a pot for Rb resistor var rb_pot=100; var range_rb=1000; function dec_rb(speedy) { if (rb_value > 5000) { //limit to 4.7K or discharge pin 7 transistor goes. rb_pot = rb_pot-(1*speedy); if (rb_pot < 1){ rb_pot=1; } rb_value = rb_pot*range_rb; } rebuild_all(); document.rb_set.rb_dsp.value = rb_pot; //end } function inc_rb(speedy) { if (rb_value < 10000000) { //limit to 10M due to leakage rb_pot = rb_pot+(1*speedy); rb_value = rb_pot*range_rb; } rebuild_all(); document.rb_set.rb_dsp.value = rb_pot; //end } //the below code for a variable Ct timing cap var ct_pot=1.0; var ct_range=1000000; function dec_ct(speedy) { if (ct_pot > 1) { //limit to 1nF due to parasitics. ct_pot = ct_pot-(1*speedy); if (ct_pot < 1){ ct_pot=1; } ct_value = ct_pot/ct_range; } rebuild_all(); document.ct_set.ct_dsp.value = ct_pot; //end } function inc_ct(speedy) { if (ct_pot < 1000) { //limit to 1000uF due to leakage errors. ct_pot = ct_pot+(1*speedy); ct_value = ct_pot/ct_range; } rebuild_all(); document.ct_set.ct_dsp.value = ct_pot; //end } function range_sel() { ct_range = document.ct_set.cap_range.value; ct_value = ct_pot/ct_range; rebuild_all(); //end } function rb_range() { range_rb = document.rb_set.range_rb.value; rb_value = rb_pot*range_rb; rebuild_all(); //end } function ra_range() { range_ra = document.ra_set.range_ra.value; ra_value = ra_pot*range_ra; rebuild_all(); //end }