View unanswered posts | View active topics It is currently Sat Nov 22, 2014 11:32 am






Reply to topic  [ 3 posts ] 
noob in need 
Author Message
Rookie

Joined: Tue Jan 29, 2013 5:17 pm
Posts: 5
Post 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:
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()
{
   while(true)
   {
      getJoystickSettings(joystick);

   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:


Tue Jan 29, 2013 5:26 pm
Profile
Rookie

Joined: Tue Jan 29, 2013 5:17 pm
Posts: 5
Post Re: noob in need
I now see I need some drivers! Woops!


Tue Jan 29, 2013 5:43 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 609
Post 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.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Jan 29, 2013 6:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.