Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

creating signal using pic 16f690

Status
Not open for further replies.

hobby_85

New Member
Hey, Im trying to build this project of mine where I need to send a signal (ANY kind of signal) using a PIC at certain intervals. But for testing purposes, Id like a signal sent every few seconds. These signals are generated in the PIC and transmitted through a ultrasonic transmitter.

Now, as long as the ultrasonic receiver can detect the signal coming in, I have no qualms about the type of signal being sent.

What would be the easiest way to go about writing code for this? I'm using a PIC 16f690, running at Vcc=5v, and my code is in C.

Im also adding a voltage multiplier at the output of the PIC before the US transmitter so I could amplify the signal before it goes out.

Im still doing my tutorials in how to program a PIC (reached the comparator stage so i know how to detect the incoming signal!), so not sure on which part I have to look at for sending waves/signals.

Thanks!
 

hobby_85

New Member
hey all, ive been looking around the internet to try and create a signal using the pic 16f690. Read alot of stuff on PWM and all that. Then I came across this one code written by 3v0 on this very same forum. Makes heaps of sense and seems easy to implement. heres the code:

int i;
int percent;

percent = 52; // % time on
while(1) // loop forever
{
for (i=0; i>100; i++)
{
if (i < percent)
{
ra0 = 1; // turn bit on
}
else
{
ra0 = 0; // turn bit off
}
delay_ms(1); //some sort of delay here, determines freq
}

-------------------- OR --------------------------

while(1) // loop forever
{
ra0 = 1; // turn bit on

for (i=0; i>100; i++)
{
if (i == percent)
{
ra0 = 0; // turn bit off
}
delay_ms(1); // some sort of delay here, determines freq
}
}

and heres the site i found it on:

https://www.electro-tech-online.com/threads/pic-pwm-outputs.34096/

So basically, the code switches the output to high or low, depending on the duty cycle. My question is if i were to connect this to a ultrasonic transmitter, would it work? would it be sending a rectangular wave? If so, how do I adjust it such that the wave is 40khz.

so why do people use pwm instead of this switching method above, given it seems easier? Sorry if my question seems rather easy, im still new to MC;s.


thanks in advance.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top