It's possible, but you will need to change the pin assignments and maybe a few other things. You could also use the 16F684 with the Pulse3.c code but that will require changing the config settings and maybe some of the register syntax. If you are not familiar with programming micros then this is a good way to start.
Announcement
Collapse
No announcement yet.
Announcement
Collapse
No announcement yet.
Differential TX driver for TDI?
Collapse
X
-
Hi Carl, I deleted the line, but it still doesn't compile in AppMain.c. I think that in AppMain.c it is set for another chip, and in the other files the code for PIC16F684 is written, there is a discrepancy. If you have time and opportunity, please fix it. Best regards.
Comment
-
Yes, I think the code is for the 16F684. If you want to use in with a different chip then you will need to modify it. Most likely the changes will be to the config lines in AppMain.c and maybe some of the timer register names. The main body of the code should run on any chip. If you don't know how to program PICs then this is an excellent way to get your feet wet. I am heading out on vacation today and cannot do anything with this.
Comment
-
Hi ,Eduardo, how far have you gotten with porting the code to the Arduino Nano? Did you manage to get it working?Originally posted by eduardo1979 View PostCould you record a video of the detector in operation, if you don't mind? I'm porting the code to Arduino because I'm not very good with PICs. AVR is much easier for me.
Comment
-
Hi, Algan,
Karl has uploaded a universal code for generating the main processes in a PI metal detector using a microcontroller. I quickly took a look at the programs published in the TDI_Std.zip folder. Unfortunately, these programs are relevant for more complex types of microcontrollers.
The PIC16F684 does not have a 4x PLL, so the maximum frequency is 20MHz with an external crystal or 8MHz with the internal oscillator and there is no way to achieve 125ns resolution. So less than 200ns per command is impossible (somewhere Karl had set 20MHz for the MC frequency when determining the delays).
Timer0 of this microcontroller has 8 bits, so the delays generated with it are in the range of 0 - 255 cycles, not 65535 (to use it you need to change its prescaler and accordingly the delay data).
Many of the registers used in the program have different names or do not exist at all on the PIC16F684.
I also assume that you are using the unlicensed/free version of XC8 (like all of us), which has many optimization procedures cut out.
Indeed, the program published by Karl is a very good basis for creating your own code for any microcontroller you want, you just need to read the Data Sheet of the chip and update things.
On the other hand, I think it will be much easier for you to write the program in ASSEMBLER, where you will be able to do perfect timing, work directly with the registers and not worry about what XC8 will think for your code. The free assembly compilers from MPLab are like a hammer.
Comment
-
It's easier to write a new code. I guess after winter I'll have more time and I'll be able to try.
Think about it and write here what your requirements are for the program, for example:
1. Only the pulses for controlling TX, main sample, ground balance sample, EFE sample, etc. will be generated.
2. The times will be set with potentiometers via ADC or in another way.
3. The frequency will be, for example, 1kHz (T cycle=1ms).
4. TX range - 20 to 150us.
5. Delays after the end of the pulse:
first sample - 4 to 50us
second sample - .............
GB sample - ..............
etc. etc.
6. Sample width - fixed or not (if not, how will it be controlled / If fixed, how long).
7. How many pins does the chip have 14 or 20 (both are in production)
8. Type of Packages UQFN or PDIP, SOIC, SSOP
8. Preferences for which pin (number) for what - TX, first sample ...
etc... etc...etc...
By the way, now it occurred to me - instead of waiting for me, write the same things to AI (like Paul did) and you will get a much better program than mine. With AI you can discuss and change anything you can think of, you will even get advice about hardware if you ask for it.
If it doesn't work - we will talk again in the spring.
Comment
-
This code should have samples like the original TDI, if my colleague Eduardo has measured them, he can say what they are exactly, and the pulse should be able to change between 2 and 5 kilohertz, it should have a low and high pulse, and regarding the AI, if you haven't watched the videos, it has already changed and is trying to fool people, it deliberately confuses you, it can give you the correct code, but you have to write to it for a few days and it repeats its mistakes, and then it also lets you always answer, but in general it tries to annoy people with its games and I wonder why the creators allowed this problem of its, but it is close to the mind to slow down the chat so that they have more traffic and profit from it for the benefit of the creators.
Comment
-
I haven't tested it for Arduino Nano, I ran all the files on Carl through AI, that's what it gave me, I don't know if it works.Attached Files
Comment
-
125ns resolution is not necessary. Run the micro on 8MHz; use Timer0 with 8us resolution for the TX pulse, this is plenty of resolution and offers a frequency as low as 512Hz. Then use Timer1 for the delays, it can run up to 0.5us resolution which is also plenty. Yes, some of the register names will change, that's a matter of getting them off the data sheet. And there is no need for a high level of optimization, there is nothing critical in the code and it should easily fit in memory.Originally posted by boilcoil View Post
The PIC16F684 does not have a 4x PLL, so the maximum frequency is 20MHz with an external crystal or 8MHz with the internal oscillator and there is no way to achieve 125ns resolution.
Timer0 of this microcontroller has 8 bits, so the delays generated with it are in the range of 0 - 255 cycles, not 65535 (to use it you need to change its prescaler and accordingly the delay data).
Many of the registers used in the program have different names or do not exist at all on the PIC16F684.
I also assume that you are using the unlicensed/free version of XC8 (like all of us), which has many optimization procedures cut out.
Comment

Comment