PDA

View Full Version : Using ASM files as include



Josuetas
- 14th August 2007, 13:40
Hi,

Well i have been working something out and now i need to use a DTMF detector, it comes to my attention that microchip has a whole project and ASM files that can be used to detect this tones without a DTMF decoder, but by using just a pic and a small ZCD. AN257.

Now my question is:

Can i use this ASM project to include it in my Picbasic Project?, i dont know any ASM and i dont want to learn any C18, i am really comfortable with PicBasic :D

Today i will be testing the project as compiled by MPLAB but i hope i could get some advise in order to decide wheter i will go through with it tomorrow.

Thanks

DJC

Darrel Taylor
- 14th August 2007, 20:31
Hi, "Doom & Gloom"'s my name for today.

First off, I'll say that I understand very little about the math involved in that application note.
When I see something like ...

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1927&stc=1&d=1187119006"></img>

My eye's gloss over, and I take another sip from the beer. :)

But after looking at AN257...., that's some serious stuff.
Probably why they have all the copyright and license restrictions.

However, I can say that the program uses "relocatable" code. (something I've never got to work with PBP).
So just using them as an include file, and calling the functions, isn't going to work.

I suppose if you actually understood what it what doing, you could rewrite it.
But with math like that, I wouldn't know where to start, or how to find the bugs that would be inevitable.

Best regards,
&nbsp; DG
&nbsp; Doom & Gloom
<br>

Josuetas
- 15th August 2007, 05:07
Hi Darrel.

Bad luck for me, the code is not that hard by the way.

Amazingly: there is no math at all in the final algorithm. I am having real fun doing this stuff by the way.

In short words the math formula of DFT (which you took the bother to take) is a simple comparision of two bits in N samples, when the sample is passed through a 1bit A/D converter (Zero cross detector for example).

What the algorithm does is:


if RealSample = StoredExpected then
Energy = Energy + 1
else
Energy = Energy - 1
endif


The stored expected is a representation of 1`s and 0īs of the signal, considering the samplig frecuency.

i.e. Stored Expected
11111000001111100000111110000011111000001111100000 111110000011111


This must be done with each sample and one can choose like 114 samples (any number, the bigger the better).

The final Energy its a great representation of the existence of the Detected Frequency in the signal. a simple excel worksheet amazed me, this is really a great filter!!

You could even try to trick the algorithm by adding two or three more frequencies at the same time and it will GET the result!

The reason to tell you all this is because my project might need optimization, i am really bad writing that way. BUT YOU ARE A WIZARD, so i might be posting code to check ;).

I Think a good include can come out of this.

By the way, is the EEPROM memory of 16f628 fast enough to be read? i am storing my Stored Expected in that memory but my result is not exact at the moment. I am getting the greatest energy around 300 with a F applied of 350.

I am attaching the excel form that amazed me in case someone is interested, you can move frequency and phase of two frequencies and watch the resultant Wave, and also watch the resultant energy, wich would show that the frequency is detected.

Darrel Taylor
- 15th August 2007, 20:40
Well that certainly makes it look easy.
A lot easier than that other formula.

It'll be interesting to see if it does as good in the real world as in the spreadsheet.

Yup, should make a good include file.


is the EEPROM memory of 16f628 fast enough to be read? ...
Reading from EEPROM only takes 1 instruction cycle, but loading the address each time adds a couple too. But it should still be plenty fast enough.
<br>