Using an arduino mega 2560 to monitor a 3D printer

Hi, I would like to use a mega 2560 to monitor various parameters on my wanhao 3i. One parameter is the heater bed on/off which is 12volts DC and I assume either PWM control or something called "bang bang" Anyway I'd like to use an optical isolator before the mega's digital input to protect it from damage. I have been trying to come up with a circuit and suitable opto chip but all I can find is for manual switching ie a human throwing a switch and not high speed. Any ideas on suitable parts? to deal with PWM from an arduino like processor as an input into an arduino? I have some Sharp PC817Cs to hand would these be fast enough?

I'm not at all sure what you are trying to do here, how accurate you need to be, or how your Mega 2560 is set up.

For instance, if you are just looking at the heater control, you could resistively divide down the heater voltage and use a small capacitor, and then read it as an analog voltage. That would take care of PWM, but for 'bang bang' you would have to take an average over a period of time since it could cycle on and off over a period of seconds. Alternatively you could monitor the actual temperature.

The optocoupler may not be the right tool for this job. It will take 5 to 20mA from the 12V heater to run the sensor and it does have an upper limit on frequency, and that's before it gets a signal to the microcontroller. If you really need electrical isolation, I'd suggest running a thermistor or a temperature sensor.

The Wanhao i3 already is running the Marlin-firmware which is compiled in the Arduino-environment.

There is no reason to cross the stream to get water - the Marlin-firmware is sending all the info you need over the USB-interface.

If i'm not mistaken, there is some extra headers on the Melzi-board where you could pipe the necessary info, too.

http://reprap.org/wiki/Melzi

// Per.