srikanthind
New Member
Could some one give me suggestion to write code for a variable delay and how to design it please
.. thank you
.. thank you
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Delay_ms(1000);
void delay (unsigned int delay_val){
for(x=0;x<=delay_val;x++)
}
Well where you start lets see how would we know, you didn't say what your using C Basic or ASM.
Next from no delay to how long would be nice to know.
And last how you want to change it would be nice.
But you can do it like this varD hold any number you want take a ADC pin with a pot that gives you 1024 steps from varD use the pot to lower or increase varD then cast that to your delay function.
check my pic tutorials - most of them include simply delay routines using nested loops.
If you also check the piclist there's a 'delay code generator', which generates the delay code for you - so you could generate a delay of (say) 100ms, and then call that the number of times you want for your specific delay.
cblock
d1
d2
d3
endc
;999997 cycles
movlw 0x08
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;3 cycles
goto $+1
nop