Compare commits

17 Commits

Author SHA1 Message Date
3fc6e81569 Fix bug in clock setup. HSE was accidentally stopped instead of HSI. This didn't have any bad effects though 2022-06-21 20:25:06 +02:00
1cc3a85471 Update gitignores 2022-06-21 20:00:54 +02:00
prozessorkern
a3e1e72a9e updated housing - enlarged tolerances and fillet 2021-05-28 23:05:16 +02:00
f4cf90ca65 Fix wrong aligments in Linkerscript 2021-05-24 12:53:09 +02:00
8589a69a3b Housing: Fix broken 3D model. 2021-05-16 15:24:12 +02:00
994899038c Firmware: Change LED display modes
* Remove SK6812 White mode. Discrete LEDs are just fine
* Move discrete White mode at the beginning of the list
2021-05-13 16:12:43 +02:00
c3074bcb6a Refactor code 2021-05-13 16:12:27 +02:00
534f917636 PCB: Recalculate a few component values for brighter discrete white LEDs. Layout doesn't change 2021-05-13 16:06:19 +02:00
89adf30a2c Housing: Correct switch cutout location 2021-05-13 16:04:23 +02:00
677bf2c9b5 Increase PWM Frequency to ~17 kHz to prevent annoying sound 2021-05-10 19:23:43 +02:00
93d15fc549 Add overtemperature shutdown 2021-05-10 18:44:56 +02:00
d9769e7b34 adaptions for HW V2.1
added PWM output for new discrete white LEDs
added 2 new SK6812 LEDs
added a default start mode
2021-05-09 14:30:39 +02:00
b9a01bcad9 Fix bug 2021-05-09 11:14:14 +02:00
4f33816f2b Fix Screw holes from M3 to M4 in mounting ring 2021-04-17 20:45:50 +02:00
c458d5cfce Housing: Filet edges 2021-04-17 18:49:22 +02:00
b79bbc82cb Take out a lot material in the housing for faster printing 2021-04-17 18:47:26 +02:00
541f542e90 Change inductor to Murata 45223C and change version to v2.1 2021-04-09 22:47:31 +02:00
13 changed files with 3689 additions and 3644 deletions

9
firmware/.gitignore vendored
View File

@@ -1,3 +1,12 @@
*.elf
memmap.map
obj/
*.creator
*.user
*.user*
*.cflags
*.cxxflags
*.files
*.includes
*.config
.qtc_clangd/*

View File

@@ -3,18 +3,19 @@
#include <stdbool.h>
#include <ring-light/temp-adc.h>
#define RING_MAX_LED 30u
#define RING_MAX_LED 32u
#define MAX_TEMP_CELSIUS 70
enum ring_modes {
RING_MODE_ALL,
RING_MODE_RED,
RING_MODE_GREEN,
RING_MODE_BLUE,
RING_MODE_WHITE,
RING_MODE_ARC,
RING_MODE_QUARTER,
RING_MODE_IN_FARBE_UND_BUNT,
RING_MODE_MAX
RING_MODE_WHITE_DISCRETE, /*!< only discrete white LEDs */
RING_MODE_RED, /*!< only red SK6812 */
RING_MODE_GREEN, /*!< only green SK6812 */
RING_MODE_BLUE, /*!< only blue SK6812 */
RING_MODE_ALL, /*!< control all LEDs at once */
RING_MODE_ARC, /*!< SK6812 closing ring */
RING_MODE_QUARTER, /*!< SK6812 walking quarter */
RING_MODE_IN_FARBE_UND_BUNT, /*!< SK6812 color mix */
RING_MODE_MAX /*!< end of list */
};
volatile int32_t temperature;
@@ -33,12 +34,13 @@ int main(void)
{
uint32_t led_val = 0x00UL;
uint32_t led_calc_val[RING_MAX_LED] = {0x00UL};
uint8_t led_pwm_val = 0u;
bool button_pressed = false;
enum ring_modes mode = RING_MODE_ALL;
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM14EN;
GPIOA->MODER |= (2<<7*2)|(2<<6*2)|(1<<3*2);
@@ -47,6 +49,11 @@ int main(void)
/* enable TIM3 on encoder inputs */
GPIOA->AFR[0] |= (1<<7*4)|(1<<6*4);
/* enable PWM output for magic LED regulator */
GPIOB->MODER |= (2<<1*2);
GPIOB->AFR[0] &= ~(0<<1*4);
/*! -# init the TIM3 to read the encoder */
TIM3->ARR = 0xFFFF;
TIM3->CNT = 0;
TIM3->CR2 = 0;
@@ -56,17 +63,45 @@ int main(void)
TIM3->PSC = 0;
TIM3->CR1 = TIM_CR1_CEN;
/*! -# Init TIM14 for PWM control of the magic LED driver */
/*! -# Count up to 255 (8 bit resolution) */
TIM14->ARR = 0x00FFu;
TIM14->CNT = 0u;
TIM14->CCR1 = 0u;
/*! -# Set prescaler to 11 ==> ca. 17 KHz */
TIM14->PSC = 11u - 1u;
/*! -# PWM Mode 1 + prefetch */
TIM14->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE;
/*! -# Enable Output compare 1 */
TIM14->CCER = TIM_CCER_CC1E;
/*! -# Finally, enable TIM14 */
TIM14->CR2 = 0;
TIM14->CR1 = TIM_CR1_CEN;
/*! -# Set initial state to all 25% */
led_val = 64u;
mode = RING_MODE_WHITE_DISCRETE;
temperature_adc_init();
SysTick_Config(800000);
while(1) {
temperature = temperature_adc_get_temp();
/*! -# Gradually dim down the LED brightness in case the temperature is too high */
if (temperature > ((MAX_TEMP_CELSIUS) * 10)) {
if (led_val > 20)
led_val--;
}
led_pwm_val = 0u;
switch (mode)
{
case RING_MODE_ALL:
for(int i = 0; i < RING_MAX_LED; i ++) {
led_calc_val[i] = (led_val << 24) + (led_val << 16) + (led_val << 8) + led_val;
led_calc_val[i] = (led_val << 24) + (led_val << 16) + (led_val << 8) + led_val;
}
led_pwm_val = led_val;
break;
case RING_MODE_RED:
for(int i = 0; i < RING_MAX_LED; i ++) {
@@ -75,23 +110,24 @@ int main(void)
break;
case RING_MODE_GREEN:
for(int i = 0; i < RING_MAX_LED; i ++) {
led_calc_val[i] = led_val << 24;
led_calc_val[i] = led_val << 24;
}
break;
case RING_MODE_BLUE:
for(int i = 0; i < RING_MAX_LED; i ++) {
led_calc_val[i] = led_val << 8;
led_calc_val[i] = led_val << 8;
}
break;
case RING_MODE_WHITE:
case RING_MODE_WHITE_DISCRETE:
for(int i = 0; i < RING_MAX_LED; i ++) {
led_calc_val[i] = led_val;
led_calc_val[i] = 0u;
}
led_pwm_val = led_val;
break;
case RING_MODE_ARC:
for(int i = 0; i < RING_MAX_LED; i ++) {
if(led_val > i*8) {
led_calc_val[i] = 0xFFFFFFFFUL;
led_calc_val[i] = 0xFFFFFFFFUL;
}
else {
led_calc_val[i] = 0x00000000UL;
@@ -101,7 +137,7 @@ int main(void)
case RING_MODE_QUARTER:
for(int i = 0; i < RING_MAX_LED; i ++) {
if((led_val / 7 > i) && (led_val / 7 < (i + 7))) {
led_calc_val[i] = 0xFFFFFFFFUL;
led_calc_val[i] = 0xFFFFFFFFUL;
}
else {
led_calc_val[i] = 0x00000000UL;
@@ -121,7 +157,7 @@ int main(void)
case 2:
led_calc_val[i] = 0x0000FF00UL;
break;
default:
break;
}
@@ -133,6 +169,8 @@ int main(void)
}
break;
}
TIM14->CCR1 = led_pwm_val;
__disable_irq();
for(int i = 0; i < RING_MAX_LED; i ++) {
sk6812_send_led(led_calc_val[i]);
@@ -165,4 +203,4 @@ int main(void)
void SysTick_Handler(void) {
wait_tick++;
}
}

View File

@@ -93,7 +93,7 @@ void __setup_clocks(void)
RCC->CFGR = tmp;
/* Turn off HSI */
RCC->CR &= ~RCC_CR_HSEON;
RCC->CR &= ~RCC_CR_HSION;
}
void __system_init(void)

View File

@@ -38,16 +38,14 @@ MEMORY
SECTIONS
{
.vectors :
.vectors : ALIGN(4)
{
. = ALIGN(4);
KEEP(*(.vectors))
. = ALIGN(4);
} >FLASH
.text :
.text : ALIGN(4)
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
@@ -57,49 +55,54 @@ SECTIONS
*(.eh_frame)
KEEP(*(.init)) /* Constructors */
KEEP(*(.fini)) /* Destructors */
} >FLASH
. = ALIGN(4);
} >FLASH =0xFF
.ARM.extab :
.ARM.extab : ALIGN(4)
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} >FLASH
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >FLASH =0xFF
.ARM :
.ARM : ALIGN(4)
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
. = ALIGN(4);
} >FLASH =0xFF
/* Constructor/Destructor tables */
.preinit_array :
.preinit_array : ALIGN(4)
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
. = ALIGN(4);
} >FLASH =0xFF
.init_array :
.init_array : ALIGN(4)
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
. = ALIGN(4);
} >FLASH =0xFF
.fini_array :
.fini_array : ALIGN(4)
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
. = ALIGN(4);
} >FLASH =0xFF
/* Initialized Data */
__ld_load_data = LOADADDR(.data);
.data :
.data : ALIGN(4)
{
. = ALIGN(4);
__ld_sdata = .;
*(.data)
*(.data*)
@@ -108,9 +111,8 @@ SECTIONS
} >RAM AT> FLASH
/* Uninitialized static data */
.bss :
.bss : ALIGN(4)
{
. = ALIGN(4);
__ld_sbss = .;
*(.bss)
*(.bss*)
@@ -119,9 +121,8 @@ SECTIONS
__ld_ebss = .;
} >RAM
.heap_stack (NOLOAD) :
.heap_stack (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
__ld_sheap = .;
. = . + __ld_heap_size;
__ld_eheap = .;

View File

@@ -54,6 +54,8 @@ int32_t temperature_adc_get_temp(void)
temp = ((temp_lf_s23_8 / 16) * vdd_lf_s23_8 / FLOAT_TO_S23_8(3.3)) * 16;
temp = (get_temp_sensor_cal() << 10) - temp;
temp = (temp * 10 / slope) + 300;
return temp;
}
static uint32_t get_vrefint_cal(void)
@@ -99,4 +101,4 @@ void DMA_CH1_IRQHandler(void)
if (isr & DMA_ISR_TCIF1) {
process_adc_samples();
}
}
}

1
housing/.gitignore vendored
View File

@@ -1 +1,2 @@
*.FCStd?
*.stl

Binary file not shown.

View File

@@ -5,8 +5,8 @@ $Descr A4 11693 8268
encoding utf-8
Sheet 3 3
Title "Microscope LED Ring Light"
Date "2021-04-06"
Rev "v2.0"
Date "2021-04-09"
Rev "v2.1"
Comp "Shimatta"
Comment1 ""
Comment2 ""
@@ -223,9 +223,9 @@ L Device:L_Core_Ferrite L2
U 1 1 60625C92
P 3350 2400
F 0 "L2" V 3575 2400 50 0000 C CNN
F 1 "DE0704-22" V 3484 2400 50 0000 C CNN
F 2 "shimatta_inductor:FerroCore_DE0704" H 3350 2400 50 0001 C CNN
F 3 "https://www.tme.eu/Document/d1f8b47d020ebf11f3b92c6891638dfa/de.pdf" H 3350 2400 50 0001 C CNN
F 1 "45223C" V 3484 2400 50 0000 C CNN
F 2 "shimatta_inductor:Murata_4500" H 3350 2400 50 0001 C CNN
F 3 "https://www.mouser.de/datasheet/2/281/kmp_4500-1858591.pdf" H 3350 2400 50 0001 C CNN
1 3350 2400
0 -1 -1 0
$EndComp
@@ -929,9 +929,11 @@ Wire Wire Line
Text Notes 3250 2100 0 50 ~ 0
22 uH
Text Notes 2150 4650 0 50 ~ 0
Max Current = 60 mA
Max Current = 60 mA\nYou may use 27k for 88mA. This turned out to be fine.
Text Notes 850 3900 0 50 ~ 0
f = 1.08 MHz
Text Notes 1650 1850 0 50 ~ 0
For the calculation of the component values see 'lp8867-calc.py'
Text Notes 6050 2800 0 50 ~ 0
(15pF)
$EndSCHEMATC

View File

@@ -6,7 +6,7 @@ encoding utf-8
Sheet 2 3
Title "Microscope LED Ring Light"
Date "2021-04-06"
Rev "v2.0"
Rev "v2.1"
Comp "Shimatta"
Comment1 ""
Comment2 ""

2
pcb/lp8867-calc.py Normal file → Executable file
View File

@@ -35,7 +35,7 @@ switching_freq = 1.1e6
output_voltage_nom = 24 + 0.9
inductor_value = 22e-6
input_voltage = 12
output_current_per_lane = 60e-3
output_current_per_lane = 110e-3
desired_e_series = es.E12
r1 = 560e3
r2 = 100e3

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
update=Sun 28 Mar 2021 03:32:14 PM CEST
update=Fri 09 Apr 2021 10:42:17 PM CEST
version=1
last_client=kicad
[general]
@@ -266,3 +266,13 @@ uViaDrill=0.1
dPairWidth=0.3
dPairGap=0.25
dPairViaGap=0.25
[schematic_editor]
version=1
PageLayoutDescrFile=
PlotDirectoryName=
SubpartIdSeparator=0
SubpartFirstId=65
NetFmtName=
SpiceAjustPassiveValues=0
LabSize=50
ERC_TestSimilarLabels=1

View File

@@ -6,7 +6,7 @@ encoding utf-8
Sheet 1 3
Title "Microscope LED Ring Light"
Date "2021-04-06"
Rev "v2.0"
Rev "v2.1"
Comp "Shimatta"
Comment1 ""
Comment2 ""
@@ -1058,7 +1058,7 @@ P 1950 1200
F 0 "SW1" H 1950 875 50 0000 C CNN
F 1 "5FS1S102M6QE " H 1950 966 50 0000 C CNN
F 2 "shimatta_switch:NINIGI-5FS1S102M6QE" H 1950 1200 50 0001 C CNN
F 3 "~" H 1950 1200 50 0001 C CNN
F 3 "https://www.tme.eu/Document/d3fdab2d1ef2b3e44d3477e847fc8839/slide_switch_5F.PDF" H 1950 1200 50 0001 C CNN
1 1950 1200
1 0 0 1
$EndComp