I’m a new programmer, and I was wondering if anyone who is familiar with the v5code text software would be able to show me an example of code similar to what I am going to be doing for PID. I’m looking to have my elevator go to a certain position and stay there (until moved) when a button is pressed. The problem is that I am not familiar with how to use the “contoller1.button.pressed()” command or much of PID in general. Any help would be appreciated!
I have lost a bit of knowledge of VEXCode as I am now coding in PROS, but considering that PID is meant to be responsive I would advise giving power to the motor in voltage while coding in VEXCode, not percent or rpm (Percent and RPM both use the motor’s internal PID so you don’t need to code them, although the PID isn’t tunable). If you are using voltage I don’t know exactly how to do that in VEXCode but if you use PROS you can code relatively similar to RobotC with “Motor = 127;” or “Motor = kP * error+ kI * integral+ kD * derivative;” But if someone has any resources to code a VEX V5 motor in voltage in VEXCode it would be very appreciated.
The holy scripts
Thank you so much! Hopefully I’ll get it all figured out soon
Some basic pseudo-code I shared in another thread for PD control yesterday.
Great for getting started and the basics of a PID loop.
(and I highly recommend checking out the document @64540A linked. It’s really helpful)
if you want to ues volt on vexcode,mabe you can use : motor.spin(fwd,12,volt);//this 12 can changed to some value you define and multiply 12 divide by 127:sticked_out_tongue_closed_eyes:
Just so you know there is a PID integrated into the motors through motor.rotateFor if you are looking for something a bit easier
Although thats the simplest way it’s not that great because you cannot tune the PID, hence is probably why they are asking because they probably never knew the motors had integrated PID because the integrated PID is so weak
So if I wanted the motor to go 50 out of 127 I do (50/127)*12 in volts?
maybe is (50*12)/127 ,I used PROS too but VEXcode’s download without wire is very easy to use~