Is it possible?
http://nxt-firmware.ni.fr.eu.org/change ... egulation/
That is the only documentation I can find about it, and it mentions the thing is implemented in NXC, and has only NXC examples, but says the "API is available in Bricxcc version 3.3.8.9 or NBC/NXC version 1.2.1 r4."
If it is in NXC, is there some sort of "not exactly C calling convention"?
I could as well use NXC of course, but it provides only a few abstractions I don't need, and not the ones I do need, so I didn't bother to learn the extra syntax.
absoute position regulation from NBC
-
- Posts: 175
- Joined: 28 Dec 2011, 13:07
- Location: Gelderland, Netherlands
- Contact:
absoute position regulation from NBC
-- Pepijn
http://studl.es Mindstorms Building Instructions
http://studl.es Mindstorms Building Instructions
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: absoute position regulation from NBC
Everything you can do in NXC you can do in NBC, as NXC is simply converted to NBC. If you look at the NBC code the NXC compiler generates, you can figure out how to do it in NBC directly.
To view the generated NBC code, use BCC to compile and hit the F12 key when it is done. A window pops up with the NBC code.
So just try to replicate that, it shouldn't be too hard in most cases. (Though beware, some NXC functions which are not natively supported by the firmware can be large.)
You can also try to look in the header files which you can find in the NBC source code folder, though I'm not completely sure you can look up every function that way.
To view the generated NBC code, use BCC to compile and hit the F12 key when it is done. A window pops up with the NBC code.
So just try to replicate that, it shouldn't be too hard in most cases. (Though beware, some NXC functions which are not natively supported by the firmware can be large.)
You can also try to look in the header files which you can find in the NBC source code folder, though I'm not completely sure you can look up every function that way.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
-
- Posts: 175
- Joined: 28 Dec 2011, 13:07
- Location: Gelderland, Netherlands
- Contact:
Re: absoute position regulation from NBC
I don't use BCC, but browsing the help on NBC revealed an -nbc option, however, it generates 7000 lines of code for my 50 line NXC program, is all of that really sent to the NXT, or is there some option to see just the actual code?
However, it just seems to do some really complicated setout statement, which makes sense I guess.
However, it just seems to do some really complicated setout statement, which makes sense I guess.
-- Pepijn
http://studl.es Mindstorms Building Instructions
http://studl.es Mindstorms Building Instructions
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: absoute position regulation from NBC
I don't use BCC either except for this because I find it more convenient. It filters out the "FILE at line ##" comments.
I think you are getting the unoptimized version of the NBC code which contains a copy of the NXT headers, which are rather large. You might be using the wrong option. I'm getting the best results with -L, but I might have a different version of NBC since I don't have the -nbc option.
I think you are getting the unoptimized version of the NBC code which contains a copy of the NXT headers, which are rather large. You might be using the wrong option. I'm getting the best results with -L, but I might have a different version of NBC since I don't have the -nbc option.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: absoute position regulation from NBC
Code: Select all
inline void PosRegEnable(byte output, byte p = PID_3, byte i = PID_1, byte d = PID_1)
{
SetOutput(output,
OutputModeField, OUT_MODE_MOTORON+OUT_MODE_BRAKE+OUT_MODE_REGULATED,
RegModeField, OUT_REGMODE_POS,
RunStateField, OUT_RUNSTATE_RUNNING,
PowerField, 0,
TurnRatioField, 0,
RegPValueField, p, RegIValueField, i, RegDValueField, d,
UpdateFlagsField, UF_UPDATE_MODE+UF_UPDATE_SPEED+UF_UPDATE_PID_VALUES+UF_UPDATE_RESET_COUNT);
Wait(MS_2);
}
Code: Select all
inline void PosRegSetAngle(byte output, long angle)
{
SetOutput(output,
TachoLimitField, angle,
UpdateFlagsField, UF_UPDATE_TACHO_LIMIT);
}
Code: Select all
inline void PosRegAddAngle(byte output, long angle_add)
{
long current_angle = GetOutput(output, TachoLimitField);
SetOutput(output,
TachoLimitField, current_angle + angle_add,
UpdateFlagsField, UF_UPDATE_TACHO_LIMIT);
}
Code: Select all
inline void PosRegSetMax(byte output, byte max_speed, byte max_acceleration)
{
SetOutput(output,
MaxSpeedField, max_speed,
MaxAccelerationField, max_acceleration,
UpdateFlagsField, UF_UPDATE_PID_VALUES);
Wait(MS_2);
}
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 175
- Joined: 28 Dec 2011, 13:07
- Location: Gelderland, Netherlands
- Contact:
Re: absoute position regulation from NBC
Whehee, thanks.
-- Pepijn
http://studl.es Mindstorms Building Instructions
http://studl.es Mindstorms Building Instructions
Who is online
Users browsing this forum: Semrush [Bot] and 3 guests