Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
My hardware solution was to put a put a linear regulator inbetween the 12v pin and the servo to drop it down to 5v.
So my question is, how do I add it into my AVR file so everything will remain properly configure?
Also, what code should I use to control a modified servo for continuous rotation?
Let's way that under load servo draws 1A, You want to drop 7V with linear regulator, that equates to 7W of wasted power and probably something that Your linear regulator is not capable of. Much better to use either separate power supply (say 2 Li-Ion batteries giving You around 7.4V, or a switching regulator which will nicely step down voltage from 12V to whatever You want without overheating).
In project designer just add separate 5V power supply to keep program happy.
if (tempbyte == 'x') act_setSpeed(¢er,DRIVE_SPEED_MAX); return 0;
Using PWM?
int curTimeDelay = 1500; // centerint targetTimeDelay = 1500; // centerlong millisToTarget = 0; // not changingunsigned int lastTime = 0;void setup() { lastTime = millis();}void loop() { readCommand(); // figures out possible new value of "targetTimeDelay" and "millisToTarget" while (millis() - lastTime < 30) { // do nothing } lastTime = millis(); if (millisToTarget == 0) { curTimeDelay = targetTimeDelay; } else { long millisToGo = (targetTimeDelay - curTimeDelay); int deltaMillis = millisToGo * 30 / millisToTarget; curTimeDelay += deltaMillis; if (millisToTarget < 30) { millisToTarget -= 30; } else { millisToTarget -= 30; } setServoPWMTime(THE_SERVO, curTimeDelay);}