Your sketch will need to detect whether the engine is actually idling. Typically, idle control valves effectively held wide open during ordinary driving and deceleration in order to avoid high manifold depression. But if you aren't concerned about emissions and EGR you could ignore all that and just accept that the controller will have the ICV pulled down against the stop trying to drop the revs most of the time. You might find that causes problems with the ICV sticking and clogging, but there's only one way to find out.
Depending on the engine's response, you might find you need to catch the revs softly as they drop down to idle rather than let the engine spin down with the throttle closed - some engines don't respond well if you leave them on overrun and then suddenly ask them to idle.
You'll need to tailor your PID settings to match the engine's throttle response and to make sure you aren't tripped up by a lumpy idle. You need to decide whether your idle controller will respond faster or slower than the engine. You want to avoid having it respond at similar speed to the engine as that will lead to hunting. Probably, you'll find that controlling the ICV slower than the engine response is easiest to get working i.e. think of it is primarily an integral controller. I think your best bet for that would be to find out what ICV position corresponds to a normal hot fast idle and park the ICV there until the revs seem to be dropping in to an idle position, then make sure you drive the ICV closed slower than the engine will respond
I think i can figure out the settings for the PID on my own, has some experience about PID from school.
Quotehttp://img405.imageshack.us/img405/2443/optokrets.png@Puke_Nukem: Why does this circuit use an optoisolator but have the two grounds connected together?Pete
The two grounds is just connected on the drawing, not in real life I've been thinking, I'm sure that PID is the right type of control for this application. As far as i know, and have learnt as school, PID is nor very suitable when the process parameters is non-constant. As for an engine, the parameters for control changes when engine goes from warm to cold, and when the loads of the idling engine are changing.