PosRegEnable -does'nt work

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

PosRegEnable -does'nt work

Post by felix2ch »

Code: Select all

  
PosRegEnable(OUT_B);
PosRegSetAngle(OUT_B, 360*3);
while(1);
bricxcc gave me "Error: undefined identifier PosRegEnable".
bricxcc version:3389.
firmware: 1.31

then , change the code to

Code: Select all

    SetOutput(OUT_B,
	       OutputModeField, OUT_MODE_MOTORON+OUT_MODE_BRAKE+OUT_MODE_REGULATED,
	       RegModeField, OUT_REGMODE_POS,
	       RunStateField, OUT_RUNSTATE_RUNNING,
	       PowerField, 0,
	       TurnRatioField, 0,
	       RegPValueField, PID_3, RegIValueField, PID_1, RegDValueField, PID_1,
	       UpdateFlagsField, UF_UPDATE_MODE+UF_UPDATE_SPEED+UF_UPDATE_PID_VALUES+UF_UPDATE_RESET_COUNT);

    Wait(MS_2);

    SetOutput(OUT_B,
	       TachoLimitField, 360*3,
	       UpdateFlagsField, UF_UPDATE_TACHO_LIMIT);
while(1);
Nothing happened. The motor keep silence.

Is there any way to move and hold position?

Thank for your help.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: PosRegEnable -does'nt work

Post by HaWe »

I personally never managed to use these posreg functions - far too weird in my estimation.
But in case you want a different customized function based on PID regulation, I could probably help...
iplewis
Posts: 25
Joined: 22 Mar 2012, 08:48

Re: PosRegEnable -does'nt work

Post by iplewis »

Do you have the enhanced NBC/NXC firmware loaded on your NXT? I believe all the regulation functions need it.
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: PosRegEnable -does'nt work

Post by felix2ch »

doc-helmut wrote:I personally never managed to use these posreg functions - far too weird in my estimation.
But in case you want a different customized function based on PID regulation, I could probably help...
Thanks. I just want motor hold the position after move.I thought it's a ordinary behavior.
For example, robot lift a heavy item, then hold it at higher position.
In NXT, I can use motor block, wait for motor stop, and brake.
In NXC ?
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: PosRegEnable -does'nt work

Post by felix2ch »

iplewis wrote:Do you have the enhanced NBC/NXC firmware loaded on your NXT? I believe all the regulation functions need it.
I checked the manual, you are right.
I found the Warning:
"This function requires the enhanced NBC/NXC firmware version 1.31+."

Thank you.
But you mean ALL regulation functions?
These functions call the "setoutput" and it has regulation parameter.
So, what can i do with setoutput and it's regulation parameter?
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: PosRegEnable -does'nt work

Post by HaWe »

felix2ch wrote:Thanks. I just want motor hold the position after move.I thought it's a ordinary behavior.
For example, robot lift a heavy item, then hold it at higher position.
In NXT, I can use motor block, wait for motor stop, and brake.
In NXC ?
In NXC it's simply Off(port), then ports are stopped and held by a current brake force - but it's not quite strong.
If you want a stronger brake force and/or avoid manual / passive moving then you'd need a different functionality
- like posreg
- or e.g., my own PID control function using the follow-up mode

Code: Select all

void RotatePIDfollowup (char port, long Target, float RotatSpeed); // persuit  target
which is able to reach an encoder target value, and hold it and permanently re-adjust it against external displacement forces
iplewis
Posts: 25
Joined: 22 Mar 2012, 08:48

Re: PosRegEnable -does'nt work

Post by iplewis »

felix2ch wrote:But you mean ALL regulation functions?
These functions call the "setoutput" and it has regulation parameter.
So, what can i do with setoutput and it's regulation parameter?
Well, I'm not really an expert, but yes, I think ALL regulation functions. As far as I understand it, the PID controller is inside the enhanced firmware (presumably in version 1.31 upwards) so if you want regulation, you need this.

I should add that I am pretty sure this is true for position regulation, I'm not so sure about the 'speed' or 'synchronisation' regulation (I've never used them), but I think they all need the enhanced firmware.

As Doc says, if you just want the 'brake' effect from NXT-G, then Off() will work. Or equivalently, you can use SetOutput() with OUT_MODE_BRAKE in the OutputModeField.

Ian.
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: PosRegEnable -does'nt work

Post by felix2ch »

I believe the official firmware supported PID and holding position, because NXT-G can do it.
After some digging works, i found the method for holding position.

Code: Select all

                SetOutput(PORT, PowerField, 0, 
                        OutputModeField, OUT_MODE_MOTORON|OUT_MODE_BRAKE|OUT_MODE_REGULATED, 
                        RegModeField, OUT_REGMODE_SPEED, 
                        RunStateField, OUT_RUNSTATE_RUNNING, 
                        TachoLimitField, 0, 
                        UpdateFlagsField, UF_UPDATE_TACHO_LIMIT|UF_UPDATE_MODE|UF_UPDATE_SPEED);
:lol:
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: PosRegEnable -does'nt work

Post by afanofosc »

Yes, the powered braking capability is part of the standard firmware and using SetOutput is the way to turn it on, though that could easily be wrapped in a preprocessor macro API function. This capability is demonstrated in NXT Power Programming and with the right search terms a number of threads can be found where it has been discussed here previously. I'm glad you were able to find an example.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: PosRegEnable -does'nt work

Post by felix2ch »

afanofosc wrote:Yes, the powered braking capability is part of the standard firmware and using SetOutput is the way to turn it on, though that could easily be wrapped in a preprocessor macro API function. This capability is demonstrated in NXT Power Programming and with the right search terms a number of threads can be found where it has been discussed here previously. I'm glad you were able to find an example.

John Hansen
Thanks.
I searched this forum using "setoutput" term again. Exactly, you were told someone about it.
:D
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests