I created two UHF NEXEDGE system LCN calculators!

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
Hello all,

I am a college freshman and about a week ago, I started coding for the very first time as I am taking an introduction to C programming course. For my first project (besides the basic "hello world"), I decided to build a program that could take a user inputted LCN and convert it to its respective frequency and vice versa. This is something I had to manually calculate in the past. Hopefully no one else has already created this tool :LOL:

I figured I would share it here with you all to take a look at, constructively critique, and possibly use for your own purposes. As I said, I am a complete novice, so I know my code probably has some bugs and could look prettier, but here it is. The .exe files can (hopefully) be found here for anyone that wants to try it out: LCN calculators - Google Drive

Let me know if there are any issues with accessing or running the files.

*Note: the second program outputs, say, "348.000000" instead of just "348" for the LCN. If anyone knows how I can remove the ".000000" please let me know!

LCN-to-frequency:

C:
#include <stdio.h>
 
int main(void)
{
   double inputLcn;
   double resultFreq;
  
   while(1)  {
 
   printf("\nPlease enter LCN: \n");   
   scanf("%lf", &inputLcn);
  
   if ((inputLcn > 0) && (inputLcn <= 400))  {
      resultFreq = 450 + (inputLcn - 1) * 0.0125;
  
      printf("The frequency is: %lf MHz\n", resultFreq);
   }
   else if ((inputLcn >= 401) && (inputLcn <= 800))  {
      resultFreq = 460 + (inputLcn - 401) * 0.0125;
      
      printf("The frequency is: %lf MHz\n", resultFreq);
   }
   else {
      printf("This LCN is used for a non-standard frequency. No frequency can be reported\n");
   }
  
   }

return 0;
}

Frequency-to-LCN:

C:
#include <stdio.h>
 
int main(void)
{
   double inputFreq;
   double resultLcn;
  
   while(1)  {
 
   printf("\nPlease enter frequency: \n");   
   scanf("%lf", &inputFreq);
  
   if ((inputFreq >= 450.0) && (inputFreq < 455.0))  {
      resultLcn = ((inputFreq - 450) / 0.0125) + 1;
  
      printf("The LCN is: %lf\n", resultLcn);
   }
   else if ((inputFreq >= 460.0) && (inputFreq < 465.0))  {
      resultLcn = ((inputFreq - 460) / 0.0125) + 401;
      
      printf("The LCN is: %lf\n", resultLcn);
   }
   else {
      printf("This frequency uses a non-standard LCN. No LCN can be reported\n");
   }
  
   }

return 0;
}
 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
13,331
Location
Raleigh, NC
Great job, thank you. Does this only work for NXDN or will it work for other modes as well?

I downloaded and attempted to run but it won't let me because cygwin1.dll is missing. Suggestions?
 
Last edited:

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
Great job, thank you. Does this only work for NXDN or will it work for other modes as well?

I downloaded and attempted to run but it won't let me because cygwin1.dll is missing. Suggestions?
This only works for NXDN as far as I am aware of.

As for the missing DLL, it is probably because my professor has us use the JGRASP development environment which requires CYGWIN. I am not sure what I would need to do to allow the program to run without needing any extra software. As I said, I have only been doing this for about a week so I have a LOT to learn.
 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
13,331
Location
Raleigh, NC
Great start and good to see you on here again. Congrats on making it to college.

UPDATE: Installed cygwin1.dll and it appears to be working fine.
 
Last edited:

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
This is what the program looks like when it is running:

1642909221646.png

1642909321568.png

EDIT: I see @Iwvmobile beat me too it! Thank you for the good grade :)
 

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
Hint: Your variable type does not need to be a double! ;)

View attachment 115516
I was thinking it needed to be a double since it was a decimal number that was being inputted, but it appears not. I changed double to int and %lf to %d and that did the trick. However, when I do that, the program spazzes out and repeatedly outputs the following over and over:

1642910450496.png

Any ideas as to why changing from double to int might cause this behavior?
 

Outerdog

T¹ ÆS Ø
Premium Subscriber
Joined
Jul 1, 2016
Messages
641
C:
#include <stdio.h>
 
int main(void)
{
   double inputFreq;
   int resultLcn;
  
   while(1)  {
 
   printf("\nPlease enter frequency: \n");   
   scanf("%lf", &inputFreq);
  
   if ((inputFreq >= 450.0) && (inputFreq < 455.0))  {
      resultLcn = ((inputFreq - 450) / 0.0125) + 1;
  
      printf("The LCN is: %d\n", resultLcn);
   }
   else if ((inputFreq >= 460.0) && (inputFreq < 465.0))  {
      resultLcn = ((inputFreq - 460) / 0.0125) + 401;
      
      printf("The LCN is: %d\n", resultLcn);
   }
   else {
      printf("This frequency uses a non-standard LCN. No LCN can be reported\n");
   }
  
   }
 

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
Paste your code in, might have accidentally deleted something and broke the loop. I just did the same thing, changed to int and %d and didn't break anything.
View attachment 115520
Ah I changed both inputFreq and resultLcn to int instead of leaving inputFreq as a double (which of course makes much more sense). It is now working correctly! I appreciate your assistance.

Now I just need to find out how to create a .exe file that doesn't require additional software/dlls to run it.
 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
13,331
Location
Raleigh, NC
Ah I changed both inputFreq and resultLcn to int instead of leaving inputFreq as a double (which of course makes much more sense). It is now working correctly! I appreciate your assistance.

Now I just need to find out how to create a .exe file that doesn't require additional software/dlls to run it.

Is the update in the google drive?
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,272
Location
Lafayette County, FL

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
I just downloaded Visual Studio as suggested and created the .exe that way. The google drive should have the updated .exe files in it now. If someone could try running them and let me know if everything works properly, that would be awesome!
 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
13,331
Location
Raleigh, NC
I just downloaded Visual Studio as suggested and created the .exe that way. The google drive should have the updated .exe files in it now. If someone could try running them and let me know if everything works properly, that would be awesome!

Google drive is empty
 

IcomIcR20

Member
Premium Subscriber
Joined
Jun 16, 2014
Messages
797
Google drive is empty
Ugh... just got this email from Google:

Your file violates Google Drive's Terms of Service
Your file "LCNtoFreq.exe" contains content that violates Google Drive's Malware and Similar Malicious Content policy and hence, some features related to this file may have been restricted. If you think this is an error and would like the Trust & Safety team to review this file, request a review below.
 
Top