During a speech in London, Nicola Sturgeon said Mr Cameron had lost votes in the Scottish independence referendum by being negative.
She said she wanted an overwhelming vote in favour of remaining in the EU.
UKIP's Scottish MEP, David Coburn, said the SNP wanted Scottish independence while "still being ruled by Brussels".
And he said leaving the EU would bring more powers back to Scotland from Brussels.
Ms Sturgeon told an invited audience at the Resolution Foundation that she would be using the referendum campaign to make the case not just for the economic benefits of the EU, but also the social and employment rights that came from membership.
But she again re-iterated that if Scotland voted to remain in the EU on 23 June while the UK as a whole voted to leave, it could trigger demands for a second independence referendum.
Opinion polls have consistently suggested that EU membership is more popular in Scotland than elsewhere in the UK.
Ms Sturgeon's intervention came as the UK government published analysis suggesting an EU exit could lead to a "decade of uncertainty", with an impact on the economy and jobs.
In her speech, Ms Sturgeon said the Scottish government continued to believe that EU membership was in the best interests of Scotland.
She pledged to make a "positive, constructive case" for remaining in the EU, and to "campaign wholeheartedly" to achieve an "overwhelming victory, across all parts of the UK, for remaining in the European Union".
The first minister added: "It is interesting to hear many of the same arguments that we heard during the Scottish referendum repeated in the early stages of the EU referendum, albeit in different contexts.
"But I do think there are some early lessons emerging from the Scottish referendum that all of us would do well to pay heed to in the weeks and months ahead."
By Brian Taylor, BBC Scotland political editor
An intriguing argument advanced today by Nicola Sturgeon anent membership of the EU. Ms Sturgeon opened, for the avoidance of doubt, with a first principle.
She confirmed to her London audience that she remained an advocate of Scottish independence. She repeated, further, that Brexit without Scottish consent might well lead to pressure for a second independence referendum.
And so we have a constructed syllogism. Brexit - Scotland = indyref2.  Hence, Ms Sturgeon is of course a supporter of Brexit? QED? Right? Fundamentally wrong?
Indeed, Ms Sturgeon went so far as to say: "I do want Scotland to be independent but I don't want Scotland to become independent because the UK chooses to leave the European Union."
Does that mean she is firmly rejecting a possible path to independence? It can sound that way but I believe the reality is rather different.
Read more from Brian
Ms Sturgeon said the Scottish referendum had shown it was possible to create a "thriving democratic debate" by encouraging people to become "truly engaged in the issues".
But she added that one of the undoubted lessons of the Scottish experience was that a "miserable, negative, fear-based campaign" saw supporters of remaining in the UK "lose a 20-point lead".
Ms Sturgeon, who repeated the Scottish government's pledge not to share a platform with Mr Cameron during the campaign, admitted that the EU was not perfect, could often be "bureaucratic and messy" and had mishandled the Greek debt crisis.
But she said the EU's achievements in areas such as environmental protection and workers rights had left millions of people "wealthier, healthier, happier and freer".
These benefits should be "celebrated not renounced", she insisted.
Ms Sturgeon said there was "no contradiction" between believing in independence for Scotland while also supporting membership of the EU.
She added: "I do want Scotland to be independent, but I don't want Scotland to become independent because the UK chooses to leave the European Union."
David Coburn MEP, the leader of UKIP in Scotland and the party's only elected representative north of the border, said: "If the SNP wanted independence, what is independent about being ruled by Brussels?
"Eighty per cent of the laws are passed in Brussels and if we Brexit, there will be lots of powers coming back to Holyrood from Brussels. We would have more powers."
He added: "Why do the SNP not want this? Because they are a pro-Europe party and they will do anything that their Brussels masters tell them to do.
"If we leave the EU, we will get back our 200-mile limits for fishing instead of having the Spanish plundering our seas.
"We will also be able to make decisions about power to keep things like Longannet Power Station open and we will be able to ensure that we can keep our industries like steel going as we will be able to set our own tariffs once we are out of the European Union."
Scotland's first minister has warned David Cameron against fighting a "miserable, negative, fear-based" EU referendum campaign.