Hi,
I have a program running a couple of sail winch servos to control some clock face hands. One servo for hour hand, one for minute hand.
I have the minute hand working well using a delay to incrementally increase the pwm to simulate the minutes, simulating a real
clock.
The servo takes +235PWM to do a full rotation so for the minute hand I have been increasing the PWM by 2 increments every 30 seconds
(Maths bit - 235PWM / 60mins = 3.9PWM per min so - 4PWM per min (rough, but ok for what I need) = 2PWM per 30 seconds.
The code below works fine for the minute hand however I have now come to doing the hour hand and I need to find a way of having
two different delays, or an alternative method to have the pwm's increasing at different speeds.
(Hour hand maths bit - 4PWM (1 Min clock time) x 10mins (1 hr clock time) = 40PWM per 60 mins 'real time'
40PWM / 60mins = 1.5PWM Per min =
1.5 increments per minute or 3 increments every two minutes (due to not being able to use 0.5 of a PWM)
I hope this makes sense,
basically I want to know if
1/there is a way of increasing, incrementally the two different PWM's with different delays within the same case?
2/does anyone know if servo's can use fractions of a PWM, for example 1503.9PWM? or will this just cause problems?
Thanks in advance, please no suggestions of using Steppers etc, I have to use servos's for this particular setup for reasons
that will take too long to explain here.
// I HAVE TAKEN OUT THE HOUR HAND CODE FOR NOW, MINUTE HAND CODE WORKS FINE
case 7: // Commence Time
MinutePulse = MinutePulse + 2; //incremental time increase every 30 seconds (30000)
//HourPulse = HourPulse + 3; //incremental time increase needs to be every two minutes (120000)
MinuteHand.writeMicroseconds(MinutePulse);
//HourHand.writeMicroseconds(HourPulse);
//Serial.print("HOUR PWM VALUE IS SET TO ");
//Serial.println(HourPulse);
Serial.print("MINUTE PWM VALUE IS SET TO ");
Serial.println(MinutePulse);
delay (30000);
break;