LDC1430/60C project - questions for software writing

6 years 5 months ago - 6 years 5 months ago #29528782 by Boarderbas
After writing 300 lines of code I run i to my fnal challenge: Getting the motor output to rotate a set amount.

I thought that:
SetConfig(_MMOD,1,2)
SetCommand(_PR,1,1000)

Would rotate the motor 1000 encoder positions. But I'm wrong. All it does is try to get to encoder count 0..
SetConfig(_MMOD,1,2)
EncoderValue = GetValue(_C,1)
NewEncoderValue = EncoderValue-1000
SetCommand(_P,1,NewEncoderValue)

Doesn't work at all...

Any idea what's wrong here/ Remember I am doing all by script. So If there are any settings i need to make in my script, please note..

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528783 by Griffin Baker
Replied by Griffin Baker on topic LDC1430/60C project - questions for software writing
You want closed loop count position in order to use the !PR commands. Setconfig(_mmod, 1, 3)

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528784 by Griffin Baker
Replied by Griffin Baker on topic LDC1430/60C project - questions for software writing
1 pulse = 4 counts

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528785 by Boarderbas
Found it!

Indeed the 3rd motor state is correct thanks. But I also need to lower the speed to 500RPM otherwise it wil gigantically overshoot and not correct due to the watchdog kicking in.

I try to move only 2 degrees on my 1:150 gearbox..

Almost done now!

I get a bit of a n oscillation at motor start. probably since I am using a 50ppr encoder. Next one I'll use 250 for smoothnes. Do you have any pointers to PID setting that will improve the behaviour. i get some smoothness in setting D to max, but that gives problems elsewhere. It may solve itself if the output shaft is properly loaded...

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528786 by Griffin Baker
Replied by Griffin Baker on topic LDC1430/60C project - questions for software writing
The position mode is mostly P gain over the I gain. So adjust your P gain so that there is minimal oscillation. Then if your motor needs a boost upon command change, you can add some D gain (Though advised not to use too much as it can lead to your motors getting damaged. Once that is set, you'll want to add some I gain so that your motor reaches the final position destination. If it begins to oscillate, you can lower your Integrator limit % lower to reduce the oscillation. This will reset the error and recalculate the new error over the time.

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528787 by Boarderbas
SetFurlPID:
	SetConfig(_KD,1,50)
	SetConfig(_KI,1,50)
	SetConfig(_KP,1,10)
	Return

SetPositionalPID:
	SetConfig(_KD,1,50)
	SetConfig(_KI,1,10)
	SetConfig(_KP,1,100)
	Return

Just set two sets of PID, One for closedloopspeed and onde for positioning

Will the "destination reached" flag be set in the way you proposed to set it up?

Please Log in or Create an account to join the conversation.

6 years 5 months ago #29528788 by Boarderbas
Got it!

Code finished. Thank you for the help! Love the controller. Get that CAN in! I could sell a lot!

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.143 seconds