View unanswered posts | View active topics It is currently Wed Aug 05, 2020 9:31 am






Reply to topic  [ 1 post ] 
Mindsensors Motor Multiplexer 
Author Message
Novice

Joined: Sun Jun 13, 2010 9:26 am
Posts: 58
Post Mindsensors Motor Multiplexer
Hello:

I have so far managed to connect and control the 2 NXT motors connected to the Mindsensors Motor Multiplexer. What I cannot seem to figure out is how to access the I2C sensor (ultrasonic sensor or the HiTechnic compass sensor). Currently both sensors are connected to the NXT, but eventually I will need one of those ports for other sensors. What code do I use to set that up and how do I read the sensor when I need to?

Code:
#pragma config(Sensor, S1,     MSMMUX,              sensorI2CCustom)
#pragma config(Sensor, S2,     USSensor,            sensorSONAR)
#pragma config(Sensor, S3,     HTCompass,           sensorI2CHiTechnicCompass)
#pragma config(Motor,  motorA,          RightMotor,    tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorC,          LeftMotor,     tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/common.h"
#include "drivers/HTMC-driver.h"
#include "drivers/MSMMUX-driver.h"

void Drive_Forward (int speed1, int speed2, int time) //set direction and speed of the 2 drive motors
{
  MSMMUXinit();
  motor[motorA] = speed1;
  motor[motorC] = speed2;
  MSMMotor(mmotor_S1_1, speed2);
  MSMMotor(mmotor_S1_2, speed1);
  wait1Msec(time);
  MSMotorStop(mmotor_S1_1);
  MSMotorStop(mmotor_S1_2);

//  MSMMotorSetTimeTarget(mmotor_S1_1, time);
//  MSMMotorSetTimeTarget(mmotor_S1_2, time);
}


task main() {

  while (true) {
    if (SensorValue(USSensor) > 30) {
      Drive_Forward(25, 25, 500);
    }
    else {
      Drive_Forward(-25, -25, 1000);
      Drive_Forward(-25, 25, 1000);
    }
  }

}


Mike,


Thu Apr 07, 2011 10:41 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.