I am turning velocity PID. each sample time is about 50+ms.
I found an abnormal speed happened almost for each run:
the last blue dot speed is abnormal , since I check the detail dumping data, before this sample, motor.set_velocity was aim to set to a smaller velocity less than the value shown in the 2nd last blue dot, however it on the contrary made the last last blue dot even bigger than the 2nd last blue dot. To prove there is something wrong at motor.velocity return value. I wrote below code to do a standalone test:
file_name= “aaaa.csv”
f = open(file_name, “a”)
Lmotor.set_velocity(85, PERCENT)
Rmotor.set_velocity(85, PERCENT)
Lmotor.spin(FORWARD)
Rmotor.spin(FORWARD)
set_speed_to_list = [80.03907,61.89551,44.69043,28.00674,15.2854,7.88203,0.6871804,-2.023939,-2.128196]# these data are from a PID experiment.
while 0.5*(Lmotor.velocity(PERCENT)+Rmotor.velocity(PERCENT)) < 81:
wait(10,MSEC)
brain.timer.clear()
for set_speed_to in set_speed_to_list:
cur_sp = 0.5*(Lmotor.velocity(PERCENT)+Rmotor.velocity(PERCENT))
Lmotor.set_velocity(set_speed_to)
Rmotor.set_velocity(set_speed_to)
param = str(brain.timer.time()) + “,” + str(cur_sp) + “,” + str(set_speed_to) + “\n”
f.write(param)
wait(30, MSEC)
f.close()
stop()
the see what I can get:
I tried to enlarge wait time, I found if wait(200, MSEC), such abnormal issue will p. However, PID controller need a small Ts, 200ms is too big, since the delay response is unacceptable.
Is this only my motors’ problem? I think everybody needs to use PID and needs to use motor.velocoty to return the velocity of current motor in MSEC level Ts, no one found such issue? do I have to buy new motors? or all motors just do have such issue: read velocity frequently (in less than 100MS level) , motors could not grantee return a correct value?