Hi all,
I’m trying to use ADC reading to control current flow.
The circuit as followed:
The FC3 program & the output waveform is attached, from what I observed through the scope, I got the same waveform regardless different values of “VAL0” settings.
If I'm not wrong with VAL0>5 setting, i should expect more OFF than ON compare to VAL0>128, hence reduce of current to LED.
The value of R=1k ohm.
Please any suggestion, how should I set the ADC?
Thanks.
ADC controlling needs advice.
ADC controlling needs advice.
- Attachments
-
- ADC-ONOFF.fcf
- (4 KiB) Downloaded 249 times
-
- Signal @ GPIO 0
- WaveFormGPIO0.jpg (96.89 KiB) Viewed 3802 times
-
- ADC-ControlCurrent.jpg (12.5 KiB) Viewed 3802 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC controlling needs advice.
Hi oookey,
It's a bit more complex than is first thought.
You want to limit the current, so that means if the current exceeds a threshold, then PWM duty is reduced.
But what if the current is not exceeded, but is less than threshold?
PWM increase?
Problem is even during the 30 second on duration, with a PWM set at 50% the current will not be flowing for 50% of the time.
Also what is your current threshold?
You may want an adjustable threshold by using up another ADC channel?
I believe the solution would be to 1st sample the current, and if under a minimum value (not the current threshold value) then at this point the PWM is off so don't use sample for any PWM adjust.
If the sample is greater than minimum current then the sample should be compared with threshold value. So if greater than current threshold value, Reduce duty of PWM, otherwise leave as is.
You will need to determine the current threshold value and resistance value.
If you can let me know the values I can assist you with a modified Flowchart.
Martin
It's a bit more complex than is first thought.
You want to limit the current, so that means if the current exceeds a threshold, then PWM duty is reduced.
But what if the current is not exceeded, but is less than threshold?
PWM increase?
Problem is even during the 30 second on duration, with a PWM set at 50% the current will not be flowing for 50% of the time.
Also what is your current threshold?
You may want an adjustable threshold by using up another ADC channel?
I believe the solution would be to 1st sample the current, and if under a minimum value (not the current threshold value) then at this point the PWM is off so don't use sample for any PWM adjust.
If the sample is greater than minimum current then the sample should be compared with threshold value. So if greater than current threshold value, Reduce duty of PWM, otherwise leave as is.
You will need to determine the current threshold value and resistance value.
If you can let me know the values I can assist you with a modified Flowchart.
Martin
Martin
Re: ADC controlling needs advice.
HI Martin,
Thanks.
If the output port is OFF, VAL0 reads value less than 5%, then ON output port, as current flows increase over 5% mark, output port OFF again.
I think I'm correct using this method to control the amount of current flow. From the scope i can see On & OFF, but this on/off is not affected by the setting of the VAL0
Thanks.
This time round I'm solely setting On & Off at the output port, no PWM involve.medelec35 wrote: You want to limit the current, so that means if the current exceeds a threshold, then PWM duty is reduced.
But what if the current is not exceeded, but is less than threshold?
PWM increase?
Martin
If the output port is OFF, VAL0 reads value less than 5%, then ON output port, as current flows increase over 5% mark, output port OFF again.
I think I'm correct using this method to control the amount of current flow. From the scope i can see On & OFF, but this on/off is not affected by the setting of the VAL0

-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC controlling needs advice.
You will need to bear in mind that if current limits and turns the pin off, then current is 0 so the pin is very rapidly turned on again.oookey wrote:This time round I'm solely setting On & Off at the output port
It will be like very rapidly turn your house light on and of 1000's times a second.
So in effect you will have a pwm waveform anyway.
That sounds like the PWM effect I have described.oookey wrote: From the scope i can see On & OFF, but this on/off is not affected by the setting of the VAL0
If it was me, I would use another ADC channel to adjust the current limit threshold.
As for the threshold value, Rather than stating over 5%. it would be better if you workout the normal current flow, add a percentage say + 10%, then use that figure as a current limit since under normal circumstances current limit is undesirable.
Martin