You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jallist
Hi there,
I have to compute a PWM value (PWMcal) (on 10 bits), depending on 4 values:
PWMprg = Value asked by the program [0..1023]
VALamb = Value of an LDR (from ADC) [0..1023]
PWMmax and PWMmin = values between which the final value (PWMcal) must be proportional to and within those two boundaries [PWMmin..PWMMax]. Those boundaries are word constants.
Examples:
If PWMprg = 0 and VALamb=0, then PWMcal=PWMmin
if PWMprg = 512 and VALamb = 512 then PWMcal=[(PWMmax-PWMmin)/1024]+PWMMin (= Half Way between PWMmin and PWMmax)
if PWMprg=1023 and VALamb=1023 then PWMcal=PWMmax
I'm not a genious on maths and can't make head or tales from it....
Any help welcome !
Thank you
David
Rob CJ
unread,
Dec 4, 2025, 1:40:04 PMDec 4
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jal...@googlegroups.com
Hi David,
Just some thoughts.
I think it is the easiest if PWMmin = 0.
I then it has to be something like this: PWMcal = ((VALamb * PRMprg) / (1023 * 1023)) * PWMmax