OpenWrt Forum Archive

Topic: programmable duty cycle signal on LED; how ?

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

would like to turn a wrt54g into a simple signal strength meter with analog indicator. Would need a little c routine that makes a square wave on one of the LED outputs of a few hundred Herz with programmable duty cycle, e.g. 100 steps or more from 0 to 100% duty to get enough accuracy. Are there timer functions in the wrt54g that I could use from C to achieve this ?
If e.g. using the schedule_timeout function, the problem will exist that the resolution is limited to one jiffie, i.1. 10 ms. So would like to use a microsecond timer, but don know whether and how it can be accessed.

(Last edited by doddel on 25 Mar 2006, 12:32)

Well you have the sleep, usleep and nanosleep standard C functions, but I am not quite sure your eye can appreciate the difference between microseconds and nanoseconds since the max resolution is 10ms if I recall.

thanks for the suggestions. Do those sleep functions that you suggest stop execution of other processes ? Would like to work with
1) fixed interrupts that occur e.g. each 10 ms, making the signal go high and defining a sufficiently high repetition rate that the meter's needle will stand still on the average DC value, and
2) an interrupt at n*100 usec after the first interrupt that returns the led voltage to zero, in which n is the duty cycle 1- 100.
There is a high resolution timer at 108 MHz that is used to calibrate the system's timimg at boot time but don't know whether a user application has access to that. 'Googled' on the subject and found some function definitions in timer.c but no application examples so far in the microsecond realm.

The execution of other processes should not be hindered by the above as the idea is to translate the reported radio signal strenght into the meter reading and do measurements of the rssi on a continuous basis, allowing antenna alignment while looking at the meter for best reception.

The discussion might have continued from here.