controlling the engine

HomeForumsMonoBrick EV3 Firmwarecontrolling the engine

This topic contains 13 replies, has 3 voices, and was last updated by Author Image Anders Søborg 3 years, 2 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #4810
    Author Image
    Roy Toren
    Participant

    Hi,
    As part of a project I need to make the engine work until it gets to a specific position and then again
    (A rubiks cube robot)
    one arm needs to flip the cube and return to its start position.
    the basket where the cube sits needs to turn 90 degrees again and again.
    Is there anyway to make this happen without the SetPower or SetSpeed functions as they are unreliable because the power of the battery changes constantly.

    Thank you,

    #4813
    Author Image
    Tcm0
    Participant
    #4816
    Author Image
    Anders Søborg
    Key Master

    Hi

    From the documentation that Max already pointed to there is a function called speedProfile which lets you move to a position. An example of this is shown here. Please let us all know how work with your cube solver…

    /Anders

    #4821
    Author Image
    Roy Toren
    Participant

    I have tried using “GetTachoCount” but it didn’t do the job.
    I have searched through the documentation and found a few things that I think can work.
    the first one is the PID although it seems a little tricky.
    the second one is the vehicle in:http://www.monobrick.dk/MonoBrickFirmwareDocumentation/class_mono_brick_firmware_1_1_movement_1_1_vehicle.html

    I saw that there was a function that uses degrees and percentages as input, I think it would be best because then there wont be any error range, like when you try to control the engine speed or power(does not rely on battery power)
    I want to hear your opinion about the second one since I got an answer for the first option.
    Thanks.
    Ps.
    I added a picture of the robot so you guys could see.
    The design was adopted from this site:

    http://mindcuber.com/mindcub3r/mindcub3r.html

    • This reply was modified 3 years, 2 months ago by Author Image Roy Toren.
    Attachments:
    You must be logged in to view attached files.
    #4831
    Author Image
    Roy Toren
    Participant

    I forgot to mention and I can’t edit now.
    I have also tried the speed profile, it works for a while but after the 10th turn with the hand robot there is starting to be an error range, that gets bigger with time.
    I have to be as accurate as possibly can, the speed profile and power profile are not reliable since they rely on the engines power at that specific moment.
    I have also tried leaving the battery charging while running the program and the error range keeps on coming.

    #4833
    Author Image
    Tcm0
    Participant

    As I said, PID is probably your best guess or at least the most acurate.
    It seems that you use the NXT color sensor and not the EV3 one. In that case the first link from the other topic to the RGB mode would be right (:P to Anders).

    #4834
    Author Image
    Roy Toren
    Participant

    I have read a little bit more about the PID.

    I Have some questions about it:

    the first one is what values should I enter in this function :
    Position PID (Motor motor, Int32 position, bool brake, sbyte max Power, float P, float I, float A, int seattle Times)
    (What is the position?, settle time?, P,I,D ?)

    The second question is how do i use it in my code, assuming my motor is connected to output A.

    And as for the color sensor, which one of them is the NXT and which one of them is the EV3? I have posted two pictures of different ones.
    can you please answer me in the topic?
    Thanks

    • This reply was modified 3 years, 2 months ago by Author Image Roy Toren.
    #4839
    Author Image
    Tcm0
    Participant

    Sorry, but I havn’t used PID so far :/ http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html gives a good introduction. There are also calculators avaible to calculate the PID. But maybe you’d better google before asking me as I don’t know so much about PID.

    #4840
    Author Image
    Anders Søborg
    Key Master

    Hi

    Have a look at this example. You might need to tune the P, I and D values to get the desired response…

    /Anders

    #4841
    Author Image
    Anders Søborg
    Key Master

    Hi

    I am actually a little puzzled by this. I think the reason that you are getting an error over time with the speed Profile is that you are suffering from gear backlash and not that a speed profile is not precise (since it moves to the desired position each time). If in fact that you have an error over timer due to the fact that the motor moves to the wrong position (tacho count) then a simple reset of the tacho should be enough. Could you please provide some more details on why the speed profile is not good enough?

    /Anders

    #4842
    Author Image
    Roy Toren
    Participant

    The PID works alot better with the testing I have done.
    I have configured it like this:
    PositionPID PID = new PositionPID(motor, 360, true, 50, P, I, D, 50);

    I left the P I and D the same as in the PID example since I don’t really know what they do, i guess 360 is a complete circle of the engine since it keeps coming back.
    I also need the engine to go in reverse(with the engine) in PID, is there anyway I can do that?

    As for the speed profile, I used it and it is probably the backlash, due to the fact that the engine is turning a cube so there is alot of friction and power involved.
    The speed profile does work, but the second it starts to make an error it does not fix it unlike what i have seen until now with the PID

    #4843
    Author Image
    Anders Søborg
    Key Master

    Hi

    I also need the engine to go in reverse(with the engine) in PID, is there anyway I can do that?

    Try with minus in front of the target position

    /Anders

    #4844
    Author Image
    Roy Toren
    Participant

    I have tried using it like this:
    PositionPID PID = new PositionPID(motor, 360, true, 50, P, I, D, 50);
    PositionPID revPID = new PositionPID(motor, -180, true, 50, P, I, D, 50);

    but it didn’t seem to do the trick, the engine only does the 360 command.
    I am aiming for the arm that flips the cube to start on the cube and then do the flip(that’s the 360)
    but then I want the arm to leave the cube and go up a bit without flipping it again(that’s why I need to reverse the engine)

    #4845
    Author Image
    Anders Søborg
    Key Master

    Hi

    I think that you are doing something wrong. The code below works fine…

    
    using System;
    using MonoBrickFirmware;
    using MonoBrickFirmware.Display.Dialogs;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.Movement;
    using System.Threading;
    
    namespace MonoBrickHelloWorld
    {
    	class MainClass
    	{
    		private const float P = 0.8f;
    		private const float I = 1800.1f;
    		private const float D = 0.5f;
    
    		public static void Main (string[] args)
    		{
    			Motor a = new Motor(MotorPort.OutA);
    			PositionPID PID = new PositionPID(a,1000, true, 50, P,I,D, 500);
    			PID.Run().WaitOne();
    			LcdConsole.WriteLine(a.GetTachoCount().ToString());
    			PID = new PositionPID(a,-1000, true, 50, P,I,D, 500);
    			PID.Run().WaitOne();
    			LcdConsole.WriteLine(a.GetTachoCount().ToString());
    
    		}
    	}
    }
    
    

    /Anders

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

Posted in

Make a donation