5 Commits

16 changed files with 5960 additions and 125 deletions

View File

@ -370,9 +370,9 @@
"meta": { "meta": {
"version": 1 "version": 1
}, },
"net_format_name": "", "net_format_name": "Spice Model",
"page_layout_descr_file": "", "page_layout_descr_file": "",
"plot_directory": "", "plot_directory": "/home/tgohle/Desktop/git/ToGo-Lab/0004-DenshaBekutoru/KiCad/0004-DenshaBekutoru/",
"spice_current_sheet_as_root": false, "spice_current_sheet_as_root": false,
"spice_external_command": "spice \"%I\"", "spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true, "spice_model_current_sheet_as_root": true,

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,39 @@
*
.subckt 0004-DenshaBekutoru
.model __D2 D
.model __D1 D
R3 Net-_D10-A_ VCC 220
D10 __D10
C5 VCC GND 100n
U4 __U4
C4 VCC GND 4.7u
U3 __U3
R4 Net-_D11-A_ VCC 220
D11 __D11
R5 Net-_U3-_RESET/PB5_ VCC 10k
R6 Net-_D4-A_ Net-_D6-K_ 220
D6 __D6
D5 __D5
R7 Net-_D6-A_ Net-_D4-K_ 220
D4 __D4
C3 Net-_D3-K_ GND 100n
U1 __U1
C2 Net-_D3-K_ GND 47u
D3 __D3
U2 __U2
D2 Net-_D2-A_ Net-_D2-K_ __D2
C1 Net-_U3-_RESET/PB5_ GND 100n
SW1 __SW1
R8 Net-_D8-A_ Net-_D5-K_ 220
D7 __D7
D8 __D8
D9 __D9
R1 Net-_D2-A_ Net-_D1-K_ 1.8k
R2 Net-_D1-A_ Net-_D2-K_ 1.8k
D1 Net-_D1-A_ Net-_D1-K_ __D1
J1 __J1
.ends

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -0,0 +1,58 @@
/*
0004_DenshaBekutoru ? Optocoupler Averaging Test (UNO)
Measures average voltage on:
- A2 -> later ATtiny85 PB3 (XTAL1, Pin 2)
- A3 -> later ATtiny85 PB4 (XTAL2, Pin 3)
Integration window is configurable via SAMPLE_WINDOW_MS.
by tgohle, last edit 20260111
*/
const unsigned long SAMPLE_WINDOW_MS = 100; // change here
const unsigned long SAMPLE_DELAY_US = 500; // delay between ADC samples
const uint8_t ADC_PIN_1 = A2; // UNO A2 -> later ATtiny85 PB3 (XTAL1, Pin 2)
const uint8_t ADC_PIN_2 = A3; // UNO A3 -> later ATtiny85 PB4 (XTAL2, Pin 3)
void setup() {
Serial.begin(115200);
pinMode(ADC_PIN_1, INPUT);
pinMode(ADC_PIN_2, INPUT);
Serial.println("=== DenshaBekutoru Optocoupler Average Test ===");
}
void loop() {
unsigned long startTime = millis();
unsigned long sum1 = 0;
unsigned long sum2 = 0;
unsigned long samples = 0;
while (millis() - startTime < SAMPLE_WINDOW_MS) {
sum1 += analogRead(ADC_PIN_1);
sum2 += analogRead(ADC_PIN_2);
samples++;
delayMicroseconds(SAMPLE_DELAY_US);
}
float avg1 = (float)sum1 / samples;
float avg2 = (float)sum2 / samples;
float v1 = avg1 * (5.0 / 1023.0);
float v2 = avg2 * (5.0 / 1023.0);
Serial.print("A2 for PB3 XTAL1, Pin2: ");
Serial.print(v1, 3);
Serial.print(" V | ");
Serial.print("A3 for PB4 XTAL2, Pin3: ");
Serial.print(v2, 3);
Serial.println(" V");
delay(300);
}