| | | | | | | |
 [] Hardware    - NXT    - Tetrix    - RCXLabVIEW Education EditionLEGO MINDSTORMS NXT-G SoftwareROBOLAB SoftwareSensorsTeaching Resources
Is it possible to use trigonometric functions (ie sin cos tan and so on) with ROBOLAB 2.9?
 19th of April, 2010
 (2 ) 50% 50%

Yes, it is definitely possible to use sin, cos, tan, and many other functions in ROBOLAB 2.9 with the RCX.

Use the 'Evaluate Expression' block, found in the 'Container' menu in ROBOLAB 2.9. The 'Evaluate Expression' icon allows you to evaluate formulas, declare floating point variables, and perform floating point math. Just input your function (for example, sin(x) ) and the block will do the math for you.

The following can be used with this block, including trig and inverse trig as described below:

Possible operands are:
subtraction: -
multiplication: *
division: /
modulus: %         [eg. 3 % 2 = 1]
bitwise AND: &   [eg. 7 & 5 = 5]
bitwise OR: |       [eg. 5 | 2 = 7 ]

variable type: int, long, float    [eg. float test]
Parentheses: ()   [eg. 5+(red*2)/abs(sqrt(yellow/5.0))]
... note the 5.0 will make sure all math is done with floating point

Possible functions are:
trigonometric (all in radians): sin, cos, asin, acos, atan   [eg. sin (1.57)=1]
standard: abs, sqrt, sgn      [eg. sgn(-2) = -1]
logarithmic: ln10, ln, exp

Predefined variables:
containers: red, blue, yellow, c1, c2, c3,..,c48 (or C1..C32)
loop count down iterators: Loop_i, Loop_j, Loop_k (counts from n-1 to 0)
Motor Encoders: e1, e2, e3 (correspond to Motor A, B, C)
random number: r  [eg. r8 gives you a random number between 0 and 8 .. max value is 255]
sensors: s1, s2, s3, s4 (or S1,..S4 or Sensor1..Sensor4)
raw sensor value: SensorRaw1..SensorRaw4
100 msec Timers: T1, T2, T3, T4 (or Timer100ms1..Timer100ms4, or t1..t4))
10msec Timers: Timer10ms1..Timer10ms4
1msec Timers: Timer1ms1... Timer1ms4
System Time (Time since on): SystemTime
Current motor state: MotorStatus1..MotorStatus3 (0=idle, 1=hold, 16=Ramp Up, 32=Running, 64=Ramp Down)
mail (RCX only): m
clock (RCX only): w

kw
 : : * : * :

© 2013 Center for Engineering Educational Outreach, Tufts University