I need to do some calculations in order to do this drawing (sorry for the quick sketch):
I need to define a set of variables and do simple calculations as much as possible in order to come up with the above sketch given that:
N: is the number of smaller circles, previously defined and always known
Separation angle SA: is the angle that should be between two circles must be calculated so the circles never intersect
Group Angle GA : the angle each little circle (group) should have when distributed around the bigger circle
R: is the radius of bigger circle which can be defined to make the calculation easier
r: is the radius of smaller Circle
How can I define or calculate the angles and the smaller radius so the N number of circles will never intersect
Thank you
An Update Here is what Ive don so far, again that I posting the equations in a programing form Iam a bit in a hurry
//assume sepration angle = 1/3 group angle for simplness , I have no idea why I did this
var groupAngle = 360 / (noGroups * 1.333);
var sepAngle = (1 / 3) * groupAngle;
//mathmatical relation
var groupRadius = Math.sin((groupAngle * Math.PI / 180) / 2) *R;
after I assumed the above I used the angles to find the center for each circle then draw it - I used sin and cos to find the center relative to the canvas I have which wasn't a problem - however the problem is which I know from the start that I should define R in away the circles will never get out of the rectangle you notice the cut out circles but for not to make things more complicated than they already r I decide R should be some how little bit less than the height of the rectangle result image Now to solve this problem I decided after the calculation and before centering my circles I will reduce the R to R-r this way all circles are shifted inside since eventually I will delete the bigger circles and have the other circles aligned correctly - I cant post another picture -
what remains here that If you keep reducing N, r gets larger to some how it miss up the whole drawing I need to restrict r to another value

HINT: if the group angle is $\alpha$ then you have the relation $\sin(\alpha/2)=r/R$. Choose then $\alpha$ and $\beta$ (separation angle) such that $\alpha+\beta=360°/N$.
EDIT.
It seems from your last edit that you want the distance between the center of the large circle and the center of a small circle to be $R-r$. In that case the above relation for $r$ should be replaced by $\sin(\alpha/2)=r/(R-r)$, whence: $$ r=R{\sin(\alpha/2)\over1+\sin(\alpha/2)}. $$ This correction might hopefully cure your problems for small values of $N$.