From 4163b773d8f88adbd1c8092e669c7378451794b2 Mon Sep 17 00:00:00 2001 From: Philipp Claves <pclaves@web.de> Date: Wed, 27 Jun 2012 20:50:00 +0200 Subject: [PATCH] PortalControl: Implement (un)lock retry, if the door sensor state does not change. (fixed patch) --- Control/cardreader_interface.c | 44 +- Control/cardreader_interface.h | 5 +- Control/door.c | 101 ++-- Control/log.c | 24 +- Control/log.h | 21 +- Control/shell/shell.c | 4 +- Main.sch | 829 ++++++++++++++++++++------------- common/serial.h | 9 +- 8 files changed, 647 insertions(+), 390 deletions(-) diff --git a/Control/cardreader_interface.c b/Control/cardreader_interface.c index 242b0c5..423063f 100644 --- a/Control/cardreader_interface.c +++ b/Control/cardreader_interface.c @@ -32,8 +32,7 @@ * Card -> Host: other ISO7816 status code (-> abort) **/ - -void unlock(void); +void cardreader_process_message(void); uint8_t check_card_status(uint8_t* msg_buffer, uint8_t length, uint8_t expected_body_length); void cardreader_select_auth_applet(void); uint8_t cardreader_select_auth_applet_result(uint8_t* msg_buffer, uint8_t length); @@ -59,11 +58,11 @@ uint8_t cardreader_sys_get_card_status(void); static uint8_t cardreader_power_state = CARDREADER_POWER_STATE_OFF; static volatile uint8_t cardreader_startup_event = 0; -#define AUTH_STATE_NONE 1 -#define AUTH_STATE_CARD_INSERTED 2 -#define AUTH_STATE_SELECTING_AUTH_APPLET 3 -#define AUTH_STATE_AUTH_REQUESTED_SENT 4 -#define AUTH_STATE_AUTH_VERYFIED 5 +#define AUTH_STATE_NONE 1 //System idle +#define AUTH_STATE_CARD_INSERTED 2 //Card has been inserted into th reader, auth will be started. +#define AUTH_STATE_SELECTING_AUTH_APPLET 3 //APDU to select the portal auth application has been sent. +#define AUTH_STATE_AUTH_REQUESTED_SENT 4 //Authorisation challange has been sent. +#define AUTH_STATE_AUTH_VERYFIED 5 //Authorisation key has been verified, new key has been sent. volatile uint8_t auth_state = AUTH_STATE_NONE; volatile uint16_t state_timeout; @@ -145,8 +144,10 @@ void cardreader_process(void){ return; } - if (!transport_data_available()) return; - + if (transport_data_available()) cardreader_process_message(); +} + +void cardreader_process_message(void){ uint8_t msg_buffer[100]; uint16_t ret = transport_receive_message(msg_buffer, 100, 400); @@ -337,11 +338,13 @@ uint8_t cardreader_update_key_result(uint8_t* msg_buffer, uint8_t length){ // cardreader_display_show_result(1); cardreader_display_clear(); - if (toggle_lock_unlock(cardreader_display_write_sz_P)){ +// if ( + toggle_lock_unlock(cardreader_display_write_sz_P); +// ){ // cardreader_display_write_sz_P(PSTR("Auth Successful")); - cardreader_display_move(0,1); - cardreader_display_write_sz_P(PSTR("Remove Card")); - } +// cardreader_display_move(0,1); +// cardreader_display_write_sz_P(PSTR("Remove Card")); +// } keystore_update_salt(); @@ -448,7 +451,6 @@ void cardreader_display_show_result(uint8_t success){ } } - void cardreader_display_set_backlight(uint8_t on){ cardreader_display_message_t msg = {CARDREADER_MSG_TYPE_DISPALY}; msg.command = CARDREADER_DISPLAY_MSG_SET_BACKLIGHT; @@ -457,4 +459,18 @@ void cardreader_display_set_backlight(uint8_t on){ uint8_t success; transport_receive_message(&success, 1, 3000); +} + +void cardreader_display_show_door_retry(void){ + cardreader_display_move(10,0); + cardreader_display_write_sz_P(PSTR("Retry")); +} + +void cardreader_display_show_door_result(uint8_t success){ + cardreader_display_move(0,1); + if (success) { + cardreader_display_write_sz_P(PSTR("OK, remove card ")); + } else { + cardreader_display_write_sz_P(PSTR("Mechanical Fail!")); + } } \ No newline at end of file diff --git a/Control/cardreader_interface.h b/Control/cardreader_interface.h index 8843bdf..eaf9e16 100644 --- a/Control/cardreader_interface.h +++ b/Control/cardreader_interface.h @@ -23,4 +23,7 @@ void cardreader_process(void); void cardreader_tick(void); uint8_t cardreader_init_card_key(KEY key); -uint8_t cardreader_clear_card_key(void); \ No newline at end of file +uint8_t cardreader_clear_card_key(void); + +void cardreader_display_show_door_retry(void); +void cardreader_display_show_door_result(uint8_t success); \ No newline at end of file diff --git a/Control/door.c b/Control/door.c index a309e06..664eaf1 100644 --- a/Control/door.c +++ b/Control/door.c @@ -1,5 +1,6 @@ #include "door.h" #include "log.h" +#include "cardreader_interface.h" //for (un)lock messages uint8_t door_read_pin_status(void); uint8_t door_update_status(uint8_t sensor_status); @@ -20,17 +21,21 @@ const char* const status_names[] PROGMEM = {status_unlocked, status_unlocking, status_locking}; -volatile uint8_t door_status; +uint8_t door_status; -volatile uint8_t sensor_candidate_status; -volatile uint8_t sensor_stability; +uint8_t sensor_candidate_status; +uint8_t sensor_stability; #define DOOR_PIN_NEEDED_STABILITY 4 -#define DOOR_COMMAND_PULSE_TIME 35 //350ms -volatile uint8_t door_command_pulse_time = 0; +#define DOOR_COMMAND_PULSE_TIME 45 //450ms +uint8_t door_command_pulse_time = 0; + +#define DOOR_COMMAND_WAIT_TIMEOUT 900 //9s +uint16_t door_command_wait_timeout = 0; + +uint8_t door_command_retry_count = 0; +#define DOOR_COMMAND_MAX_RETRY 1 -#define DOOR_COMMAND_WAIT_TIMEOUT 1000 //10s -volatile uint16_t door_command_wait_timeout = 0; void door_init(void){ DOOR_PORT &= ~(COMMAND_UNLOCK_PIN | COMMAND_LOCK_PIN); //commnd pins off @@ -52,7 +57,9 @@ void door_init(void){ void door_tick(void){ if (door_command_pulse_time != 0) { door_command_pulse_time--; - if (door_command_pulse_time == 0) DOOR_PORT &= (uint8_t)~(COMMAND_LOCK_PIN|COMMAND_UNLOCK_PIN); + if (door_command_pulse_time == 0) { + DOOR_PORT &= (uint8_t)~(COMMAND_LOCK_PIN|COMMAND_UNLOCK_PIN); + } } if ( ((door_status & DOOR_STATUS_UNLOCKING) && !(door_status & DOOR_STATUS_UNLOCKED)) @@ -60,12 +67,30 @@ void door_tick(void){ door_command_wait_timeout--; if (door_command_wait_timeout == 0){ - printf_P(PSTR("Error: Door command timeout\n")); log_append(LOG_EVENT_DOOR_COMMAND_TIMEOUT, 0); - //TODO: Retry (and turn keymatic power on if currently off) + printf_P(PSTR("Error: Door command timeout!")); - door_status &= (uint8_t)~(DOOR_STATUS_UNLOCKING | DOOR_STATUS_LOCKING); //clear activity flags + if (door_command_retry_count < DOOR_COMMAND_MAX_RETRY){ + printf_P(PSTR(" Retry...\n")); + cardreader_display_show_door_retry(); + uint8_t retry = door_command_retry_count; + + //TODO: turn keymatic power on if currently off? + if (door_status & DOOR_STATUS_UNLOCKING) unlock(); + if (door_status & DOOR_STATUS_LOCKING ) lock(); + //lock/unlock resets the counter, restore it. + door_command_retry_count = retry + 1; + + } else { + + log_append(LOG_EVENT_DOOR_COMMAND_RETRY_FAIL, 0); + + printf_P(" Giving Up :((\n"); + cardreader_display_show_door_result(0); + + door_status &= (uint8_t)~(DOOR_STATUS_UNLOCKING | DOOR_STATUS_LOCKING); //clear activity flags + } } } @@ -95,8 +120,15 @@ uint8_t door_read_pin_status(void){ uint8_t door_update_status(uint8_t sensor_status){ uint8_t new_door_status = (sensor_status & DOOR_STATUS_HW_MASK) | (door_status & DOOR_STATUS_SW_MASK); - if (new_door_status & DOOR_STATUS_LOCKED) new_door_status &= (uint8_t)~DOOR_STATUS_LOCKING; - if (new_door_status & DOOR_STATUS_UNLOCKED) new_door_status &= (uint8_t)~DOOR_STATUS_UNLOCKING; + if ((new_door_status & DOOR_STATUS_LOCKED) && (door_status & DOOR_STATUS_LOCKING)){ + new_door_status &= (uint8_t)~DOOR_STATUS_LOCKING; + cardreader_display_show_door_result(1); + } + + if ((new_door_status & DOOR_STATUS_UNLOCKED) && (door_status & DOOR_STATUS_UNLOCKING)){ + new_door_status &= (uint8_t)~DOOR_STATUS_UNLOCKING; + cardreader_display_show_door_result(1); + } if (is_alarm_status(new_door_status)) new_door_status |= DOOR_STATUS_ALARM; @@ -114,7 +146,7 @@ uint8_t is_alarm_status(uint8_t door_status){ //NOTE: This condition is supposed to trigger, if the door is slammed open. // We can't use the LOCKED sensor, because the connection between lock bolt and frame will be interrupted by this. - // This connection is what the sensor actually detects. TODO: Can we improove this? + // This connection is what the sensor actually detects. TODO: Can we improve this? // The UNLOCKED sensor, however will be uneffected, leaving the lock sensors in an // undefined (neither locked nor unlocked) state. We trigger an alarm if this occurs when the door is open. // Unfortunately the UNLOCKED has shown failures in the past, possibly causing a false alarm. @@ -136,6 +168,7 @@ uint8_t door_get_status(void){ void unlock(void){ door_command_pulse_time = DOOR_COMMAND_PULSE_TIME; door_command_wait_timeout = DOOR_COMMAND_WAIT_TIMEOUT; + door_command_retry_count = 0; door_status = (door_status & (uint8_t)~DOOR_STATUS_LOCKING) | DOOR_STATUS_UNLOCKING; DOOR_PORT = (DOOR_PORT & (uint8_t)~COMMAND_LOCK_PIN) | COMMAND_UNLOCK_PIN; @@ -144,6 +177,9 @@ void unlock(void){ void lock(void){ door_command_pulse_time = DOOR_COMMAND_PULSE_TIME; door_command_wait_timeout = DOOR_COMMAND_WAIT_TIMEOUT; + door_command_retry_count = 0; + +// printf_P(PSTR(".")); door_status = (door_status & (uint8_t)~DOOR_STATUS_UNLOCKING) | DOOR_STATUS_LOCKING; DOOR_PORT = (DOOR_PORT & (uint8_t)~COMMAND_UNLOCK_PIN) | COMMAND_LOCK_PIN; @@ -158,34 +194,47 @@ uint8_t toggle_lock_unlock( void (*msg_target)(const char*) ){ } uint8_t unlock_checked( void (*msg_target)(const char*) ){ + uint8_t ok = 0; + const char* msg; + if (door_status & DOOR_STATUS_UNLOCKED){ - msg_target(PSTR("Already unlocked\n")); + msg = PSTR("Already unlocked\n"); } else if (door_status & DOOR_STATUS_LOCKING){ - msg_target(PSTR("Can't unlock while locking\n")); + msg = PSTR("Can't unlock while locking\n"); } else { unlock(); - msg_target(PSTR("Unlocking...\n")); - return 1; + msg = PSTR("Unlocking...\n"); + ok = 1; } - return 0; + + printf_P(msg); + if (msg_target) msg_target(msg); + + return ok; } uint8_t lock_checked( void (*msg_target)(const char*) ){ + uint8_t ok = 0; + const char* msg; if (is_alarm_status(door_status)){ - msg_target(PSTR("Can't lock in alarm state\n")); + msg = PSTR("Can't lock in alarm state\n"); } else if (door_status & DOOR_STATUS_UNLOCKING) { - msg_target(PSTR("Can't lock while unlocking\n")); + msg = PSTR("Can't lock while unlocking\n"); } else if (door_status & DOOR_STATUS_OPEN){ - msg_target(PSTR("Can't lock while door open\n")); + msg = PSTR("Can't lock while door open\n"); } else if (door_status & DOOR_STATUS_LOCKED){ - msg_target(PSTR("Already locked\n")); + msg = PSTR("Already locked\n"); } else { lock(); - msg_target(PSTR("Locking...\n")); - return 1; + msg = PSTR("Locking...\n"); + ok = 1; } - return 0; + + printf_P(msg); + if (msg_target) msg_target(msg); + + return ok; } uint8_t door_clear_alarm(void){ diff --git a/Control/log.c b/Control/log.c index c2ce307..2158ae3 100644 --- a/Control/log.c +++ b/Control/log.c @@ -5,16 +5,17 @@ #include "door.h" #include "power_monitor.h" -const char log_event_startup[] PROGMEM = "== System Started =="; -const char log_event_alarm_raised[] PROGMEM = "Alarm Raised"; -const char log_event_alarm_changed[] PROGMEM = "State change during Alarm"; -const char log_event_alarm_login[] PROGMEM = "Login during Alarm"; -const char log_event_alarm_disabled[] PROGMEM = "Alarm disabled"; -const char log_event_ac_fail[] PROGMEM = "AC Power Fail"; -const char log_event_ac_return[] PROGMEM = "AC Power Restored"; -const char log_event_main_battery_low[] PROGMEM = "Main Battery Low"; -const char log_event_keymatic_battery_low[] PROGMEM = "Keymatic Battery Low"; -const char log_event_door_command_timeout[] PROGMEM = "Door command Timeout"; +const char log_event_startup[] PROGMEM = "== System Started =="; +const char log_event_alarm_raised[] PROGMEM = "Alarm Raised"; +const char log_event_alarm_changed[] PROGMEM = "State change during Alarm"; +const char log_event_alarm_login[] PROGMEM = "Login during Alarm"; +const char log_event_alarm_disabled[] PROGMEM = "Alarm disabled"; +const char log_event_ac_fail[] PROGMEM = "AC Power Fail"; +const char log_event_ac_return[] PROGMEM = "AC Power Restored"; +const char log_event_main_battery_low[] PROGMEM = "Main Battery Low"; +const char log_event_keymatic_battery_low[] PROGMEM = "Keymatic Battery Low"; +const char log_event_door_command_timeout[] PROGMEM = "Door command Timeout"; +const char log_event_door_command_retry_fail[] PROGMEM = "Door command retry failed"; const char* const event_names[] PROGMEM = {log_event_startup, log_event_alarm_raised, @@ -25,7 +26,8 @@ const char* const event_names[] PROGMEM = {log_event_startup, log_event_ac_return, log_event_main_battery_low, log_event_keymatic_battery_low, - log_event_door_command_timeout}; + log_event_door_command_timeout, + log_event_door_command_retry_fail}; uint8_t log_get_first_entry_index(void){ uint8_t l = eeprom_read_byte(LOG_START_POINTER_LOCATION); diff --git a/Control/log.h b/Control/log.h index 111d446..67825eb 100644 --- a/Control/log.h +++ b/Control/log.h @@ -20,16 +20,17 @@ struct log_entry_t{ #define LOG_START_POINTER_LOCATION ((void*)(EEPROM_SIZE-1)) #define LOG_END_POINTER_LOCATION ((void*)(EEPROM_SIZE-2)) -#define LOG_EVENT_STARTUP 0x00 -#define LOG_EVENT_ALARM_RAISED 0x01 -#define LOG_EVENT_ALARM_CHANGED 0x02 -#define LOG_EVENT_ALARM_LOGIN 0x03 -#define LOG_EVENT_ALARM_DISABLED 0x04 -#define LOG_EVENT_AC_FAIL 0x05 -#define LOG_EVENT_AC_RETURN 0x06 -#define LOG_EVENT_MAIN_BATTERY_LOW 0x07 -#define LOG_EVENT_KEYMATIC_BATTERY_LOW 0x08 -#define LOG_EVENT_DOOR_COMMAND_TIMEOUT 0x09 +#define LOG_EVENT_STARTUP 0x00 +#define LOG_EVENT_ALARM_RAISED 0x01 +#define LOG_EVENT_ALARM_CHANGED 0x02 +#define LOG_EVENT_ALARM_LOGIN 0x03 +#define LOG_EVENT_ALARM_DISABLED 0x04 +#define LOG_EVENT_AC_FAIL 0x05 +#define LOG_EVENT_AC_RETURN 0x06 +#define LOG_EVENT_MAIN_BATTERY_LOW 0x07 +#define LOG_EVENT_KEYMATIC_BATTERY_LOW 0x08 +#define LOG_EVENT_DOOR_COMMAND_TIMEOUT 0x09 +#define LOG_EVENT_DOOR_COMMAND_RETRY_FAIL 0x0A #define LOG_EVENT_NONE 0xFF diff --git a/Control/shell/shell.c b/Control/shell/shell.c index 15f840b..158f354 100644 --- a/Control/shell/shell.c +++ b/Control/shell/shell.c @@ -302,14 +302,14 @@ void cmd_lock(readline_parsed_cmd_t* cmd){ if ((cmd->num_args > 0) && (strcmp(cmd->args[0], "-f") == 0)){ lock(); } else { - lock_checked(print_P); + lock_checked(0); } } void cmd_unlock(readline_parsed_cmd_t* cmd){ if ((cmd->num_args > 0) && (strcmp(cmd->args[0], "-f") == 0)){ unlock(); } else { - unlock_checked(print_P); + unlock_checked(0); } } diff --git a/Main.sch b/Main.sch index 1b57a6e..ba90b21 100644 --- a/Main.sch +++ b/Main.sch @@ -1,4 +1,4 @@ -EESchema Schematic File Version 2 date Mi 04 Mai 2011 00:11:36 CEST +EESchema Schematic File Version 2 date Do 15 Mär 2012 14:16:25 CET LIBS:power LIBS:device LIBS:transistors @@ -35,7 +35,7 @@ EELAYER END $Descr A4 11700 8267 Sheet 1 1 Title "" -Date "3 may 2011" +Date "15 mar 2012" Rev "" Comp "" Comment1 "" @@ -43,521 +43,710 @@ Comment2 "" Comment3 "" Comment4 "" $EndDescr -Connection ~ 5350 5650 Wire Wire Line - 5350 5350 5350 5650 + 6600 3300 6600 3100 Wire Wire Line - 3350 5650 2250 5650 + 6600 3100 6600 3000 Wire Wire Line - 2250 5650 2250 5000 + 8100 5750 8000 5750 Wire Wire Line - 2250 5000 2150 5000 + 8000 5750 7900 5750 +Connection ~ 7900 5150 Wire Wire Line - 550 5450 550 5400 + 7900 5250 7900 5150 +Connection ~ 2550 1400 Wire Wire Line - 550 5400 650 5400 + 2550 1150 2550 1400 Wire Wire Line - 650 5400 650 5500 + 2550 1400 2550 1500 +Connection ~ 3150 1400 Wire Wire Line - 650 5500 950 5500 + 2950 1400 3150 1400 +Connection ~ 3250 1400 Wire Wire Line - 950 5400 750 5400 + 3450 1400 3250 1400 Wire Wire Line - 750 5400 750 6350 + 3350 1150 3450 1150 Wire Wire Line - 750 6350 2400 6350 + 3350 1150 3350 1500 +Connection ~ 3150 5500 Wire Wire Line - 5650 6000 5650 5950 + 3000 5550 3000 5500 +Connection ~ 5250 5550 Wire Wire Line - 5650 5950 5550 5950 -Connection ~ 4450 6450 + 5250 5350 5250 5550 Wire Wire Line - 4450 6250 4450 6550 -Connection ~ 8450 2000 + 1850 5200 1850 5500 Wire Wire Line - 8450 2300 8450 1950 -Connection ~ 6200 2800 + 1850 5500 1750 5500 Wire Wire Line - 6200 2700 6200 3000 -Connection ~ 5200 3100 + 2400 6150 2050 6150 Wire Wire Line - 5450 3200 5450 3100 + 2050 6150 2050 5300 Wire Wire Line - 5450 3100 5000 3100 + 2050 5300 1750 5300 Wire Wire Line - 6150 7600 6150 5550 + 5800 6950 5800 6900 Wire Wire Line - 5550 5400 5550 5350 + 5800 6900 5650 6900 +Connection ~ 4550 7400 Wire Wire Line - 6400 1350 6400 2100 + 4550 7300 4550 7400 Wire Wire Line - 6400 2100 4200 2100 -Connection ~ 7550 6200 -Connection ~ 7350 6200 + 4550 7400 4550 7500 Wire Wire Line - 7700 6200 7350 6200 -Connection ~ 6050 6450 + 5700 7700 5700 7700 Wire Wire Line - 6050 6450 6650 6450 + 4200 4900 4500 4900 Wire Wire Line - 6200 1350 6100 1350 + 4500 4900 4500 6150 Wire Wire Line - 6100 1350 6100 1450 + 4500 6150 4400 6150 Wire Wire Line - 3250 5500 3000 5500 -Connection ~ 3150 5500 + 4400 6150 4400 6250 Wire Wire Line - 1900 550 3250 550 -Connection ~ 2200 550 + 4400 6250 4000 6250 +Connection ~ 8350 2400 Wire Wire Line - 6650 7050 6650 7150 + 8350 2400 8350 2250 Wire Wire Line - 7350 6650 7450 6650 + 8350 2250 8250 2250 Wire Wire Line - 8150 6200 8150 6450 + 8250 2250 8250 2300 Wire Wire Line - 8150 6450 7350 6450 + 8050 2400 8350 2400 Wire Wire Line - 6650 6650 6600 6650 -Connection ~ 7800 4500 + 8350 2400 8450 2400 Wire Wire Line - 7800 4500 7850 4500 + 4700 1900 5000 1900 +Connection ~ 6200 2900 Wire Wire Line - 7850 4500 7850 4550 + 5450 3400 5300 3400 Wire Wire Line - 7800 4250 7800 4650 + 5300 3400 5300 3500 Wire Wire Line - 7800 4650 8200 4650 + 5300 3500 4200 3500 Wire Wire Line - 7800 2300 7800 3750 + 4200 3500 4200 3400 Wire Wire Line - 7800 2300 4200 2300 + 6050 5650 6050 6450 Wire Wire Line - 5400 2800 5300 2800 + 6050 6450 6050 6550 Wire Wire Line - 5400 3000 5100 3000 + 6050 6550 6050 7500 Wire Wire Line - 7250 2600 7050 2600 + 5850 6350 5850 5850 Wire Wire Line - 7050 2600 7050 2400 -Connection ~ 6600 2500 + 5850 5850 4800 5850 Wire Wire Line - 6600 2600 6600 2500 -Connection ~ 6500 3100 + 4800 5850 4800 4600 Wire Wire Line - 6500 3300 6500 3000 + 4800 4600 4200 4600 +Connection ~ 6150 6350 Wire Wire Line - 6500 3000 6200 3000 + 6650 6350 6150 6350 Wire Wire Line - 4400 2900 4400 2600 + 4200 2200 6300 2200 Wire Wire Line - 4400 2900 4200 2900 + 6300 2200 6300 1350 Wire Wire Line - 5200 2800 5200 2900 + 2250 5800 2250 5950 Wire Wire Line - 5200 2800 4600 2800 + 2250 5800 3350 5800 Wire Wire Line - 5500 4550 5650 4550 + 2200 2350 2200 2600 Wire Wire Line - 1800 3000 1600 3000 + 8050 6650 8050 6550 Wire Wire Line - 1700 6900 1700 6850 + 8050 6550 7350 6550 Wire Wire Line - 7050 5700 7050 5800 + 7200 6200 7200 6100 Wire Wire Line - 7250 5700 7250 5800 + 7200 6100 7350 6100 Wire Wire Line - 7500 4950 7500 5800 + 7350 6100 7350 6200 Wire Wire Line - 7700 6000 6950 6000 -Connection ~ 8200 4950 + 7350 6200 7350 6350 Wire Wire Line - 7500 4950 8900 4950 + 8050 2000 8450 2000 Wire Wire Line - 6950 5000 6950 4950 + 8200 4550 7950 4550 Wire Wire Line - 7150 5000 7150 4950 + 7950 4550 7950 4250 Wire Wire Line - 7250 5000 7250 4700 + 5400 2600 4400 2600 Wire Wire Line - 7250 4700 6400 4700 -Connection ~ 6600 3100 -Connection ~ 3050 550 + 5400 2900 5200 2900 +Connection ~ 7400 3100 Wire Wire Line - 2200 1000 2200 550 + 7250 3100 7400 3100 Wire Wire Line - 2550 1400 2550 1500 -Connection ~ 3150 1400 + 4200 2400 7050 2400 +Connection ~ 6800 2500 Wire Wire Line - 2950 1400 3150 1400 -Connection ~ 3250 550 -Connection ~ 5650 4350 -Connection ~ 5000 4350 + 6800 2500 6800 2600 Wire Wire Line - 5150 4350 5000 4350 + 7050 3100 6600 3100 Wire Wire Line - 1850 7450 1850 7250 + 6600 3100 6500 3100 Wire Wire Line - 6150 7600 5950 7600 + 6500 3100 6350 3100 Wire Wire Line - 6150 5550 5100 5550 + 6350 3100 6350 3250 Wire Wire Line - 5100 5550 5100 4200 + 8450 2600 7400 2600 Wire Wire Line - 5950 7500 6050 7500 + 5300 2700 5300 2800 Wire Wire Line - 5000 5650 6050 5650 + 5300 2700 5200 2700 Wire Wire Line - 5000 5650 5000 4300 + 5100 2900 5100 3000 Wire Wire Line - 5000 4300 4200 4300 -Connection ~ 5000 3300 + 5100 2900 4500 2900 Wire Wire Line - 5000 3000 5000 3400 + 5650 4200 5650 4350 Wire Wire Line - 3850 5800 4700 5800 + 5650 4350 5650 4650 Wire Wire Line - 4700 5800 4700 4700 + 3250 1500 3250 1400 Wire Wire Line - 4700 4700 4200 4700 + 3250 1400 3250 1250 Wire Wire Line - 1700 5950 2250 5950 + 4700 2500 6600 2500 Wire Wire Line - 1700 6250 2400 6250 + 6600 2500 6800 2500 Wire Wire Line - 5700 4100 5700 4850 + 6800 2500 8450 2500 Wire Wire Line - 5700 4100 4200 4100 + 2400 6850 2000 6850 Wire Wire Line - 6500 3900 4200 3900 + 2000 6850 1850 6850 Wire Wire Line - 6500 3700 4200 3700 + 1850 6850 1700 6850 +Connection ~ 7250 5800 Wire Wire Line - 6600 3100 6600 3000 + 7500 5800 7250 5800 Wire Wire Line - 7800 3750 7950 3750 + 7250 5800 7050 5800 Wire Wire Line - 5700 4850 5900 4850 -Connection ~ 6300 4550 -Connection ~ 6300 3800 + 6950 5700 6950 6000 +Connection ~ 6950 4950 Wire Wire Line - 6300 4150 6300 3800 -Connection ~ 6000 3600 + 6750 4950 6950 4950 Wire Wire Line - 6000 4150 6000 3600 + 6950 4950 7150 4950 Wire Wire Line - 7600 5900 7600 5050 + 6750 4950 6750 5050 Wire Wire Line - 7600 5900 7150 5900 + 7050 5000 7050 4850 Wire Wire Line - 7150 5900 7150 5700 + 7050 4850 6400 4850 Wire Wire Line - 7500 4250 7600 4250 + 6550 4400 6550 4550 Wire Wire Line - 7600 3750 7600 1600 + 3150 1500 3150 1400 Wire Wire Line - 5450 1600 5350 1600 + 3150 1400 3150 1150 +Connection ~ 5100 4200 Wire Wire Line - 5350 1600 5350 1650 + 5150 4200 5100 4200 Wire Wire Line - 2400 7450 1700 7450 + 5100 4200 4200 4200 +Connection ~ 1850 6850 +Connection ~ 2000 6850 +Connection ~ 1850 7450 Wire Wire Line - 2000 7450 2000 7050 + 7400 2600 7400 3100 Wire Wire Line - 2000 6850 2000 6550 + 7400 3100 7400 3750 Wire Wire Line - 4000 6050 4400 6050 + 7400 3750 7400 4750 +Connection ~ 6150 6650 Wire Wire Line - 4400 6050 4400 5000 + 6150 6650 5850 6650 +Connection ~ 6050 6550 Wire Wire Line - 4400 5000 4200 5000 + 5850 6550 6050 6550 Wire Wire Line - 4000 6150 4200 6150 + 5950 7300 5950 5750 Wire Wire Line - 4200 6150 4200 5200 + 5950 5750 4900 5750 Wire Wire Line - 3000 5500 3000 5550 + 4900 5750 4900 4500 Wire Wire Line - 1350 2350 1350 2300 -Connection ~ 1550 2300 + 4900 4500 4200 4500 +Connection ~ 4450 6350 +Connection ~ 5000 3200 Wire Wire Line - 1350 2300 1550 2300 + 1850 4750 1850 4800 Wire Wire Line - 1950 2600 2200 2600 + 4200 4800 4600 4800 Wire Wire Line - 1600 3000 1600 3100 + 4600 4800 4600 5650 Wire Wire Line - 4500 2800 4500 2900 + 4600 5650 3850 5650 Wire Wire Line - 4500 2800 4200 2800 + 1850 6450 1850 6050 Wire Wire Line - 4200 2700 4600 2700 + 1700 6150 1950 6150 Wire Wire Line - 4600 2700 4600 2800 + 5900 4000 5900 4700 Wire Wire Line - 2200 1500 2200 1800 + 5900 4000 4200 4000 Wire Wire Line - 1950 2000 2200 2000 + 6600 3800 6400 3800 Wire Wire Line - 2200 2000 2200 2200 + 6400 3800 4200 3800 Wire Wire Line - 1550 2000 1550 2600 + 6600 3600 6100 3600 Wire Wire Line - 2200 1800 2100 1800 + 6100 3600 4200 3600 Wire Wire Line - 4200 5100 4300 5100 + 5850 1600 7600 1600 +Connection ~ 8200 5050 Wire Wire Line - 4300 5100 4300 6350 + 8900 5050 8200 5050 Wire Wire Line - 4300 6350 4000 6350 + 8200 5050 8100 5050 Wire Wire Line - 1700 7450 1700 7350 -Connection ~ 2000 7450 + 8100 5050 7600 5050 +Connection ~ 6550 4550 Wire Wire Line - 1700 6050 1850 6050 + 6800 4450 6800 4400 Wire Wire Line - 2400 6050 1950 6050 + 6800 4400 6700 4400 Wire Wire Line - 1950 6050 1950 6150 -Connection ~ 5000 3100 + 6700 4400 6700 4550 Wire Wire Line - 5200 3150 5200 3100 + 6700 4550 6550 4550 Wire Wire Line - 4700 1800 4700 1300 + 6550 4550 6400 4550 Wire Wire Line - 4700 1300 5650 1300 + 6400 4550 6250 4550 Wire Wire Line - 7600 4250 7600 4450 + 6250 4550 6100 4550 Wire Wire Line - 7500 3750 7400 3750 -Connection ~ 7400 3750 + 5900 4700 5900 4700 +Connection ~ 6250 4550 +Connection ~ 6550 3900 Wire Wire Line - 7800 4750 8200 4750 + 6550 4000 6550 3900 +Connection ~ 6250 3700 +Wire Wire Line + 6250 4000 6250 3700 Wire Wire Line - 8200 5150 7700 5150 + 6250 4400 6250 4550 Wire Wire Line 7700 5150 7700 6000 Wire Wire Line - 6150 4400 6150 4550 + 7700 5150 7900 5150 Wire Wire Line - 6150 4000 6150 3700 -Connection ~ 6150 3700 + 7900 5150 8200 5150 Wire Wire Line - 6450 4000 6450 3900 -Connection ~ 6450 3900 -Connection ~ 6150 4550 + 7800 4750 8200 4750 +Connection ~ 7400 3750 Wire Wire Line - 5900 4700 5800 4700 + 7500 3750 7400 3750 Wire Wire Line - 6000 4550 6600 4550 + 7600 4450 7600 4250 Wire Wire Line - 6600 4550 6600 4400 + 5650 1300 4700 1300 Wire Wire Line - 6600 4400 6700 4400 + 4700 1300 4700 1800 Wire Wire Line - 6700 4400 6700 4450 -Connection ~ 6450 4550 + 5200 3150 5200 3100 +Connection ~ 5000 3100 Wire Wire Line - 7600 5050 8900 5050 -Connection ~ 8200 5050 + 1950 6150 1950 6050 Wire Wire Line - 7600 1600 5850 1600 + 1950 6050 2400 6050 Wire Wire Line - 6500 3600 4200 3600 + 1850 6050 1700 6050 +Connection ~ 2000 7450 Wire Wire Line - 6500 3800 4200 3800 + 1700 7350 1700 7450 Wire Wire Line - 4200 4000 5800 4000 + 4000 6350 4300 6350 Wire Wire Line - 5800 4000 5800 4700 + 4300 6350 4300 5100 Wire Wire Line - 1950 6150 1700 6150 + 4300 5100 4200 5100 Wire Wire Line - 1850 6050 1850 6450 + 2100 1800 2200 1800 Wire Wire Line - 3850 5650 4600 5650 + 1550 2000 1550 2300 Wire Wire Line - 4600 5650 4600 4800 + 1550 2300 1550 2600 Wire Wire Line - 4600 4800 4200 4800 + 2200 2200 2200 2000 Wire Wire Line - 1850 4750 1850 4800 -Connection ~ 5000 3200 -Connection ~ 4450 6350 + 2200 2000 1950 2000 Wire Wire Line - 4200 4500 4900 4500 + 2200 1800 2200 1500 Wire Wire Line - 4900 4500 4900 5750 + 4600 2700 4600 2800 Wire Wire Line - 4900 5750 5950 5750 + 4600 2700 4200 2700 Wire Wire Line - 5950 5750 5950 7300 + 4200 2800 4500 2800 Wire Wire Line - 5850 6550 6050 6550 -Connection ~ 6050 6550 + 4500 2800 4500 2900 Wire Wire Line - 5850 6650 6150 6650 -Connection ~ 6150 6650 + 1600 3100 1600 3000 Wire Wire Line - 7400 4750 7400 2600 -Connection ~ 1850 7450 -Connection ~ 2000 6850 -Connection ~ 1850 6850 + 2200 2600 1950 2600 Wire Wire Line - 5150 4200 4200 4200 -Connection ~ 5100 4200 + 1550 2300 1350 2300 +Connection ~ 1550 2300 Wire Wire Line - 3450 1400 3250 1400 + 1350 2300 1350 2350 Wire Wire Line - 3150 1500 3150 1150 + 4200 5200 4200 6150 Wire Wire Line - 3150 1150 3050 1150 + 4200 6150 4000 6150 Wire Wire Line - 3050 1150 3050 550 + 4200 5000 4400 5000 Wire Wire Line - 6450 4400 6450 4550 + 4400 5000 4400 6050 Wire Wire Line - 6400 4850 7050 4850 + 4400 6050 4000 6050 Wire Wire Line - 7050 4850 7050 5000 + 2000 6850 2000 6550 Wire Wire Line - 6750 5050 6750 4950 + 2000 7450 2000 7050 Wire Wire Line - 6750 4950 7150 4950 -Connection ~ 6950 4950 + 1700 7450 1850 7450 Wire Wire Line - 6950 6000 6950 5700 + 1850 7450 2000 7450 Wire Wire Line - 7500 5800 7050 5800 -Connection ~ 7250 5800 + 2000 7450 2400 7450 Wire Wire Line - 1700 6850 2400 6850 + 5350 1650 5350 1600 Wire Wire Line - 4700 2500 8450 2500 + 5350 1600 5450 1600 Wire Wire Line - 3250 1500 3250 1250 -Connection ~ 3250 1400 + 7600 1600 7600 3750 Wire Wire Line - 5650 4550 5650 4200 + 7600 4250 7500 4250 Wire Wire Line - 4500 2900 5100 2900 + 7150 5700 7150 5900 Wire Wire Line - 5100 2900 5100 3000 + 7150 5900 7600 5900 Wire Wire Line - 5200 2700 5300 2700 + 7600 5900 7600 5050 Wire Wire Line - 5300 2700 5300 2800 + 6100 4150 6100 3600 +Connection ~ 6100 3600 Wire Wire Line - 7400 2600 8450 2600 + 6400 4150 6400 3800 +Connection ~ 6400 3800 +Connection ~ 6400 4550 Wire Wire Line - 6350 3250 6350 3100 + 5900 4850 5800 4850 Wire Wire Line - 6350 3100 7050 3100 + 7950 3750 7800 3750 Wire Wire Line - 6800 2500 6800 2600 -Connection ~ 6800 2500 + 6600 3700 6250 3700 Wire Wire Line - 7050 2400 4200 2400 + 6250 3700 4200 3700 Wire Wire Line - 7250 3100 7400 3100 -Connection ~ 7400 3100 + 6600 3900 6550 3900 Wire Wire Line - 5200 2900 5400 2900 + 6550 3900 4200 3900 Wire Wire Line - 4400 2600 5400 2600 + 4200 4100 5800 4100 Wire Wire Line - 7950 4250 7950 4550 + 5800 4100 5800 4850 Wire Wire Line - 7950 4550 8200 4550 + 1700 6250 2400 6250 Wire Wire Line - 8050 2000 8450 2000 + 2250 5950 1700 5950 Wire Wire Line - 7350 6350 7350 6100 + 4200 4700 4700 4700 Wire Wire Line - 7350 6100 7200 6100 + 4700 4700 4700 5800 Wire Wire Line - 7200 6100 7200 6200 + 4700 5800 3850 5800 Wire Wire Line - 7350 6550 8050 6550 + 5000 3000 5000 3100 Wire Wire Line - 8050 6550 8050 6650 + 5000 3100 5000 3200 Wire Wire Line - 3850 1400 3850 1500 + 5000 3200 5000 3300 Wire Wire Line - 2200 2600 2200 2350 + 5000 3300 5000 3400 +Connection ~ 5000 3300 Wire Wire Line - 3350 5800 2250 5800 + 4200 4300 5000 4300 Wire Wire Line - 2250 5800 2250 5950 + 5000 4300 5000 4350 Wire Wire Line - 6300 1350 6300 2200 + 5000 4350 5000 5650 Wire Wire Line - 6300 2200 4200 2200 + 5000 5650 5350 5650 Wire Wire Line - 6150 6350 6650 6350 -Connection ~ 6150 6350 + 5350 5650 6050 5650 +Wire Wire Line + 6050 7500 5950 7500 Wire Wire Line - 4200 4600 4800 4600 + 5100 4200 5100 5550 Wire Wire Line - 4800 4600 4800 5850 + 5100 5550 5250 5550 Wire Wire Line - 4800 5850 5850 5850 + 5250 5550 6150 5550 Wire Wire Line - 5850 5850 5850 6350 + 5950 7600 6150 7600 Wire Wire Line - 6050 5650 6050 7500 + 1850 7450 1850 7250 Wire Wire Line - 4200 3400 4200 3500 + 5150 4350 5000 4350 +Connection ~ 5000 4350 +Connection ~ 5650 4350 Wire Wire Line - 4200 3500 5300 3500 + 2200 1000 2200 550 +Connection ~ 3050 550 +Connection ~ 6600 3100 Wire Wire Line - 5300 3500 5300 3400 + 6400 4700 7250 4700 Wire Wire Line - 5300 3400 5450 3400 -Connection ~ 6200 2900 + 7250 4700 7250 5000 Wire Wire Line - 4700 1900 5000 1900 + 7150 4950 7150 5000 Wire Wire Line - 8050 2400 8450 2400 + 6950 5000 6950 4950 Wire Wire Line - 8250 2300 8250 2250 + 8900 4950 8200 4950 Wire Wire Line - 8250 2250 8350 2250 + 8200 4950 7500 4950 +Connection ~ 8200 4950 Wire Wire Line - 8350 2250 8350 2400 -Connection ~ 8350 2400 + 7700 6000 6950 6000 Wire Wire Line - 4000 6250 4400 6250 + 7500 4950 7500 5800 Wire Wire Line - 4400 6250 4400 6150 + 7250 5700 7250 5800 Wire Wire Line - 4400 6150 4500 6150 + 7050 5800 7050 5700 Wire Wire Line - 4500 6150 4500 4900 + 1700 6850 1700 6900 Wire Wire Line - 4500 4900 4200 4900 + 1600 3000 1800 3000 Wire Wire Line - 5700 7700 5700 7700 + 5650 4650 5500 4650 Wire Wire Line - 4550 7300 4550 7500 -Connection ~ 4550 7400 + 4600 2800 5200 2800 Wire Wire Line - 5650 6900 5800 6900 + 5200 2800 5200 2900 +Wire Wire Line + 4200 2900 4400 2900 Wire Wire Line - 5800 6900 5800 6950 + 4400 2900 4400 2600 Wire Wire Line - 1750 5300 2050 5300 + 6500 3000 6200 3000 Wire Wire Line - 2050 5300 2050 6150 + 6500 3000 6500 3100 +Connection ~ 6500 3100 Wire Wire Line - 2050 6150 2400 6150 + 6600 2500 6600 2600 +Connection ~ 6600 2500 Wire Wire Line - 1750 5500 1850 5500 + 7050 2400 7050 2600 Wire Wire Line - 1850 5500 1850 5200 + 7050 2600 7250 2600 Wire Wire Line - 5250 5350 5250 5550 -Connection ~ 5250 5550 + 5100 3000 5400 3000 +Wire Wire Line + 5300 2800 5400 2800 +Wire Wire Line + 4200 2300 7800 2300 +Wire Wire Line + 7800 2300 7800 3750 +Wire Wire Line + 8200 4650 7800 4650 +Wire Wire Line + 7800 4650 7800 4500 +Wire Wire Line + 7800 4500 7800 4250 +Wire Wire Line + 7850 4550 7850 4500 +Wire Wire Line + 7850 4500 7800 4500 +Connection ~ 7800 4500 +Wire Wire Line + 6650 6650 6600 6650 +Wire Wire Line + 7350 6450 8150 6450 +Wire Wire Line + 8150 6450 8150 6200 +Wire Wire Line + 7350 6650 7450 6650 +Wire Wire Line + 6650 7050 6650 7150 +Connection ~ 2200 550 +Wire Wire Line + 6100 1450 6100 1350 +Wire Wire Line + 6100 1350 6200 1350 +Wire Wire Line + 6050 6450 6650 6450 +Connection ~ 6050 6450 +Wire Wire Line + 7350 6200 7550 6200 +Wire Wire Line + 7550 6200 7700 6200 +Connection ~ 7350 6200 +Connection ~ 7550 6200 +Wire Wire Line + 4200 2100 6400 2100 +Wire Wire Line + 6400 2100 6400 1350 +Wire Wire Line + 5550 5400 5550 5350 +Wire Wire Line + 6150 7600 6150 6650 +Wire Wire Line + 6150 6650 6150 6350 +Wire Wire Line + 6150 6350 6150 5550 +Wire Wire Line + 5000 3100 5200 3100 +Wire Wire Line + 5200 3100 5450 3100 +Wire Wire Line + 5450 3100 5450 3200 +Connection ~ 5200 3100 +Wire Wire Line + 6200 3000 6200 2900 +Wire Wire Line + 6200 2900 6200 2800 +Wire Wire Line + 6200 2800 6200 2700 +Connection ~ 6200 2800 +Wire Wire Line + 8450 2300 8450 2000 +Wire Wire Line + 8450 2000 8450 1950 +Connection ~ 8450 2000 +Wire Wire Line + 4450 6250 4450 6350 +Wire Wire Line + 4450 6350 4450 6450 +Wire Wire Line + 4450 6450 4450 6550 +Connection ~ 4450 6450 +Wire Wire Line + 5550 5950 5650 5950 +Wire Wire Line + 5650 5950 5650 6000 +Wire Wire Line + 2400 6350 750 6350 +Wire Wire Line + 750 6350 750 5400 +Wire Wire Line + 750 5400 950 5400 +Wire Wire Line + 950 5500 650 5500 +Wire Wire Line + 650 5500 650 5400 +Wire Wire Line + 650 5400 550 5400 +Wire Wire Line + 550 5400 550 5450 +Wire Wire Line + 2150 5000 2250 5000 +Wire Wire Line + 2250 5000 2250 5650 +Wire Wire Line + 2250 5650 3350 5650 +Wire Wire Line + 5350 5350 5350 5650 +Connection ~ 5350 5650 +Connection ~ 3050 5500 +Wire Wire Line + 3000 5500 3050 5500 +Wire Wire Line + 3050 5500 3150 5500 +Wire Wire Line + 3150 5500 3250 5500 +Wire Wire Line + 3250 5500 3350 5500 +Connection ~ 3250 5500 +Wire Wire Line + 1900 550 2200 550 +Wire Wire Line + 2200 550 3050 550 +Wire Wire Line + 3050 550 3250 550 +Wire Wire Line + 3250 550 3450 550 +Wire Wire Line + 3450 550 3450 1150 +Connection ~ 3250 550 +Wire Wire Line + 3150 1150 3050 1150 +Wire Wire Line + 3050 1150 2950 1150 +Connection ~ 3050 1150 +Wire Wire Line + 3050 1500 3050 1150 +Wire Wire Line + 3050 1150 3050 550 +Wire Wire Line + 3850 1500 3850 1400 +Wire Wire Line + 3850 1400 3850 1150 +Connection ~ 3850 1400 +Wire Wire Line + 8100 5250 8100 5050 +Connection ~ 8100 5050 +Wire Wire Line + 8000 5850 8000 5750 +Connection ~ 8000 5750 +$Comp +L GND #PWR? +U 1 1 4F61E51B +P 8000 5850 +F 0 "#PWR?" H 8000 5850 30 0001 C CNN +F 1 "GND" H 8000 5780 30 0001 C CNN + 1 8000 5850 + 1 0 0 -1 +$EndComp +$Comp +L R R24 +U 1 1 4F61E4F1 +P 8100 5500 +F 0 "R24" V 8180 5500 50 0000 C CNN +F 1 "100k" V 8100 5500 50 0000 C CNN + 1 8100 5500 + 1 0 0 -1 +$EndComp +$Comp +L R R23 +U 1 1 4F61E4E6 +P 7900 5500 +F 0 "R23" V 7980 5500 50 0000 C CNN +F 1 "100k" V 7900 5500 50 0000 C CNN + 1 7900 5500 + 1 0 0 -1 +$EndComp +$Comp +L C C6 +U 1 1 4F61DFF3 +P 3650 1150 +F 0 "C6" V 3700 1250 50 0000 L CNN +F 1 "100nF" V 3550 1300 50 0000 L CNN + 1 3650 1150 + 0 1 1 0 +$EndComp +$Comp +L C C4 +U 1 1 4F61DFE9 +P 2750 1400 +F 0 "C4" V 2800 1500 50 0000 L CNN +F 1 "100nF" V 2650 1550 50 0000 L CNN + 1 2750 1400 + 0 1 1 0 +$EndComp NoConn ~ 950 5700 NoConn ~ 1750 5700 NoConn ~ 1750 5400 @@ -844,8 +1033,8 @@ F 1 "RNG" V 6350 1000 50 0000 C CNN 1 6300 1000 0 -1 -1 0 $EndComp -NoConn ~ 6500 3500 -NoConn ~ 6500 3400 +NoConn ~ 6600 3500 +NoConn ~ 6600 3400 $Comp L R R22 U 1 1 4D3F19C4 @@ -885,19 +1074,19 @@ $EndComp $Comp L C C5 U 1 1 4D3F1433 -P 2750 1400 -F 0 "C5" V 2800 1500 50 0000 L CNN -F 1 "100nF" V 2650 1550 50 0000 L CNN - 1 2750 1400 +P 2750 1150 +F 0 "C5" V 2800 1250 50 0000 L CNN +F 1 "100nF" V 2650 1300 50 0000 L CNN + 1 2750 1150 0 1 1 0 $EndComp $Comp L +5V #PWR07 U 1 1 4D39D7B1 -P 5500 4550 -F 0 "#PWR07" H 5500 4640 20 0001 C CNN -F 1 "+5V" H 5500 4640 30 0000 C CNN - 1 5500 4550 +P 5500 4650 +F 0 "#PWR07" H 5500 4740 20 0001 C CNN +F 1 "+5V" H 5500 4740 30 0000 C CNN + 1 5500 4650 1 0 0 -1 $EndComp $Comp @@ -1004,7 +1193,7 @@ L BC307 Q3 U 1 1 4D36290D P 1950 5000 F 0 "Q3" V 2150 4900 50 0000 C CNN -F 1 "PNP BC557" V 1800 5050 50 0000 C CNN +F 1 "PNP BC328" V 1800 5050 50 0000 C CNN 1 1950 5000 -1 0 0 1 $EndComp @@ -1101,46 +1290,46 @@ $EndComp $Comp L GND #PWR020 U 1 1 4D094C1F -P 6700 4450 -F 0 "#PWR020" H 6700 4450 30 0001 C CNN -F 1 "GND" H 6700 4380 30 0001 C CNN - 1 6700 4450 +P 6800 4450 +F 0 "#PWR020" H 6800 4450 30 0001 C CNN +F 1 "GND" H 6800 4380 30 0001 C CNN + 1 6800 4450 1 0 0 -1 $EndComp $Comp L C C16 U 1 1 4D094AF6 -P 6000 4350 -F 0 "C16" H 5850 4400 50 0000 L CNN -F 1 "100nF" H 5850 4250 50 0000 L CNN - 1 6000 4350 +P 6100 4350 +F 0 "C16" H 5950 4400 50 0000 L CNN +F 1 "100nF" H 5950 4250 50 0000 L CNN + 1 6100 4350 1 0 0 -1 $EndComp $Comp L C C19 U 1 1 4D094AC9 -P 6300 4350 -F 0 "C19" H 6450 4400 50 0000 L CNN -F 1 "100nF" H 6400 4600 50 0000 L CNN - 1 6300 4350 +P 6400 4350 +F 0 "C19" H 6550 4400 50 0000 L CNN +F 1 "100nF" H 6500 4600 50 0000 L CNN + 1 6400 4350 1 0 0 -1 $EndComp $Comp L C C17 U 1 1 4D094AC6 -P 6150 4200 -F 0 "C17" H 6050 4100 50 0000 L CNN -F 1 "100nF" H 6200 3950 50 0000 L CNN - 1 6150 4200 +P 6250 4200 +F 0 "C17" H 6150 4100 50 0000 L CNN +F 1 "100nF" H 6300 3950 50 0000 L CNN + 1 6250 4200 1 0 0 -1 $EndComp $Comp L C C18 U 1 1 4D094A8E -P 6450 4200 -F 0 "C18" H 6500 4300 50 0000 L CNN -F 1 "100nF" H 6600 4100 50 0000 L CNN - 1 6450 4200 +P 6550 4200 +F 0 "C18" H 6600 4300 50 0000 L CNN +F 1 "100nF" H 6700 4100 50 0000 L CNN + 1 6550 4200 -1 0 0 1 $EndComp $Comp @@ -1218,10 +1407,10 @@ $EndComp $Comp L CONN_7 JP7 U 1 1 4D093CC0 -P 6850 3600 -F 0 "JP7" H 6850 3900 60 0000 C CNN -F 1 "Sensors" V 6920 3600 60 0000 C CNN - 1 6850 3600 +P 6950 3600 +F 0 "JP7" H 6950 3900 60 0000 C CNN +F 1 "Sensors" V 7020 3600 60 0000 C CNN + 1 6950 3600 1 0 0 -1 $EndComp $Comp @@ -1482,7 +1671,7 @@ F 1 "MAX232" H 3200 5900 70 0000 C CNN -1 0 0 1 $EndComp $Comp -L ATMEGA32-P IC1 +L ATMEGA32-A IC1 U 1 1 4D091A70 P 3200 3500 F 0 "IC1" H 2400 5330 50 0000 L BNN diff --git a/common/serial.h b/common/serial.h index 8efe63d..16b1dac 100644 --- a/common/serial.h +++ b/common/serial.h @@ -154,18 +154,15 @@ void FUNC_switch_baudrate(uint32_t baud){ } void FUNC_switch_mode_receive(void){ - //Wait for empty transmit buffer - while ( !( UCSRA & (1 << UDRE)) ) {;} + while ( !( UCSRA & (1 << TXC)) ) {;} //Wait for transmit complete UCSRB &= ~(1<<TXEN); - _delay_ms(1); UCSRB |= (1<<RXEN); - while (UCSRA & (1 << RXC)){ //trash receive buffer - UDR; - } + while (UCSRA & (1 << RXC)){UDR;} //trash receive buffer } void FUNC_switch_mode_transmit(void){ UCSRB |= (1<<TXEN); UCSRB &= ~(1<<RXEN); + while (UCSRA & (1 << RXC)){UDR;} //trash receive buffer } -- GitLab