Can someone explain detonation vs pre ingintion

well hopefully im right....pre ignition (pinging) is cause by timing. you are making the spark plug light off to soon. Detonation happens without the plug firing. Heat of compression ignites the fuel causing an explosion before the piston is all the way up. If you have to much compression and crappy fuel this happens

Ok Brian. Thank you.

Question........1. If there is crappy fuel and it ignites on it own is this when the motor "diesels" when you turn it off?

2. Can it ignite during compression cycle prior to plug sparking?

3. If crappy fuel is to blame...why would it ignite with bad fuel and not good or higher octane fuel?

Still trying to understand.

Thanks