noob in need
Page 1 of 1

Author:  picaroon123 [ Tue Jan 29, 2013 5:26 pm ]
Post subject:  noob in need

Hello all.
I am new to RobotC, but have experience with NXT-G and arduino. Recently I tried to use a Mindstorms NXT with a HiTechnic component (HiTechnic DC motor controller and TETRIX motor), and met some trouble :| . I had set it up to run more HiTechnic controllers and to receive commands from a joystiq, here is the code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S2, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motor1,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motor2,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motor3,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motor4,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     motor5,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     motor6,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C2_1,     motor7,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C2_2,     motor8,        tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

long map(long x, long in_min, long in_max, long out_min, long out_max)
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

int a = joystick.joy1_y1;
int b = joystick.joy1_y2;
int c = joystick.joy1_x1;
int d = joystick.joy1_x2;
int e = joystick.joy1_Buttons;

int mVal1 = map (a, -123, 123, -25, 25);
int mVal2 = map (b, -123, 123, -25, 25);
int mVal3 = map (c, -123, 123, -25, 25);
int mVal4 = map (d, -123, 123, -25, 25);

task main()

   motor[motor1] = 100;\
   motor[motor2] = 100;
   motor[motor3] = 100;
   motor[motorF] =100;


In the way of hardware, I provided 6v of power to the HiTechnic Controller, attached motors to both the Motor1 and 2 channels, and of course a cord from the HiTechnic controller to the NXT by way of port A. I wouldn't be surprised if I have more than a few mistakes to clean up, but I can't find any helpful online guides. Thanks for the help! :mrgreen:

Author:  picaroon123 [ Tue Jan 29, 2013 5:43 pm ]
Post subject:  Re: noob in need

I now see I need some drivers! Woops!

Author:  JohnWatson [ Tue Jan 29, 2013 6:20 pm ]
Post subject:  Re: noob in need

There are a couple of issues I am seeing with the setup. First, the HiTechnic Motor Controller is designed for 12 volt motors and needs a +9 to +15 volt DC power source (usually a battery) in order to work properly; 6 volts may be enough to power the LED's but it will probably cause unexpected results with the motors. It looks like you have the motor controllers set up on Sensor Port 1, but have physically connected the NXT to the controller via Motor Port A; you will need to use Sensor Port 1 to connect to the Motor Controller.

I would suggest taking a look through ourVideo Trainer Curriculum for NXT/TETRIX; it will walk you through, step by step, on how to set up and program a TETRIX robot. I would also suggest taking a look through ourTETRIX page on the ROBOTC wiki, which has information on the commands and functions used to setup and control the HiTechnic Motor and Servo controllers via ROBOTC.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group