Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of all_combined_week6 by
Diff: ACS.cpp
- Revision:
- 7:5cf19bfdbacd
- Parent:
- 6:82153349cc9b
--- a/ACS.cpp Tue Jul 15 10:04:38 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#include "ACS.h"
-
-
-PwmOut PWM1(p6); //Functions used to generate PWM signal
- //PWM output comes from pins p6
-Serial pc1(USBTX, USBRX);
-
-
-void FUNC_ACS_GENPWM()
- {
- printf("\nEnterd PWMGEN function\n");
- double DCx = 0; //Duty cycle of Moment in x, y, z directions
- double ix = 0; //Current sent in x, y, z TR's
- float timep = 0.02 ;
- double Mx=1.5; //Time period is set to 0.2s
- //Moment in x, y, z directions
-
-
- ix = Mx * 0.3 ; //Moment and Current always have the linear relationship
-
- if( ix>0&& ix < 0.006 ) //Current and Duty cycle have the linear relationship between 1% and 100%
- {
- DCx = 6*1000000*pow(ix,4) - 377291*pow(ix,3) + 4689.6*pow(ix,2) + 149.19*ix - 0.0008;
- PWM1.period(timep);
- PWM1 = DCx/100 ;
- }
- else if( ix >= 0.006&& ix < 0.0116)
- {
- DCx = 1*100000000*pow(ix,4) - 5*1000000*pow(ix,3) + 62603*pow(ix,2) - 199.29*ix + 0.7648;
- PWM1.period(timep);
- PWM1 = DCx/100 ;
- }
- else if (ix >= 0.0116&& ix < 0.0624)
- {
-
- DCx = 212444*pow(ix,4) - 33244*pow(ix,3) + 1778.4*pow(ix,2) + 120.91*ix + 0.3878;
- PWM1.period(timep);
- PWM1 = DCx/100 ;
- }
- else if(ix >= 0.0624&& ix < 0.555)
- {
- printf("\nACS entered if\n");
- DCx = 331.15*pow(ix,4) - 368.09*pow(ix,3) + 140.43*pow(ix,2) + 158.59*ix + 0.0338;
- PWM1.period(timep);
- PWM1 = DCx/100 ;
- }
- else if(ix==0)
- {
- DCx = 0;
- PWM1.period(timep);
- PWM1 = DCx/100 ;
- }
- else
- {
- // pc.printf("!!!!!!!!!!Error!!!!!!!!!");
- }
-
-
-printf("\nExited PWMGEN function\n");
-}
-
\ No newline at end of file
