Sine wave from 16F628A

Status
Not open for further replies.

whiz115

Member
Hi!

I want to make a PIC output sine wave from RA2 pin. I don't care about specific frequency i want to modify the code for my needs.

If someone is kind enough to help me it would be nice... i could take a seat and try to do it by myself but probably i won't be able to do such stuff until 5-6 months or so and i need this code now!

thank you!
 
You can't output a sine wave on a single pin unless you use PWM and this would have to be on RB3 in order for it to work. Have a read of this thread, it may give you some ideas.

Mike.
 
Pommie what does this code of yours do? can i use it for my needs?

 
It outputs a sine wave on the lower 4 bits of Port B. An R2R DAC (google it) is required to convert to an analogue value. If you read the whole thread you should get a better idea of what it does.

Mike.
 
so... i need the above code a resistor network connected to the corresponding pins and an opamp?

and probably i need accurate resistor values 1% tolerance for that... right?
is there any easier way? you said something about using just one pin with PWM...
 
Last edited:
Yes, that will give you a noisy 200Hz output, adding a filter should make it cleaner. Note, it is only 4 bit and so is very "stepy". It would be fairly simple to change it to 8 bit and get a much smoother waveform.

Mike.
 
well... i just need a sine wave out, 200Hz it's fine with me...i don't mind if it noisy or not so accurate.

but i would like it simpler, because it's for a fast experiment and i don't have time chassing 1% resistors and setting up op-amps..
 
whiz115 said:
well... i just need a sine wave out, 200Hz it's fine with me...i don't mind if it noisy or not so accurate.

but i would like it simpler, because it's for a fast experiment and i don't have time chassing 1% resistors and setting up op-amps..

For only 4 bits, 5% resistors should be fine.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…