Page 1 of 2
PosRegEnable -does'nt work
Posted: 02 Jul 2013, 08:20
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.
Re: PosRegEnable -does'nt work
Posted: 02 Jul 2013, 12:47
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...
Re: PosRegEnable -does'nt work
Posted: 02 Jul 2013, 13:31
by iplewis
Do you have the enhanced NBC/NXC firmware loaded on your NXT? I believe all the regulation functions need it.
Re: PosRegEnable -does'nt work
Posted: 03 Jul 2013, 02:08
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 ?
Re: PosRegEnable -does'nt work
Posted: 03 Jul 2013, 02:19
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?
Re: PosRegEnable -does'nt work
Posted: 03 Jul 2013, 06:47
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
Re: PosRegEnable -does'nt work
Posted: 03 Jul 2013, 12:59
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.
Re: PosRegEnable -does'nt work
Posted: 04 Jul 2013, 02:00
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);
Re: PosRegEnable -does'nt work
Posted: 04 Jul 2013, 04:08
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
Re: PosRegEnable -does'nt work
Posted: 04 Jul 2013, 04:35
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.