restructuring

This commit is contained in:
2022-03-10 11:04:14 +03:00
parent 29560b7c0c
commit 733dbd75d2
1758 changed files with 14 additions and 26855 deletions

View File

@@ -0,0 +1,134 @@
BINARY = servo
BOOTPORT ?= /dev/ttyUSB0
BOOTSPEED ?= 115200
# MCU FAMILY
FAMILY = F0
# MCU code
MCU = F030x4
DEFS = -DEBUG
# change this linking script depending on particular MCU model,
# for example, if you have STM32F103VBT6, you should write:
LDSCRIPT = stm32f030f.ld
INDEPENDENT_HEADERS=
FP_FLAGS ?= -msoft-float
ASM_FLAGS = -mthumb -mcpu=cortex-m0 -march=armv6-m -mtune=cortex-m0
ARCH_FLAGS = $(ASM_FLAGS) $(FP_FLAGS)
###############################################################################
# Executables
PREFIX ?= /opt/bin/arm-none-eabi
RM := rm -f
RMDIR := rmdir
CC := $(PREFIX)-gcc
LD := $(PREFIX)-gcc
AR := $(PREFIX)-ar
AS := $(PREFIX)-as
OBJCOPY := $(PREFIX)-objcopy
OBJDUMP := $(PREFIX)-objdump
GDB := $(PREFIX)-gdb
STFLASH := $(shell which st-flash)
STBOOT := $(shell which stm32flash)
###############################################################################
# Source files
OBJDIR = mk
LDSCRIPT ?= $(BINARY).ld
SRC := $(wildcard *.c)
OBJS := $(addprefix $(OBJDIR)/, $(SRC:%.c=%.o))
STARTUP = $(OBJDIR)/startup.o
OBJS += $(STARTUP)
DEPS := $(OBJS:.o=.d)
INC_DIR ?= ../inc
INCLUDE := -I$(INC_DIR)/Fx -I$(INC_DIR)/cm
LIB_DIR := $(INC_DIR)/ld
###############################################################################
# C flags
CFLAGS += -O2 -g -MD -D__thumb2__=1
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
CFLAGS += -Wredundant-decls $(INCLUDE)
# -Wmissing-prototypes -Wstrict-prototypes
CFLAGS += -fno-common -ffunction-sections -fdata-sections
###############################################################################
# Linker flags
LDFLAGS += --static -nostartfiles
#--specs=nano.specs
LDFLAGS += -L$(LIB_DIR)
LDFLAGS += -T$(LDSCRIPT)
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
LDFLAGS += -Wl,--gc-sections
###############################################################################
# Used libraries
LDLIBS += -Wl,--start-group -lc -lgcc -Wl,--end-group
LDLIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
DEFS += -DSTM32$(FAMILY) -DSTM32$(MCU)
#.SUFFIXES: .elf .bin .hex .srec .list .map .images
#.SECONDEXPANSION:
#.SECONDARY:
ELF := $(OBJDIR)/$(BINARY).elf
LIST := $(OBJDIR)/$(BINARY).list
BIN := $(BINARY).bin
HEX := $(BINARY).hex
all: bin list
elf: $(ELF)
bin: $(BIN)
hex: $(HEX)
list: $(LIST)
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif
$(OBJDIR):
mkdir $(OBJDIR)
$(STARTUP): $(INC_DIR)/startup/vector.c
$(CC) $(CFLAGS) $(DEFS) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
$(OBJDIR)/%.o: %.c
@echo " CC $<"
$(CC) $(CFLAGS) $(DEFS) $(INCLUDE) $(ARCH_FLAGS) -o $@ -c $<
$(BIN): $(ELF)
@echo " OBJCOPY $(BIN)"
$(OBJCOPY) -Obinary $(ELF) $(BIN)
$(HEX): $(ELF)
@echo " OBJCOPY $(HEX)"
$(OBJCOPY) -Oihex $(ELF) $(HEX)
$(LIST): $(ELF)
@echo " OBJDUMP $(LIST)"
$(OBJDUMP) -S $(ELF) > $(LIST)
$(ELF): $(OBJDIR) $(OBJS)
@echo " LD $(ELF)"
$(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(ELF)
clean:
@echo " CLEAN"
$(RM) $(OBJS) $(DEPS) $(ELF) $(HEX) $(LIST) $(OBJDIR)/*.map
@rmdir $(OBJDIR) 2>/dev/null || true
flash: $(BIN)
@echo " FLASH $(BIN)"
$(STFLASH) write $(BIN) 0x8000000
boot: $(BIN)
@echo " LOAD $(BIN) through bootloader"
$(STBOOT) -b$(BOOTSPEED) $(BOOTPORT) -w $(BIN)
.PHONY: clean flash boot

View File

@@ -0,0 +1,38 @@
Servo motors SG-90 management
=============================
## GPIO
- PA0..PA3 - 4 ADC inputs
- PA6 - (TIM3_CH1) - Servo1,
- PA7 - (TIM3_CH2) - Servo2,
- PA9 - (USART_Tx) - TX,
- PA10 - (USART_Rx) - RX,
- PB1 - (TIM3_CH4) - Servo3,
- PF1 - (OpenDrain) - external LED or laser (0 - active)
## UART
115200N1, not more than 100ms between data bytes in command.
To turn ON human terminal (without timeout) send "####".
## Protocol
All commands are in brackets: `[ command line ]`.
'[' clears earlier input; '\n', '\r', ' ', '\t' are ignored.
All messages are asynchronous!
## Commands
* **d** - debugging commands:
* **A** - get raw ADC values,
* **w** - watchdog test;
* **R** - reset;
* **t** - get MCU temperature;
* **V** - get VDD value.
## Messages
## Servos
The board controls up to three servos like SG-90.
Three timer's outputs used for this purpose. Timer frequency 50Hz, pulse width from 500 to 2400us.

View File

@@ -0,0 +1,74 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adc.h"
/**
* @brief ADC_array - array for ADC channels with median filtering:
* 0..3 - external channels
* 4 - internal Tsens
* 5 - Vref
*/
#define TSENS_CHAN (4)
#define VREF_CHAN (5)
uint16_t ADC_array[NUMBER_OF_ADC_CHANNELS*9];
/**
* @brief getADCval - calculate median value for `nch` channel
* @param nch - number of channel
* @return
*/
uint16_t getADCval(int nch){
int i, addr = nch;
register uint16_t temp;
#define PIX_SORT(a,b) { if ((a)>(b)) PIX_SWAP((a),(b)); }
#define PIX_SWAP(a,b) { temp=(a);(a)=(b);(b)=temp; }
uint16_t p[9];
for(i = 0; i < 9; ++i, addr += NUMBER_OF_ADC_CHANNELS) // first we should prepare array for optmed
p[i] = ADC_array[addr];
PIX_SORT(p[1], p[2]) ; PIX_SORT(p[4], p[5]) ; PIX_SORT(p[7], p[8]) ;
PIX_SORT(p[0], p[1]) ; PIX_SORT(p[3], p[4]) ; PIX_SORT(p[6], p[7]) ;
PIX_SORT(p[1], p[2]) ; PIX_SORT(p[4], p[5]) ; PIX_SORT(p[7], p[8]) ;
PIX_SORT(p[0], p[3]) ; PIX_SORT(p[5], p[8]) ; PIX_SORT(p[4], p[7]) ;
PIX_SORT(p[3], p[6]) ; PIX_SORT(p[1], p[4]) ; PIX_SORT(p[2], p[5]) ;
PIX_SORT(p[4], p[7]) ; PIX_SORT(p[4], p[2]) ; PIX_SORT(p[6], p[4]) ;
PIX_SORT(p[4], p[2]) ;
return p[4];
#undef PIX_SORT
#undef PIX_SWAP
}
// return MCU temperature (degrees of celsius * 10)
int32_t getMCUtemp(){
getVdd();
// make correction on Vdd value
// int32_t temperature = (int32_t)ADC_array[4] * VddValue / 330;
int32_t ADval = getADCval(TSENS_CHAN);
int32_t temperature = (int32_t) *TEMP30_CAL_ADDR - ADval;
temperature *= (int32_t)(1100 - 300);
temperature /= (int32_t)(*TEMP30_CAL_ADDR - *TEMP110_CAL_ADDR);
temperature += 300;
return(temperature);
}
// return Vdd * 100 (V)
uint32_t getVdd(){
uint32_t vdd = ((uint32_t) *VREFINT_CAL_ADDR) * (uint32_t)330; // 3.3V
vdd /= getADCval(VREF_CHAN);
return vdd;
}

View File

@@ -0,0 +1,29 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADC_H
#define ADC_H
#include "stm32f0.h"
#define NUMBER_OF_ADC_CHANNELS (6)
extern uint16_t ADC_array[];
int32_t getMCUtemp();
uint32_t getVdd();
uint16_t getADCval(int nch);
#endif // ADC_H

View File

@@ -0,0 +1,179 @@
/*
* This file is part of the Servo project.
* Copyright 2019 Edward Emelianov <eddy@sao.ru>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "effects.h"
#include "hardware.h"
#include "usart.h"
uint8_t dma_eff = 0;
static effect_t current_ef[3] = {EFF_NONE, EFF_NONE, EFF_NONE};
static int8_t cntr[3] = {0,0,0}, dir[3] = {1,1,1};
#define SPD_STP (25)
static void eff_madwipe(int n){
static uint32_t speed[3] = {SPD_STP, SPD_STP, SPD_STP};
if(onposition(n)){ // move back
if((speed[n]+=SPD_STP) > SG90_STEP) speed[n] = SPD_STP;
int val = 0;
if(getPWM(n) < SG90_MIDPULSE) val = 1;
setPWM(n, val, speed[n]);
}
}
static void eff_wipe(int n){
if(onposition(n)){ // move back
int val = 0;
if(getPWM(n) < SG90_MIDPULSE) val = 1;
if(++cntr[n] < 4){ // stay a little in outermost positions
setPWM(n, getPWM(n), SG90_STEP/2);
}else{
cntr[n] = 0;
setPWM(n, val, SG90_STEP/2);
}
}
}
static void eff_pendulum(int n){
const uint16_t steps[41] = {0, 10, 21, 33, 47, 62, 79, 97, 117, 140, 165, 193, 224, 258, 295, 337, 383, 434,
490, 552, 621, 697, 766, 828, 884, 935, 981, 1023, 1060, 1094, 1125, 1153, 1178,
1201, 1221, 1239, 1256, 1271, 1285, 1297, 1308};
if(onposition(n)){
setPWM(n, SG90_MINPULSE + steps[cntr[n]], SG90_STEP);
cntr[n] += dir[n];
if(cntr[n] == -1){ // min position
dir[n] = 1;
cntr[n] = 0; // repeat zero position one time
}else if(cntr[n] == 41){ // max position
dir[n] = -1;
cntr[n] = 40; // and this position needs to repeat too
}
}
}
static void eff_pendsm(int n){
const uint16_t steps[19] = {0, 6, 10, 15, 22, 30, 40, 52, 66, 82, 101, 123, 148, 177, 210, 247, 289, 336, 389};
if(onposition(n)){
setPWM(n, SG90_MINPULSE + steps[cntr[n]], SG90_STEP);
cntr[n] += dir[n];
if(cntr[n] == -1){ // min position
dir[n] = 1;
cntr[n] = 1;
}else if(cntr[n] == 19){ // max position
dir[n] = -1;
cntr[n] = 18;
}
}
}
// buffers for different DMA effects, by pairs: 1st number is CCR1, 2nd is CCR2
static const uint16_t dmabufsmall[] = { 1400,800,1400,800,
1400,1000,1400,1000,
1600,1000,1600,1000,
1600,800,1600,800,};
static const uint16_t dmabufmed[] = { 1400,800,1400,800,1400,800,1400,800,
1400,1000,1400,1000,1400,1000,1400,1000,
1600,1000,1600,1000,1600,1000,1600,1000,
1600,800,1600,800,1600,800,1600,800};
static const uint16_t dmabufbig[] = { 1400,800,1400,800,1400,800,1400,800,1400,800,1400,800,
1400,1000,1400,1000,1400,1000,1400,1000,1400,1000,1400,1000,
1600,1000,1600,1000,1600,1000,1600,1000,1600,1000,1600,1000,
1600,800,1600,800,1600,800,1600,800,1600,800,1600,800};
static const uint16_t dmabuftest[] = { 1400,800,1400,840,1400,880,1400,920,1400,960,1400,1000,
1400,1000,1440,1000,1480,1000,1520,1000,1560,1000,1600,1000,
1600,1000,1600,960,1600,920,1600,880,1600,840,1600,800,
1600,800,1560,800,1520,800,1480,800,1440,800,1400,800};
static const uint16_t dmabufstar[] = { 1300,930,1300,930,1300,930,1300,930,1300,930,1300,930,
1500,930,1500,930,1500,930,1500,930,1500,930,1500,930,
1330,800,1330,800,1330,800,1330,800,1330,800,1330,800,
1400,1000,1400,1000,1400,1000,1400,1000,1400,1000,1400,1000,
1470,800,1470,800,1470,800,1470,800,1470,800,1470,800};
static void DMA_eff(const void* buff, uint8_t len){
DMA1_Channel3->CMAR = (uint32_t)(buff);
DMA1_Channel3->CNDTR = len;
DMA1_Channel3->CCR |= DMA_CCR_EN;
TIM3->DIER |= TIM_DIER_UDE;
}
void proc_effect(){
for(int i = 0; i < 3; ++i){
switch(current_ef[i]){
case EFF_WIPE:
eff_wipe(i);
break;
case EFF_MADWIPE:
eff_madwipe(i);
break;
case EFF_PENDULUM:
eff_pendulum(i);
break;
case EFF_SMPENDULUM:
eff_pendsm(i);
break;
case EFF_NONE:
default:
break;
}
}
}
effect_t set_effect(int n, effect_t eff){
if(n < 0 || n > 2) return EFF_NONE;
cntr[n] = 0;
dir[n] = 1;
if(dma_eff){
TIM3->DIER &= ~TIM_DIER_UDE; // turn off DMA requests from UE
DMA1_Channel3->CCR &= ~DMA_CCR_EN; // turn off DMA if current was with it
dma_eff = 0;
TIM3->CCR1 = SG90_MIDPULSE;
TIM3->CCR2 = SG90_MIDPULSE;
}
switch(eff){
case EFF_DMASMALL:
DMA_eff(dmabufsmall, sizeof(dmabufsmall)/sizeof(uint16_t));
dma_eff = 1;
break;
case EFF_DMAMED:
DMA_eff(dmabufmed, sizeof(dmabufmed)/sizeof(uint16_t));
dma_eff = 1;
break;
case EFF_DMABIG:
DMA_eff(dmabufbig, sizeof(dmabufbig)/sizeof(uint16_t));
dma_eff = 1;
break;
case EFF_DMATEST:
DMA_eff(dmabuftest, sizeof(dmabuftest)/sizeof(uint16_t));
dma_eff = 1;
break;
case EFF_DMASTAR:
DMA_eff(dmabufstar, sizeof(dmabufstar)/sizeof(uint16_t));
dma_eff = 1;
break;
default:
break;
}
if(dma_eff){
current_ef[0] = current_ef[1] = eff;
}else current_ef[n] = eff;
return eff;
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of the Servo project.
* Copyright 2019 Edward Emelianov <eddy@sao.ru>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef EFFECTS_H__
#define EFFECTS_H__
#include "stm32f0.h"
typedef enum{
EFF_NONE,
EFF_WIPE,
EFF_MADWIPE,
EFF_PENDULUM,
EFF_SMPENDULUM,
EFF_DMASMALL,
EFF_DMAMED,
EFF_DMABIG,
EFF_DMATEST,
EFF_DMASTAR
} effect_t;
extern uint8_t dma_eff;
void proc_effect();
effect_t set_effect(int n, effect_t eff);
#endif // EFFECTS_H__

View File

@@ -0,0 +1,268 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adc.h"
#include "effects.h"
#include "hardware.h"
#include "usart.h"
uint32_t sg90step = SG90DEFSTEP;
static inline void iwdg_setup(){
/* Enable the peripheral clock RTC */
/* (1) Enable the LSI (40kHz) */
/* (2) Wait while it is not ready */
RCC->CSR |= RCC_CSR_LSION; /* (1) */
while((RCC->CSR & RCC_CSR_LSIRDY) != RCC_CSR_LSIRDY); /* (2) */
/* Configure IWDG */
/* (1) Activate IWDG (not needed if done in option bytes) */
/* (2) Enable write access to IWDG registers */
/* (3) Set prescaler by 64 (1.6ms for each tick) */
/* (4) Set reload value to have a rollover each 1s */
/* (5) Check if flags are reset */
/* (6) Refresh counter */
IWDG->KR = IWDG_START; /* (1) */
IWDG->KR = IWDG_WRITE_ACCESS; /* (2) */
IWDG->PR = IWDG_PR_PR_1; /* (3) */
IWDG->RLR = 625; /* (4) */
while(IWDG->SR); /* (5) */
IWDG->KR = IWDG_REFRESH; /* (6) */
}
static inline void adc_setup(){
uint16_t ctr = 0; // 0xfff0 - more than 1.3ms
// Enable clocking
/* (1) Enable the peripheral clock of the ADC */
/* (2) Start HSI14 RC oscillator */
/* (3) Wait HSI14 is ready */
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; /* (1) */
RCC->CR2 |= RCC_CR2_HSI14ON; /* (2) */
while ((RCC->CR2 & RCC_CR2_HSI14RDY) == 0 && ++ctr < 0xfff0){}; /* (3) */
// calibration
/* (1) Ensure that ADEN = 0 */
/* (2) Clear ADEN */
/* (3) Launch the calibration by setting ADCAL */
/* (4) Wait until ADCAL=0 */
if ((ADC1->CR & ADC_CR_ADEN) != 0){ /* (1) */
ADC1->CR &= (uint32_t)(~ADC_CR_ADEN); /* (2) */
}
ADC1->CR |= ADC_CR_ADCAL; /* (3) */
ctr = 0; // ADC calibration time is 5.9us
while ((ADC1->CR & ADC_CR_ADCAL) != 0 && ++ctr < 0xfff0){}; /* (4) */
// enable ADC
ctr = 0;
do{
ADC1->CR |= ADC_CR_ADEN;
}while ((ADC1->ISR & ADC_ISR_ADRDY) == 0 && ++ctr < 0xfff0);
// configure ADC
/* (1) Select HSI14 by writing 00 in CKMODE (reset value) */
/* (2) Select the continuous mode */
/* (3) Select CHSEL0..3 - ADC inputs, 16,17 - t. sensor and vref */
/* (4) Select a sampling mode of 111 i.e. 239.5 ADC clk to be greater than 17.1us */
/* (5) Wake-up the VREFINT and Temperature sensor (only for VBAT, Temp sensor and VRefInt) */
// ADC1->CFGR2 &= ~ADC_CFGR2_CKMODE; /* (1) */
ADC1->CFGR1 |= ADC_CFGR1_CONT; /* (2)*/
ADC1->CHSELR = ADC_CHSELR_CHSEL0 | ADC_CHSELR_CHSEL1 | ADC_CHSELR_CHSEL2 |
ADC_CHSELR_CHSEL3 | ADC_CHSELR_CHSEL16 | ADC_CHSELR_CHSEL17; /* (3)*/
ADC1->SMPR |= ADC_SMPR_SMP_0 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_2; /* (4) */
ADC->CCR |= ADC_CCR_TSEN | ADC_CCR_VREFEN; /* (5) */
// configure DMA for ADC
// DMA for AIN
/* (1) Enable the peripheral clock on DMA */
/* (2) Enable DMA transfer on ADC and circular mode */
/* (3) Configure the peripheral data register address */
/* (4) Configure the memory address */
/* (5) Configure the number of DMA tranfer to be performs on DMA channel 1 */
/* (6) Configure increment, size, interrupts and circular mode */
/* (7) Enable DMA Channel 1 */
RCC->AHBENR |= RCC_AHBENR_DMA1EN; /* (1) */
ADC1->CFGR1 |= ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG; /* (2) */
DMA1_Channel1->CPAR = (uint32_t) (&(ADC1->DR)); /* (3) */
DMA1_Channel1->CMAR = (uint32_t)(ADC_array); /* (4) */
DMA1_Channel1->CNDTR = NUMBER_OF_ADC_CHANNELS * 9; /* (5) */
DMA1_Channel1->CCR |= DMA_CCR_MINC | DMA_CCR_MSIZE_0 | DMA_CCR_PSIZE_0 | DMA_CCR_CIRC; /* (6) */
DMA1_Channel1->CCR |= DMA_CCR_EN; /* (7) */
ADC1->CR |= ADC_CR_ADSTART; /* start the ADC conversions */
}
/**
* @brief gpio_setup - setup GPIOs for external IO
* GPIO pinout:
* PF1 - open drain - ext. LED/laser
* PA0..PA3 - ADC_IN0..3
* PA4 - open drain - onboard LED (always ON when board works)
* PB1, PA6, PA7 - Alt. F. - PWM outputs
* Registers
* MODER - input/output/alternate/analog (2 bit)
* OTYPER - 0 pushpull, 1 opendrain
* OSPEEDR - x0 low, 01 medium, 11 high
* PUPDR - no/pullup/pulldown/resr (2 bit)
* IDR - input
* ODR - output
* BSRR - 0..15 - set, 16..31 - reset
* BRR - 0..15 - reset
* AFRL/AFRH - alternate functions (4 bit, AF: 0..7); L - AFR0..7, H - ARF8..15
*/
static inline void gpio_setup(){
// Enable clocks to the GPIO subsystems
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOFEN;
// PA6/7 - AF; PB1 - AF
GPIOA->MODER = GPIO_MODER_MODER6_AF | GPIO_MODER_MODER7_AF |
GPIO_MODER_MODER0_AI | GPIO_MODER_MODER1_AI |
GPIO_MODER_MODER2_AI | GPIO_MODER_MODER3_AI |
GPIO_MODER_MODER4_O;
GPIOA->OTYPER = GPIO_OTYPER_OT_4;
GPIOB->MODER = GPIO_MODER_MODER1_AF;
//RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; // enable syscfg clock for EXTI
GPIOF->ODR = 1<<1;
GPIOF->MODER = GPIO_MODER_MODER1_O;
GPIOF->OTYPER = GPIO_OTYPER_OT_1;
// alternate functions:
// PA6 - TIM3_CH1, PA7 - TIM3_CH2, PB1 - TIM3_CH4 (all - AF1)
GPIOA->AFR[0] = (GPIOA->AFR[0] &~ (GPIO_AFRL_AFRL6 | GPIO_AFRL_AFRL7)) \
| (1 << (6 * 4)) | (1 << (7 * 4));
GPIOB->AFR[0] = (GPIOB->AFR[0] &~ (GPIO_AFRL_AFRL1)) \
| (1 << (1 * 4)) ;
}
// change period of PWM
// MAX freq - 200Hz!!!
void setTIM3T(uint32_t T){
if(T < 1000 || T > 65536) return;
TIM3->ARR = T - 1;
// step = ampl / freq(Hz) * 3
sg90step = SG90_AMPL * T;
sg90step >>= 18; // /262144
}
static inline void timers_setup(){
// timer 3 ch1, 2, 4 PWM for three servos
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
// PWM mode 1 (active -> inactive) on all three channels
TIM3->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 |
TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1;
TIM3->CCMR2 = TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4M_1;
// frequency
TIM3->PSC = 47; // 1MHz -> 1us per tick
// ARR for 8-bit PWM
TIM3->ARR = 19999; // 50Hz
// enable main output
TIM3->BDTR |= TIM_BDTR_MOE;
// enable PWM output
TIM3->CCER = TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC4E;
TIM3->DIER = TIM_DIER_UIE; //TIM_DIER_CC1IE | TIM_DIER_CC2IE | TIM_DIER_CC4IE;
// enable timer & ARR buffering
TIM3->CR1 |= TIM_CR1_CEN | TIM_CR1_ARPE;
RCC->AHBENR |= RCC_AHBENR_DMA1EN;
// DMA for more effects (channel 3 -> TIM3_UP)
DMA1_Channel3->CPAR = (uint32_t)(&(TIM3->DMAR)); // each writing to DMAR will change next register
// memsiz 16bit, psiz 32bit, memincrement, from memory, circulate
DMA1_Channel3->CCR |= DMA_CCR_MSIZE_0 | DMA_CCR_PSIZE_1
| DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_CIRC;
TIM3->DCR = (1 << 8) | // DBL=1 -- two transfers
(((uint32_t)&TIM3->CCR1 - (uint32_t)&TIM3->CR1) >> 2); // reg = (DBA + TIM3->CR1)/4
NVIC_EnableIRQ(TIM3_IRQn);
}
void hw_setup(){
sysreset();
gpio_setup();
adc_setup();
timers_setup();
USART1_config();
iwdg_setup();
}
static uint32_t target_Val[3] = {SG90_MIDPULSE, SG90_MIDPULSE, SG90_MIDPULSE};
static uint32_t target_Speed[3] = {SG90DEFSTEP, SG90DEFSTEP, SG90DEFSTEP};
static uint8_t onpos[3] = {0,0,0};
volatile uint32_t *addr[3] = {&TIM3->CCR1, &TIM3->CCR2, &TIM3->CCR4};
int32_t getPWM(int nch){
return *addr[nch];
}
// return current value
int32_t setPWM(int nch, uint32_t val, uint32_t speed){
if(nch < 0 || nch > 2) return 0;
if(speed > 0){
if(speed > SG90_STEP) speed = SG90_STEP;
target_Speed[nch] = speed;
}
uint8_t ch = 1;
if(val >= SG90_MINPULSE && val <= SG90_MAXPULSE) target_Val[nch] = val;
else if(val == 0) target_Val[nch] = SG90_MINPULSE;
else if(val == 1) target_Val[nch] = SG90_MAXPULSE;
else if(val == 2) target_Val[nch] = SG90_MIDPULSE;
else ch = 0;
if(ch){
onpos[nch] = 0;
}
return *addr[nch];
}
uint8_t onposition(int nch){
return onpos[nch];
}
static void chkPWM(int n){
if(n < 0 || n > 2) return;
uint32_t cur = *addr[n], tg = target_Val[n];
if(cur == tg){
onpos[n] = 1;
return;
}
uint32_t diff = tg - cur;
int sign = 1;
if(cur > tg){
diff = cur - tg;
sign = -1;
}
if(diff > target_Speed[n]) diff = target_Speed[n];
*addr[n] = cur + sign*diff;
}
void tim3_isr(){
/*
if(TIM3->SR & TIM_SR_CC1IF){ // 1st channel
chkPWM(0);
}
if(TIM3->SR & TIM_SR_CC2IF){ // 2nd channel
chkPWM(1);
}
if(TIM3->SR & TIM_SR_CC4IF){ // 3rd channel
chkPWM(2);
}*/
if(TIM3->SR & TIM_SR_UIF){
if(!dma_eff){
chkPWM(0);
chkPWM(1);
chkPWM(2);
}
}
TIM3->SR = 0;
}
/*
void exti0_1_isr(){
if (EXTI->PR & EXTI_PR_PR1){
EXTI->PR |= EXTI_PR_PR1; // Clear the pending bit
;
}
}
*/

View File

@@ -0,0 +1,40 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef HARDWARE_H
#define HARDWARE_H
#include "stm32f0.h"
// minimal and maximal pulse length for SG90
#define SG90_MINPULSE (700)
#define SG90_MAXPULSE (2100)
#define SG90_MIDPULSE ((SG90_MINPULSE+SG90_MAXPULSE)/2)
#define SG90_AMPL (SG90_MAXPULSE-SG90_MINPULSE)
#define SG90DEFSTEP (100)
#define SG90_STEP (sg90step)
extern volatile uint32_t Tms;
extern uint32_t sg90step;
void hw_setup(void);
int32_t setPWM(int nch, uint32_t val, uint32_t speed);
int32_t getPWM(int nch);
uint8_t onposition(int nch);
void setTIM3T(uint32_t T);
#endif // HARDWARE_H

View File

@@ -0,0 +1,107 @@
"Source:","/tmp/kicad/Servo_control.sch"
"Date:","óÒ 13 ÍÁÒ 2019 17:09:04"
"Tool:","Eeschema (6.0.0-rc1-dev-1613-ga55d9819b)"
"Generator:","/usr/local/share/kicad/plugins/bom_csv_grouped_by_value.py"
"Component Count:","59"
"Individual Components:"
"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet"
"","","BZ1","Buzzer","Device:Buzzer","Buzzer_Beeper:Buzzer_12x9.5RM7.6","~"
"","","C1","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C2","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C3","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C4","47u","Servo_control-rescue:CP-Chiller_control-rescue","Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A_Pad1.53x1.40mm_HandSolder",""
"","","C5","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C6","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C7","22p","Device:C","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C8","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C9","22p","Device:C","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C10","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C11","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C12","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"","","C13","1u","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","C14","10u","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_1206_3216Metric_Pad1.24x1.80mm_HandSolder",""
"","","D1","USB6B1","elements:USB6B1","Package_SOIC:SOIC-8_3.9x4.9mm_P1.27mm",""
"","","D2","SP0504BAHT","Power_Protection:SP0504BAHT","Package_TO_SOT_SMD:SOT-23-5","http://www.littelfuse.com/~/media/files/littelfuse/technical%20resources/documents/data%20sheets/sp05xxba.pdf"
"","","D3","SMAJ5.0","Device:D","Diode_SMD:D_SMA_Handsoldering",""
"","","D4","SMAJ5.0","Device:D","Diode_SMD:D_SMA_Handsoldering",""
"","","D5","SS14","Device:D_Schottky","Diode_SMD:D_SMA_Handsoldering",""
"","","J1","USB_B_Micro","Servo_control-rescue:USB_B_Micro-Connector_Specialized","Connector_USB:USB_Micro-B_Wuerth-629105150521","~"
"","","J2","ADC_in","Connector_Generic:Conn_01x06","Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_Vertical","~"
"","","J3","Jumper0","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"","","J4","Jumper1","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"","","J5","Dig_In","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"","","J6","Ext_LED","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"","","J7","Servo1","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"","","J8","Servo2","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"","","J9","Servo3","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"","","J10","5V","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"","","L1","BMBA 0.1mH","Servo_control-rescue:L-Chiller_control-rescue","Inductor_SMD:L_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","Q1","2N7002","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"","","Q2","SI2300","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"","","Q3","2N7002","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"","","Q4","2N7002","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"","","Q5","2N7002","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"","","R1","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R2","220","Device:R","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R3","220","Device:R","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R4","220","Device:R","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R5","220","Device:R","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R6","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R7","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R8","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R9","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R10","1k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R11","1k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R12","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R13","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R14","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R15","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R16","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","R17","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"","","SW1","Reset","Servo_control-rescue:SW_Push-Chiller_control-rescue","Button_Switch_SMD:SW_SPST_FSMSM",""
"","","SW2","Boot","Servo_control-rescue:SW_Push-Chiller_control-rescue","Button_Switch_SMD:SW_SPST_FSMSM",""
"","","U1","LM1117-3.3","Servo_control-rescue:LM1117-3.3-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-223-3_TabPin2",""
"","","U2","CH340G","ch34x:CH340G","Package_SOIC:SOIC-16_3.9x9.9mm_P1.27mm",""
"","","U3","STM32F030F4Px","Servo_control-rescue:STM32F030F4Px-Chiller_control-rescue","Package_SSOP:TSSOP-20_4.4x6.5mm_P0.65mm",""
"","","Y1","12MHz","Device:Crystal","Crystal:Crystal_HC49-U_Vertical",""
"Collated Components:"
"Item","Qty","Reference(s)","Value","LibPart","Footprint","Datasheet"
"1","1","BZ1","Buzzer","Device:Buzzer","Buzzer_Beeper:Buzzer_12x9.5RM7.6","~"
"2","9","C1, C2, C3, C5, C6, C8, C10, C11, C12","0.1","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"3","1","C4","47u","Servo_control-rescue:CP-Chiller_control-rescue","Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A_Pad1.53x1.40mm_HandSolder",""
"4","2","C7, C9","22p","Device:C","Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder",""
"5","1","C13","1u","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"6","1","C14","10u","Servo_control-rescue:C-Chiller_control-rescue","Capacitor_SMD:C_1206_3216Metric_Pad1.24x1.80mm_HandSolder",""
"7","1","D1","USB6B1","elements:USB6B1","Package_SOIC:SOIC-8_3.9x4.9mm_P1.27mm",""
"8","1","D2","SP0504BAHT","Power_Protection:SP0504BAHT","Package_TO_SOT_SMD:SOT-23-5","http://www.littelfuse.com/~/media/files/littelfuse/technical%20resources/documents/data%20sheets/sp05xxba.pdf"
"9","2","D3, D4","SMAJ5.0","Device:D","Diode_SMD:D_SMA_Handsoldering",""
"10","1","D5","SS14","Device:D_Schottky","Diode_SMD:D_SMA_Handsoldering",""
"11","1","J1","USB_B_Micro","Servo_control-rescue:USB_B_Micro-Connector_Specialized","Connector_USB:USB_Micro-B_Wuerth-629105150521","~"
"12","1","J2","ADC_in","Connector_Generic:Conn_01x06","Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_Vertical","~"
"13","1","J3","Jumper0","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"14","1","J4","Jumper1","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"15","1","J5","Dig_In","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"16","1","J6","Ext_LED","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"17","1","J7","Servo1","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"18","1","J8","Servo2","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"19","1","J9","Servo3","Connector_Generic:Conn_01x03","Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical","~"
"20","1","J10","5V","Connector_Generic:Conn_01x02","Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical","~"
"21","1","L1","BMBA 0.1mH","Servo_control-rescue:L-Chiller_control-rescue","Inductor_SMD:L_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"22","4","Q1, Q3, Q4, Q5","2N7002","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"23","1","Q2","SI2300","Servo_control-rescue:Q_NMOS_GSD-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-23",""
"24","6","R1, R7, R9, R15, R16, R17","10k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"25","4","R2, R3, R4, R5","220","Device:R","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"26","5","R6, R8, R12, R13, R14","510","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"27","2","R10, R11","1k","Servo_control-rescue:R-Chiller_control-rescue","Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder",""
"28","1","SW1","Reset","Servo_control-rescue:SW_Push-Chiller_control-rescue","Button_Switch_SMD:SW_SPST_FSMSM",""
"29","1","SW2","Boot","Servo_control-rescue:SW_Push-Chiller_control-rescue","Button_Switch_SMD:SW_SPST_FSMSM",""
"30","1","U1","LM1117-3.3","Servo_control-rescue:LM1117-3.3-Chiller_control-rescue","Package_TO_SOT_SMD:SOT-223-3_TabPin2",""
"31","1","U2","CH340G","ch34x:CH340G","Package_SOIC:SOIC-16_3.9x9.9mm_P1.27mm",""
"32","1","U3","STM32F030F4Px","Servo_control-rescue:STM32F030F4Px-Chiller_control-rescue","Package_SSOP:TSSOP-20_4.4x6.5mm_P0.65mm",""
"33","1","Y1","12MHz","Device:Crystal","Crystal:Crystal_HC49-U_Vertical",""

View File

@@ -0,0 +1,480 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# +12V-Chiller_control-rescue
#
DEF +12V-Chiller_control-rescue #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+12V-Chiller_control-rescue" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +12V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# +3.3V-Chiller_control-rescue
#
DEF +3.3V-Chiller_control-rescue #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+3.3V-Chiller_control-rescue" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +3V3 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# +3.3VADC-Chiller_control-rescue
#
DEF +3.3VADC-Chiller_control-rescue #PWR 0 0 Y Y 1 F P
F0 "#PWR" 150 -50 50 H I C CNN
F1 "+3.3VADC-Chiller_control-rescue" 0 100 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 3 0 1 0 0 0 0 40 0 40 N
P 6 0 1 0 0 40 20 20 0 70 -20 20 0 40 0 40 N
X +3.3VADC 1 0 0 0 U 50 50 0 0 W N
ENDDRAW
ENDDEF
#
# +5V-power
#
DEF +5V-power #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+5V-power" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +5V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# C-Chiller_control-rescue
#
DEF C-Chiller_control-rescue C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "C-Chiller_control-rescue" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
C_*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CP-Chiller_control-rescue
#
DEF CP-Chiller_control-rescue C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "CP-Chiller_control-rescue" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
CP_*
$ENDFPLIST
DRAW
S -90 20 -90 40 0 1 0 N
S -90 20 90 20 0 1 0 N
S 90 -20 -90 -40 0 1 0 F
S 90 40 -90 40 0 1 0 N
S 90 40 90 20 0 1 0 N
P 2 0 1 0 -70 90 -30 90 N
P 2 0 1 0 -50 110 -50 70 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Conn_01x02-Chiller_control-rescue
#
DEF Conn_01x02-Chiller_control-rescue J 0 40 Y N 1 F N
F0 "J" 0 100 50 H V C CNN
F1 "Conn_01x02-Chiller_control-rescue" 0 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_??x*mm*
Connector*:*1x??x*mm*
Pin?Header?Straight?1X*
Pin?Header?Angled?1X*
Socket?Strip?Straight?1X*
Socket?Strip?Angled?1X*
$ENDFPLIST
DRAW
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 50 50 -150 1 1 10 f
X Pin_1 1 -200 0 150 R 50 50 1 1 P
X Pin_2 2 -200 -100 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# D-Chiller_control-rescue
#
DEF D-Chiller_control-rescue D 0 40 N N 1 F N
F0 "D" 0 100 50 H V C CNN
F1 "D-Chiller_control-rescue" 0 -100 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
TO-???*
*SingleDiode
*_Diode_*
*SingleDiode*
D_*
$ENDFPLIST
DRAW
P 2 0 1 8 -50 50 -50 -50 N
P 2 0 1 0 50 0 -50 0 N
P 4 0 1 8 50 50 50 -50 -50 0 50 50 N
X K 1 -150 0 100 R 50 50 1 1 P
X A 2 150 0 100 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# DB9_Female-Chiller_control-rescue
#
DEF DB9_Female-Chiller_control-rescue J 0 40 Y N 1 F N
F0 "J" 0 550 50 H V C CNN
F1 "DB9_Female-Chiller_control-rescue" 0 -575 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
DB*F*
$ENDFPLIST
DRAW
C -70 -400 30 0 1 0 N
C -70 -200 30 0 1 0 N
C -70 0 30 0 1 0 N
C -70 200 30 0 1 0 N
C -70 400 30 0 1 0 N
C 50 -300 30 0 1 0 N
C 50 -100 30 0 1 0 N
C 50 100 30 0 1 0 N
C 50 300 30 0 1 0 N
P 2 0 1 0 -150 -400 -100 -400 N
P 2 0 1 0 -150 -300 20 -300 N
P 2 0 1 0 -150 -200 -100 -200 N
P 2 0 1 0 -150 -100 20 -100 N
P 2 0 1 0 -150 0 -100 0 N
P 2 0 1 0 -150 100 20 100 N
P 2 0 1 0 -150 200 -100 200 N
P 2 0 1 0 -150 300 20 300 N
P 2 0 1 0 -150 400 -100 400 N
P 5 0 1 10 -150 525 -150 -525 150 -375 150 375 -150 525 f
X 1 1 -300 400 150 R 50 50 1 1 P
X 2 2 -300 200 150 R 50 50 1 1 P
X 3 3 -300 0 150 R 50 50 1 1 P
X 4 4 -300 -200 150 R 50 50 1 1 P
X 5 5 -300 -400 150 R 50 50 1 1 P
X 6 6 -300 300 150 R 50 50 1 1 P
X 7 7 -300 100 150 R 50 50 1 1 P
X 8 8 -300 -100 150 R 50 50 1 1 P
X 9 9 -300 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# GND-Chiller_control-rescue
#
DEF GND-Chiller_control-rescue #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "GND-Chiller_control-rescue" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# L-Chiller_control-rescue
#
DEF L-Chiller_control-rescue L 0 40 N N 1 F N
F0 "L" -50 0 50 V V C CNN
F1 "L-Chiller_control-rescue" 75 0 50 V V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Choke_*
*Coil*
Inductor_*
L_*
$ENDFPLIST
DRAW
A 0 -75 25 -899 899 0 1 0 N 0 -100 0 -50
A 0 -25 25 -899 899 0 1 0 N 0 -50 0 0
A 0 25 25 -899 899 0 1 0 N 0 0 0 50
A 0 75 25 -899 899 0 1 0 N 0 50 0 100
X 1 1 0 150 50 D 50 50 1 1 P
X 2 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# LM1117-3.3-Chiller_control-rescue
#
DEF LM1117-3.3-Chiller_control-rescue U 0 10 Y Y 1 F N
F0 "U" -150 125 50 H V C CNN
F1 "LM1117-3.3-Chiller_control-rescue" 0 125 50 H V L CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
SOT?223*
TO?263*
TO?252*
TO?220*
$ENDFPLIST
DRAW
S -200 -200 200 75 0 1 10 f
X GND 1 0 -300 100 U 50 50 1 1 W
X VO 2 300 0 100 L 50 50 1 1 w
X VI 3 -300 0 100 R 50 50 1 1 W
ENDDRAW
ENDDEF
#
# MAX3232-Chiller_control-rescue
#
DEF MAX3232-Chiller_control-rescue U 0 40 Y Y 1 F N
F0 "U" -100 1125 50 H V R CNN
F1 "MAX3232-Chiller_control-rescue" -100 1050 50 H V R CNN
F2 "" 50 -1050 50 H I L CNN
F3 "" 0 100 50 H I C CNN
$FPLIST
SOIC*Pitch1.27mm*
DIP*W7.62mm*
TSSOP*4.4x5mm*Pitch0.65mm*
$ENDFPLIST
DRAW
C -100 -700 25 0 1 10 N
C -100 -500 25 0 1 10 N
C 25 -300 25 0 1 10 N
C 25 -100 25 0 1 10 N
T 0 -450 -900 50 0 0 0 LOGIC Normal 0 C C
T 0 450 -900 50 0 0 0 RS232 Normal 0 C C
S -600 -1000 600 1000 0 1 10 f
P 2 0 1 10 -150 -300 -325 -300 N
P 2 0 1 10 -150 -100 -325 -100 N
P 2 0 1 10 -125 -700 -325 -700 N
P 2 0 1 10 -125 -500 -325 -500 N
P 2 0 1 10 50 -300 250 -300 N
P 2 0 1 10 50 -100 250 -100 N
P 2 0 1 10 75 -700 250 -700 N
P 2 0 1 10 75 -500 250 -500 N
P 4 0 1 10 -150 -225 -150 -375 0 -300 -150 -225 N
P 4 0 1 10 -150 -25 -150 -175 0 -100 -150 -25 N
P 4 0 1 10 75 -625 75 -775 -75 -700 75 -625 N
P 4 0 1 10 75 -425 75 -575 -75 -500 75 -425 N
X C1+ 1 -800 900 200 R 50 50 1 1 P
X T2IN 10 -800 -300 200 R 50 50 1 1 I
X T1IN 11 -800 -100 200 R 50 50 1 1 I
X R1OUT 12 -800 -500 200 R 50 50 1 1 O
X R1IN 13 800 -500 200 L 50 50 1 1 I
X T1OUT 14 800 -100 200 L 50 50 1 1 O
X GND 15 0 -1200 200 U 50 50 1 1 W
X VCC 16 0 1200 200 D 50 50 1 1 W
X VS+ 2 800 400 200 L 50 50 1 1 w
X C1- 3 -800 600 200 R 50 50 1 1 P
X C2+ 4 800 900 200 L 50 50 1 1 P
X C2- 5 800 600 200 L 50 50 1 1 P
X VS- 6 800 100 200 L 50 50 1 1 w
X T2OUT 7 800 -300 200 L 50 50 1 1 O
X R2IN 8 800 -700 200 L 50 50 1 1 I
X R2OUT 9 -800 -700 200 R 50 50 1 1 O
ENDDRAW
ENDDEF
#
# PWR_FLAG-Chiller_control-rescue
#
DEF PWR_FLAG-Chiller_control-rescue #FLG 0 0 N N 1 F P
F0 "#FLG" 0 75 50 H I C CNN
F1 "PWR_FLAG-Chiller_control-rescue" 0 150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N
X pwr 1 0 0 0 U 50 50 0 0 w
ENDDRAW
ENDDEF
#
# Q_NMOS_GDS-Chiller_control-rescue
#
DEF Q_NMOS_GDS-Chiller_control-rescue Q 0 0 Y N 1 F N
F0 "Q" 200 50 50 H V L CNN
F1 "Q_NMOS_GDS-Chiller_control-rescue" 200 -50 50 H V L CNN
F2 "" 200 100 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
C 65 0 111 0 1 10 N
C 100 -70 11 0 1 0 F
C 100 70 11 0 1 0 F
P 2 0 1 0 2 0 10 0 N
P 2 0 1 0 30 -70 100 -70 N
P 2 0 1 10 30 -50 30 -90 N
P 2 0 1 0 30 0 100 0 N
P 2 0 1 10 30 20 30 -20 N
P 2 0 1 0 30 70 100 70 N
P 2 0 1 10 30 90 30 50 N
P 2 0 1 0 100 -70 100 -100 N
P 2 0 1 0 100 -70 100 0 N
P 2 0 1 0 100 100 100 70 N
P 3 0 1 10 10 75 10 -75 10 -75 N
P 4 0 1 0 40 0 80 15 80 -15 40 0 F
P 4 0 1 0 100 -70 130 -70 130 70 100 70 N
P 4 0 1 0 110 20 115 15 145 15 150 10 N
P 4 0 1 0 130 15 115 -10 145 -10 130 15 N
X G 1 -200 0 200 R 50 50 1 1 I
X D 2 100 200 100 D 50 50 1 1 P
X S 3 100 -200 100 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Q_NMOS_GSD-Chiller_control-rescue
#
DEF Q_NMOS_GSD-Chiller_control-rescue Q 0 0 Y N 1 F N
F0 "Q" 200 50 50 H V L CNN
F1 "Q_NMOS_GSD-Chiller_control-rescue" 200 -50 50 H V L CNN
F2 "" 200 100 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
C 65 0 111 0 1 10 N
C 100 -70 11 0 1 0 F
C 100 70 11 0 1 0 F
P 2 0 1 0 2 0 10 0 N
P 2 0 1 0 30 -70 100 -70 N
P 2 0 1 10 30 -50 30 -90 N
P 2 0 1 0 30 0 100 0 N
P 2 0 1 10 30 20 30 -20 N
P 2 0 1 0 30 70 100 70 N
P 2 0 1 10 30 90 30 50 N
P 2 0 1 0 100 -70 100 -100 N
P 2 0 1 0 100 -70 100 0 N
P 2 0 1 0 100 100 100 70 N
P 3 0 1 10 10 75 10 -75 10 -75 N
P 4 0 1 0 40 0 80 15 80 -15 40 0 F
P 4 0 1 0 100 -70 130 -70 130 70 100 70 N
P 4 0 1 0 110 20 115 15 145 15 150 10 N
P 4 0 1 0 130 15 115 -10 145 -10 130 15 N
X G 1 -200 0 200 R 50 50 1 1 I
X S 2 100 -200 100 U 50 50 1 1 P
X D 3 100 200 100 D 50 50 1 1 P
ENDDRAW
ENDDEF
#
# R-Chiller_control-rescue
#
DEF R-Chiller_control-rescue R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "R-Chiller_control-rescue" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
R_*
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# STM32F030F4Px-Chiller_control-rescue
#
DEF STM32F030F4Px-Chiller_control-rescue U 0 40 Y Y 1 L N
F0 "U" -1600 925 50 H V L BNN
F1 "STM32F030F4Px-Chiller_control-rescue" 1600 925 50 H V R BNN
F2 "Housings_SSOP:TSSOP-20_4.4x6.5mm_Pitch0.65mm" 1600 875 50 H I R TNN
F3 "" 0 0 50 H I C CNN
DRAW
S -1600 -800 1600 900 0 1 10 f
X BOOT0 1 -1700 400 100 R 50 50 1 1 I
X ADC_IN4/SPI1_NSS/TIM14_CH1/USART1_CK/PA4 10 1700 200 100 L 50 50 1 1 B
X ADC_IN5/SPI1_SCK/PA5 11 1700 100 100 L 50 50 1 1 B
X ADC_IN6/SPI1_MISO/TIM16_CH1/TIM1_BKIN/TIM3_CH1/PA6 12 1700 0 100 L 50 50 1 1 B
X ADC_IN7/SPI1_MOSI/TIM14_CH1/TIM17_CH1/TIM1_CH1N/TIM3_CH2/PA7 13 1700 -100 100 L 50 50 1 1 B
X PB1/ADC_IN9/TIM14_CH1/TIM1_CH3N/TIM3_CH4 14 -1700 -500 100 R 50 50 1 1 B
X VSS 15 0 -900 100 U 50 50 1 1 W
X VDD 16 -100 1000 100 D 50 50 1 1 W
X I2C1_SCL/TIM1_CH2/USART1_TX/PA9 17 1700 -200 100 L 50 50 1 1 B
X I2C1_SDA/TIM17_BKIN/TIM1_CH3/USART1_RX/PA10 18 1700 -300 100 L 50 50 1 1 B
X IR_OUT/SYS_SWDIO/PA13 19 1700 -400 100 L 50 50 1 1 B
X PF0/RCC_OSC_IN 2 -1700 -200 100 R 50 50 1 1 I
X SYS_SWCLK/USART1_TX/PA14 20 1700 -500 100 L 50 50 1 1 B
X PF1/RCC_OSC_OUT 3 -1700 -300 100 R 50 50 1 1 I
X NRST 4 -1700 600 100 R 50 50 1 1 I
X VDDA 5 0 1000 100 D 50 50 1 1 W
X ADC_IN0/RTC_TAMP2/SYS_WKUP1/USART1_CTS/PA0 6 1700 600 100 L 50 50 1 1 B
X ADC_IN1/USART1_DE/USART1_RTS/PA1 7 1700 500 100 L 50 50 1 1 B
X ADC_IN2/USART1_TX/PA2 8 1700 400 100 L 50 50 1 1 B
X ADC_IN3/USART1_RX/PA3 9 1700 300 100 L 50 50 1 1 B
ENDDRAW
ENDDEF
#
# SW_Push-Chiller_control-rescue
#
DEF SW_Push-Chiller_control-rescue SW 0 40 N N 1 F N
F0 "SW" 50 100 50 H V L CNN
F1 "SW_Push-Chiller_control-rescue" 0 -60 50 H V C CNN
F2 "" 0 200 50 H I C CNN
F3 "" 0 200 50 H I C CNN
DRAW
C -80 0 20 0 1 0 N
C 80 0 20 0 1 0 N
P 2 0 1 0 0 50 0 120 N
P 2 0 1 0 100 50 -100 50 N
X 1 1 -200 0 100 R 50 50 0 1 P
X 2 2 200 0 100 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
# USB_B_Micro-Connector_Specialized
#
DEF USB_B_Micro-Connector_Specialized J 0 40 Y Y 1 F N
F0 "J" -200 450 50 H V L CNN
F1 "USB_B_Micro-Connector_Specialized" -200 350 50 H V L CNN
F2 "" 150 -50 50 H I C CNN
F3 "" 150 -50 50 H I C CNN
$FPLIST
USB*
$ENDFPLIST
DRAW
C -150 85 25 0 1 10 F
C -25 135 15 0 1 10 F
S -200 -300 200 300 0 1 10 f
S -5 -300 5 -270 0 1 0 N
S 10 50 -20 20 0 1 10 F
S 200 -205 170 -195 0 1 0 N
S 200 -105 170 -95 0 1 0 N
S 200 -5 170 5 0 1 0 N
S 200 195 170 205 0 1 0 N
P 2 0 1 10 -75 85 25 85 N
P 4 0 1 10 -125 85 -100 85 -50 135 -25 135 N
P 4 0 1 10 -100 85 -75 85 -50 35 0 35 N
P 4 0 1 10 25 110 25 60 75 85 25 110 F
P 5 0 1 0 -170 220 -70 220 -80 190 -160 190 -170 220 F
P 9 0 1 0 -185 230 -185 220 -175 190 -175 180 -65 180 -65 190 -55 220 -55 230 -185 230 N
X VBUS 1 300 200 100 L 50 50 1 1 w
X D- 2 300 -100 100 L 50 50 1 1 P
X D+ 3 300 0 100 L 50 50 1 1 P
X ID 4 300 -200 100 L 50 50 1 1 P
X GND 5 0 -400 100 U 50 50 1 1 w
X Shield 6 -100 -400 100 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
#End Library

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,901 @@
(export (version D)
(design
(source /Big/Data/00__Electronics/STM32/F0-nolib/Servo/kicad/Servo_control.sch)
(date "Вт 12 мар 2019 21:12:54")
(tool "Eeschema 5.0.1")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title)
(company)
(rev)
(date)
(source Servo_control.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref C4)
(value 47u)
(footprint Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A_Pad1.53x1.40mm_HandSolder)
(libsource (lib Servo_control-rescue) (part CP-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 58C454F6))
(comp (ref C3)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 590D4150))
(comp (ref C2)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 590D4832))
(comp (ref SW2)
(value Boot)
(footprint Button_Switch_SMD:SW_SPST_FSMSM)
(libsource (lib Servo_control-rescue) (part SW_Push-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5909F6B6))
(comp (ref SW1)
(value Reset)
(footprint Button_Switch_SMD:SW_SPST_FSMSM)
(libsource (lib Servo_control-rescue) (part SW_Push-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 590A0134))
(comp (ref C1)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5A178C32))
(comp (ref C13)
(value 1u)
(footprint Capacitor_SMD:C_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5A1AB970))
(comp (ref U1)
(value LM1117-3.3)
(footprint Package_TO_SOT_SMD:SOT-223-3_TabPin2)
(libsource (lib Servo_control-rescue) (part LM1117-3.3-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5A2588E7))
(comp (ref C5)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEE1D09))
(comp (ref L1)
(value "BMBA 0.1mH")
(footprint Inductor_SMD:L_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part L-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEE7949))
(comp (ref C14)
(value 10u)
(footprint Capacitor_SMD:C_1206_3216Metric_Pad1.24x1.80mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEE8065))
(comp (ref R15)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEEBD18))
(comp (ref R12)
(value 510)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEEBD1E))
(comp (ref Q3)
(value 2N7002)
(footprint Package_TO_SOT_SMD:SOT-23)
(libsource (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEEBD24))
(comp (ref Q2)
(value SI2300)
(footprint Package_TO_SOT_SMD:SOT-23)
(libsource (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5BEEB585))
(comp (ref BZ1)
(value Buzzer)
(footprint Buzzer_Beeper:Buzzer_12x9.5RM7.6)
(datasheet ~)
(libsource (lib Device) (part Buzzer) (description "Buzzer, polar"))
(sheetpath (names /) (tstamps /))
(tstamp 5C83133C))
(comp (ref Q4)
(value 2N7002)
(footprint Package_TO_SOT_SMD:SOT-23)
(libsource (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C8882AE))
(comp (ref Q5)
(value 2N7002)
(footprint Package_TO_SOT_SMD:SOT-23)
(libsource (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C888320))
(comp (ref J7)
(value Servo1)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x03) (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C88A162))
(comp (ref J8)
(value Servo2)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x03) (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C83F212))
(comp (ref J9)
(value Servo3)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x03) (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C83F4E9))
(comp (ref R13)
(value 510)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C84B03F))
(comp (ref R14)
(value 510)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C84B0D1))
(comp (ref R16)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C84B278))
(comp (ref R17)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C84B3BD))
(comp (ref D2)
(value SP0504BAHT)
(footprint Package_TO_SOT_SMD:SOT-23-5)
(datasheet http://www.littelfuse.com/~/media/files/littelfuse/technical%20resources/documents/data%20sheets/sp05xxba.pdf)
(libsource (lib Power_Protection) (part SP0504BAHT) (description "TVS Diode Array, 5.5V Standoff, 4 Channels, SOT-23-5 package"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8580E1))
(comp (ref J2)
(value ADC_in)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x06) (description "Generic connector, single row, 01x06, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C85A71E))
(comp (ref R3)
(value 220)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5C85BD06))
(comp (ref R4)
(value 220)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5C85C1A1))
(comp (ref R5)
(value 220)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5C85C24A))
(comp (ref R2)
(value 220)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5C85C2A8))
(comp (ref C8)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C86267B))
(comp (ref C10)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C862E72))
(comp (ref C11)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C862EDE))
(comp (ref C12)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C864D09))
(comp (ref U2)
(value CH340G)
(footprint Package_SOIC:SOIC-16_3.9x9.9mm_P1.27mm)
(libsource (lib ch34x) (part CH340G) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C891E7A))
(comp (ref C6)
(value 0.1)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Servo_control-rescue) (part C-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C8AFE6B))
(comp (ref Y1)
(value 12MHz)
(footprint Crystal:Crystal_HC49-U_Vertical)
(libsource (lib Device) (part Crystal) (description "Two pin crystal"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8CDA20))
(comp (ref C7)
(value 22p)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8CDF63))
(comp (ref C9)
(value 22p)
(footprint Capacitor_SMD:C_0603_1608Metric_Pad0.84x1.00mm_HandSolder)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8CE285))
(comp (ref Q1)
(value 2N7002)
(footprint Package_TO_SOT_SMD:SOT-23)
(libsource (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C9233AA))
(comp (ref R8)
(value 510)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C924EC0))
(comp (ref R9)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C924F9E))
(comp (ref R6)
(value 510)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C929CAD))
(comp (ref R7)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C929D7F))
(comp (ref J6)
(value Ext_LED)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C93CB05))
(comp (ref R1)
(value 10k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C943CF3))
(comp (ref D3)
(value SMAJ5.0)
(footprint Diode_SMD:D_SMA_Handsoldering)
(libsource (lib Device) (part D) (description Diode))
(sheetpath (names /) (tstamps /))
(tstamp 5C95243A))
(comp (ref D4)
(value SMAJ5.0)
(footprint Diode_SMD:D_SMA_Handsoldering)
(libsource (lib Device) (part D) (description Diode))
(sheetpath (names /) (tstamps /))
(tstamp 5C952A1B))
(comp (ref R10)
(value 1k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C957A49))
(comp (ref R11)
(value 1k)
(footprint Resistor_SMD:R_0805_2012Metric_Pad1.15x1.50mm_HandSolder)
(libsource (lib Servo_control-rescue) (part R-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C957B70))
(comp (ref J5)
(value Dig_In)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x03) (description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C9581BA))
(comp (ref J3)
(value Jumper0)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C98F117))
(comp (ref J4)
(value Jumper1)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C98F3D6))
(comp (ref J1)
(value USB_B_Micro)
(footprint Connector_USB:USB_Micro-B_Wuerth-629105150521)
(datasheet ~)
(libsource (lib Connector_Specialized) (part USB_B_Micro) (description "USB Micro Type B connector"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8BC41C))
(comp (ref D1)
(value USB6B1)
(footprint Package_SOIC:SOIC-8_3.9x4.9mm_P1.27mm)
(libsource (lib elements) (part USB6B1) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5C9BF24E))
(comp (ref U3)
(value STM32F030F4Px)
(footprint Package_SSOP:TSSOP-20_4.4x6.5mm_P0.65mm)
(libsource (lib Servo_control-rescue) (part STM32F030F4Px-Chiller_control-rescue) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5A189F52))
(comp (ref D5)
(value SS14)
(footprint Diode_SMD:D_SMA_Handsoldering)
(libsource (lib Device) (part D_Schottky) (description "Schottky diode"))
(sheetpath (names /) (tstamps /))
(tstamp 5C886D5C))
(comp (ref J10)
(value 5V)
(footprint Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5C8877B6)))
(libparts
(libpart (lib Connector_Generic) (part Conn_01x02)
(description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x02))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))))
(libpart (lib Connector_Generic) (part Conn_01x03)
(description "Generic connector, single row, 01x03, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x03))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))))
(libpart (lib Connector_Generic) (part Conn_01x06)
(description "Generic connector, single row, 01x06, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x06))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))
(pin (num 5) (name Pin_5) (type passive))
(pin (num 6) (name Pin_6) (type passive))))
(libpart (lib Connector_Specialized) (part USB_B_Micro)
(aliases
(alias USB_B_Mini))
(description "USB Micro Type B connector")
(docs ~)
(footprints
(fp USB*))
(fields
(field (name Reference) J)
(field (name Value) USB_B_Micro))
(pins
(pin (num 1) (name VBUS) (type power_out))
(pin (num 2) (name D-) (type passive))
(pin (num 3) (name D+) (type passive))
(pin (num 4) (name ID) (type passive))
(pin (num 5) (name GND) (type power_out))
(pin (num 6) (name Shield) (type passive))))
(libpart (lib Device) (part Buzzer)
(description "Buzzer, polar")
(footprints
(fp *Buzzer*))
(fields
(field (name Reference) BZ)
(field (name Value) Buzzer))
(pins
(pin (num 1) (name -) (type passive))
(pin (num 2) (name +) (type passive))))
(libpart (lib Device) (part C)
(description "Unpolarized capacitor")
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Device) (part Crystal)
(description "Two pin crystal")
(footprints
(fp Crystal*))
(fields
(field (name Reference) Y)
(field (name Value) Crystal))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib Device) (part D)
(description Diode)
(footprints
(fp TO-???*)
(fp *SingleDiode)
(fp *_Diode_*)
(fp *SingleDiode*)
(fp D_*))
(fields
(field (name Reference) D)
(field (name Value) D))
(pins
(pin (num 1) (name K) (type passive))
(pin (num 2) (name A) (type passive))))
(libpart (lib Device) (part D_Schottky)
(description "Schottky diode")
(footprints
(fp TO-???*)
(fp *SingleDiode)
(fp *_Diode_*)
(fp *SingleDiode*)
(fp D_*))
(fields
(field (name Reference) D)
(field (name Value) D_Schottky))
(pins
(pin (num 1) (name K) (type passive))
(pin (num 2) (name A) (type passive))))
(libpart (lib Device) (part R)
(description Resistor)
(footprints
(fp R_*)
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Power_Protection) (part SP0504BAHT)
(description "TVS Diode Array, 5.5V Standoff, 4 Channels, SOT-23-5 package")
(docs http://www.littelfuse.com/~/media/files/littelfuse/technical%20resources/documents/data%20sheets/sp05xxba.pdf)
(footprints
(fp SOT?23*))
(fields
(field (name Reference) D)
(field (name Value) SP0504BAHT)
(field (name Footprint) Package_TO_SOT_SMD:SOT-23-5))
(pins
(pin (num 1) (name K) (type input))
(pin (num 2) (name A) (type input))
(pin (num 3) (name K) (type input))
(pin (num 4) (name K) (type input))
(pin (num 5) (name K) (type input))))
(libpart (lib Servo_control-rescue) (part C-Chiller_control-rescue)
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C-Chiller_control-rescue))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Servo_control-rescue) (part CP-Chiller_control-rescue)
(footprints
(fp CP_*))
(fields
(field (name Reference) C)
(field (name Value) CP-Chiller_control-rescue))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Servo_control-rescue) (part L-Chiller_control-rescue)
(footprints
(fp Choke_*)
(fp *Coil*)
(fp Inductor_*)
(fp L_*))
(fields
(field (name Reference) L)
(field (name Value) L-Chiller_control-rescue))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib Servo_control-rescue) (part LM1117-3.3-Chiller_control-rescue)
(footprints
(fp SOT?223*)
(fp TO?263*)
(fp TO?252*)
(fp TO?220*))
(fields
(field (name Reference) U)
(field (name Value) LM1117-3.3-Chiller_control-rescue))
(pins
(pin (num 1) (name GND) (type power_in))
(pin (num 2) (name VO) (type power_out))
(pin (num 3) (name VI) (type power_in))))
(libpart (lib Servo_control-rescue) (part Q_NMOS_GSD-Chiller_control-rescue)
(fields
(field (name Reference) Q)
(field (name Value) Q_NMOS_GSD-Chiller_control-rescue))
(pins
(pin (num 1) (name G) (type input))
(pin (num 2) (name S) (type passive))
(pin (num 3) (name D) (type passive))))
(libpart (lib Servo_control-rescue) (part R-Chiller_control-rescue)
(footprints
(fp R_*)
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R-Chiller_control-rescue))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Servo_control-rescue) (part STM32F030F4Px-Chiller_control-rescue)
(fields
(field (name Reference) U)
(field (name Value) STM32F030F4Px-Chiller_control-rescue)
(field (name Footprint) Housings_SSOP:TSSOP-20_4.4x6.5mm_Pitch0.65mm))
(pins
(pin (num 1) (name BOOT0) (type input))
(pin (num 2) (name PF0/RCC_OSC_IN) (type input))
(pin (num 3) (name PF1/RCC_OSC_OUT) (type input))
(pin (num 4) (name NRST) (type input))
(pin (num 5) (name VDDA) (type power_in))
(pin (num 6) (name ADC_IN0/RTC_TAMP2/SYS_WKUP1/USART1_CTS/PA0) (type BiDi))
(pin (num 7) (name ADC_IN1/USART1_DE/USART1_RTS/PA1) (type BiDi))
(pin (num 8) (name ADC_IN2/USART1_TX/PA2) (type BiDi))
(pin (num 9) (name ADC_IN3/USART1_RX/PA3) (type BiDi))
(pin (num 10) (name ADC_IN4/SPI1_NSS/TIM14_CH1/USART1_CK/PA4) (type BiDi))
(pin (num 11) (name ADC_IN5/SPI1_SCK/PA5) (type BiDi))
(pin (num 12) (name ADC_IN6/SPI1_MISO/TIM16_CH1/TIM1_BKIN/TIM3_CH1/PA6) (type BiDi))
(pin (num 13) (name ADC_IN7/SPI1_MOSI/TIM14_CH1/TIM17_CH1/TIM1_CH1N/TIM3_CH2/PA7) (type BiDi))
(pin (num 14) (name PB1/ADC_IN9/TIM14_CH1/TIM1_CH3N/TIM3_CH4) (type BiDi))
(pin (num 15) (name VSS) (type power_in))
(pin (num 16) (name VDD) (type power_in))
(pin (num 17) (name I2C1_SCL/TIM1_CH2/USART1_TX/PA9) (type BiDi))
(pin (num 18) (name I2C1_SDA/TIM17_BKIN/TIM1_CH3/USART1_RX/PA10) (type BiDi))
(pin (num 19) (name IR_OUT/SYS_SWDIO/PA13) (type BiDi))
(pin (num 20) (name SYS_SWCLK/USART1_TX/PA14) (type BiDi))))
(libpart (lib Servo_control-rescue) (part SW_Push-Chiller_control-rescue)
(fields
(field (name Reference) SW)
(field (name Value) SW_Push-Chiller_control-rescue))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib ch34x) (part CH340G)
(fields
(field (name Reference) U)
(field (name Value) CH340G))
(pins
(pin (num 1) (name GND) (type power_in))
(pin (num 2) (name TX) (type output))
(pin (num 3) (name RX) (type input))
(pin (num 4) (name V3) (type passive))
(pin (num 5) (name D+) (type BiDi))
(pin (num 6) (name D-) (type BiDi))
(pin (num 7) (name XI) (type input))
(pin (num 8) (name XO) (type input))
(pin (num 9) (name CTS) (type output))
(pin (num 10) (name DSR) (type output))
(pin (num 11) (name RI) (type output))
(pin (num 12) (name DCD) (type output))
(pin (num 13) (name DTR) (type output))
(pin (num 14) (name RTS) (type output))
(pin (num 15) (name RS232) (type input))
(pin (num 16) (name VCC) (type power_in))))
(libpart (lib elements) (part USB6B1)
(footprints
(fp SO8))
(fields
(field (name Reference) D)
(field (name Value) USB6B1))
(pins
(pin (num 1) (name VCC) (type passive))
(pin (num 2) (name I/O1) (type passive))
(pin (num 3) (name I/O2) (type passive))
(pin (num 4) (name GND) (type passive))
(pin (num 5) (name GND) (type passive))
(pin (num 6) (name I/O2) (type passive))
(pin (num 7) (name I/O1) (type passive))
(pin (num 8) (name VCC) (type passive)))))
(libraries
(library (logical Connector_Generic)
(uri /usr/share/kicad/library/Connector_Generic.lib))
(library (logical Connector_Specialized)
(uri /usr/share/kicad/library/Connector_Specialized.lib))
(library (logical Device)
(uri /usr/share/kicad/library/Device.lib))
(library (logical Power_Protection)
(uri /usr/share/kicad/library/Power_Protection.lib))
(library (logical Servo_control-rescue)
(uri /Big/Data/00__Electronics/STM32/F0-nolib/Servo/kicad/Servo_control-rescue.lib))
(library (logical ch34x)
(uri /Big/Data/00__Electronics/STM32/F0-nolib/Servo/kicad/ch34x.lib))
(library (logical elements)
(uri /Big/Data/00__Electronics/STM32/F0-nolib/Servo/kicad/elements.lib)))
(nets
(net (code 1) (name "Net-(Q2-Pad1)")
(node (ref R8) (pin 1))
(node (ref Q2) (pin 1)))
(net (code 2) (name "Net-(BZ1-Pad2)")
(node (ref BZ1) (pin 2))
(node (ref Q1) (pin 3)))
(net (code 3) (name "Net-(Q1-Pad1)")
(node (ref Q1) (pin 1))
(node (ref R6) (pin 1)))
(net (code 4) (name "Net-(J1-Pad4)")
(node (ref J1) (pin 4)))
(net (code 5) (name "Net-(C7-Pad1)")
(node (ref C7) (pin 1))
(node (ref Y1) (pin 1))
(node (ref U2) (pin 7)))
(net (code 6) (name /DigOut1)
(node (ref R8) (pin 2))
(node (ref R9) (pin 2))
(node (ref U3) (pin 3)))
(net (code 7) (name "Net-(C9-Pad1)")
(node (ref C9) (pin 1))
(node (ref U2) (pin 8))
(node (ref Y1) (pin 2)))
(net (code 8) (name GND)
(node (ref U3) (pin 15))
(node (ref SW1) (pin 2))
(node (ref Q3) (pin 2))
(node (ref Q5) (pin 2))
(node (ref J10) (pin 2))
(node (ref J4) (pin 1))
(node (ref J3) (pin 1))
(node (ref J5) (pin 1))
(node (ref D1) (pin 5))
(node (ref C12) (pin 2))
(node (ref C11) (pin 2))
(node (ref C10) (pin 2))
(node (ref C8) (pin 2))
(node (ref Q4) (pin 2))
(node (ref Q2) (pin 2))
(node (ref R16) (pin 1))
(node (ref J9) (pin 1))
(node (ref J8) (pin 1))
(node (ref J7) (pin 1))
(node (ref R15) (pin 1))
(node (ref C13) (pin 2))
(node (ref C1) (pin 2))
(node (ref C2) (pin 2))
(node (ref C3) (pin 2))
(node (ref C4) (pin 2))
(node (ref C14) (pin 1))
(node (ref C5) (pin 2))
(node (ref U1) (pin 1))
(node (ref J2) (pin 1))
(node (ref D2) (pin 2))
(node (ref R17) (pin 1))
(node (ref R1) (pin 1))
(node (ref C6) (pin 2))
(node (ref Q1) (pin 2))
(node (ref U2) (pin 1))
(node (ref R9) (pin 1))
(node (ref R7) (pin 1))
(node (ref C9) (pin 2))
(node (ref C7) (pin 2))
(node (ref D3) (pin 2))
(node (ref D4) (pin 2)))
(net (code 9) (name "Net-(J5-Pad3)")
(node (ref J5) (pin 3))
(node (ref R10) (pin 2)))
(net (code 10) (name +3.3VADC)
(node (ref L1) (pin 2))
(node (ref C14) (pin 2))
(node (ref U3) (pin 5))
(node (ref J2) (pin 6)))
(net (code 11) (name "Net-(J6-Pad2)")
(node (ref J6) (pin 2))
(node (ref Q2) (pin 3)))
(net (code 12) (name "Net-(U2-Pad9)")
(node (ref U2) (pin 9)))
(net (code 13) (name "Net-(D1-Pad7)")
(node (ref D1) (pin 7))
(node (ref U2) (pin 5)))
(net (code 14) (name "Net-(C6-Pad1)")
(node (ref U2) (pin 4))
(node (ref C6) (pin 1)))
(net (code 15) (name /USART_Tx)
(node (ref U2) (pin 3))
(node (ref U3) (pin 17)))
(net (code 16) (name /USART_Rx)
(node (ref U3) (pin 18))
(node (ref U2) (pin 2)))
(net (code 17) (name "Net-(U2-Pad10)")
(node (ref U2) (pin 10)))
(net (code 18) (name +3V3)
(node (ref U2) (pin 16))
(node (ref U3) (pin 16))
(node (ref U1) (pin 2))
(node (ref C5) (pin 1))
(node (ref L1) (pin 1))
(node (ref C4) (pin 1))
(node (ref C13) (pin 1))
(node (ref SW2) (pin 2)))
(net (code 19) (name "Net-(D1-Pad6)")
(node (ref D1) (pin 6))
(node (ref U2) (pin 6)))
(net (code 20) (name "Net-(J5-Pad2)")
(node (ref R11) (pin 2))
(node (ref J5) (pin 2)))
(net (code 21) (name "Net-(U2-Pad15)")
(node (ref U2) (pin 15)))
(net (code 22) (name "Net-(U2-Pad14)")
(node (ref U2) (pin 14)))
(net (code 23) (name "Net-(U2-Pad13)")
(node (ref U2) (pin 13)))
(net (code 24) (name "Net-(U2-Pad12)")
(node (ref U2) (pin 12)))
(net (code 25) (name "Net-(U2-Pad11)")
(node (ref U2) (pin 11)))
(net (code 26) (name /ADC3)
(node (ref C8) (pin 1))
(node (ref U3) (pin 9))
(node (ref D2) (pin 4))
(node (ref R5) (pin 1)))
(net (code 27) (name /ADC2)
(node (ref D2) (pin 5))
(node (ref R4) (pin 1))
(node (ref C10) (pin 1))
(node (ref U3) (pin 8)))
(net (code 28) (name /ADC1)
(node (ref D2) (pin 1))
(node (ref U3) (pin 7))
(node (ref C11) (pin 1))
(node (ref R3) (pin 1)))
(net (code 29) (name /ADC0)
(node (ref R2) (pin 1))
(node (ref C12) (pin 1))
(node (ref D2) (pin 3))
(node (ref U3) (pin 6)))
(net (code 30) (name /DigOut0)
(node (ref R6) (pin 2))
(node (ref R7) (pin 2))
(node (ref U3) (pin 2)))
(net (code 31) (name /TIM3_CH1)
(node (ref R15) (pin 2))
(node (ref R12) (pin 2))
(node (ref U3) (pin 12)))
(net (code 32) (name "Net-(D1-Pad3)")
(node (ref D1) (pin 3))
(node (ref J1) (pin 3)))
(net (code 33) (name "Net-(D1-Pad2)")
(node (ref J1) (pin 2))
(node (ref D1) (pin 2)))
(net (code 34) (name +5V)
(node (ref BZ1) (pin 1))
(node (ref D5) (pin 1))
(node (ref J6) (pin 1))
(node (ref U1) (pin 3))
(node (ref J10) (pin 1))
(node (ref C1) (pin 1))
(node (ref J9) (pin 2))
(node (ref J8) (pin 2))
(node (ref J7) (pin 2)))
(net (code 35) (name "Net-(D1-Pad8)")
(node (ref D1) (pin 8))
(node (ref D5) (pin 2)))
(net (code 36) (name /DigIn1)
(node (ref U3) (pin 20))
(node (ref R10) (pin 1))
(node (ref D4) (pin 1)))
(net (code 37) (name /Jumper1)
(node (ref U3) (pin 11))
(node (ref J4) (pin 2)))
(net (code 38) (name /Jumper0)
(node (ref U3) (pin 10))
(node (ref J3) (pin 2)))
(net (code 39) (name /DigIn0)
(node (ref U3) (pin 19))
(node (ref D3) (pin 1))
(node (ref R11) (pin 1)))
(net (code 40) (name "Net-(D1-Pad1)")
(node (ref J1) (pin 1))
(node (ref D1) (pin 1)))
(net (code 41) (name "Net-(D1-Pad4)")
(node (ref J1) (pin 5))
(node (ref D1) (pin 4))
(node (ref J1) (pin 6)))
(net (code 42) (name /NRST)
(node (ref SW1) (pin 1))
(node (ref C2) (pin 1))
(node (ref U3) (pin 4)))
(net (code 43) (name /BOOT0)
(node (ref U3) (pin 1))
(node (ref R1) (pin 2))
(node (ref SW2) (pin 1))
(node (ref C3) (pin 1)))
(net (code 44) (name "Net-(J7-Pad3)")
(node (ref Q3) (pin 3))
(node (ref J7) (pin 3)))
(net (code 45) (name "Net-(Q3-Pad1)")
(node (ref Q3) (pin 1))
(node (ref R12) (pin 1)))
(net (code 46) (name "Net-(J2-Pad4)")
(node (ref R3) (pin 2))
(node (ref J2) (pin 4)))
(net (code 47) (name /TIM3_CH4)
(node (ref R14) (pin 2))
(node (ref U3) (pin 14))
(node (ref R17) (pin 2)))
(net (code 48) (name /TIM3_CH2)
(node (ref R16) (pin 2))
(node (ref R13) (pin 2))
(node (ref U3) (pin 13)))
(net (code 49) (name "Net-(Q5-Pad1)")
(node (ref R14) (pin 1))
(node (ref Q5) (pin 1)))
(net (code 50) (name "Net-(Q4-Pad1)")
(node (ref Q4) (pin 1))
(node (ref R13) (pin 1)))
(net (code 51) (name "Net-(J2-Pad5)")
(node (ref R2) (pin 2))
(node (ref J2) (pin 5)))
(net (code 52) (name "Net-(J2-Pad3)")
(node (ref R4) (pin 2))
(node (ref J2) (pin 3)))
(net (code 53) (name "Net-(J2-Pad2)")
(node (ref R5) (pin 2))
(node (ref J2) (pin 2)))
(net (code 54) (name "Net-(J8-Pad3)")
(node (ref J8) (pin 3))
(node (ref Q4) (pin 3)))
(net (code 55) (name "Net-(J9-Pad3)")
(node (ref J9) (pin 3))
(node (ref Q5) (pin 3)))))

View File

@@ -0,0 +1,100 @@
update=Вс 27 янв 2019 15:05:22
version=1
last_client=kicad
[cvpcb]
version=1
NetIExt=net
[general]
version=1
[schematic_editor]
version=1
PageLayoutDescrFile=
PlotDirectoryName=
SubpartIdSeparator=0
SubpartFirstId=65
NetFmtName=Pcbnew
SpiceForceRefPrefix=0
SpiceUseNetNumbers=0
LabSize=60
[eeschema]
version=1
LibDir=
[pcbnew]
version=1
PageLayoutDescrFile=
LastNetListRead=Chiller_control.net
CopperLayerCount=2
BoardThickness=1.6
AllowMicroVias=0
AllowBlindVias=0
RequireCourtyardDefinitions=0
ProhibitOverlappingCourtyards=1
MinTrackWidth=0.2
MinViaDiameter=0.4
MinViaDrill=0.3
MinMicroViaDiameter=0.2
MinMicroViaDrill=0.09999999999999999
MinHoleToHole=0.25
TrackWidth1=0.5
TrackWidth2=0.25
TrackWidth3=0.5
TrackWidth4=1
TrackWidth5=2
ViaDiameter1=1.2
ViaDrill1=0.6
ViaDiameter2=1.2
ViaDrill2=0.6
ViaDiameter3=1.5
ViaDrill3=0.8
ViaDiameter4=2.5
ViaDrill4=1
dPairWidth1=0.2
dPairGap1=0.25
dPairViaGap1=0.25
SilkLineWidth=0.15
SilkTextSizeV=1
SilkTextSizeH=1
SilkTextSizeThickness=0.15
SilkTextItalic=0
SilkTextUpright=1
CopperLineWidth=0.2
CopperTextSizeV=1.5
CopperTextSizeH=1.5
CopperTextThickness=0.3
CopperTextItalic=0
CopperTextUpright=1
EdgeCutLineWidth=0.15
CourtyardLineWidth=0.05
OthersLineWidth=0.15
OthersTextSizeV=1
OthersTextSizeH=1
OthersTextSizeThickness=0.15
OthersTextItalic=0
OthersTextUpright=1
SolderMaskClearance=0.2
SolderMaskMinWidth=0.25
SolderPasteClearance=0
SolderPasteRatio=-0
[pcbnew/Netclasses]
[pcbnew/Netclasses/1]
Name=power
Clearance=0.3
TrackWidth=1
ViaDiameter=2.5
ViaDrill=0.8
uViaDiameter=0.3
uViaDrill=0.1
dPairWidth=0.2
dPairGap=0.25
dPairViaGap=0.25
[pcbnew/Netclasses/2]
Name=wide
Clearance=0.5
TrackWidth=2
ViaDiameter=2.5
ViaDrill=0.8
uViaDiameter=0.3
uViaDrill=0.1
dPairWidth=0.2
dPairGap=0.25
dPairViaGap=0.25

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# CH340G
#
DEF CH340G U 0 40 Y Y 1 F N
F0 "U" 25 475 60 H V C CNN
F1 "CH340G" 0 -475 60 H V C CNN
F2 "" 100 -200 60 H V C CNN
F3 "" 100 -200 60 H V C CNN
DRAW
S -250 400 250 -400 0 1 0 N
X GND 1 -450 350 200 R 50 50 1 1 W
X TX 2 -450 250 200 R 50 50 1 1 O
X RX 3 -450 150 200 R 50 50 1 1 I
X V3 4 -450 50 200 R 50 50 1 1 P
X D+ 5 -450 -50 200 R 50 50 1 1 B
X D- 6 -450 -150 200 R 50 50 1 1 B
X XI 7 -450 -250 200 R 50 50 1 1 I
X XO 8 -450 -350 200 R 50 50 1 1 I
X CTS 9 450 -350 200 L 50 50 1 1 O
X DSR 10 450 -250 200 L 50 50 1 1 O
X RI 11 450 -150 200 L 50 50 1 1 O
X DCD 12 450 -50 200 L 50 50 1 1 O
X DTR 13 450 50 200 L 50 50 1 1 O
X RTS 14 450 150 200 L 50 50 1 1 O
X RS232 15 450 250 200 L 50 50 1 1 I
X VCC 16 450 350 200 L 50 50 1 1 W
ENDDRAW
ENDDEF
#
#End Library

View File

@@ -0,0 +1,190 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# 74HC4051
#
DEF 74HC4051 U 0 10 Y Y 1 F N
F0 "U" 0 0 50 H V C CNN
F1 "74HC4051" 0 -150 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
SO16
TSSOP16
SSOP16
DHVQFN16
$ENDFPLIST
DRAW
S -400 450 400 -450 0 1 0 N
X Y4 1 700 -50 300 L 50 50 1 1 B
X Y6 2 700 -250 300 L 50 50 1 1 B
X Z 3 0 -750 300 U 50 50 1 1 B
X Y7 4 700 -350 300 L 50 50 1 1 B
X Y5 5 700 -150 300 L 50 50 1 1 B
X ~E 6 -700 -350 300 R 50 50 1 1 I I
X VEE 7 -700 0 300 R 50 50 1 1 W
X GND 8 -700 -200 300 R 50 50 1 1 W
X S2 9 -700 150 300 R 50 50 1 1 I
X S1 10 -700 250 300 R 50 50 1 1 I
X S0 11 -700 350 300 R 50 50 1 1 I
X Y3 12 700 50 300 L 50 50 1 1 B
X Y0 13 700 350 300 L 50 50 1 1 B
X Y1 14 700 250 300 L 50 50 1 1 B
X Y2 15 700 150 300 L 50 50 1 1 B
X VCC 16 -700 -100 300 R 50 50 1 1 W
ENDDRAW
ENDDEF
#
# D_Schottky_x2_ACom_AKK
#
DEF D_Schottky_x2_ACom_AKK D 0 30 Y N 1 F N
F0 "D" 50 -100 50 H V C CNN
F1 "D_Schottky_x2_ACom_AKK" 0 100 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
P 2 0 1 0 -140 0 150 0 N
P 2 0 1 0 0 0 0 -100 N
P 3 0 1 8 -150 50 -150 -50 -150 -50 N
P 3 0 1 8 150 50 150 -50 150 -50 N
P 4 0 1 8 -150 50 -170 50 -170 40 -170 40 N
P 4 0 1 8 150 -50 170 -50 170 -40 170 -40 N
P 4 0 1 8 150 50 130 50 130 40 130 40 N
P 5 0 1 8 -130 -40 -130 -50 -150 -50 -150 -50 -150 -50 N
P 6 0 1 8 -50 -50 -150 0 -50 50 -50 -50 -50 -50 -50 -50 N
P 6 0 1 8 50 50 150 0 50 -50 50 50 50 50 50 50 N
X A 1 0 -200 100 U 50 50 0 1 P
X K 2 -300 0 150 R 50 50 0 1 P
X K 3 300 0 150 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
# LM1117-ADJ
#
DEF LM1117-ADJ U 0 30 Y Y 1 F N
F0 "U" 100 -250 50 H V C CNN
F1 "LM1117-ADJ" 0 250 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
ALIAS LM1117-1.8 LM1117-2.5 LM1117-3.3 LM1117-5.0
$FPLIST
SOT-223*
TO-263*
TO-252*
$ENDFPLIST
DRAW
S -200 -200 200 200 0 1 10 f
X GND/ADJ 1 0 -300 100 U 50 50 1 1 W
X VO 2 300 0 100 L 50 50 1 1 w
X VI 3 -300 0 100 R 50 50 1 1 W
ENDDRAW
ENDDEF
#
# PESD1CAN
#
DEF PESD1CAN D 0 30 Y N 1 F N
F0 "D" 0 -350 50 H V C CNN
F1 "PESD1CAN" 50 150 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
SOT23
$ENDFPLIST
DRAW
S -200 100 300 -300 0 1 0 N
P 2 0 1 0 -140 -200 150 -200 N
P 2 0 1 0 -140 0 150 0 N
P 3 0 1 8 -150 -150 -150 -250 -150 -250 N
P 3 0 1 8 -150 50 -150 -50 -150 -50 N
P 3 0 1 8 150 -150 150 -250 150 -250 N
P 3 0 1 8 150 50 150 -50 150 -50 N
P 4 0 1 8 -150 -150 -170 -150 -170 -160 -170 -160 N
P 4 0 1 8 -150 50 -170 50 -170 40 -170 40 N
P 4 0 1 8 150 -250 170 -250 170 -240 170 -240 N
P 4 0 1 8 150 -150 130 -150 130 -160 130 -160 N
P 4 0 1 8 150 -50 170 -50 170 -40 170 -40 N
P 4 0 1 0 150 0 250 0 250 -200 150 -200 N
P 4 0 1 8 150 50 130 50 130 40 130 40 N
P 5 0 1 8 -130 -240 -130 -250 -150 -250 -150 -250 -150 -250 N
P 5 0 1 8 -130 -40 -130 -50 -150 -50 -150 -50 -150 -50 N
P 6 0 1 8 -50 -250 -150 -200 -50 -150 -50 -250 -50 -250 -50 -250 N
P 6 0 1 8 -50 -50 -150 0 -50 50 -50 -50 -50 -50 -50 -50 N
P 6 0 1 8 50 -150 150 -200 50 -250 50 -150 50 -150 50 -150 N
P 6 0 1 8 50 50 150 0 50 -50 50 50 50 50 50 50 N
X K 1 -300 0 150 R 50 50 0 1 P
X K 2 -300 -200 150 R 50 50 0 1 P
X O 3 400 -100 150 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
# TPS2051
#
DEF TPS2051 U 0 40 Y Y 1 F N
F0 "U" 0 -300 60 H V C CNN
F1 "TPS2051" 0 300 60 H V C CNN
F2 "" 0 0 60 H I C CNN
F3 "" 0 0 60 H I C CNN
DRAW
S -250 250 250 -250 0 1 0 N
X GND 1 -450 150 200 R 50 50 1 1 W
X IN 2 -450 50 200 R 50 50 1 1 W
X IN 3 -450 -50 200 R 50 50 1 1 P
X EN 4 -450 -150 200 R 50 50 1 1 I
X ~OC 5 450 -150 200 L 50 50 1 1 O
X OUT 6 450 -50 200 L 50 50 1 1 P
X OUT 7 450 50 200 L 50 50 1 1 P
X OUT 8 450 150 200 L 50 50 1 1 w
ENDDRAW
ENDDEF
#
# USB6B1
#
DEF USB6B1 D 0 30 Y N 1 F N
F0 "D" 0 -450 50 H V C CNN
F1 "USB6B1" 0 400 50 H V C CNN
F2 "" 200 -100 50 V V C CNN
F3 "" 200 -100 50 V V C CNN
$FPLIST
SO8
$ENDFPLIST
DRAW
C -150 -300 7 0 1 0 N
C -150 100 7 0 1 0 N
C -150 300 7 0 1 0 N
C 0 -300 7 0 1 0 N
C 0 -100 7 0 1 0 N
C 0 300 7 0 1 0 N
C 200 -300 7 0 1 0 N
C 200 300 7 0 1 0 N
S -300 -100 300 -100 0 1 0 N
S -300 300 300 300 0 1 0 N
S -200 -150 -100 -150 0 1 0 N
S -200 250 -100 250 0 1 0 N
S -150 300 -150 -300 0 1 0 N
S -50 -150 50 -150 0 1 0 N
S -50 250 50 250 0 1 0 N
S 0 300 0 -300 0 1 0 N
S 200 300 200 -300 0 1 0 N
S 300 -300 -300 -300 0 1 0 N
S 300 100 -300 100 0 1 0 N
P 3 0 1 8 150 50 250 50 250 50 N
P 4 0 1 8 150 50 150 30 160 30 160 30 N
P 4 0 1 8 250 50 250 70 240 70 240 70 N
P 5 0 1 0 -250 350 300 350 300 -350 -250 -350 -250 350 N
P 6 0 1 8 -200 -250 -150 -150 -100 -250 -200 -250 -200 -250 -200 -250 N
P 6 0 1 8 -200 150 -150 250 -100 150 -200 150 -200 150 -200 150 N
P 6 0 1 8 -50 -250 0 -150 50 -250 -50 -250 -50 -250 -50 -250 N
P 6 0 1 8 -50 150 0 250 50 150 -50 150 -50 150 -50 150 N
P 6 0 1 8 150 -50 200 50 250 -50 150 -50 150 -50 150 -50 N
X VCC 1 -500 300 200 R 50 50 1 1 P
X I/O1 2 -500 100 200 R 50 50 1 1 P
X I/O2 3 -500 -100 200 R 50 50 1 1 P
X GND 4 -500 -300 200 R 50 50 1 1 P
X GND 5 500 -300 200 L 50 50 1 1 P
X I/O2 6 500 -100 200 L 50 50 1 1 P
X I/O1 7 500 100 200 L 50 50 1 1 P
X VCC 8 500 300 200 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
#End Library

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
(fp_lib_table
(lib (name modules)(type KiCad)(uri modules.pretty)(options "")(descr ""))
)

View File

@@ -0,0 +1,31 @@
(module DB9-F (layer F.Cu) (tedit 546362FD)
(descr "Connecteur DB9 femelle couche")
(tags "CONN DB9")
(fp_text reference XP** (at -6.3 -5.3) (layer F.SilkS)
(effects (font (thickness 0.3048)))
)
(fp_text value DB9F (at 7.7 -5.1) (layer F.SilkS)
(effects (font (thickness 0.3048)))
)
(fp_line (start -16.129 2.286) (end 16.383 2.286) (layer F.SilkS) (width 0.3048))
(fp_line (start 16.383 2.286) (end 16.383 -9.494) (layer F.SilkS) (width 0.3048))
(fp_line (start 16.383 -9.494) (end -16.129 -9.494) (layer F.SilkS) (width 0.3048))
(fp_line (start -16.129 -9.494) (end -16.129 2.286) (layer F.SilkS) (width 0.3048))
(fp_line (start -9.017 -7.874) (end 9.271 -7.874) (layer F.SilkS) (width 0.3048))
(pad "" thru_hole circle (at 12.827 -1.27) (size 3.81 3.81) (drill 3.048) (layers *.Cu *.Mask F.SilkS))
(pad "" thru_hole circle (at -12.573 -1.27) (size 3.81 3.81) (drill 3.048) (layers *.Cu *.Mask F.SilkS))
(pad 1 thru_hole rect (at -5.461 1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 2 thru_hole circle (at -2.667 1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 3 thru_hole circle (at 0 1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 4 thru_hole circle (at 2.794 1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 5 thru_hole circle (at 5.588 1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 6 thru_hole circle (at -4.064 -1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 7 thru_hole circle (at -1.27 -1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 8 thru_hole circle (at 1.397 -1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(pad 9 thru_hole circle (at 4.191 -1.27) (size 1.524 1.524) (drill 1.016) (layers *.Cu *.Mask F.SilkS))
(model conn_DBxx/db9_female_pin90deg.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)

View File

@@ -0,0 +1,45 @@
(module TO-220-3_Horizontal_TabDown (layer F.Cu) (tedit 5BEBD722)
(descr "TO-220-3, Horizontal, RM 2.54mm, see https://www.vishay.com/docs/66542/to-220-1.pdf")
(tags "TO-220-3 Horizontal RM 2.54mm")
(fp_text reference Q1 (at 2.54 -20.58) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value IRL3303 (at 2.54 2) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_circle (center 2.54 -16.66) (end 4.39 -16.66) (layer F.Fab) (width 0.1))
(fp_line (start -2.46 -13.06) (end -2.46 -19.46) (layer F.Fab) (width 0.1))
(fp_line (start -2.46 -19.46) (end 7.54 -19.46) (layer F.Fab) (width 0.1))
(fp_line (start 7.54 -19.46) (end 7.54 -13.06) (layer F.Fab) (width 0.1))
(fp_line (start 7.54 -13.06) (end -2.46 -13.06) (layer F.Fab) (width 0.1))
(fp_line (start -2.46 -3.81) (end -2.46 -13.06) (layer F.Fab) (width 0.1))
(fp_line (start -2.46 -13.06) (end 7.54 -13.06) (layer F.Fab) (width 0.1))
(fp_line (start 7.54 -13.06) (end 7.54 -3.81) (layer F.Fab) (width 0.1))
(fp_line (start 7.54 -3.81) (end -2.46 -3.81) (layer F.Fab) (width 0.1))
(fp_line (start 0 -3.81) (end 0 0) (layer F.Fab) (width 0.1))
(fp_line (start 2.54 -3.81) (end 2.54 0) (layer F.Fab) (width 0.1))
(fp_line (start 5.08 -3.81) (end 5.08 0) (layer F.Fab) (width 0.1))
(fp_line (start -2.58 -3.69) (end 7.66 -3.69) (layer F.SilkS) (width 0.12))
(fp_line (start -2.58 -19.58) (end 7.66 -19.58) (layer F.SilkS) (width 0.12))
(fp_line (start -2.58 -19.58) (end -2.58 -3.69) (layer F.SilkS) (width 0.12))
(fp_line (start 7.66 -19.58) (end 7.66 -3.69) (layer F.SilkS) (width 0.12))
(fp_line (start 0 -3.69) (end 0 -1.15) (layer F.SilkS) (width 0.12))
(fp_line (start 2.54 -3.69) (end 2.54 -1.15) (layer F.SilkS) (width 0.12))
(fp_line (start 5.08 -3.69) (end 5.08 -1.15) (layer F.SilkS) (width 0.12))
(fp_line (start -2.71 -19.71) (end -2.71 1.25) (layer F.CrtYd) (width 0.05))
(fp_line (start -2.71 1.25) (end 7.79 1.25) (layer F.CrtYd) (width 0.05))
(fp_line (start 7.79 1.25) (end 7.79 -19.71) (layer F.CrtYd) (width 0.05))
(fp_line (start 7.79 -19.71) (end -2.71 -19.71) (layer F.CrtYd) (width 0.05))
(fp_text user %R (at 2.54 -20.58) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 2 thru_hole rect (at 2.54 -16.66) (size 12 7) (drill 3.5) (layers *.Cu *.Mask))
(pad 1 thru_hole rect (at 0 0) (size 1.905 2) (drill 1.1) (layers *.Cu *.Mask))
(pad 2 thru_hole oval (at 2.54 0) (size 1.905 2) (drill 1.1) (layers *.Cu *.Mask))
(pad 3 thru_hole oval (at 5.08 0) (size 1.905 2) (drill 1.1) (layers *.Cu *.Mask))
(model ${KISYS3DMOD}/Package_TO_SOT_THT.3dshapes/TO-220-3_Horizontal_TabDown.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)

View File

@@ -0,0 +1,10 @@
(module VIA (layer F.Cu) (tedit 5C8804C2)
(fp_text reference REF** (at 0 0.5) (layer F.SilkS) hide
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value VIA (at 0 -0.5) (layer F.Fab) hide
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 1 thru_hole circle (at 0 0) (size 1.5 1.5) (drill 0.6) (layers *.Cu *.Mask)
(zone_connect 1))
)

View File

@@ -0,0 +1,14 @@
(module hole_3mm (layer F.Cu) (tedit 5BF13739)
(fp_text reference hole_3mm (at 0 -2.54) (layer F.SilkS) hide
(effects (font (size 1.5 1.5) (thickness 0.3)))
)
(fp_text value Val** (at 0 3.175) (layer F.SilkS) hide
(effects (font (size 1.5 1.5) (thickness 0.3)))
)
(fp_line (start 0 2.5) (end 0 1.5) (layer F.SilkS) (width 0.3))
(fp_line (start -2.5 0) (end -1.5 0) (layer F.SilkS) (width 0.3))
(fp_line (start 2.5 0) (end 1.5 0) (layer F.SilkS) (width 0.3))
(fp_line (start 0 -1.5) (end 0 -2.5) (layer F.SilkS) (width 0.3))
(fp_circle (center 0 0) (end 2.5 0) (layer F.SilkS) (width 0.3))
(pad "" np_thru_hole circle (at 0 0) (size 3 3) (drill 1) (layers *.Cu *.Mask))
)

View File

@@ -0,0 +1,6 @@
(sym_lib_table
(lib (name Chiller_control-rescue)(type Legacy)(uri ${KIPRJMOD}/Chiller_control-rescue.lib)(options "")(descr ""))
(lib (name Servo_control-rescue)(type Legacy)(uri ${KIPRJMOD}/Servo_control-rescue.lib)(options "")(descr ""))
(lib (name ch34x)(type Legacy)(uri ${KIPRJMOD}/ch34x.lib)(options "")(descr ""))
(lib (name elements)(type Legacy)(uri ${KIPRJMOD}/elements.lib)(options "")(descr ""))
)

View File

@@ -0,0 +1,63 @@
/*
* main.c
*
* Copyright 2018 Edward V. Emelianoff <eddy@sao.ru, edward.emelianoff@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "adc.h"
#include "effects.h"
#include "hardware.h"
#include "protocol.h"
#include "usart.h"
#include <string.h> // memcpy
#include <stm32f0.h>
volatile uint32_t Tms = 0;
// Called when systick fires
void sys_tick_handler(void){
++Tms;
}
int main(void){
char *txt;
hw_setup();
SysTick_Config(6000, 1);
SEND("Servos controller v0.1\n");
if(RCC->CSR & RCC_CSR_IWDGRSTF){ // watchdog reset occured
SEND("WDGRESET=1\n");
}
if(RCC->CSR & RCC_CSR_SFTRSTF){ // software reset occured
SEND("SOFTRESET=1\n");
}
RCC->CSR |= RCC_CSR_RMVF; // remove reset flags
while (1){
IWDG->KR = IWDG_REFRESH;
if(usart1_getline(&txt)){ // usart1 received command, process it
txt = process_command(txt);
}else txt = NULL;
if(txt){ // text waits for sending
while(ALL_OK != usart1_send(txt, 0)){
IWDG->KR = IWDG_REFRESH;
}
}
proc_effect();
IWDG->KR = IWDG_REFRESH;
usart1_sendbuf();
}
}

View File

@@ -0,0 +1,29 @@
/*
* This file is part of the Chiller project.
* Copyright 2019 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adc.h"
#include "hardware.h"
#include "mainloop.h"
/**
* @brief mainloop - the main servos loop
* by timer check current states & change them
*/
void mainloop(){
;
}

View File

@@ -0,0 +1,21 @@
/*
* This file is part of the Chiller project.
* Copyright 2019 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stm32f0.h>
void mainloop();

View File

@@ -0,0 +1,223 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "adc.h"
#include "effects.h"
#include "hardware.h"
#include "protocol.h"
#include "usart.h"
extern uint8_t crit_error;
#ifdef EBUG
static void putADC(int n){
put_string("ADC");
put_char('0' + n);
put_string(" value: ");
put_uint(getADCval(n));
put_char('\n');
// while(LINE_BUSY == usart1_sendbuf());
}
/**
* @brief debugging_proc - debugging functions
* @param command - rest of cmd
*/
static void debugging_proc(const char *command){
char ch;
int i;
switch(*command++){
case 'w':
SEND("Test watchdog\n");
while(1){nop();}
break;
case 'A': // raw ADC values depending on next symbol
ch = *command;
if(ch == 'A' || ch == 'B'){
for(i = 0; i < NUMBER_OF_ADC_CHANNELS; ++i){
putADC(i);
}
}else{
i = ch - '0';
if(i < 0 || i >= NUMBER_OF_ADC_CHANNELS){
SEND("Wrong channel nuber!\n");
}else putADC(i);
}
break;
case 'B':
SEND("B command\n");
break;
default:
SEND("wrong command\n");
break;
}
while(LINE_BUSY == usart1_sendbuf()){nop();};
}
#endif
static void chPWM(const char *command){
int n = *command++ - '1';
if(n < 0 || n > 2){
put_string("Wrong PWM channel number");
return;
}
int32_t CCR = getPWM(n);
if((command = getnum(command, &CCR))){
set_effect(n, EFF_NONE);
int32_t speed = SG90_STEP;
if(*command++ == ','){
getnum(command, &speed);
}
//CCR =
setPWM(n, CCR, speed);
}
put_string("pulse");
put_char('1' + n);
put_char('=');
put_int(CCR);
put_char('\n');
}
static void set_servoT(const char *buf){
int32_t T;
if(!getnum(buf, &T) || T < 1000 || T > 65535){
put_string("Bad period value\n");
usart1_sendbuf();
return;
}
put_string("Set period to ");
put_int(T);
put_string(" us\n");
setTIM3T(T);
usart1_sendbuf();
}
static void chk_effect(const char *cmd, effect_t eff, const char *name){
if(set_effect(*(++cmd)-'1', eff) == eff){
put_string("Turn on ");
put_string(name);
put_string(" effect\n");
}else put_string("err\n");
}
static void DMA_effect(const char *cmd){
int n = *cmd - '1';
if(n < 0 || n > 4){
put_string("Wrong DMA eff. number\n");
return;
}
put_string("DMA effect ");
put_char(*cmd);
put_string(" enabled\n");
switch(n){
case 0:
set_effect(0, EFF_DMASMALL);
break;
case 1:
set_effect(0, EFF_DMAMED);
break;
case 2:
set_effect(0, EFF_DMABIG);
break;
case 3:
set_effect(0, EFF_DMATEST);
break;
case 4:
set_effect(0, EFF_DMASTAR);
break;
default:
break;
}
}
/**
* @brief process_command - command parser
* @param command - command text (all inside [] without spaces)
* @return text to send over terminal or NULL
*/
char *process_command(const char *command){
char *ret = NULL;
usart1_sendbuf(); // send buffer (if it is already filled)
switch(*command){
case '?': // help
SEND_BLK(
"1-3[pos[,speed]]- set/get xth pulse length (us) (0,1,2 - min, max, mid)\n"
"fx - servo period (us)\n"
"Dx - DMA effect x\n"
"Mn - set Mad Wipe effect\n"
"Pn - set Pendulum effect\n"
"R - reset\n"
"Sn - set Small Pendulum effect\n"
"t - get MCU temperature (approx.)\n"
"V - get Vdd\n"
"Wn - set Wipe effect\n"
);
#ifdef EBUG
SEND_BLK("d -> goto debug:\n"
"\tAx - get raw ADCx value (A for all)\n"
"\tw - test watchdog\n"
);
#endif
break;
case '1':
case '2':
case '3':
chPWM(command);
break;
case 'f':
set_servoT(++command);
break;
case 'D':
DMA_effect(++command);
break;
case 'M':
chk_effect(command, EFF_MADWIPE, "mad wipe");
break;
case 'P':
chk_effect(command, EFF_PENDULUM, "pendulum");
break;
case 'R': // reset MCU
NVIC_SystemReset();
break;
case 'S':
chk_effect(command, EFF_SMPENDULUM, "small pendulum");
break;
case 't': // get mcu T
put_string("MCUTEMP10=");
put_int(getMCUtemp());
put_char('\n');
break;
case 'V': // get Vdd
put_string("VDD100=");
put_uint(getVdd());
put_char('\n');
break;
case 'W':
chk_effect(command, EFF_WIPE, "wipe");
break;
#ifdef EBUG
case 'd':
debugging_proc(++command);
return NULL;
break;
#endif
}
usart1_sendbuf();
return ret;
}

View File

@@ -0,0 +1,24 @@
/*
* This file is part of the Chiller project.
* Copyright 2018 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROTOCOL_C
#define PROTOCOL_C
#include <stm32f0.h>
char *process_command(const char *command);
#endif // PROTOCOL_C

Binary file not shown.

View File

@@ -0,0 +1,302 @@
/*
* usart.c
*
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "usart.h"
#include <string.h> // memcpy
extern volatile uint32_t Tms;
static int datalen[2] = {0,0}; // received data line length (including '\n')
uint8_t bufovr = 0; // input buffer overfull
static uint8_t linerdy = 0 // received data ready
,dlen = 0 // length of data in current buffer
,txrdy = 1 // transmission done
;
static int rbufno = 0; // current rbuf number
static char rbuf[2][UARTBUFSZ+1], tbuf[UARTBUFSZ]; // receive & transmit buffers
static char *recvdata = NULL;
static char trbuf[UARTBUFSZ+1]; // auxiliary buffer for data transmission
static int trbufidx = 0;
int put_char(char c){
if(trbufidx >= UARTBUFSZ - 1){
for(int i = 0; i < 72000000 && ALL_OK != usart1_sendbuf(); ++i)
if(i == 72000000) return 1;
}
trbuf[trbufidx++] = c;
return 0;
}
// write zero-terminated string
int put_string(const char *str){
while(*str){
if(put_char(*str++)) return 1; //error! shouldn't be!!!
}
return 0; // all OK
}
/**
* Fill trbuf with integer value
* @param N - integer value
* @return 1 if buffer overflow; oterwise return 0
*/
int put_int(int32_t N){
if(N < 0){
if(put_char('-')) return 1;
N = -N;
}
return put_uint((uint32_t) N);
}
int put_uint(uint32_t N){
char buf[10];
int L = 0;
if(N){
while(N){
buf[L++] = N % 10 + '0';
N /= 10;
}
while(L--) if(put_char(buf[L])) return 1;
}else if(put_char('0')) return 1;
return 0;
}
/**
* @brief usart1_sendbuf - send temporary transmission buffer (trbuf) over USART
* @return Tx status
*/
TXstatus usart1_sendbuf(){
int len = trbufidx;
if(len == 0) return ALL_OK;
else if(len > UARTBUFSZ) len = UARTBUFSZ;
TXstatus s = usart1_send(trbuf, len);
if(s == ALL_OK) trbufidx = 0;
return s;
}
void USART1_config(){
/* Enable the peripheral clock of GPIOA */
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
/* GPIO configuration for USART1 signals */
/* (1) Select AF mode (10) on PA9 and PA10 */
/* (2) AF1 for USART1 signals */
GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER9|GPIO_MODER_MODER10))\
| (GPIO_MODER_MODER9_1 | GPIO_MODER_MODER10_1); /* (1) */
GPIOA->AFR[1] = (GPIOA->AFR[1] &~ (GPIO_AFRH_AFRH1 | GPIO_AFRH_AFRH2))\
| (1 << (1 * 4)) | (1 << (2 * 4)); /* (2) */
/* Enable the peripheral clock USART1 */
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
/* Configure USART1 */
/* (1) oversampling by 16, 115200 baud */
/* (2) 8 data bit, 1 start bit, 1 stop bit, no parity */
USART1->BRR = 480000 / 1152; /* (1) */
USART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; /* (2) */
/* polling idle frame Transmission */
while(!(USART1->ISR & USART_ISR_TC)){}
USART1->ICR |= USART_ICR_TCCF; /* clear TC flag */
USART1->CR1 |= USART_CR1_RXNEIE; /* enable TC, TXE & RXNE interrupt */
RCC->AHBENR |= RCC_AHBENR_DMA1EN;
DMA1_Channel2->CPAR = (uint32_t) &(USART1->TDR); // periph
DMA1_Channel2->CMAR = (uint32_t) tbuf; // mem
DMA1_Channel2->CCR |= DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE; // 8bit, mem++, mem->per, transcompl irq
USART1->CR3 = USART_CR3_DMAT;
NVIC_SetPriority(DMA1_Channel2_3_IRQn, 3);
NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
/* Configure IT */
/* (3) Set priority for USART1_IRQn */
/* (4) Enable USART1_IRQn */
NVIC_SetPriority(USART1_IRQn, 0); /* (3) */
NVIC_EnableIRQ(USART1_IRQn); /* (4) */
}
#ifdef EBUG
#define TMO 0
#else
#define TMO 1
#endif
void usart1_isr(){
static uint8_t timeout = TMO // == 0 for human interface without timeout
,nctr = 0 // counter of '#' received
,incmd = 0 // ==1 - inside command
;
static uint32_t tmout = 0;
if(USART1->ISR & USART_ISR_RXNE){ // RX not emty - receive next char
// read RDR clears flag
uint8_t rb = USART1->RDR;
if(timeout && rb == '#'){ // chek '#' without timeout
if(++nctr == 4){ // "####" received - turn off timeout
timeout = 0;
nctr = 0;
datalen[rbufno] = 0; // reset all incoming data
incmd = 0;
return;
}
}else nctr = 0;
if(!incmd){
if(rb == '['){ // open command or reset previoud input
datalen[rbufno] = 0;
incmd = 1;
}
return;
}
if(timeout){ // check timeout only inside commands
if(tmout && Tms >= tmout){ // set overflow flag
bufovr = 1;
datalen[rbufno] = 0;
}else{
tmout = Tms + TIMEOUT_MS;
if(!tmout) tmout = 1; // prevent 0
}
}
switch(rb){
case '[':
datalen[rbufno] = 0;
tmout = 0;
break;
case ']': // close command - line ready!
dlen = datalen[rbufno];
if(dlen){
linerdy = 1;
incmd = 0;
recvdata = rbuf[rbufno];
rbuf[rbufno][dlen] = 0;
rbufno = !rbufno;
datalen[rbufno] = 0;
}
tmout = 0;
break;
case '\r':
case '\n':
case ' ':
case '\t':
return;
break;
default:
break;
}
if(datalen[rbufno] < UARTBUFSZ){ // put next char into buf
rbuf[rbufno][datalen[rbufno]++] = rb;
}else{ // buffer overrun
bufovr = 1;
datalen[rbufno] = 0;
incmd = 0;
tmout = 0;
}
}
}
void dma1_channel2_3_isr(){
if(DMA1->ISR & DMA_ISR_TCIF2){ // Tx
DMA1->IFCR |= DMA_IFCR_CTCIF2; // clear TC flag
txrdy = 1;
}
}
/**
* return length of received data (without trailing zero)
*/
int usart1_getline(char **line){
if(!linerdy) return 0;
linerdy = 0;
if(bufovr){
bufovr = 0;
return 0;
}
*line = recvdata;
return dlen;
}
/**
* @brief usart1_send send buffer `str` adding trailing '\n'
* @param str - string to send (without '\n' at end)
* @param len - its length or 0 to auto count
* @return
*/
TXstatus usart1_send(const char *str, int len){
if(!txrdy) return LINE_BUSY;
if(len > UARTBUFSZ - 1) return STR_TOO_LONG;
txrdy = 0;
if(len == 0){
const char *ptr = str;
while(*ptr++) ++len;
}
if(len == 0) return ALL_OK;
DMA1_Channel2->CCR &= ~DMA_CCR_EN;
memcpy(tbuf, str, len);
// tbuf[len++] = '\n';
DMA1_Channel2->CNDTR = len;
DMA1_Channel2->CCR |= DMA_CCR_EN; // start transmission
return ALL_OK;
}
TXstatus usart1_send_blocking(const char *str, int len){
if(!txrdy) return LINE_BUSY;
if(len == 0){
const char *ptr = str;
while(*ptr++) ++len;
}
if(len == 0) return ALL_OK;
for(int i = 0; i < len; ++i){
USART1->TDR = *str++;
while(!(USART1->ISR & USART_ISR_TXE));
}
// USART1->TDR = '\n';
while(!(USART1->ISR & USART_ISR_TC));
txrdy = 1;
return ALL_OK;
}
// read `buf` and get first integer `N` in it
// @return pointer to first non-number if all OK or NULL if first symbol isn't a space or number
char *getnum(const char *buf, int32_t *N){
char c;
int positive = -1;
int32_t val = 0;
//usart1_send_blocking(buf, 0);
while((c = *buf++)){
if(c == '\t' || c == ' '){
if(positive < 0) continue; // beginning spaces
else break; // spaces after number
}
if(c == '-'){
if(positive < 0){
positive = 0;
continue;
}else break; // there already was `-` or number
}
if(c < '0' || c > '9') break;
if(positive < 0) positive = 1;
val = val * 10 + (int32_t)(c - '0');
}
if(positive != -1){
if(positive == 0){
if(val == 0) return NULL; // single '-'
val = -val;
}
*N = val;
}else return NULL;
/* usart1_sendbuf();
put_uint(val);
put_char('\n');*/
return (char*)buf-1;
}

View File

@@ -0,0 +1,59 @@
/*
* usart.h
*
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#pragma once
#ifndef __USART_H__
#define __USART_H__
#include "stm32f0.h"
// input and output buffers size
#define UARTBUFSZ (64)
// timeout between data bytes
#define TIMEOUT_MS (100)
typedef enum{
ALL_OK,
LINE_BUSY,
STR_TOO_LONG
} TXstatus;
#define usart1ovr() (bufovr)
// send constant string
#define SEND_BLK(x) do{while(LINE_BUSY == usart1_send_blocking(x, sizeof(x)-1)) IWDG->KR = IWDG_REFRESH;}while(0)
#define SEND(x) do{while(LINE_BUSY == usart1_send(x, sizeof(x)-1)) IWDG->KR = IWDG_REFRESH;}while(0)
extern uint8_t bufovr;
void USART1_config();
int usart1_getline(char **line);
TXstatus usart1_send(const char *str, int len);
TXstatus usart1_send_blocking(const char *str, int len);
TXstatus usart1_sendbuf();
int put_char(char c);
int put_string(const char *str);
int put_int(int32_t N);
int put_uint(uint32_t N);
char *getnum(const char *buf, int32_t *N);
#endif // __USART_H__