Sinus generation with PIC


Closed Thread
Results 1 to 14 of 14
  1. #1
    martarse's Avatar
    martarse Guest

    Default Sinus generation with PIC

    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

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb DTMF

    Hi, Martin

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

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

    Alain

  3. #3
    martarse's Avatar
    martarse Guest


    Did you find this post helpful? Yes | No

    Default

    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!

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb

    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 ...

  5. #5
    martarse's Avatar
    martarse Guest


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    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
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Red face

    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

  8. #8
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Ooops!

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

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  9. #9
    martarse's Avatar
    martarse Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  10. #10
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    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

  11. #11
    martarse's Avatar
    martarse Guest


    Did you find this post helpful? Yes | No

    Default

    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

  12. #12
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    http://www.byonics.com apears to be down

  13. #13
    martarse's Avatar
    martarse Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  14. #14
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb

    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

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts