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 |
* * 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]); } |