Click here to Skip to main content
15,887,812 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Disabling Windows ShortCut Keys Pin
Joan M14-Aug-12 23:25
professionalJoan M14-Aug-12 23:25 
QuestionAccessing Pixels with CreateDIBSection Pin
Member 925534913-Aug-12 20:38
Member 925534913-Aug-12 20:38 
AnswerRe: Accessing Pixels with CreateDIBSection Pin
Eugen Podsypalnikov13-Aug-12 21:05
Eugen Podsypalnikov13-Aug-12 21:05 
GeneralRe: Accessing Pixels with CreateDIBSection Pin
Member 925534913-Aug-12 22:23
Member 925534913-Aug-12 22:23 
AnswerRe: Accessing Pixels with CreateDIBSection Pin
pasztorpisti13-Aug-12 22:54
pasztorpisti13-Aug-12 22:54 
GeneralRe: Accessing Pixels with CreateDIBSection Pin
Member 925534914-Aug-12 7:58
Member 925534914-Aug-12 7:58 
GeneralRe: Accessing Pixels with CreateDIBSection Pin
pasztorpisti14-Aug-12 8:09
pasztorpisti14-Aug-12 8:09 
QuestionSpeed up a numerical Calculation. Circular Queue Pin
whitbuzben1813-Aug-12 7:55
whitbuzben1813-Aug-12 7:55 
Hi Guys

I have designed a digital controller in matlab. The continuos s domain controller is as follows:

1.16e006 s^2 + 6.287e006 s + 2.436e006
--------------------------------------
s^2 + 10 s

The discretised z domain version (with a sampling rate of 100Hz) is as follows:

1.16e006 z^2 - 2.26e006 z + 1.1e006
-----------------------------------
z^2 - 1.905 z + 0.9048

Now i have managed to program this in C++ and it "sort of" works. However the code is by no means optimal and therefore does not execute as quickly as it should. The code basically looks like this:
C++
    float SpeedDemand;
    float SpeedError;
    float MeasuredGeneratorSpeed;
    float y;

    float numcoeff[3];
    float dencoeff [3];

    numcoeff[0] = 1160000;
    numcoeff[1] = -2260000;
    numcoeff[2] = 1100000;

    dencoeff[0] = 1;
    dencoeff[1] = -1.905;
    dencoeff[2] = 0.9048;

    static float xprevious[3];
    static float yprevious[3];



SpeedError = MeasuredGeneratorSpeed - SpeedDemand;
xprevious[0] = SpeedError; //current input value
y = xprevious[0]*numcoeff[0];  // get it started

y += ((xprevious[1]*numcoeff[1])+(xprevious[2]*numcoeff[2])-(yprevious[1]*dencoeff[1])-(yprevious[2]*dencoeff[2]));

xprevious[2] = xprevious[1]; //Shift the values down
xprevious[1] = xprevious[0];
yprevious[2] = yprevious[1];
yprevious[1] = y; // Current Output 


Where xprevious[],yprevious[] are arrays that i define earlier in the program. They are used to store the previous input and output values. X is the input and Y is the output. The numbers stored in the numcoeff[] and dencoeff[] arrays correspond to the coefficients in the z domain transfer function shown at the top. Is there a faster way to do this calculation in c++, perhaps by using a circular queue!!??. Unfortunately my programming knowledge is not great(I'm a Matlab guy). If there is a better way to do it that would speed up the calculation perhaps someone could give me an eample of how to do it. By the way all the variables and arrays are floating point. Any help or advice would be much appreciated.

Many Thanks
Ben

modified 14-Aug-12 5:16am.

AnswerRe: Speed up a numerical Calculation. Circular Queue Pin
Chris Losinger13-Aug-12 9:25
professionalChris Losinger13-Aug-12 9:25 
GeneralRe: Speed up a numerical Calculation. Circular Queue Pin
pasztorpisti13-Aug-12 13:19
pasztorpisti13-Aug-12 13:19 
AnswerRe: Speed up a numerical Calculation. Circular Queue Pin
Software_Developer13-Aug-12 10:33
Software_Developer13-Aug-12 10:33 
QuestionVIsual Studio Plug-in for Heap Storage Pin
ForNow13-Aug-12 2:58
ForNow13-Aug-12 2:58 
QuestionRe: VIsual Studio Plug-in for Heap Storage Pin
_AnsHUMAN_ 14-Aug-12 1:54
_AnsHUMAN_ 14-Aug-12 1:54 
AnswerRe: VIsual Studio Plug-in for Heap Storage Pin
ForNow14-Aug-12 6:41
ForNow14-Aug-12 6:41 
QuestionReplace a view in splitter window runtime. Pin
Rishav Prabhakar13-Aug-12 0:47
Rishav Prabhakar13-Aug-12 0:47 
AnswerRe: Replace a view in splitter window runtime. Pin
Richard MacCutchan13-Aug-12 3:04
mveRichard MacCutchan13-Aug-12 3:04 
GeneralRe: Replace a view in splitter window runtime. Pin
Rishav Prabhakar13-Aug-12 3:22
Rishav Prabhakar13-Aug-12 3:22 
GeneralRe: Replace a view in splitter window runtime. Pin
Richard MacCutchan13-Aug-12 3:29
mveRichard MacCutchan13-Aug-12 3:29 
QuestionHow to pan client area of a window using C++/VC++ code Pin
Member 935377612-Aug-12 23:52
Member 935377612-Aug-12 23:52 
AnswerRe: How to pan a window using C++/VC++ code Pin
pasztorpisti13-Aug-12 2:19
pasztorpisti13-Aug-12 2:19 
GeneralRe: How to pan a window using C++/VC++ code Pin
Member 935377616-Aug-12 20:17
Member 935377616-Aug-12 20:17 
AnswerRe: How to pan a window using C++/VC++ code Pin
Software_Developer13-Aug-12 8:42
Software_Developer13-Aug-12 8:42 
GeneralRe: How to pan client area of a window using C++/VC++ code Pin
Member 935377618-Aug-12 19:35
Member 935377618-Aug-12 19:35 
AnswerRe: How to pan a window using C++/VC++ code Pin
pasztorpisti13-Aug-12 11:54
pasztorpisti13-Aug-12 11:54 
GeneralRe: How to pan a window using C++/VC++ code Pin
Member 935377613-Aug-12 20:17
Member 935377613-Aug-12 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.