Help needed with PWM and Op-Amp (for Arduino)

ronv

Joined Nov 12, 2008
3,770
Arduino Mega2560 has default PWM frequency near about 490 Hz. It comes around 2mS. If you can do cap calculations you can find the cap will charge to 5V in roughly about 1 sec with 2mS pulse width and 100% Duty. It no where needed to charge the cap in one cycle.



BAD 358? I doubt. I still try to check with your first suggestion to tie everything floating to ground cause it makes sense to me. I didn't understand the second one. Please elaborate.
My bad. I just looked at your values in post 1. Everything is ok up to 50%.
I think the problem may be that the 358 can't drive 20 ma. Try it with 470 ohm load instead of 250. Or are you saying the output from the adrino is not 5 volts when you hook it up to the 4.7k.
 

Thread Starter

aadityadengle

Joined Feb 8, 2012
16
I think the problem may be that the 358 can't drive 20 ma.
No, it is not surely. because that is not expected from 358. I just want to have 0V to 5V programmable voltages from 358. driving 4mA - 20mA is done by other unit. that unit is taking 0V to 5V as input signals and converting it to 4mA - 20mA. If I disconnect the converter unit, still I am not getting 5V at 100% duty.


Everything is ok up to 50%
Not even that, every thing OK at 0% duty only (means output is 0v at 0% duty) apart from this at any duty the output at arduino pin itself is only 76% of what it should normally give. I think rest of 24% is sinking somewhere. How can I find there are no negative voltages generating?
Can it be like arduino is lacking to supply enough current?

Or are you saying the output from the adrino is not 5 volts when you hook it up to the 4.7k.
You got right here, this is what my problem is.
 

crutschow

Joined Mar 14, 2008
31,116
..................
[ronv said:
Or are you saying the output from the adrino is not 5 volts when you hook it up to the 4.7k.]


You got right here, this is what my problem is.
A CMOS output will not deliver the full supply voltage if it has to deliver any significant current, such as required by a 4.7kΩ load.
Try at least 47kΩ with the capacitor reduced by the same factor (1/10).
 

ebeowulf17

Joined Aug 12, 2014
3,307
A CMOS output will not deliver the full supply voltage if it has to deliver any significant current, such as required by a 4.7kΩ load.
Try at least 47kΩ with the capacitor reduced by the same factor (1/10).
5V into 4.7kΩ is just over 1mA. I never would've thought of 1mA as significant current. If I'm reading and understanding your comment correctly, then I'm learning something new today about CMOS. (Admittedly, I knew essentially nothing about CMOS previously, but I wouldn't have guessed such limits.)

But also, the Arduino Mega IO pins claim to be capable of 20mA each. Are specs like this a little misleading? Is the pin capable of 20mA, but with voltage sagging down to 3.8V in the process, and also capable of 5V output, but only into very high impedance loads?
 

crutschow

Joined Mar 14, 2008
31,116
5V into 4.7kΩ is just over 1mA. I never would've thought of 1mA as significant current. If I'm reading and understanding your comment correctly, then I'm learning something new today about CMOS. (Admittedly, I knew essentially nothing about CMOS previously, but I wouldn't have guessed such limits.)

But also, the Arduino Mega IO pins claim to be capable of 20mA each. Are specs like this a little misleading? Is the pin capable of 20mA, but with voltage sagging down to 3.8V in the process, and also capable of 5V output, but only into very high impedance loads?
The question is: 20mA at what output voltage?
All CMOS outputs have an inherent transistor resistance which causes a voltage drop as the current increases.
3.8V does seem a large drop for 1mA load current but you can't argue with results, if that's the only load on the output.
Try a higher resistance and see what happens.
 

Thread Starter

aadityadengle

Joined Feb 8, 2012
16
Guys Thank you for your support. through this discussion I have come to know many new things. As of now I am shifting over MCP4921 (DAC with SPI Interface) just to fight against time. I am preserving my current circuit to find out the root cause of the problem. It will take 2-3 days to commission MCP4921. Then only I can resume the work current problem.

By the way What I can guess is as per the Arduino docs, and various unofficial pinout diagrams like http://yourduino.com/docs/MegaPinOut.png, I am not supplying enough voltage. Please pay your attention to the comment located just above the barrel jack, it clearly says "7V to 12V Vin depending on current drawn." I must have overlooked this comment and have designed every thing.
When I checked my circuit (module by module) before going for a PCB it works fine and haven't have received any problem. As on the PCB all modules are connected simultaneously and are drawing current all at once, I probably running out of current there. Just for your info I have following modules on the same PCB or on other one which is connected to main PCB.

Main PCB:
1. Arduino.
2. RS485 to Serial Converter for Modbus.
3. ESP8266.
4. 12 nos of switch debouncing circuits.
5. PWM to Voltage converter (one which we are discussing about).

Daughter PCB:
1. 4 Nos of PCF8575 (16 I/O each) (For this board, power is drawn from main board)


I am powering all this with a std. computer PSU (SMPS).
 

ebeowulf17

Joined Aug 12, 2014
3,307
Guys Thank you for your support. through this discussion I have come to know many new things. As of now I am shifting over MCP4921 (DAC with SPI Interface) just to fight against time. I am preserving my current circuit to find out the root cause of the problem. It will take 2-3 days to commission MCP4921. Then only I can resume the work current problem.

By the way What I can guess is as per the Arduino docs, and various unofficial pinout diagrams like http://yourduino.com/docs/MegaPinOut.png, I am not supplying enough voltage. Please pay your attention to the comment located just above the barrel jack, it clearly says "7V to 12V Vin depending on current drawn." I must have overlooked this comment and have designed every thing.
When I checked my circuit (module by module) before going for a PCB it works fine and haven't have received any problem. As on the PCB all modules are connected simultaneously and are drawing current all at once, I probably running out of current there. Just for your info I have following modules on the same PCB or on other one which is connected to main PCB.

Main PCB:
1. Arduino.
2. RS485 to Serial Converter for Modbus.
3. ESP8266.
4. 12 nos of switch debouncing circuits.
5. PWM to Voltage converter (one which we are discussing about).

Daughter PCB:
1. 4 Nos of PCF8575 (16 I/O each) (For this board, power is drawn from main board)


I am powering all this with a std. computer PSU (SMPS).
What power are you providing, and how are you connecting it? Computer PSU could mean 12V or 5V, and power could be fed into Arduino through barrel jack, Vin pin, or 5V pin. Each scenario has different implications.
 
Top