Trig functions in NXT-G

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Trig functions in NXT-G

Post by afanofosc »

New blocks often are written to encapsulate a specific task, such as reading values from I2C sensors made by HiTechnic or Mindsensors.com. A number of custom blocks that you can install into the LEGO MINDSTORMS NXT software provide things like cos, sin, sqrt, etc... They don't call a new opcode or system call. They use existing opcodes and system calls to do multiple things that by wrapping in a convenient package can be easily reused. So the cos block mentioned earlier in this thread uses an algorithm to approximate the value of cosine for whatever input you wire into the block. If the firmware had a native cos opcode and the NXT-G compiler could dynamically generate the right output for new opcodes it would be possible to write an NXT-G block that just emitted something like "cos out, angle" which would write cos(angle) to the provided output variable.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

Re: Trig functions in NXT-G

Post by schodet »

Writing NXT-G blocks is still a mystery for me. How is it done?

There should be a way to make a really ugly hack to give NXT-G more access to new firmware, one of the ugliest would be to use a specific I2C address to talk to the firmware, but I am sure (read: I hope) there is cleaner ways.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests