Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   pulsing digital out pins, not as fast as pwms (http://www.chiefdelphi.com/forums/showthread.php?t=56292)

Generalx5 29-03-2007 22:50

pulsing digital out pins, not as fast as pwms
 
Anyone know a code for pulsing digital out pins? sort of like pwm signals....when the on time is constant but the off time can be adjusted? I am inputing an anolog signal so it controls the length of the off pulses...

EHaskins 29-03-2007 22:58

Re: pulsing digital out pins, not as fast as pwms
 
You may want to look into Kevin Watson's PWM replacement code.
http://www.chiefdelphi.com/forums/sh...ad.php?t=51802

The Lucas 29-03-2007 23:11

Re: pulsing digital out pins, not as fast as pwms
 
what kind of time scale do you need (ie how long on and off)? There are really 2 methods I can think of:
Timers and interrupts (using this Kevin code as base)
User controlled custom PWMs (using this Kevin code as base)

There is always good code at Kevin's Repository.
Depending on your application one of these options is better. Can you explain your application more precisely?

NOTE: the interrupt code is old (last processor) but still decent for copying the the timers interrupt and initialization code

Generalx5 01-04-2007 17:26

Re: pulsing digital out pins, not as fast as pwms
 
Those codes are complicated,..need more time to learn that stuff hahaa.

SgtMillhouse648 01-04-2007 18:45

Re: pulsing digital out pins, not as fast as pwms
 
i dont know if you could do it on a loop count basis, have it increment a counter each time through the loop, and then once it is within a certain range set a digout equal to one? something like

if(counter < 5)
{
counter = counter + 1;
rcdigout01 = 0;
}
elseif(5 <= counter <= 7)
{
counter = counter + 1;
rcdigout01 = 1;
}
else
{
counter = 0
rcdigout01 = 0
}


will this work? I know we did a thing like this when we were working on a delay in our camera search routine to make it pause in between movements

Malhon

ericand 02-04-2007 18:52

Re: pulsing digital out pins, not as fast as pwms
 
Quote:

Originally Posted by Generalx5 (Post 607488)
Anyone know a code for pulsing digital out pins? sort of like pwm signals....when the on time is constant but the off time can be adjusted? I am inputing an anolog signal so it controls the length of the off pulses...

When are you reading the analog signal? How are you reading it?

If you are reading the analog signal using the default get_analog_value()
continuously as you try to pulse the digital I/O pins, you may be getting into trouble due to the delays that the get_analog... puts in while it waits for the A/D conversion. You can eliminate most of the delay by using Kevin's A/D converter which uses the A/D conversion interrupt and a timer to run the conversion continuously in the background.

If you are only checking the analog value once in a while, then using Kevin's A/D code would not be of as much benefit.


All times are GMT -5. The time now is 00:20.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi