From 61d13470defb4f6178dd013b4ca168c247e870c3 Mon Sep 17 00:00:00 2001 From: Christian Lind Madsen Date: Sun, 11 May 2025 22:33:48 +0200 Subject: [PATCH] first commit --- .gitmodules | 15 +++ .vs/solar_mppt_converter/v14/.atsuo | Bin 0 -> 20992 bytes avr_adc_driver | 1 + avr_global_config.h | 37 ++++++ avr_gpio_driver | 1 + avr_timer_driver | 1 + cm_pid_regulator | 1 + cm_task_manager | 1 + main.c | 18 +++ mppt_app.c | 25 ++++ mppt_app.h | 16 +++ solar_mppt_converter.atsln | 22 ++++ solar_mppt_converter.componentinfo.xml | 86 +++++++++++++ solar_mppt_converter.cproj | 165 +++++++++++++++++++++++++ 14 files changed, 389 insertions(+) create mode 100644 .gitmodules create mode 100644 .vs/solar_mppt_converter/v14/.atsuo create mode 160000 avr_adc_driver create mode 100644 avr_global_config.h create mode 160000 avr_gpio_driver create mode 160000 avr_timer_driver create mode 160000 cm_pid_regulator create mode 160000 cm_task_manager create mode 100644 main.c create mode 100644 mppt_app.c create mode 100644 mppt_app.h create mode 100644 solar_mppt_converter.atsln create mode 100644 solar_mppt_converter.componentinfo.xml create mode 100644 solar_mppt_converter.cproj diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8430052 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "avr_timer_driver"] + path = avr_timer_driver + url = https://OZ1CM@bitbucket.org/oz1cm/avr_timer_driver.git +[submodule "avr_gpio_driver"] + path = avr_gpio_driver + url = https://OZ1CM@bitbucket.org/oz1cm/avr_gpio_driver.git +[submodule "avr_adc_driver"] + path = avr_adc_driver + url = https://OZ1CM@bitbucket.org/oz1cm/avr_adc_driver.git +[submodule "cm_pid_regulator"] + path = cm_pid_regulator + url = https://OZ1CM@bitbucket.org/oz1cm/cm_pid_regulator.git +[submodule "cm_task_manager"] + path = cm_task_manager + url = https://OZ1CM@bitbucket.org/oz1cm/cm_task_manager.git diff --git a/.vs/solar_mppt_converter/v14/.atsuo b/.vs/solar_mppt_converter/v14/.atsuo new file mode 100644 index 0000000000000000000000000000000000000000..5c64ea0169285b54025f313776fd8a7330e1f550 GIT binary patch literal 20992 zcmeHPTWlj&8J=vr+w{Vvw3Jd{8`@>rHk-uv%WfBHdmKByUz0dZN$v629(#O=$Co(W z0^$XP#4DAMkXi{O#6v|I)LQ@Pfp4`TiNt?$~kciIcROlHdC0 za^}qW&pGp-|NqZ-PV&3AANc4cY$$vN++lX5=EfZEg;sh@AZ(}gMI2T|Bt{Q}kYQ@b0eNge&cgOjL17R>J_xSu|a{73Qbt2A&y z_knL{J8;A`jc@w4)MxjD>HYznKMwvF_*3AAzz>7zvwjw=E#^x@_u6Npt}i10m%*37 zPk~9^DIHG_e30Y+h283{@&7AQ7Lcm{hZz3@x~7ym{+PhykJ9*m9PLrHV|>e%r`qwa zzIPUn$PTDuozAmJ(~doL{L?$?_^0^bxW@lID4S%R((&~GeP4>{D0ZWGj`V=ODfPYj z{V5MIeRDdK-Bb-gzP3EE|@?eqDMEk}O#UHB9Q2WQ_Ri6cLK{`g{ zM#NJ`8NJzF~ z=2o@QXl-%zT8D48_~z!w#A;TkEpjCO+%vVdD3ad*v4<12PpKm+wNFl^7X9OQW?1;Q zP1uSmvxTvv%%*wVlkM6>D%lZA`i*ha-R zsd-18FJkG5#Nce0BaqeL>@g zd>Gke)t8^fe@e`&C;m&I-_(3sT{sEX#1f3)^@Z~RF%mweT5q%|bCe>(^JOLNKx!8G1R=Ne3D9kG$^Q@Q-|77C#LfR?{ipa%ul~{e?;S8v6tn*_X1)~vs<9`JQAnO|RYuU1eES{M z@kf}TUisuNpY9jvk!Ko`EKPs~>h7tSs|^{;xREilTaTu z`WWSh5r51Of7pJG{BQ_(A*#)}&N5e|7M431tV!D=B7kYaJJR+SeQlQQ(SnBMJo{P0}qQC|DUaDT z{<9bUR%JF5{J}dfs|BfxtV;1Ck6EPBn8zzK%q6|Z{{gc8Ln&Nt+|On{%+IX1akNCy zz#yP)iPV$2dnMg(s-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W*VU^Yf5oVliQz={9LgdutxnoTR6~RB~!`gb%~Zt zqY|t6ik67cU5yK#jh&3SxhxcyJ8c8MX2`O+sHc>Qbi4k@TBgW3g^Ix!C>lJuLO7IJ zDsC@X*+N%Z75%HZ{LcJ*F`Y6jh3n}xPu{oTu_jY-Xlb_M;`5e_=m_`Liz~L26siV< zjqa{FnK9>=gxGeanf1EOye()5);)qFEVbR`^&3NnzOv>bL0{muH=rr$R=97(o&+E?e-$wmT@PPsITM_>}o4p z&IBZ*E55y&_PTBJop4zcd+YXMDcuuN&BR)8ZFx7?E5^80wi^uBtl<#b>zE3urKokj zoZm3#1HMG4yq!xeRn5G)9g8?qjpcaSU$F+3d||#E&sOa%drqnub}O!VS1Zx3B})$1 z+OiL05Q908NL#(lN}yOQUL$`yK#wx=3c)~{a)U(^1;b`f9&k++@0;->`GedeDdf~R lpBm>=<9uqI4`ZAOfhDknR +#include "avr_gpio_driver/avr_gpio.h" + +#define AVR_ATTINY_414 +#define F_CPU 16000000 + +// Input Current sense +#define PORT_IIN_SENSE GPIO_PORTA +#define PIN_IIN_SENSE 1 + +// Input Voltage Sense +#define PORT_VIN_SENSE GPIO_PORTA +#define PIN_VIN_SENSE 2 + +// Output Current sense +#define PORT_IOUT_SENSE GPIO_PORTA +#define PIN_IOUT_SENSE 3 + +// Output Voltage Sense +#define PORT_VOUT_SENSE GPIO_PORTA +#define PIN_VOUT_SENSE 4 + +// PWM Output +#define PORT_BUCK_PWM GPIO_PORTB +#define PIN_BUCK_PWM 0 + +#endif /* AVR_GLOBAL_CONFIG_H_ */ \ No newline at end of file diff --git a/avr_gpio_driver b/avr_gpio_driver new file mode 160000 index 0000000..f59eff5 --- /dev/null +++ b/avr_gpio_driver @@ -0,0 +1 @@ +Subproject commit f59eff5cb163dd3f02eeb0a5d909e1bb20d731d5 diff --git a/avr_timer_driver b/avr_timer_driver new file mode 160000 index 0000000..59fe4e6 --- /dev/null +++ b/avr_timer_driver @@ -0,0 +1 @@ +Subproject commit 59fe4e65c75ad595f09ffff7551fb7ef726c3f60 diff --git a/cm_pid_regulator b/cm_pid_regulator new file mode 160000 index 0000000..c3b9479 --- /dev/null +++ b/cm_pid_regulator @@ -0,0 +1 @@ +Subproject commit c3b9479903f3399910b0036da721ba70ee8df8b9 diff --git a/cm_task_manager b/cm_task_manager new file mode 160000 index 0000000..c6b3c93 --- /dev/null +++ b/cm_task_manager @@ -0,0 +1 @@ +Subproject commit c6b3c93074fa24dace48e16a935f260dc3989c4c diff --git a/main.c b/main.c new file mode 100644 index 0000000..68b47cb --- /dev/null +++ b/main.c @@ -0,0 +1,18 @@ +/* + * solar_mppt_converter.c + * + * Created: 11-05-2025 19:01:26 + * Author : Christian L. V. Madsen (OZ1CM) + */ + +#include + + +int main(void) +{ + /* Replace with your application code */ + while (1) + { + } +} + diff --git a/mppt_app.c b/mppt_app.c new file mode 100644 index 0000000..e9be61a --- /dev/null +++ b/mppt_app.c @@ -0,0 +1,25 @@ +/* + * mppt_app.c + * + * Created: 11-05-2025 21:49:02 + * Author: Christian L. V. Madsen (OZ1CM) + */ +#include "mppt_app.h" + + +// We are using resistor dividers that has a divide down factor of 8. +uint16_t voltLowToHigh(uint16_t low_voltage){ + + if(low_voltage > 2500) return 20000; + + return low_voltage << 3; +} + +// We are using differential amplifier with gain of 16. +uint16_t voltToCurrent(uint16_t low_voltage){ + + if(low_voltage > 2500) return 1000; + + return low_voltage << 4; + +} \ No newline at end of file diff --git a/mppt_app.h b/mppt_app.h new file mode 100644 index 0000000..b266aa9 --- /dev/null +++ b/mppt_app.h @@ -0,0 +1,16 @@ +/* + * mppt_app.h + * + * Created: 11-05-2025 21:48:42 + * Author: Christian L. V. Madsen (OZ1CM) + */ + + +#ifndef MPPT_APP_H_ +#define MPPT_APP_H_ + + + + + +#endif /* MPPT_APP_H_ */ \ No newline at end of file diff --git a/solar_mppt_converter.atsln b/solar_mppt_converter.atsln new file mode 100644 index 0000000..5bb037d --- /dev/null +++ b/solar_mppt_converter.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "solar_mppt_converter", "solar_mppt_converter.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/solar_mppt_converter.componentinfo.xml b/solar_mppt_converter.componentinfo.xml new file mode 100644 index 0000000..af880e9 --- /dev/null +++ b/solar_mppt_converter.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.10.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.10.348\include\ + + include + C + + + include/ + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.10.348\include\avr\iotn414.h + + header + C + R5QjRc+IBjtCXYuU6PYTbg== + + include/avr/iotn414.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.10.348\templates\main.c + template + source + C Exe + v/wDU2ZjZ/2x3ilPyP0C0w== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.10.348\templates\main.cpp + template + source + C Exe + mkKaE95TOoATsuBGv6jmxg== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.10.348\gcc\dev\attiny414 + + libraryPrefix + GCC + + + gcc/dev/attiny414 + + + + + ATtiny_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.10.348/Atmel.ATtiny_DFP.pdsc + 1.10.348 + true + ATtiny414 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/solar_mppt_converter.cproj b/solar_mppt_converter.cproj new file mode 100644 index 0000000..3cf6b5a --- /dev/null +++ b/solar_mppt_converter.cproj @@ -0,0 +1,165 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATtiny414 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + solar_mppt_converter + solar_mppt_converter + solar_mppt_converter + Native + true + false + true + true + + + true + + 2 + 0 + 0 + + + + + + -mmcu=attiny414 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\gcc\dev\attiny414" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\ + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\ + + + + + + + + + -mmcu=attiny414 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\gcc\dev\attiny414" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\ + + + Optimize debugging experience (-Og) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATtiny_DFP\1.10.348\include\ + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + + + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + + \ No newline at end of file