View unanswered posts | View active topics It is currently Mon Oct 19, 2020 11:40 pm






Reply to topic  [ 4 posts ] 
SMUX Issues 
Author Message
Rookie

Joined: Tue Nov 25, 2014 6:05 pm
Posts: 2
Post SMUX Issues
Hello. I'm having issues with the SMUX. I wrote a simple program that shows the value of three sensors on the nxt display. I was just using this to check that the SMUX was returning values to the nxt. I previously wrote a program that showed 2 sensor values. This program worked just fine. However, now neither program will work. I made no adjustments to the code. The SMUX battery is charged and every thing is plugged in properly. The program is below.
Code:
#pragma config(Sensor, S3,     SMUX,           sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//



#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.x\Sample Programs\NXT\3rd Party Driver Library\include\hitechnic-sensormux.h"
#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.x\Sample Programs\NXT\3rd Party Driver Library\include\hitechnic-irseeker-v2.h"
#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.x\Sample Programs\NXT\3rd Party Driver Library\include\lego-ultrasound.h"
#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.x\Sample Programs\NXT\3rd Party Driver Library\include\hitechnic-gyro.h"
// ir in SMUX port 1
// sonar in SMUX port 2
// gyro in SMUX port 3
#define irSeeker msensor_S3_1
#define Sonar msensor_S3_2
#define GYRO msensor_S3_3

// Global Variables
float currHeading = 0;
int BeaconDir = 0;
int SonarDist = 0;

task getHeading () { // get gyroscope heading
   float delTime = 0;
   float prevHeading = 0;
   float curRate = 0;

   HTGYROstartCal(GYRO);
   playSound(soundBeepBeep);
   while (true) {
      time1[T1] = 0;
      curRate = HTGYROreadRot(GYRO);
      if (abs(curRate) > 3) {
         prevHeading = currHeading;
         currHeading = prevHeading + curRate * delTime;
         if (currHeading > 360) currHeading -= 360;
         else if (currHeading < 0) currHeading += 360;
      }
      wait1Msec(5);
      delTime = ((float)time1[T1]) / 1000;
      //delTime /= 1000;
   }
}
task SensorValues(){// updates sensor values
   tHTIRS2 irSeeker;
   while (true){
      readSensor(&irSeeker);
      SonarDist = USreadDist(Sonar);
      BeaconDir = irSeeker.acDirection;
   }
}

task main()
{
   wait1Msec(2000);
   startTask(getHeading);
   startTask(SensorValues);
  wait1Msec(2000);
   tHTIRS2 irSeeker;
   readSensor(&irSeeker);

   while (true){
      SonarDist = USreadDist(Sonar);
     BeaconDir = irSeeker.acDirection;
      displayCenteredBigTextLine(1, "%d", currHeading);
      displayCenteredBigTextLine(3, "%d", SonarDist);
      displayCenteredBigTextLine(5, "%d", BeaconDir);
   }
}


When I try to run the program, I get this:"ERROR, You have not setup the sensor port correctly.
Please refer to one of the examples." Does anyone have any advice on the program? Any general help on the SMUX would be appreciated.


Tue Nov 25, 2014 7:26 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: SMUX Issues
Is this on an NXT or EV3?

= 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]


Wed Nov 26, 2014 12:44 am
Profile WWW
Rookie

Joined: Tue Nov 25, 2014 6:05 pm
Posts: 2
Post Re: SMUX Issues
It's on a NXT.


Wed Nov 26, 2014 4:46 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: SMUX Issues
You cannot read the sensors from multiple tasks at once, it will lead to deadlock situations.
Also, which version of ROBOTC are you using?

= 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 Nov 28, 2014 2:33 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.