element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
NexGen Flight Simuator Nexgen: CANaerospace: RSS: C-3436A Radio: Build iii: Code Review
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: phoenixcomm
  • Date Created: 23 Sep 2021 9:01 PM Date Created
  • Views 639 views
  • Likes 1 like
  • Comments 0 comments
  • offtheshelfch
  • flight simulator
  • nexgen
  • c-3436a/arn-30d
  • avrdude
  • rss
  • arduino code base
  • bare metal system
Related
Recommended

Nexgen: CANaerospace: RSS: C-3436A Radio: Build iii: Code Review

phoenixcomm
phoenixcomm
23 Sep 2021

image

Well here I am again after taking a new (very old) look at the code base (2016) which had been lost, but nothing is really never lost on the Internet. I found my old code at Hackster.io and took a look at it. What I had done was to weigh each of the bits, in binary and then deliver an integer representation of the bits:

int temp = (  frac[0] + ( frac[1]*2) + ( frac[2]) + ( frac[3]*8) + ( frac[4]*16));

My code base is not finished but at the very least now I have no errors in the IDE. Now the only thing to do is to compare 2 integers in a loop 10x for the KHz and 20x for the MHz.

I have kind of had it with the Arduino IDE and its butchered C code really C++ more butchy. My plan is to buy an Arduino JTAG burner, about 20 bucks for the kit, from Aidafuit, and see how that works out. Then I will use AVRdude + what I call bare-metal programming, in ANSI C with the Eclipse IDE.

C-3436.ino C-3436.h

// Read High Frequency Contacts

  for (byte hcount = 5; hcount < 10; hcount++) {

    hund[hcount] = digitalRead( pins[hcount] );}

  htest = calc_H();

 

  //Get Channel info

  chanLow =  calc_F();

  chanHigh = calc_H();

 

 

int TPrint = 1;

  if( TPrint == 1 ) {

    int ncount;

//Write one line at a time: in this format count:n:n:n:....\n

    Serial.print(ncount);  // prints line number

    Serial.print("-");

   

    Serial.print(":");

   

    Serial.print("-");

    Serial.write(chanHigh);

    Serial.print(":");

    Serial.write(chanLow);

    Serial.print("\n"); //Write one line at a time: in this format count:n:n:n:....\n

} /* TESTprint */

 

 

} // end of if powerPin

} // end of loop()

 

 

 

 

 

 

 

This Test Script is run in a Linux Terminal Session. You must first find the USB port number "/dev/ttyACM0" with a program called lsusb.

 

 

import serial
ser = serial.Serial (
  port = '/dev/ttyACM0',
  baudrate = 115200,
  parity = serial.PARITY_NONE,
  stopbits = serial.STOPBITS_ONE,
  bytesize = serial.EIGHTBITS,
  timeout = 10
)

while True:
  print ( ser.readline())

ser.close ()

*

* C-3436A.h

*

*  C. Harrison Aug  21, 2014 Creation

*              Sept 17, 2021 modified

*/

 

 

// for print testing we must define TESTprint =1

 

 

// we need to list the digital input pins:

 

 

// Pin defs

// please note: arrays F[] & H[] are being indexed 0-5

int F[]= { 22, 23, 24, 25, 26 };

int H[]= { 27, 28, 29, 30, 31 };

 

 

int powerPin = 39;

int dialLight = 40;

// now we need the variables & arrays

 

 

int frac[5];

int hund[5];

 

 

int pwr, pwr0;

byte ftest;

byte htest;

 

 

int pins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31};

 

 

// High & Low bit patterns {16, 8, 4, 2, 0}   // max number = 31

// I will do the convertions staticly now

int lowBits[10][5]= {{1,1,0,1,0},{1,0,0,0,1},{0,1,0,0,0},{0,0,1,0,0},{0,0,0,1,0},

                   {1,0,0,0,0},{0,0,0,0,1},{0,1,0,0,1},{0,1,1,0,0},{0,0,1,1,0}};

 

 

byte  Lcode []=   { 26, 17, 8, 4, 2, 16, 1, 9, 12, 6 };              

 

 

int highBits[20][5] = {{1,1,0,0,1},{1,1,0,0,0},{1,1,1,0,0},{1,0,0,0,1},{1,1,1,1,0},

                       {0,0,0,1,0},{0,1,1,1,1},{0,0,1,0,0},{1,0,1,1,1},{0,1,0,0,0},

                       {0,0,0,1,1},{1,0,0,0,0},{1,0,1,0,1},{0,0,0,0,1},{0,0,1,1,0},

                       {0,1,0,1,1},{0,0,1,0,1},{0,0,1,1,0},{1,0,0,1,0},{0,1,1,0,0}};

                 

byte Hcode[][2]= {{13, 0}, {20, 108},{28, 109},{17, 110},{30,111},

                  {2, 112},{15, 113},{4,  114},{23, 115},{8, 116},

                  {3, 117},{16, 118},{17, 119},{1,  120},{6, 121},

                  {11,122},{5,  123},{6,  124},{18, 125},{12, 126}};    

 

 

                              

byte chanHigh, chanLow;

calculation functions some test functions

byte calc_F(){

  int temp = (  frac[0] + ( frac[1]*2) + ( frac[2]) + ( frac[3]*8) + ( frac[4]*16));

  return( temp );

}

 

 

byte calc_H(){

  int temp = (( hund[5] + hund[6]*2) + (hund[7]*4) + (hund[8]*8) + (hund[9]*16));

  return( temp );

}

byte Ltest() {

  byte i;

  for (  i = 0; i < 10; i++ ){

      if ( ftest == Lcode [i] ){

         break;}

      else continue; }

     return( i );  }

 

 

byte Htest() {

  byte i;

  for (  i = 0; i < 20; i++ ){

     if ( htest == Hcode[i][0] ){

         break;}

     else   continue; }

        return( Hcode[i][1]); }

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube