sample 12F683_pwm_adc.jal

24 views
Skip to first unread message

hans

unread,
Jul 1, 2021, 11:40:57 AM7/1/21
to jallib
Hello, it's me again
I have tested this sample. The PWM goes from zero to about 25% and again.. manual set of the PWM gives the normal result, so i feel there is something wrong with the ADC reading.
Hans

hans

unread,
Jul 1, 2021, 1:23:47 PM7/1/21
to jallib
I have now downloaded the adc.jal from the latest discussion ( june 2021), same result.

Op donderdag 1 juli 2021 om 17:40:57 UTC+2 schreef hans:

hans

unread,
Jul 1, 2021, 2:16:18 PM7/1/21
to jallib
I have solved the problem by changing this part:

var word measure                                -- ADC value / PWM duty cycle

-- ---- mainline ----
forever loop
   measure = adc_read_low_res(ADC_CHANNEL)
   measure = measure *4
         -- get ADC result
   pwm1_set_dutycycle_ratio(measure)
    --pwm1_set_dutycycle_percent(100)
           -- copy to PWM duty cycle
end loop

Op donderdag 1 juli 2021 om 19:23:47 UTC+2 schreef hans:

vsurducan

unread,
Jul 2, 2021, 1:11:41 AM7/2/21
to jal...@googlegroups.com
ADC measurement is 8bit wide while your PWM has 10bit.
Measure your potmeter with 10bit resolution and then pass the result to the PWM.
Your solution is ok if resolution loss does not count.



--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/8202716d-2ae4-4407-8f6e-4a1e0181c1d8n%40googlegroups.com.

hans

unread,
Jul 2, 2021, 1:54:20 PM7/2/21
to jallib
Thanks vasile, I have tested your advice, oke.

Op vrijdag 2 juli 2021 om 07:11:41 UTC+2 schreef vasile:
Reply all
Reply to author
Forward
0 new messages