Originally posted by calebsone
View Post
Announcement
Collapse
No announcement yet.
IDX-PRO+VDI
Collapse
X
-
-
https://www.youtube.com/watch?v=5j_XM0L0BKg
https://www.youtube.com/watch?v=MgnMAwk0K9Y
this is not the same hex codes ! which can be downloaded hex of the first video ?
Comment
-
Originally posted by Orbit View Posthttps://www.youtube.com/watch?v=5j_XM0L0BKg
https://www.youtube.com/watch?v=MgnMAwk0K9Y
this is not the same hex codes ! which can be downloaded hex of the first video ?
Comment
-
Post #38 might have what you were looking for:
http://www.geotech1.com/forums/showt...sed-VDI!/page2 It has a lot of explainations on what the code actually does.
I have done a lot of experimenting since then with the Arduino's but not much practical application. Toward the end of the thread I posted the latest code I have been experimenting with. It's really accurate for such a simple program, plus a nice simulated "Spectra graph" that actually works!
https://www.youtube.com/watch?v=K-K-...ature=youtu.be
It's not the hex code but if you have an Arduino UNO or Micro you can just copy and paste, verify and download and away you go. The only thing additional you may need is the Liquid Crystal library in the same directory as your sketch. Additionally, It's nice to uncomment the Serial.print commands, start your serial monitor on the upper right corner of the Arduino app and see what it's actually gathering for samples.
#include <LiquidCrystal.h>
// Connections for IDX.
//LCD PIN Connect to
//======= ===========
// 1 (VSS) GND Arduino pin*
// 2 (VDD) +5V Arduino pin
// 3 (contrast) Resistor or pot to Arduino GND
// 4 RS Arduino pin 12
// 5 R/W Arduino pin 11
// 6 Enable Arduino pin 10
// (Data 4) Arduino pin 5
// (Data 5) Arduino pin 4
// (Data 6) Arduino pin 3
// (Data 7) Arduino pin 2
// Backlight + Resistor to Arduino pin 13**
// ** Use current limiting resistor < 40 OHMS
// No preamps to Arduino necessary! Make direct connections as follows.
// IDX U3 Pin 1 to Arduino A0
// IDX U3 Pin 14 to Arduino A1
// Caveat - - - Phase offset follows DISC setting. "0" phase setting = audio rejected targets.
// Cut diode D1 or D2 clipping diode for improved accuracy
// assign liquid crystal pins
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight
//Create custom bar characters
byte bar0[8]={
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
byte bar1[8]={
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111
};
byte bar2[8]={
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111
};
byte bar3[8]={
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111
};
byte bar4[8]={
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111
};
byte bar5[8]={
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte bar6[8]={
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte bar7[8]={
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
// Sensors
int sensorPinx = A0; // Intialize analog pin A0 and name it "sensorPinx" for the all metal channel
int sensorPinr = A1; // Intialize analog pin A1 and name it "sensorPinr" for the all disc channel
//Variables
float sensorValuex = 0; // assign a floating point value of "0" to a variable called "sensorValuex"
float sensorValuer = 0; // assign a floating point value of "0" to a variable called "sensorValuer"
float slope; // assign a floating point value of "0" to a variable called "slope"
int n = 0; // assign an integer value of "0" to a variable called "n"
int cursorClmn = 0; // assign an integer value of "0" to a variable called "cursorClmn"
int numSamples = 0; // assign an integer value of "0" to a variable called "numsamples"
float slopeTotals; // assign an integer value of "0" to a variabel called "slopeTotals"
float slopeAve = 0; // assign an integer value of "0" to a variable called "slopeAve"
int VDI = 0; // assign an integer value of "0" to a variable called "VDI"
float rad = 0;
float phase = 0;
// bar positions 0 through 7 (8 columns)
int b0 = 0;
int b1 = 0;
int b2 = 0;
int b3 = 0;
int b4 = 0;
int b5 = 0;
int b6 = 0;
int b7 = 0;
//int b8 = 0;
//int b9 = 0;
//int b10 = 0;
//int b11 = 0;
//int b12 = 0;
//int b13 = 0;
//int b14 = 0;
//int b15 = 0;
// program setup follows
void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print( "ArcTan Calc"); // print whatever you want
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print("032415"); // print whatever you want
delay (2000); // display the above for 2 seconds
lcd.clear(); // Clear the LCD
// Serial.begin(9600);
//Create customer characters
lcd.createChar(0,bar0);
lcd.createChar(1,bar1);
lcd.createChar(2,bar2);
lcd.createChar(3,bar3);
lcd.createChar(4,bar4);
lcd.createChar(5,bar5);
lcd.createChar(6,bar6);
lcd.createChar(7,bar7);
}
// The main loop follows
void loop()
{
first: //This is a label called "first" so a goto statement can find the beginning of the loop when called
sensorValuex = analogRead (sensorPinx); //Read the analog pin A0 and store it's value as sensorValuex (it will be between 0 and 1023)
sensorValuer = analogRead (sensorPinr); //Read the analog pin A1 and store it's value as sensorValuer (it will be between 0 and 1023)
//Change SensorValues below to adjust VDI sensitivity
if (sensorValuex > 2) { //If this sensorvalue becomes > 5 it executes the next line. If not, it drops to the "else" statement and goes to the beginning again ("first")
if (sensorValuer > 2) { //If this sensorvalue becomes > 5 it executes the next line. If not, it drops to the "else" statement and goes to the beginning again ("first")
for (int n = 0 ; n < 25 ; n ++) //Starts a counter to read the sensors again in a loop 85 times
{
sensorValuex = analogRead(sensorPinx); //Read the analog pin A0 and store it's value as sensorValuex (it will be between 0 and 1023)
sensorValuer = analogRead (sensorPinr); //Read the analog pin A1 and store it's value as sensorValuer (it will be between 0 and 1023)
slope=sensorValuex / sensorValuer; // calculate R/X ratio and call it "slope"
// Serial.print (" x=");
// Serial.print (sensorValuex);
// Serial.print (" r=");
//Serial.print (sensorValuer);
rad = atan (slope); //calculate the phase angle
phase = ((rad) * (57.295)); // converts radians to Degrees
// Serial.print (" phase=");
// Serial.print (phase);
// assign a phase to a column position
if (phase > 35) {
b7 = b7 + 1;
goto endincbars;
}
if (phase > 30) {
b6 = b6 + 1;
goto endincbars;
}
if (phase > 25) {
b5 = b5 + 1;
goto endincbars;
}
if (phase > 20) {
b4 = b4 + 1;
goto endincbars;
}
if (phase > 15) {
b3 = b3 + 1;
goto endincbars;
}
if (phase > 10) {
b2 = b2 + 1;
goto endincbars;
}
if (phase > 5) {
b1 = b1 + 1;
goto endincbars;
}
if (phase > 0.1) {
b0 = b0 + 1;
}
endincbars:
//Serial.println(phase);
slopeTotals = slopeTotals + slope;
}
}
}
else {
goto first; // runs a loop until the sensors become low again, then goes to the label called "first"
}
slopeAve = slopeTotals/25; // take all the slope values and average them.
// Serial.println("xxxxxxxxxxxxxxxxx");
// alternately, you can calculate the true phase angle by uncommenting the next two lines:
rad = atan (slopeAve); //calculate the phase angle
phase = ((rad) * (57.295)); // converts radians to Degrees
// Serial.println(phase);
//Serial.println("xxxxxxxxxxxxxxxxx");
// you can manipulate the range of how your VDI numbers are calulated by changing the line below
//cursorClmn = (phase/3); // slopeAve will typically be between .1 and 9. It just converts it to an integer number between 1 and 10.. used to position the "*" character
// tone (8,(cursorClmn * 200), 100); // produces a tone of 200 Hz X the mumber above for 100 mS on pin #8
lcd.clear(); //clear LCD
//if (VDI > 98 ) {
// lcd.clear();
// goto finish;
//}
lcd.setCursor(0,0); //Set cursor on line 0, column 0
lcd.print("Phase = "); // print "phase ="
// alternately, you can uncomment the next line to display true phase
lcd.print (phase); // prints phase angle instead of full scale readings
lcd.setCursor(0,1); // Positions the cursor on a particular column on row 1
// resize all bars over 7 to 7
if (b0 > 7) {
b0 = 7;
}
lcd.write(b0);
if (b1 > 7) {
b1 = 7;
}
lcd.write(b1);
if (b2 > 7) {
b2 = 7;
}
lcd.write(b2);
if (b3 > 7) {
b3 = 7;
}
lcd.write(b3);
if (b4 > 7) {
b4 = 7;
lcd.write(b4);
}
if (b5 > 7) {
b5 = 7;
lcd.write(b5);
}
lcd.write(b5);
if (b6 > 7) {
b6 = 7;
}
lcd.write(b6);
if (b7 > 7) {
b7 = 7;
}
lcd.write(b7);
// prints the "*" character in that partular column
//finish:
delay (100); // display the VDI numbers for 100 mS before going to the beginning of the code again
numSamples = 0; // reset all numbers back to "0"
slopeTotals = 0;
slopeAve = 0;
slope = 0;
n = 0;
b0 = 0;
b1 = 0;
b2 = 0;
b3 = 0;
b4 = 0;
b5 = 0;
b6 = 0;
b7 = 0;
//b8 = 0;
//b9 = 0;
//b10 = 0;
//b11 = 0;
//b12 = 0;
//b13 = 0;
//b14 = 0;
}
Comment
-
dfbowers:
There is a bug in the code above, in the display bars....
if (b3 > 7)
{
b3 = 7;
}
lcd.write(b3);
if (b4 > 7)
{
b4 = 7;
lcd.write(b4);
}
if (b5 > 7)
{
b5 = 7;
lcd.write(b5);
}
lcd.write(b5);
if (b6 > 7)
{
b6 = 7;
}
lcd.write(b6);
if (b7 > 7)
{
b7 = 7;
}
lcd.write(b7);
In this section of code consider b3 is > 7 it gets set to 0 and then printed outside of the if statement. That is good
if b4 > 7 then you set it to 7 and write it INSIDE of the if. so the only time that B4 will be written is if it is >7.
The same error exists in the b5 >7
Second comment: Goto's are really a no no in C. I have rewritten the code to eliminate them, have not tested it, but while i
was doing so I discovered this bug.
There are a couple of things missing from this code in my opinion.
There should be in addition to the phase, an indication of what you see. is it in the Dime range? howabout a pull tab?
The second feature that would be nice, is a timer running showing how long you have had the unit on and running.
The third feature that would be nice, is a reject range array. If the vdi number is between certain ranges, you just don't show it.
And the user can set those.
make two display screens, one default, the other slectable by holding a button down.
The little 8 character bar graph is pretty cool. On a 16 character display, there is also enough room to display the signal intensity as well, so why not display the average of the
X and r channels.
Screen 1 where VIDKIND is a 7 character place for displaying the "guess", and XX:XX is the time since you turned it on, with a user option to be able to set the time and have it downcount
so you can go hunt for say 45 min and get an indication that it is time to pack up and go back to work
P= phase, and bb is the bar graph
VIDKIND XX:XX
P=xxxx bbbbbbbb
Screen 2 the pinpoint screen when you hold the pinpoint button down (call it a depth screen or whatever.)
Where mm is the depth in inches computed from the intensity averages. and bbbbbbbb is your graph, and X and R are the intensity averages that you computed the slope off of.
X=XXXX R=XXXX mm
P=XXXX bbbbbbbb
Comment
Comment