Error compiling for board Generic STM32F1 series

Post here first, or if you can't find a relevant section!
Post Reply
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

I've getting the error below while compiling using arduino IDE into STMF103C8T6 (Blackpill).

Code: Select all

IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/avr" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32/LL" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32/usb" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32/OpenAMP" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32/usb/hid" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino/stm32/usb/cdc" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Drivers/STM32F4xx_HAL_Driver/Inc" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Drivers/STM32F4xx_HAL_Driver/Src" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/STM32F4xx" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/OpenAMP" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/OpenAMP/open-amp/lib/include" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/OpenAMP/libmetal/lib/include" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Middlewares/OpenAMP/virtual_driver" -DSTM32F4xx -DARDUINO=10819 -DARDUINO_BLACKPILL_F401CE -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"BLACKPILL_F401CE\"" "-DVARIANT_H=\"variant_BLACKPILL_F401Cx.h\"" -DSTM32F401xE -DHAL_UART_MODULE_ENABLED "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\tools\\CMSIS\\5.7.0/CMSIS/Core/Include/" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\tools\\CMSIS\\5.7.0/CMSIS/DSP/Include" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\tools\\CMSIS\\5.7.0/CMSIS/DSP/PrivateInclude" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\cores\\arduino" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\variants\\STM32F4xx\\F401CC(F-U-Y)_F401C(B-D-E)(U-Y)" "-IC:\\Users\\User\\Documents\\ArduinoData\\packages\\STMicroelectronics\\hardware\\stm32\\2.5.0\\libraries\\SrcWrapper\\src" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_332111\\sketch\\SrcWrapper.cpp" -o "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_332111\\sketch\\SrcWrapper.cpp.o"
In file included from C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/wiring.h:48,
                 from C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/Arduino.h:36,
                 from C:\Users\User\AppData\Local\Temp\arduino_build_332111\sketch\Faraz_Droop.ino.cpp:1:
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:242:1: note: in expansion of macro 'Serial'
  242 | Serial.print(n);
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:243:1: note: in expansion of macro 'Serial'
  243 | Serial.print("Ia_1 =");
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:244:1: note: in expansion of macro 'Serial'
  244 | Serial.print(ia_1[n]);
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:245:1: note: in expansion of macro 'Serial'
  245 | Serial.print("Ib =");
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:246:1: note: in expansion of macro 'Serial'
  246 | Serial.print(ib_1[n]);
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:247:1: note: in expansion of macro 'Serial'
  247 | Serial.print("Ic =");
      | ^~~~~~
C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\cores\arduino/WSerial.h:58:24: error: 'Serial1' does not name a type; did you mean 'Serial'?
   58 |         #define Serial Serial1
      |                        ^~~~~~~
C:\Users\User\Desktop\Faraz_Droop\Faraz_Droop.ino:248:1: note: in expansion of macro 'Serial'
  248 | Serial.println(ic_1[n]);
      | ^~~~~~
Using library SrcWrapper at version 1.0.1 in folder: C:\Users\User\Documents\ArduinoData\packages\STMicroelectronics\hardware\stm32\2.5.0\libraries\SrcWrapper 
exit status 1
Error compiling for board Generic STM32F1 series.
the whole error
https://we.tl/t-njh73HMVRB

On the other hand the other code is uploading fine for the same setting.
setting: https://we.tl/t-x9fHXV4hGW

The code I'm working on is basically i just converted it from MATLAB to arduino IDE, I don't what type of error I did :(
Arduino Code:
https://we.tl/t-qMCMguMeTa

and when i use serial1.print it shows '.' token some type of error.

Any type of help will be appreciated.
Thanks in Advance
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Error compiling for board Generic STM32F1 series

Post by fpiSTM »

Could you be more precise with your setup?
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Re: Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

@fpiSTM
I use blackpill STMF103C8T6 with ST-LINK and FDTI, and it works fine when select the shared setting above means the code is successfully uploaded but when I use the shared code to compile into this it gives me the error "ERROR COMPILING FOR BOARD GENERIES STM32F1 SERIES".
I used arduino IDE to compile and upload the code in the STM but unfortunately it gives me that error. I also tried with Serial1.print but there's nothing happened.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Error compiling for board Generic STM32F1 series

Post by fpiSTM »

Well it builds fine by default so something is wrong wi5h your sketch or config... so as stated you don't provide enough information. Sketch, options, ...
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Re: Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

kindly, check the setting file i shared as a link because the other code i use in arduino is working fine on the same setting.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Error compiling for board Generic STM32F1 series

Post by fpiSTM »

Well share the code here else I could not help....
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Re: Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

#include <math.h>

// Voltages and Current of load
// yahn values define hongi, 200 values of each parameters

double va_1[] = {15.5091227894435,-5.36814829343161,4.77825614224858,14.9200345244603,25.0471492256280,35.1495864313483,45.2173630048096,55.2405342959398,65.2092025725870,75.1135258521888,84.9437269808729,94.6901028533187,104.343033698139,113.892992374841,123.330553642885,132.646403373170,141.831347678971,150.876321947918,159.772399759721,168.510801676557,177.082903894508,185.480246745548,193.694543040339,201.717686242721,209.541758467193,217.159038291089,224.562008373456,231.743362872934,238.696014657166,245.413102296567,251.887996835465,258.114308333904,264.085892173627,269.796855121989,275.241561147814,280.414636983442,285.310977427465,289.925750382934,294.254401626040,298.292659300577,302.036538133742,305.482343369114,308.626674412933,311.466428190072,313.998802206394,316.221297314481,318.131720179982,319.728185446178,321.009117594591,321.973252499841,322.619638677176,322.947638221478,322.956927436797,322.647497155799,322.019652748812,321.074013822467,319.811513608214,318.233398041342,316.341224531387,314.136860425158,311.622481163892,308.800568136356,305.673906230014,302.245581082680,298.518976037369,294.497768803342,290.185927826653,285.587708373770,280.707648332145,275.550563731860,270.121543992795,264.425946901979,258.469393326101,252.257761664399,245.797182047382,239.094030287138,232.154921585173,224.986704004007,217.596451708963,209.991457986820,202.179228048220,194.167471620930,185.964095341273,177.577194951232,169.015047308929,160.286102220365,151.398974100486,142.362433471789,133.185398308881,123.876925237509,114.446200596771,104.902531373301,95.2553360164012,85.5141351431696,75.6885421427983,65.7882536893205,55.8230401721635,45.8027360539538,35.7372301650903,25.6364559446619,15.5103816373429,5.36900045593895,-4.77767928070773,-14.9196440247206,-25.0468848813515,-35.1494074865515,-45.2172418702017,-55.2404522952699,-65.2091470631832,-75.1134882757408,-84.9437015439317,-94.6900856340761,-104.343022041772,-113.892984484199,-123.330548301406,-132.646399757318,-141.831345231262,-150.876320290970,-159.772398638069,-168.510800917268,-177.082903380517,-185.480246397607,-193.694542804805,-201.717686083280,-209.541758359262,-217.159038218026,-224.562008323998,-231.743362839453,-238.696014634502,-245.413102281225,-251.887996825080,-258.114308326874,-264.085892168868,-269.796855118768,-275.241561145634,-280.414636981966,-285.310977426467,-289.925750382259,-294.254401625584,-298.292659300268,-302.036538133533,-305.482343368973,-308.626674412838,-311.466428190008,-313.998802206351,-316.221297314452,-318.131720179963,-319.728185446165,-321.009117594583,-321.973252499836,-322.619638677173,-322.947638221477,-322.956927436797,-322.647497155799,-322.019652748813,-321.074013822467,-319.811513608215,-318.233398041343,-316.341224531388,-314.136860425159,-311.622481163894,-308.800568136357,-305.673906230015,-302.245581082681,-298.518976037371,-294.497768803344,-290.185927826654,-285.587708373772,-280.707648332146,-275.550563731861,-270.121543992796,-264.425946901980,-258.469393326102,-252.257761664400,-245.797182047383,-239.094030287140,-232.154921585174,-224.986704004008,-217.596451708964,-209.991457986821,-202.179228048221,-194.167471620931,-185.964095341274,-177.577194951233,-169.015047308930,-160.286102220366,-151.398974100487,-142.362433471790,-133.185398308881,-123.876925237510,-114.446200596772,-104.902531373301,-95.2553360164018,-85.5141351431701,-75.6885421427988,-65.7882536893209,-55.8230401721639,-45.8027360539542,-35.7372301650906,-25.6364559446621,-15.5103816373431};
double vb_1[] = {-271.642420437847,-276.996905802610,-282.078113575616,-286.881001786440,-291.400811994628,-295.633071122681,-299.573593932344,-303.218485842971,-306.564145886874,-309.607269661849,-312.344852185235,-314.774190583979,-316.892886575543,-318.698848708473,-320.190294340954,-321.365751342204,-322.224059506131,-322.764371669804,-322.986154531558,-322.889189165145,-322.473571227568,-321.739710859111,-320.688332274812,-319.320473047199,-317.637483080603,-315.641023277800,-313.333063900104,-310.715882622427,-307.792062285120,-304.564488344783,-301.036346026494,-297.211117180270,-293.092576844824,-288.684789522001,-283.992105165578,-279.019154888356,-273.770846391797,-268.252359122704,-262.469139161725,-256.426893848721,-250.131586150314,-243.589428775149,-236.806878042706,-229.790627511685,-222.547601374275,-215.084947622811,-207.410030995567,-199.530425708648,-191.453907981156,-183.188448360999,-174.742203858919,-166.123509898513,-157.340872090171,-148.402957837071,-139.318587781491,-130.096727099909,-120.746476655447,-111.277064016425,-101.697834349861,-92.0182411989228,-82.2478371534179,-72.3962644225443,-62.4732453191925,-52.4885726651971,-42.4521001270033,-32.3737324912882,-22.2634158901324,-12.1311279853878,-1.98686812193047,8.15935254048575,18.2975209070351,28.4176318295356,38.5096979803226,48.5637597085353,58.5698948690894,68.5182286146368,78.3989431408475,88.2022873753974,97.9185866010990,107.538252003679,117.051790134783,126.449812280857,135.723043728681,144.862332918386,153.858660474943,162.703148109191,171.387067379645,179.901848306407,188.239087828704,196.390558097694,204.348214596361,212.104204078481,219.650872318826,226.980771666963,234.086668397186,240.961549847327,247.598631339409,253.991362875304,260.133435600790,266.018788031628,271.641612035516,276.996358564015,282.077743128787,286.880751016749,291.400642238991,295.632956208568,299.573516142567,303.218433184082,306.564110240050,309.607245531144,312.344835850235,314.774179526190,316.892879090101,318.698843641290,320.190290910784,321.365749020190,322.224057934271,322.764370605752,322.986153811261,322.889188677548,322.473570897495,321.739710635673,320.688332123558,319.320472944810,317.637483011293,315.641023230881,313.333063868344,310.715882600927,307.792062270567,304.564488334931,301.036346019826,297.211117175757,293.092576841768,288.684789519933,283.992105164178,279.019154887409,273.770846391157,268.252359122271,262.469139161432,256.426893848523,250.131586150180,243.589428775059,236.806878042645,229.790627511645,222.547601374248,215.084947622793,207.410030995555,199.530425708640,191.453907981151,183.188448360996,174.742203858917,166.123509898512,157.340872090171,148.402957837071,139.318587781492,130.096727099909,120.746476655447,111.277064016425,101.697834349862,92.0182411989232,82.2478371534183,72.3962644225447,62.4732453191929,52.4885726651975,42.4521001270036,32.3737324912886,22.2634158901327,12.1311279853880,1.98686812193065,-8.15935254048559,-18.2975209070349,-28.4176318295355,-38.5096979803226,-48.5637597085353,-58.5698948690895,-68.5182286146369,-78.3989431408477,-88.2022873753976,-97.9185866010992,-107.538252003680,-117.051790134783,-126.449812280857,-135.723043728681,-144.862332918387,-153.858660474943,-162.703148109192,-171.387067379646,-179.901848306408,-188.239087828704,-196.390558097695,-204.348214596362,-212.104204078481,-219.650872318826,-226.980771666964,-234.086668397187,-240.961549847328,-247.598631339410,-253.991362875305,-260.133435600791,-266.018788031629,-271.641612035518};
double vc_1[] = {287.151543227290,282.365054096042,277.299857433368,271.960967261980,266.353662769000,260.483484691332,254.356230927535,247.977951547031,241.354943314287,234.493743809660,227.401125204362,220.084087730661,212.549852877404,204.805856333632,196.859740698069,188.719347969034,180.392711827159,171.888049721886,163.213754771837,154.378387488588,145.390667333059,136.259464113563,126.993789234473,117.602786804477,108.095724613410,98.4819849867108,88.7710555266477,78.9725197494932,69.0960476279547,59.1513860482161,49.1483491910294,39.0968088463666,29.0066846711970,18.8879344000122,8.75054401776364,-1.39548209508556,-11.5401310356675,-21.6733912602296,-31.7852624643156,-41.8657654518561,-51.9049519834279,-61.8929145939645,-71.8197963702268,-81.6758006783863,-91.4512008321186,-101.136349691669,-110.721689184416,-120.197759737530,-129.555209613435,-138.784804138842,-147.877434818257,-156.824128322965,-165.616055346626,-174.244539318728,-182.701064967321,-190.977286722558,-199.065036952767,-206.956334024917,-214.643390181525,-222.118619226235,-229.374644010474,-236.404303713812,-243.200660910821,-249.757008417483,-256.066875910366,-262.124036312054,-267.922511936520,-273.456580388382,-278.720780210214,-283.709916272346,-288.419064899830,-292.843578731514,-296.979091306424,-300.821521372934,-304.367076916472,-307.612258901775,-310.553864726021,-313.188991379404,-315.515038310062,-317.529709990499,-319.231018183002,-320.617283901787,-321.687139069954,-322.439527869618,-322.873707783871,-322.989250329556,-322.786041480131,-322.264281778196,-321.424486137584,-320.267483335203,-318.794415193132,-317.006735451781,-314.906208335227,-312.494906810133,-309.775210539984,-306.749803536647,-303.421671511572,-299.794098929258,-295.870665765880,-291.655243976290,-287.151993672859,-282.365359019954,-277.300063848079,-271.961106992029,-266.353757357639,-260.483548722017,-254.356274272365,-247.977980888812,-241.354963176867,-234.493757255403,-227.401134306303,-220.084093892114,-212.549857048329,-204.805859157092,-196.859742609377,-188.719349262873,-180.392712703009,-171.888050314783,-163.213755173192,-154.378387760281,-145.390667516979,-136.259464238065,-126.993789318754,-117.602786861530,-108.095724652031,-98.4819850128554,-88.7710555443462,-78.9725197614740,-69.0960476360652,-59.1513860537064,-49.1483491947461,-39.0968088488826,-29.0066846729003,-18.8879344011652,-8.75054401854421,1.39548209455715,11.5401310353098,21.6733912599874,31.7852624641517,41.8657654517452,51.9049519833528,61.8929145939137,71.8197963701926,81.6758006783631,91.4512008321030,101.136349691659,110.721689184409,120.197759737525,129.555209613432,138.784804138840,147.877434818256,156.824128322965,165.616055346626,174.244539318728,182.701064967321,190.977286722558,199.065036952767,206.956334024917,214.643390181526,222.118619226236,229.374644010475,236.404303713812,243.200660910822,249.757008417484,256.066875910367,262.124036312055,267.922511936521,273.456580388383,278.720780210215,283.709916272347,288.419064899831,292.843578731515,296.979091306425,300.821521372935,304.367076916473,307.612258901776,310.553864726022,313.188991379406,315.515038310063,317.529709990500,319.231018183004,320.617283901788,321.687139069955,322.439527869620,322.873707783872,322.989250329558,322.786041480133,322.264281778197,321.424486137586,320.267483335205,318.794415193133,317.006735451783,314.906208335228,312.494906810134,309.775210539985,306.749803536649,303.421671511573,299.794098929259,295.870665765881,291.655243976291,287.151993672861};
double ia_1[] = {-0.246216727820910,-0.151250261252534,-0.0561324297784594,0.0390422186278987,0.134179299008295,0.229184611787742,0.323964187825453,0.418424348717112,0.512471777288381,0.606013594824981,0.698957442671636,0.791211566568140,0.882684902589270,0.973287163892877,1.06292892770937,1.15152172216101,1.23897811260483,1.32521178726466,1.41013764196684,1.49367186382737,1.57573201376188,1.65623710770537,1.73510769644057,1.81226594394168,1.88763570414640,1.96114259607402,2.03271407721092,2.10227951508798,2.16977025697741,2.23511969763857,2.29826334504523,2.35913888402861,2.41768623777306,2.47384762710334,2.52756762750486,2.57879322382034,2.62747386256903,2.67356150183658,2.71701065868648,2.75777845404606,2.79582465502289,2.83111171460972,2.86360480873885,2.89327187064919,2.92008362253230,2.94401360442605,2.96503820032737,2.98313666149842,2.99829112694306,3.01048664103350,3.01971116826972,3.02595560515701,3.02921378919007,3.02948250493461,3.02676148720064,3.02105342130415,3.01236394041704,3.00070162000784,2.98607796937879,2.96850742030752,2.94800731280466,2.92459787800129,2.89830221818332,2.86914628399226,2.83715884881514,2.80237148038858,2.76481850964528,2.72453699683354,2.68156669494327,2.63595001047456,2.58773196158761,2.53696013367524,2.48368463240184,2.42795803425514,2.36983533465956,2.30937389370236,2.24663337952616,2.18167570944370,2.11456498883292,2.04536744787269,1.97415137618162,1.90098705542443,1.82594668995249,1.74910433554679,1.67053582633382,1.59031869994650,1.50853212100383,1.42525680298503,1.34057492857501,1.25457006856007,1.16732709935353,1.07893211923305,0.989472363371930,0.899036117748611,0.807712632019020,0.715592031437954,0.622765227916332,0.529323830302114,0.435360053973428,0.340966629833126,0.246236712794579,0.151263789849023,0.0561415878051842,-0.0390360192077623,-0.134175102382626,-0.229181770930595,-0.323962264740106,-0.418423046906757,-0.512470896042937,-0.606012998276085,-0.698957038844769,-0.791211293202220,-0.882684717537377,-0.973287038624142,-1.06292884291015,-1.15152166475717,-1.23897807374596,-1.32521176095960,-1.41013762415993,-1.49367185177319,-1.57573200560194,-1.65623710218160,-1.73510769270132,-1.81226594141044,-1.88763570243291,-1.96114259491410,-2.03271407642572,-2.10227951455645,-2.16977025661760,-2.23511969739501,-2.29826334488035,-2.35913888391700,-2.41768623769751,-2.47384762705221,-2.52756762747025,-2.57879322379692,-2.62747386255317,-2.67356150182585,-2.71701065867923,-2.75777845404115,-2.79582465501957,-2.83111171460748,-2.86360480873734,-2.89327187064816,-2.92008362253161,-2.94401360442559,-2.96503820032706,-2.98313666149822,-2.99829112694293,-3.01048664103342,-3.01971116826967,-3.02595560515698,-3.02921378919005,-3.02948250493461,-3.02676148720064,-3.02105342130416,-3.01236394041704,-3.00070162000785,-2.98607796937880,-2.96850742030753,-2.94800731280467,-2.92459787800130,-2.89830221818333,-2.86914628399228,-2.83715884881515,-2.80237148038859,-2.76481850964529,-2.72453699683355,-2.68156669494328,-2.63595001047457,-2.58773196158762,-2.53696013367525,-2.48368463240185,-2.42795803425516,-2.36983533465957,-2.30937389370237,-2.24663337952617,-2.18167570944371,-2.11456498883293,-2.04536744787270,-1.97415137618163,-1.90098705542444,-1.82594668995250,-1.74910433554680,-1.67053582633383,-1.59031869994651,-1.50853212100384,-1.42525680298503,-1.34057492857502,-1.25457006856007,-1.16732709935354,-1.07893211923305,-0.989472363371935,-0.899036117748616,-0.807712632019025,-0.715592031437959,-0.622765227916336,-0.529323830302118,-0.435360053973431,-0.340966629833129,-0.246236712794582};
double ib_1[] = {-2.49204106129298,-2.54493121760986,-2.59531118209814,-2.64313080031866,-2.68834258527712,-2.73090171883581,-2.77076606517529,-2.80789619154908,-2.84225539309951,-2.87380971953654,-2.90252800218157,-2.92838188035341,-2.95134582639617,-2.97139716886770,-2.98851611355685,-3.00268576209948,-3.01389212803346,-3.02212415018069,-3.02737370327828,-3.02963560580432,-3.02890762496089,-3.02519047878915,-3.01848783540093,-3.00880630931820,-2.99615545491799,-2.98054775698475,-2.96199861837683,-2.94052634481724,-2.91615212682233,-2.88890001878541,-2.85879691523534,-2.82587252429310,-2.79015933835223,-2.75169260201196,-2.71051027729447,-2.66665300618061,-2.62016407050091,-2.57108934922144,-2.51947727316674,-2.46537877722433,-2.40884725007808,-2.34993848151998,-2.28871060739236,-2.22522405221477,-2.15954146955231,-2.09172768018407,-2.02184960813288,-1.94997621461935,-1.87617843000550,-1.80052908379502,-1.72310283275935,-1.64397608726048,-1.56322693584312,-1.48093506817077,-1.39718169638159,-1.31204947494188,-1.22562241907605,-1.13798582185378,-1.04922617001604,-0.959431058623096,-0.868689104608811,-0.777089859326385,-0.684723720171999,-0.591681841373500,-0.498056044032179,-0.403938725506434,-0.309422768226727,-0.214601448031844,-0.119568342116901,-0.0244172366839489,0.0707579656136814,0.165863338341964,0.260805023980226,0.355489326547192,0.449822804067602,0.543712360788163,0.637065339051815,0.729789610739654,0.821793668190259,0.912986714506713,1.00327875316217,1.09258067681557,1.18080435524981,1.26786272234567,1.35366986200548,1.43814109294204,1.52119305224875,1.60274377766875,1.68271278848179,1.76102116492898,1.83759162609704,1.91234860618527,1.98521832907984,2.05612888116193,2.12501028227775,2.19179455480057,2.25641579071636,2.31881021666709,2.37891625688733,2.43667459397206,2.49202822741582,2.54492252986534,2.59530530103011,2.64312681919776,2.68833989030343,2.73089989450459,2.77076483021540,2.80789535555729,2.84225482718455,2.87380933644697,2.90252774285352,2.92838170480429,2.95134570756023,2.97139708842310,2.98851605910081,3.00268572523610,3.01389210307923,3.02212413328822,3.02737369184312,3.02963559806343,3.02890761972078,3.02519047524193,3.01848783299968,3.00880630769271,2.99615545381764,2.98054775623988,2.96199861787260,2.94052634447591,2.91615212659127,2.88890001862900,2.85879691512947,2.82587252422144,2.79015933830373,2.75169260197913,2.71051027727225,2.66665300616557,2.62016407049073,2.57108934921456,2.51947727316209,2.46537877722118,2.40884725007595,2.34993848151854,2.28871060739139,2.22522405221412,2.15954146955187,2.09172768018377,2.02184960813268,1.94997621461922,1.87617843000542,1.80052908379496,1.72310283275931,1.64397608726045,1.56322693584311,1.48093506817076,1.39718169638159,1.31204947494188,1.22562241907605,1.13798582185378,1.04922617001604,0.959431058623100,0.868689104608815,0.777089859326389,0.684723720172003,0.591681841373503,0.498056044032183,0.403938725506437,0.309422768226730,0.214601448031847,0.119568342116903,0.0244172366839507,-0.0707579656136800,-0.165863338341963,-0.260805023980225,-0.355489326547192,-0.449822804067603,-0.543712360788164,-0.637065339051816,-0.729789610739655,-0.821793668190261,-0.912986714506715,-1.00327875316217,-1.09258067681557,-1.18080435524982,-1.26786272234567,-1.35366986200549,-1.43814109294205,-1.52119305224875,-1.60274377766875,-1.68271278848179,-1.76102116492898,-1.83759162609705,-1.91234860618528,-1.98521832907985,-2.05612888116193,-2.12501028227776,-2.19179455480058,-2.25641579071637,-2.31881021666710,-2.37891625688734,-2.43667459397207,-2.49202822741583};
double ic_1[] = {2.73825778911389,2.69618147886239,2.65144361187660,2.60408858169076,2.55416328626882,2.50171710704806,2.44680187734984,2.38947184283197,2.32978361581113,2.26779612471156,2.20357055950993,2.13717031378527,2.06866092380690,1.99811000497483,1.92558718584748,1.85116403993847,1.77491401542863,1.69691236291603,1.61723606131144,1.53596374197695,1.45317561119901,1.36895337108379,1.28338013896035,1.19654036537652,1.10851975077159,1.01940516091072,0.929284541165914,0.838246829729260,0.746381869844918,0.653780321146837,0.560533570190115,0.466733640264498,0.372473100579179,0.277844974908616,0.182942649789608,0.0878597823602690,-0.00730979206812065,-0.102472152615142,-0.197533385519741,-0.292399676821731,-0.386977404944811,-0.481173233089745,-0.574894201346492,-0.668047818434413,-0.760542152979988,-0.852285924241977,-0.943188592194492,-1.03316044687907,-1.12211269693756,-1.20995755723849,-1.29660833551037,-1.38197951789654,-1.46598685334695,-1.54854743676384,-1.62957979081905,-1.70900394636228,-1.78674152134099,-1.86271579815406,-1.93685179936275,-2.00907636168442,-2.07931820819584,-2.14750801867490,-2.21357849801132,-2.27746444261876,-2.33910280478296,-2.39843275488214,-2.45539574141855,-2.50993554880170,-2.56199835282637,-2.61153277379061,-2.65848992720129,-2.70282347201720,-2.74448965638207,-2.78344736080234,-2.81965813872716,-2.85308625449052,-2.88369871857797,-2.91146532018335,-2.93635865702318,-2.95835416237941,-2.97743012934379,-2.99356773224000,-3.00675104520231,-3.01696705789245,-3.02420568833930,-3.02845979288854,-3.02972517325258,-3.02800058065377,-3.02328771705680,-3.01559123348904,-3.00491872545057,-2.99128072541832,-2.97469069245177,-2.95516499891054,-2.93272291429677,-2.90738658623852,-2.87918101863269,-2.84813404696921,-2.81427631086076,-2.77764122380518,-2.73826494021040,-2.69618631971437,-2.65144688883529,-2.60409079999000,-2.55416478792081,-2.50171812357399,-2.44680256547530,-2.38947230865053,-2.32978393114161,-2.26779633817088,-2.20357070400875,-2.13717041160207,-2.06866099002286,-1.99811004979896,-1.92558721619065,-1.85116406047893,-1.77491402933327,-1.69691237232861,-1.61723606768319,-1.53596374629023,-1.45317561411884,-1.36895337306033,-1.28338014029835,-1.19654036628227,-1.10851975138473,-1.01940516132578,-0.929284541446884,-0.838246829919461,-0.746381869973673,-0.653780321233997,-0.560533570249118,-0.466733640304441,-0.372473100606218,-0.277844974926920,-0.182942649801999,-0.0878597823686574,0.00730979206244202,0.102472152611298,0.197533385517139,0.292399676819969,0.386977404943619,0.481173233088938,0.574894201345947,0.668047818434045,0.760542152979739,0.852285924241810,0.943188592194380,1.03316044687899,1.12211269693751,1.20995755723846,1.29660833551035,1.38197951789652,1.46598685334694,1.54854743676384,1.62957979081905,1.70900394636228,1.78674152134099,1.86271579815406,1.93685179936275,2.00907636168443,2.07931820819585,2.14750801867491,2.21357849801132,2.27746444261877,2.33910280478297,2.39843275488215,2.45539574141856,2.50993554880170,2.56199835282638,2.61153277379062,2.65848992720130,2.70282347201721,2.74448965638208,2.78344736080235,2.81965813872717,2.85308625449053,2.88369871857798,2.91146532018336,2.93635865702319,2.95835416237942,2.97743012934380,2.99356773224001,3.00675104520232,3.01696705789247,3.02420568833932,3.02845979288856,3.02972517325259,3.02800058065379,3.02328771705681,3.01559123348906,3.00491872545059,2.99128072541833,2.97469069245178,2.95516499891055,2.93272291429678,2.90738658623853,2.87918101863270,2.84813404696922,2.81427631086077,2.77764122380519,2.73826494021041};

//DQ initialization

double V1q[201] = {};
double V1d[201] = {};
double I1q[201] = {};
double I1d[201] = {};

//Theta Initialization

double theta1 [201] = {};

//Initializations

//double fnom = 50;
double Ts = 1e-4;

//Active And Reactive Power

double Pf1new [201]={};
double Pf1old [201]={};
double Qf1new [201]={};
double Qf1old [201]={};

//Inverse DQ Trabsformation Parameters

double sine_a[201] = {};
double sine_b[201] = {};
double sine_c[201] = {};

//Computed Powers

double P_1 [201] = {};
double Q_1 [201] = {};

//V1d_off=zeros(size(t)); I1d_off=zeros(size(t));

//angular frequencies

const double wc=2*PI*50*9.94e-6;
const double wL=2*PI*50*5.1e-3;

//PI controller parameters

double kpv=0.006245486195;
double kiv=7.59150924004;
double kpi=32.04424507;
double kii=33740.7051;

//PI controller error parameters

double f1error[201] = {};
double error_vd[201] = {};
double error_vq[201] = {};
double error_id[201] = {};
double error_iq[201] = {};

//PI controller proportional parameters

double prop_vd[201] = {};
double prop_vq[201] = {};
double prop_id[201] = {};
double prop_iq[201] = {};

//PI controller integeral parameters

double int_vd[201] = {};
double int_vq[201] = {};
double int_id[201] = {};
double int_iq[201] = {};

//DQ Reference Parameters

double Vd_ref[201] = {};
double id_ref[201] = {};
double iq_ref[201] = {};
double Vq_ref[201] = {};

double frequency[201]= {};
//Inverse Transformation Parameters

double Vd_inv[201] = {};
double Vq_inv[201] = {};

// Droop Control Parameters

const double kf1=0.01;
const double kv1=0.05;
const double fnom = 50.00;
const double Vnom = 400.00;
const double Pbase = 10000;
const double m1=kf1*(fnom/Pbase);
const double n1=kv1*(Vnom/Pbase);

void setup() {

Serial.setRx(PA10);
Serial.setTx(PA9);
Serial.begin(2400);
//Serial.print("start");

}

void loop() {

theta1[0]=0.00;
V1d[0]=0.00;
V1q[0]=0.00;
I1d[0]=0.0;
I1q[0]=0.0;
Vd_ref[0]=0.0;
//Vq_ref[0]=0;
id_ref[0]=0.0;
iq_ref[0]=0.0;
Vq_inv[0]=0.0;
Vd_inv[0]=0.0;

//Main loop starts here

for (int n = 1; n < 200; n++)
{
//Droop constants

//dq computations final

V1d[n]=(2/3)*((sin(theta1[n-1]))*va_1[n-1]+(sin(theta1[n-1]-((2*PI)/3)))*vb_1[n-1]+(sin(theta1[n-1]+((2*PI)/3)))*vc_1[n-1]);
V1q[n]=(2/3)*((cos(theta1[n-1]))*va_1[n-1]+(cos(theta1[n-1]-((2*PI)/3)))*vb_1[n-1]+(cos(theta1[n-1]+((2*PI)/3)))*vc_1[n-1]);
I1d[n]=(2/3)*((sin(theta1[n-1]))*ia_1[n-1]+(sin(theta1[n-1]-((2*PI)/3)))*ib_1[n-1]+(sin(theta1[n-1]+((2*PI)/3)))*ic_1[n-1]);
I1q[n]=(2/3)*((cos(theta1[n-1]))*ia_1[n-1]+(cos(theta1[n-1]-((2*PI)/3)))*ib_1[n-1]+(cos(theta1[n-1]+((2*PI)/3)))*ic_1[n-1]);
//u_q[0] = Uq_plus[n];
Serial.print("Ts = ");
Serial.print(Ts);
Serial.print("n= ");

Pf1new[n]=P_1[n-1] - Pbase;
frequency[n] = (fnom-(Pf1new[n]*m1)); // % 0.0003142* // Constant is 2*pi*Ts=2*3.14*50e-6=0.0003142
theta1[n-1]=theta1[n-1]+(2*PI*(frequency[n]*Ts));

//Power Computation

P_1[n]=( V1d[n]*I1d[n] + V1q[n]*I1q[n] );
Q_1[n]=( V1q[n]*I1d[n] - V1d[n]*I1q[n] );


//Filter

Pf1new[n]= P_1[n]-Pbase;
Qf1new[n]= Q_1[n];

//VD reference===

Vd_ref[n] = Vnom-(Qf1new[n]*(n1)); //Note that Vq_ref=0 by default


//PI controller for Vd

error_vd[n]=((sqrt(2))*Vd_ref[n-1])-(V1d[n-1]);
prop_vd[n]=kpv*error_vd[n-1];
int_vd[n]=(kiv * Ts * error_vd[n-1])+int_vd[n-1];

if (int_vd[n] > 1) {
int_vd[n+1] = 1;
}

else if(int_vd[n] < -1) {
int_vd[n+1] = -1;
}

id_ref[n]=(prop_vd[n])+(int_vd[n])-(wc * V1q[n-1]);

//PI controller for Vq

error_vq[n]= Vq_ref[n] -(V1q[n-1]); //error_vq(n)= 0.0888900000 - V1q(n-1);
prop_vq[n]=kpv*error_vq[n-1];
int_vq[n]= (kiv * Ts *error_vq[n-1]) + int_vq[n-1];

if (int_vq[n] > 1) {
int_vq[n+1] = 1;
}

else if (int_vq[n] < -1) {
int_vq[n+1] = -1;
}

iq_ref[n]= prop_vq[n] + int_vq[n] +(wc * V1d[n-1]);

//PI controller for Id

error_id[n] = id_ref[n-1] - I1d[n-1];
prop_id[n] = kpi * error_id[n-1];
int_id[n]= (kii * Ts * error_id[n-1])+ int_id[n-1];

if (int_id[n] > 1) {
int_id[n+1] = 1;
}

else if (int_id[n] < -1) {
int_id[n+1] = -1;
}

Vd_inv[n]=prop_id[n] + int_id[n]-(wL * I1q[n-1]);

//PI controller for Iq

error_iq[n] = iq_ref[n-1] - I1q[n-1];
prop_iq[n] = kpi * error_iq[n-1];
int_iq[n] = int_iq[n-1] + kii * Ts * error_iq[n-1];

if (int_iq[n] > 1) {
int_iq[n+1] = 1;
}

else if (int_iq[n] < -1) {
int_iq[n+1] = -1;
}

Vq_inv[n]= prop_iq[n] + int_iq[n] + wL * I1d[n-1];

// Inverse Transformation

sine_a[n] = (Vd_inv[n-1]*sin(theta1[n-1])) + (Vq_inv[n-1]*cos(theta1[n-1]));
sine_b[n] = (Vd_inv[n-1]*sin(theta1[n-1])) - ((2*PI)/3) + (Vq_inv[n-1]*cos(theta1[n-1]) - ((2*PI)/3));
sine_c[n] = (Vd_inv[n-1]*sin(theta1[n-1])) + ((2*PI)/3) + (Vq_inv[n-1]*cos(theta1[n-1]) + ((2*PI)/3));

}
}
Serial.print(n);
Serial.print("Ia_1 =");
Serial.print(ia_1[n]);
Serial.print("Ib =");
Serial.print(ib_1[n]);
Serial.print("Ic =");
Serial.println(ic_1[n]);
//Serial.print(va_1[n]);
//Serial.print(",");
//Serial.print(vb_1[n]);
//Serial.print(",");
//Serial.print(vc_1[n]);
//Serial.print(",");
//Serial.print(ia_1[n]);
//Serial.print(",");
//Serial.print(ib_1[n]);
//Serial.print(",");
//Serial.print(ic_1[n]);
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Re: Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

@fpiSTM
Can you help me you out bro?
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Error compiling for board Generic STM32F1 series

Post by fpiSTM »

Are you serious with your code ?
You called Serial outside any function.... If you'd pay attention it is quite easy to find and a basic coding rule.
KH3ER1
Posts: 10
Joined: Sat May 13, 2023 9:07 pm

Re: Error compiling for board Generic STM32F1 series

Post by KH3ER1 »

@fpiSTM
Thankyou so much mate! It works now, my bad!
Post Reply

Return to “General discussion”