Function Generator using Microcontroller PIC18F452

Thread Starter

Ranayh

Joined May 6, 2013
8
Hey everyone,

We're supposed to create a function generator using a micro pic18f452 and a 0808DAC and I'm very stuck on the code. Can any1 help me begin? Thanks!
 

WBahn

Joined Mar 31, 2012
30,077
You need to show some effort to solve YOUR homework problem. Describe how you are going to break down the tasks that need to be accomplished and at least describe WHAT has to be accomplished and HOW you think you might go about accomplishing it.
 

mitko89

Joined Sep 20, 2012
127
As far as I remember you could also use the PWM module of the PIC to generate different signal forms. Download the datasheet from the MC website and take a closer look. On the MC site there are plenty of app notes that you can reffer in future(DESIGN SUPPORT->Documentation->Application Notes). The one you need is AN655. You can also check the MC forum if you haven't already. Hope this will be enough for you to begin.
 

atferrari

Joined Jan 6, 2004
4,771
As far as I remember you could also use the PWM module of the PIC to generate different signal forms.
Your recollection is misleading. He was asked to do something different, specific enough.

Better he does what Wbahn suggested: thinking on what he was asked to get, how he would do it with what he was already told to use.

DACs convert binary input into analogic signals. THAT's the point. Rigorous thinking could bring him to a clear idea.
 

Thread Starter

Ranayh

Joined May 6, 2013
8
You need to show some effort to solve YOUR homework problem. Describe how you are going to break down the tasks that need to be accomplished and at least describe WHAT has to be accomplished and HOW you think you might go about accomplishing it.
well i do know how to make the lookup table for the sine wave, and i was thinking of generating the square wave using timer0, im not sure what i can do about the triangle, i wasnt given much detail about what i need to do with this project, like for example i duno how i can chose between which wave signal i want as output. thats what i need help with just a little bit of organization its ind of all over the place.

thanks for the push :)

also im a girl lol
 

WBahn

Joined Mar 31, 2012
30,077
Well, welcome to the forum young lady! (Yes, it's another assumption that you are 'young', but given most of us here, it's a pretty safe assumption, at least in relative terms :D)

If push came to shove, you could always use a look up table for the triangle wave, too. But you can probably figure out how to leverage that fact that, for a triangle way, you are incrementing up or down the same amount each time. But, as with the sine wave, you need to pay attention to frequencies that don't match your sample rate nicely.

For determining which output to use, that's normally covered in the spec somehow. If it isn't then there are lots of ways of doing it. The simplest is probably to have two input pins that you apply one of four signals to in order to specify NO output, SINE, TRIANGLE, SQUARE. Lots of other alternatives, though.

Take it one step at a time. Get it so that you can output one waveform (pick one) and get that working how you like it. Then add the additional waveforms. They should each take less time because you will have learned quite a bit getting the first one to work.
 

WBahn

Joined Mar 31, 2012
30,077
Because if she does it "exactly" the same way, then they will both be sine waves! :D

But the suggestion is very valid. You will probably have some code inefficiency as a result, but the simpler implementation will probably be quicker and more robust and what you give up in "unnecessary" look up table data you may well gain back in simplified code structure.
 

atferrari

Joined Jan 6, 2004
4,771
Because if she does it "exactly" the same way, then they will both be sine waves! :D

But the suggestion is very valid. You will probably have some code inefficiency as a result, but the simpler implementation will probably be quicker and more robust and what you give up in "unnecessary" look up table data you may well gain back in simplified code structure.
Hola WBahn

I am afraid that to make it "universal" the LUT is what should be changed with the procedure staying the same. Simplifying the code by playing numeric tricks would mean, most probably, to write different (albeit simpler) code for few signals other than sine. A nice exercise but not practical.
 

WBahn

Joined Mar 31, 2012
30,077
Hola WBahn

I am afraid that to make it "universal" the LUT is what should be changed with the procedure staying the same. Simplifying the code by playing numeric tricks would mean, most probably, to write different (albeit simpler) code for few signals other than sine. A nice exercise but not practical.
I'm agreeing that, from most perspectives, a LUT-based approach makes more sense. Other factors weigh into it, for instance if you don't have enough space to store the LUT data. Also, you may make it LUT-based but still not universal in that you may be relying on various degrees and types of symmetry to reduce the size of the LUT.

Plus, at the end of the day, a big part of what matters may well be the fact that this is an exercise intended to achieve certain things, practicality notwithstanding. We have no idea based on what has been presented, but it could well be that different implementation methods for each of the waveforms is what is expected.
 

atferrari

Joined Jan 6, 2004
4,771
I'm agreeing that, from most perspectives, a LUT-based approach makes more sense. Other factors weigh into it, for instance if you don't have enough space to store the LUT data. Also, you may make it LUT-based but still not universal in that you may be relying on various degrees and types of symmetry to reduce the size of the LUT.

Plus, at the end of the day, a big part of what matters may well be the fact that this is an exercise intended to achieve certain things, practicality notwithstanding. We have no idea based on what has been presented, but it could well be that different implementation methods for each of the waveforms is what is expected.
The paragraph above transpires the lecturer on you. Good! I agree!.
 
Top