Dear all.
Here i am trying to do simple algorithm.I wanna formula to calculate actual position in algorithm
Desired angle calculation:
desired angle=-0.00227272727273x + 102.272727273 where x= (3600*hour)+(minute*60)
actual angle:actual actuator stroke is 600mm ,3.2mm/sec speed ,0.192mm/min. I wanted to run actuator from morning 7 AM to 18PM. approximately 11 hour/660 minutes,How can i convert this mm/min movement into 45 deg to -45 deg .
7AM assume deg :45 , 0mm actuator initial length
12:30 assume deg :0 , 300mm length
18:00 assume deg -45,600mm actuator final length
half code with desired angle.
Here i am trying to do simple algorithm.I wanna formula to calculate actual position in algorithm
Desired angle calculation:
desired angle=-0.00227272727273x + 102.272727273 where x= (3600*hour)+(minute*60)
actual angle:actual actuator stroke is 600mm ,3.2mm/sec speed ,0.192mm/min. I wanted to run actuator from morning 7 AM to 18PM. approximately 11 hour/660 minutes,How can i convert this mm/min movement into 45 deg to -45 deg .
7AM assume deg :45 , 0mm actuator initial length
12:30 assume deg :0 , 300mm length
18:00 assume deg -45,600mm actuator final length
half code with desired angle.
Rich (BB code):
static int hh;
static int mm;
static int ss;
signed int degree;
unsigned int TS;
static float slope= 0.00227272727273;
static float intercept=- 102.272727273;
void setup()
{
Serial.begin(9600);
hh=06;
mm=45;
}
void loop()
{
calc_min();
if(hh<24)
{
Serial.print("HH-MM: ");
Serial.print(hh);Serial.print(":");Serial.println(mm);
TS=(3600*hh)+(60*mm);
Serial.print("TS:");
Serial.println(TS);
degree=(TS*slope)+intercept;
Serial.print("Desired Degree:");
Serial.println(degree);
Serial.println("..................");
}
delay(1000);
}
void calc_min()
{
if(mm<60)
{
mm=mm+5;
}else if(mm==60)
{
mm=0;hh=hh+1;
}
}
Attachments
-
78.7 KB Views: 24
-
82.1 KB Views: 26