Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 9th December 2006, 07:00 PM   (permalink)
Default timing in PICs

Hello Dudes!!!

Need your help in writing a code that performs the following ( assembly or picbasic it does not matter)

I have no problem in using any of the following PIC16F84, F877 , F73

What i need is produce a 1 V for 20 seconds
and then produces 2 V for 30 seconds
of course we must play with the hardware part too.

What are your suggestions???
pouchito is offline  
Old 9th December 2006, 07:12 PM   (permalink)
Default

The quick and easy way to get an analog voltage out of a micro controller is to use PWM. If you turn a pin on and off 1000 times a second and vary the duty cycle the average voltage is going to be equivilant to the duty cycle (on time) So if your PWM signal is on 50% of the time the voltage should be approximatly 2.5 volts (if you're running your pic at 5 volts) But that's average voltage. In order to turn that into an actual analog signal you need to use a resistor in series with the load and a capacitor shorted to ground. This will let the low frequency (signal) through and shunt the higher frequency (PWM frequency) to ground. There is ripple in this output voltage though so it would help if you told us what this 1 or 2 volt signal was going to do.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 9th December 2006, 07:25 PM   (permalink)
Default

Thanks a lot Sceadwian
Appreciated

Can you provide me with a sample code if possible or any doc??
pouchito is offline  
Old 9th December 2006, 09:20 PM   (permalink)
Default

There is more than enough available examples of how to use a PIC's PWM output as a digital to analog converter out there, a simple google search will keep your reading for hours. You simply set a PWM output at the highest possible frequency that will still give it an 8 bit wide duty cycle. Any basic tutorial on a PIC's PWM output abilities will teach you all you need to know.
Also look up "Low pass filter" in wikipedia, The most basic form of it is as I described above, a resistor in series with the output and a capacitor shorted to signal ground. But it depends on how fast you need your voltage to change. You will still always have some ripple (related to the PWM frequency) on the output, but the higher the frequency you use for PWM the easier it is to filter out, especially if you only need the signal to change slowly.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 9th December 2006, 09:22 PM   (permalink)
Default

Thanks again
pouchito is offline  
Old 10th December 2006, 01:27 PM   (permalink)
Default

You can also use the comparator reference pin on the 16F628 mcu to get voltages like 0.8, 1.5,2 etc.
arunb is offline  
Old 10th December 2006, 03:53 PM   (permalink)
Default

The cut off frequency of the LPF should be the same as the PWM frequency or slightly more than it?
__________________
Superman returns..
bananasiong is offline  
Old 10th December 2006, 05:48 PM   (permalink)
Default

The cutoff frequency should match the highest frequency component of the signal you're trying to create. The lower the cutoff frequency compared to the PWM frequency the less ripple.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Timing Circuit with Relay Coded_Bananas Electronic Projects Design/Ideas/Reviews 6 6th October 2006 08:28 AM
Timing Diagram and waveform viewer available for PIC? janetsmith2000@yahoo.com Micro Controllers 7 12th August 2005 02:17 AM
Where to buy PICs in the UK?? 2camjohn Micro Controllers 1 7th March 2005 07:01 PM
PIC Programmer with 18F PICs Timmymna Micro Controllers 5 22nd October 2004 01:44 PM
I am interested in PiCs but dont know much about them cubdh23 Micro Controllers 2 10th July 2004 08:07 AM



All times are GMT. The time now is 04:45 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker