This is an Arduino PI forum = and this is arduino program
Announcement
Collapse
No announcement yet.
Modified sketch for improved timing precision.
Collapse
X
-
-
In this version,
- floating arithmetic replaced by integers.
- timing parameters defined in microseconds
- interrupt code minimized, parts moved to loop
- mainSample delay can be as low as 1us
Aduino_PI2.0.1.zip
Comment
-
Teleno I had high hopes that your mods would improve the sensitivity, but in actual operation, was worse than the code I am using from Gunghouk
Also, there is an annoying background whistle. My test gold ring was only found at 25cm, where as with the fast-write code from Gunghouk was 40cm.
No idea why. I will investigate further when I have some time. I was using your version 2.0
Comment
-
Originally posted by SaltyDog View PostTeleno I had high hopes that your mods would improve the sensitivity, but in actual operation, was worse than the code I am using from Gunghouk
Also, there is an annoying background whistle. My test gold ring was only found at 25cm, where as with the fast-write code from Gunghouk was 40cm.
No idea why. I will investigate further when I have some time. I was using your version 2.0
I focused on the timing and I might inadvertently have broken other parts of the code.
Is the timing of the pulses right? The delays and pulse widths? I mean on the scope.
Comment
-
Originally posted by Teleno View Post
If yiu post the sketch you're using I can look at the differences and maybe figure out the problem.
I focused on the timing and I might inadvertently have broken other parts of the code.
Is the timing of the pulses right? The delays and pulse widths? I mean on the scope.
Comment
-
Originally posted by SaltyDog View Post
I don't have time at the moment, have my Daughters wedding ... will try after that with your latest code. I presume you have a full working unit that performs in the field, not just on the bench? Correct timing is one thing, but actual use is the best ..
Enjoy the wedding, and congrats I suppose.
Comment
-
Originally posted by Teleno View Post
My code is based on the original by George. I might have missed improvements by others, including delays and pulse widths. Would really like to see your code.
Enjoy the wedding, and congrats I suppose.Attached Files
Comment
-
Originally posted by SaltyDog View Post
The code I was using is attached.
These are the signals I get on my setup, including sound. They match the original sketch exactly. Audio 490 Hz, period 1000ms, delay 10us, etc.
Using this sketch Arduino_PI2.0.1.zip
Tx pulse and mainSample:
Tx pulse and efeSample
Sound on pin 11.
I'm mystified about the whistle cause I haven't touched the sound.
Comment
-
Here is the code. You will need to swap the pins back of course.Attached Files
Comment
-
Originally posted by SaltyDog View PostWhy is mainsample and efeSample inverted? They should be the same polarity as Tx Pulse.
Look at the schematic and see NPN transistors Q3 and Q4 and guess the polarity of the base signal to turn them on.
Also look at the original code:
PHP Code:digitalWrite(mainSamplePin, syncDemodOn); // Turn on main sample gate
...
digitalWrite(mainSamplePin, syncDemodOff); // Turn off main sample gate
PHP Code:const byte syncDemodOn = LOW; // Sample gate turns on when input high
const byte syncDemodOff = HIGH; // Sample gate turns off when input low
Comment
-
I expected to see the waveforms at TP5 and TP8, they should be positive, as is the original code and the fast code from Gunghouk.
Anyway, I have to go and sort out the wedding ... talk in a week.
Look at the schematic and see NPN transistors Q3 and Q4 and guess the polarity of the base signal to turn them on.
Comment
-
Originally posted by SaltyDog View PostHere is the code. You will need to swap the pins back of course.
Code in my file (original):
PHP Code:void loop() {
if (readDelayPot == true) {
delayVal = analogRead(delayPin); // Read the delay pot
mainDelay = delayVal * clockCycle + defMainDelay; // Offset main sample delay
calcTimerValues(); // Calculate new timer values
readDelayPot = false; // Set read delay pot flag to false
}
}
Improved code by Gounghouk:
PHP Code:void loop() { // Read potentiometer,mask out the bottom 3 jittery bits and double the range if selected
MainDelay = DefMainDelay + ((analogRead(delayPin) & 0x03F<<potRange); // new delay value
CalcTimerValues(); // Calculate new timer values
}
Comment
-
Originally posted by SaltyDog View PostI expected to see the waveforms at TP5 and TP8, they should be positive, as is the original code and the fast code from Gunghouk.
Anyway, I have to go and sort out the wedding ... talk in a week.
And please don't talk to me like an idiot, I am an Electronics Engineer of 50 yrs experience.
So the scope refers to the polarities at the base of the transistors, not at their collectors.
So don't take offence because there was a misunderstanding, we were looking at different nodes.
I haven't changed the polarity in the code, so it won't change in the PCB either.
For future reference: I will always talk about the signals at the pins of tne Arduino Nano.
Comment
Comment