View unanswered posts | View active topics It is currently Sat Jun 23, 2018 11:46 pm

Reply to topic  [ 5 posts ] 
force sensor on mux 
Author Message

Joined: Tue Jul 17, 2012 8:11 pm
Posts: 20
Post force sensor on mux
ok so my force sensor is in the sensor mux since it is supported by xander since i can see an example of it in 3.2. however the only value that returns out of the force sensor is 1021 constantly no matter how much force i put on the sensor which is an odd # that im not sure where it is coming from. i used ur example structure. any ideas?
this number came out from the debug stream as the value for _force, and i set _force = HTFreadSensor(HTFORCE); in a while loop. and HTFORCE is set as a const tMUXSensor HTFORCE = msensor_S3_4; at the top. any problems with this or is there something i have to do?

Fri Jan 04, 2013 1:33 am

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: force sensor on mux
It would help if you pasted in your RobotC program in between [code] and [/code] tags.

Fri Jan 04, 2013 2:10 am

Joined: Tue Jul 17, 2012 8:11 pm
Posts: 20
Post Re: force sensor on mux
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  HTMotor)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     HTTMUX,         sensorAnalogInactive)
#pragma config(Sensor, S3,     HTSMUX,         sensorI2CCustom)
#pragma config(Sensor, S4,     HTCOLOR,        sensorCOLORFULL)
#pragma config(Motor,  mtr_S1_C1_1,     rightDrive,    tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     leftDrive,     tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     liftLeft,      tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     liftRight,     tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C4_1,     arm,           tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C4_2,     motorI,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C3_1,    rightGate,            tServoStandard)
#pragma config(Servo,  srvo_S1_C3_2,    leftGate,             tServoStandard)
#pragma config(Servo,  srvo_S1_C3_3,    wrist,                tServoStandard)
#pragma config(Servo,  srvo_S1_C3_4,    pusher,               tServoStandard)
#pragma config(Servo,  srvo_S1_C3_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C3_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//////////                                                                                                    //////////
//////////                                       OUR AMAZING TELEOP CODE                                      //////////
//////////                                   BY: Iman Nandi and Frank Zhou                                    //////////
//////////                                                                                                    //////////
//#include "LEGOLS-driver.h"
#include "JoystickDriver.c"  //Include file to "handle" the Bluetooth messages.
#include "drivers/common.h"
#include "drivers/hitechnic-touchmux.h"
#include "drivers/hitechnic-sensormux.h"
#include "hitechnic-colour-v2.h"
#include "drivers/lego-light.h"
#include "drivers/hitechnic-force.h"

const tMUXSensor LEGOLS = msensor_S3_1;
const tMUXSensor HTFORCE = msensor_S3_4;

void initializeRobot() //initialize the robot
   alive(); //calibrate();
   servo(leftGate) = 0; // set the servo controlled ring gates to 0
   servo(rightGate) = 255;
   nMotorEncoder[rightDrive] = 0;//reset the value of encoder B to zero
   nMotorEncoder[leftDrive] = 0;
task main()
int _force = 0;
while (true)//the while loop of teleop

      getJoystickSettings(joystick);//get the layout of the joystick for programming the correct joystick model
      _force = HTFreadSensor(HTFORCE);
                 writeDebugStreamLine("force: %d", HTFreadSensor(HTFORCE));
      //writeDebugStreamLine("forcev: %d", SensorValue(HTFORCE));
              if (50 >= _force > 45)
         heavyRing = true;
         int force = _force;
         nxtDisplayCenteredTextLine(3,"%d, %d","true",force);
      else if (_force > 50 || 45 >= _force)
         heavyRing = false;
      if(_force > 50)
         twoHeavyRings = true;
      else if(50 >= _force)
         twoHeavyRings = false;
if(heavyRing == true)
         SensorType[HTCOLOR] = sensorCOLORRED;
      else if(twoHeavyRings == true)
         SensorType[HTCOLOR] = sensorCOLORBLUE;
         SensorType[HTCOLOR] = sensorCOLORNONE;

just the parts with _force and HTFORCE involved are what you are looking at this is only part of my teleop which is all u need to see for my problem. the values set for my force ranges in the teleop were the numbers that came out before i plugged into a sensor MUX. it was originally in port 4 of the nxt.

Fri Jan 04, 2013 6:57 am
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: force sensor on mux
Are you using ROBOTC 3.55B2? If not, upgrade, there are many issues in 3.54 that have to do with casting from ubyte to int, which affect the drivers.

= Xander

| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Fri Jan 04, 2013 7:11 am
Profile WWW

Joined: Tue Jul 17, 2012 8:11 pm
Posts: 20
Post Re: force sensor on mux
i am but i can check it to see if it works when i have a meeting today.

Fri Jan 04, 2013 8:36 am
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.