PDA

View Full Version : Sinus generation with PIC



martarse
- 12th August 2004, 04:02
Hello,

I want to generate "clean" sinus wave that will be decoded by a modem. At this time, I have generate a square wave with a PIC16f84a but I've got some problem with the filtration that cause some delay to the signal when I changing the frequency (FSK system).

I want to try another way to generate my sine wave that do not need many filtration.

Someone told me about using 4 pins on the pic with voltage resistor divider to generate 16 voltages levels thats could be a good sine wave when all pins are well synchronized ? Someone have already try this with a PIC and can says me more.

thanks

Acetronics2
- 12th August 2004, 12:42
Hi, Martin

There's all you need already done ...and downloadable ASM

ELECTRONIQUE PRATIQUE
N° 247 page 86 >
www.eprat.com

Alain

martarse
- 13th August 2004, 13:20
Alain,

your web site does not work. the good one is www.electroniquepratique.com but the edition #247 is not available on the Internet...

Anyways, I've make some test on my side.

high portb.0 '0001
pause duree

low portb.0 '0010
high portb.1
pause duree

high portb.0 '0011
pause duree

low portb.0 '0100
low portb.1
high portb.2
pause duree
...
... until '1111


I want to optimize this code because it uses many many space.

I use this method :

portb=%00000000

portb=%00000001
pause duree
portb=%00000010
pause duree
portb=%00000011
pause duree
portb=%00000100
pause duree
....

That does not work ?

someone have an idea?

maybe a FOR loop could be also better!

thanks!

Acetronics2
- 13th August 2004, 14:21
Hi, Martin

Did you remark, you add 1 to PortB value at each time ...sounds pretty good for a loop ...you jump off for portB = 0

But take care: with Portx = y ... no capacitive load allowed !!!

That's all !!!

Alain

PS: I have a look to Elec.Prat. programs I have already downloaded ...

martarse
- 13th August 2004, 14:57
Alain,

What do you mean by :"with Portx = y ... no capacitive load allowed !!!"

I will not be able to use a RC filter at the exit?

Is it not the same thing that using HIGH portx and LOW portx?

thanks

Dwayne
- 13th August 2004, 15:28
Hello Martarse,

M>>Anyways, I've make some test on my side.

high portb.0 '0001
pause duree

low portb.0 '0010
high portb.1
pause duree

high portb.0 '0011
pause duree

low portb.0 '0100
low portb.1
high portb.2
pause duree
...
... until '1111


I want to optimize this code because it uses many many space.

<<

Try the following: this simplified your code to count to 15 using your first 4 bits. If you want to go higher, remove the for-next loop. and let it "recycle" itself.

TRISB=%00000000
counter var byte
Portb=0;

Loop:
for counter=0 to 7 step 1
Portb=Portb+1
Next counter
Portb=0
goto Loop


Dwayne

Acetronics2
- 13th August 2004, 18:06
Hi, Martin

No, it's not the same ...so why High and Low commands ??

Capacitve load ...mmmmh, I don't know exactly at how many nF it begins ...may be, it's better not to ask for more than the 20 or 25 mA given by the data books !!!

I Only now driving directly 1 µF and more do not work with = ...
There are some trails to do ... to find the real limit !

Ah ! the article from Elec.Prat. was signed by Marc LAURY ...may be you could contact him via the book editor ...

Another solution could be to use the sine conformer section of an ICL 8038 ...

Alain

Dwayne
- 13th August 2004, 20:20
Ooops!

the for and next loop should be
for counter=0 to 15 step 1! (for the byte) sorry.

Dwayne

martarse
- 13th August 2004, 21:09
Thanks Alain for the details. I'll take care of that 20mA.

Dwayne, I'm thinking about the FOR loop. I want to generate a sine wave. If I use a FOR loop I'll have to change the pause between all increment otherwise I'll get a triangular wave that will not be very good for the filter.

I'll make some others tests with all your advices.

thanks.

I'll keep you informed with these tests.

NavMicroSystems
- 14th August 2004, 00:02
martarse

why don't you just use a single chip FSK modem?

I doubt you'll get an "acceptable" sine at a precise frequency and timing out of a 16F84,

The part count and effort for filtering will be much more than with a FSK modem.

(I have tried to build a switching StepUp / StepDown DC-DC converter based on a PIC and had to realise soon that it doesn't make sense. There are single chip solutions available that do a better job at a lower price)

regards

martarse
- 14th August 2004, 00:14
Hello,

Because they are discontinued by the manufacturer or too expensive and I want to stay at very low cost.

I've check for the TCM3105 and some other. If they are not discontinued, the crazy vendor ask me 20 to 30$ for 1 unit only! It's a little bit too expensive...considering the PIC Price.

On the other way, Byonics (http://www.byonics.com/ --> see the tinytrak) doing the job with a PIC. I've just found interesting to try to make that myself!

PS: If someone have some information about FSK chip taht could be available at low cost, let me know...

thanks,
Martin

NavMicroSystems
- 14th August 2004, 01:03
http://www.byonics.com apears to be down

martarse
- 14th August 2004, 01:29
I've just try it and It seems to be online and running!??

Maybe a link between your ISP and the server in USA or some other link used to pass over the atlantic.

Acetronics2
- 16th August 2004, 16:10
Hi, martin

one more idea ...you have sine and cosine functions in PBB, it would be nice to use it with a constant time pich, no ?

Alain