My parents divorced after 18 years because my Mum had an affair and my Dad moved out. A year later she became very ill and was hospitalised, my Dad moved back into the family home to look after me and my DS, we were 12 & 14 at the time. When Mum came home after 6 months in hospital, she was too ill to be left alone for long, and certainly too unwell to 'run the household' and care for us children, so Dad stayed - even sleeping in the same room as Mum for the first 6 weeks to nurse her in the night. Once Mum was stronger, Dad moved to the spare room. He moved out of the family home again 3 months after that, but because they'd pulled together as a team to get the family through a really tough patch, the animosity faded and for a while they became nurse and patient, then 'Team Parents' again, eventually becoming firm friends.
Now, more than 20 years later, they both say that being friends has made parenting us both so much easier than it might have been if they had remained angry at one another. It meant that they were happy to compromise when they needed to and were able to have proper discussions when big decisions about us children needed to be made. It also made things a whole lot nicer for me and my sister - my Dad had been really hurt and angry when they first split up and my Mum carried on seeing the chap she'd been having the affair with, so that was a horrible period. For me, being able to seat them next to each other at the top table during my wedding (when DH's divorced parents had to be separated by seating the Best Man between them...) was a particularly lovely thing, which few children of divorced parents are able to experience without a certain amount of trepidation!
I think it's worth aiming to be friends with your ex when you have DC and I think it's great that you're taking the reins, rather than just crossing your fingers and hoping. It makes life easier for you in the long run and your DC will be happier for it - it can be horribly upsetting hearing one parent put down the other.
It may seem like you've got a mountain to climb, but start off with remembering that when it comes to the children, you're on the same side (Team Parents!) - you both want the same thing; whatever is best for them. If you focus on that to begin with (and can encourage him to do so as well!), then you'll be off to a great start!
Good luck!