LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

C to Labview

Hi all,
 
I am fairly new to Labview and I have been given a project at work to convert an existing c code to labview. I will provide the section of the code That is giving me problems to see if any of you could assist me in writing it in labview.
 

void

CPokey2Dlg::FindN(unsigned char Channel)

{

double FreqOne,NFrac;

int NReg;

int iDividend;

NFrac = FreqOne/(double)2.8e6;

NReg = int(NFrac+.5);

m_EditChannelTwo = NReg;

UpdateData(false);

// if (NReg >= NFrac)

NFrac = (

double)262144*(NFrac - (double)NReg);

// else

// NFrac = int((262144*((double)NReg-NFrac))+.5);

if (NFrac <0)

NFrac =

int(NFrac -.5);

else

NFrac =

int(NFrac +.5);

// m_EditChannelTwo = NFrac;

// UpdateData(false);

 

NReg = NReg - 32;

iDividend = (

int)NFrac;

m_EditChannelTwo = NFrac;

UpdateData(

false);

// format for register

SKY72300[0] = (

unsigned char)(NReg >> 8);

SKY72300[0] = SKY72300[0] & 0x01;

SKY72300[1] = (

unsigned char)NReg;

SKY72300[2] = (

unsigned char)(iDividend >> 16);

SKY72300[2] = SKY72300[2] & 0x03;

SKY72300[2] = SKY72300[2] | 0x10;

SKY72300[3] = (

unsigned char)(iDividend >> 8);

SKY72300[4] = 0x20;

SKY72300[5] = (

unsigned char)(iDividend);

}

 

Thanks

0 Kudos
Message 1 of 4
(3,182 Views)
What exactly is "giving you problems"? Are you not sure how to do numeric calculations, or how to do shifting, or ...

If you simply don't know how to code LabVIEW, then, if you haven't, I would suggest starting by going though the LabVIEW tutorial that ships with LabVIEW. You can also look in the NI Developer Zone for links to numerous LabVIEW learning sources.
Message 2 of 4
(3,175 Views)
I can do the calculations, but not so sure on the shifting. I have used labview for about three months now.
0 Kudos
Message 3 of 4
(3,170 Views)
To do shifting use the "Logical Shift" function, accessible from the "Numeric->Data Manipulation" functions palette:


As indicated in the Detailed Help, y can be positive or negative depending on which way you want to shift.

Message Edited by smercurio_fc on 10-09-2007 12:46 PM

Message 4 of 4
(3,165 Views)