system
July 25, 2014, 6:12am
1
I am a new student and recently started on a new project and I got a duty cycle of 100% despite the controller produced an negative value.
Any suggestions to fix this issue such that my duty cycle will be 0 when controller produced an negative value.
What is the code?
Can you explain better that thing of "the controller produced an negative value"?
Never apply a negitave voltage to the input of an arduino, you will damage it.
Hi, can you please post your code and a diagram of how you are measuring the PWM output.
A CAD or a picture of a hand drawn circuit in jpg, png or pdf will be fine.
Hope to help..
Tom...
system
July 25, 2014, 9:25am
5
Hi.
You could set up a threshold so that when it hits the negative value, it automatically switches the duty cycle to 0% instead of 100%.
Cheers.
Not clear to me if this "controller" is the Arduino or another device connected to it?
system
July 25, 2014, 10:13am
7
I got a duty cycle of 100% despite the controller produced an negative value.
Looks like a classic case of GIGO.
Robin2
July 25, 2014, 1:22pm
8
I was sure I had replied to this earlier today - but I must have consigned it to the ether.
You need to check the value before using it with analogWrite. For example
if (x < 0) {
x = 0;
}
analogWrite(x);
...R