New from HiTechnic: a Barometric Sensor (via I’d Rather Be Building Robots)

17 07 2011

About to board, so I don’t have time to write up a post, so here’s a reblog of Xander’s post at I’d Rather Be Building Robots:

New from HiTechnic: a Barometric Sensor HiTechnic have released a new sensor: a barometric sensor that can also measure temperature! If you ever wanted to make your own weather station, then this is perfect for the job! It measures the pressure in 1/1000th of an inch of Mercury, which can easily be converted other units like Pascal and PSI. The temperature is measured in 1/10th degrees Celcius. I already have a driver and test program for it and I’ll be sure to release it very shortly … Read More

via I’d Rather Be Building Robots





RobotC: Precise Motor Positioning Tool

27 05 2011

UPDATE: Download this program w/ setup, usage instructions and a demo here; get the driver (optional) here.

Programming my current project, Bionic NXTPod 3.0, I broke the actuators a few times by having the slide run into either the top or bottom. This was caused by my motor control: every time it went up or down, the encoders were reset, not considering whether or not the motor was exactly on target. As the errors built up, the actuators were torn down.

Looking for a solution, I saw HiTechnic‘s motor PID block – for NXT-G – which lets the motor move to an absolute encoder position, without resetting in between. Using this method, the error – usually not more than 2-3 degrees – is eliminated every time the motor moves to a new position, because the block compares the desired position to the actual position, not the assumed “0 point”. For example:

  • The motor needs to go to 200 degrees and then back to 100
  • The program starts, and the motor overshoots to 201 degrees
  • Without the HiTechnic block: the motor would move back 100 degrees – because it thinks it’s at exactly 200 degrees – ending up at 101
  • With the HiTechnic block: the motor would move back 101 degrees (201-100) ending up at 100
But, since the block’s for NXT-G, that wouldn’t work for me. So, I made a similar (but not quite as versatile) RobotC function:

void PositionMotor(char motorToTurn, int absoluteDegrees){
  if(nMotorEncoder[motorToTurn] == absoluteDegrees){}
  else if(nMotorEncoder[motorToTurn] < absoluteDegrees){
    bMotorReflected[motorToTurn] = false;
    nMotorEncoderTarget[motorToTurn] = absoluteDegrees-nMotorEncoder[motorToTurn];
    motor[motorToTurn] = 75;
    while(nMotorRunState[motorToTurn] != runStateIdle){}
    motor[motorToTurn] = 0;
  }
  else{
    bMotorReflected[motorToTurn] = false;
    nMotorEncoderTarget[motorToTurn] = nMotorEncoder[motorToTurn]-absoluteDegrees;
    bMotorReflected[motorToTurn] = true;
    motor[motorToTurn] = 75;
    while(nMotorRunState[motorToTurn] != runStateIdle){}
    motor[motorToTurn] = 0;
  }
}

All you do is input the motor you want to move – like “motorA” or “motorC” – and the amount of degrees, measured from your “0 position” (by default, this is the position your motor is in when the program starts), and it does all the work for you.




HiTechnic Experimenter’s kit I2C output addresses

2 05 2011

I couldn’t find all of these addresses anywhere, so I tested them to see what pins (B0 – B5) they’d turn on. A white box means that that address is turned on, and a black box means it’s off. Thanks to Xander and bullestock for helping me complete this list:

The following image cannot be displayed: I2C output addresses on HiTechnic Experimenters Kit





Putting the HiTechnic Magnetic Field Sensor to the Test

20 01 2011

Since I received my HiTechnic magnetic field sensor, I’ve always wanted to put it to the test. In this post, I’ll discuss the sensor’s response time and it’s precision, to see if it can be used as angle sensor. These tests were inspired by a comment on mightor’s blog by Sparra Mc.

First, let’s look at the time it takes for the sensor to update its reading. The main part of the testing program is a 10-seconds loop with about four commands and no waiting, so the program runs through it thousands of times. The magnetic field sensor value is taken at the beginning of the loop, and then compared to the previous value. If the values are the same, nothing happens and the loop restarts. If they’re different, though, a variable holding the total amount of readings is increased by one. After the loop ends, this variable is divided by ten to get the readings per second. The experiment was repeated 25 times. These are the results:

HiTechnic Magnetic Sensor Readings per Second bar graphThese values average to about 325 readings per second, which is even more than HiTechnic specify of their website! So, the HiTechnic magnetic field sensor updates about every 3 mSecs.

Even though a low update time is important, precision matters, too. My second and last experiment focused on that. The program it runs on makes the motor (with magnet attached to it – the magnet was positioned to give the maximum possible value at the experiment’s start) run slowly, while taking a magnetic field reading every ten encoder ticks. That resulted in a total of 36 readings. The below graph shows those readings vs. the position (in degrees) the motor was in.

Motor Encoder vs Magnetic Field Sensor Value line graphThese values look precise enough, and, if the magnet was horizontal in the beginning (to give a 0 value), one could use it as a rotation sensor. The only problem being that the value gets negative, which might be confusing to program.

Overall, I think the HiTechnic magnetic field sensor is great and performs awesomely. With its precision it could be used for almost anything, including for (some suggestions from around the web):

  • distance measurement
  • communication
  • angle measurement
  • in-floor beacons for decision making
  • much more!

So, to anyone reading this, I would STRONGLY recommend buying the HiTechnic magnetic field sensor! More info:





Magnetic Field Sensor Grapher

16 01 2011

This program graphs magnetic field sensor values, keeping track of the maximum read value. The graph remembers 100 past values, which move to the left whenever there’s a new value (each 20 milliseconds), after which they’re forgotten. So, the graph shows values of up to two seconds ago. Furthermore, the scale of the graph is adjustable (by turning motor A), so it can adapt to different kinds of magnets. Here’s some screenshots (taken in RobotC  NXT remote screen):

Starting ScreenRegular graphingLess precise, bigger range graphingMore precise, smaller range graphing

The graphing program can easily be adjusted to work with different sensors including light, sound, touch and ultrasound.

More info:





NXT communication using HiTechnic Magnetic Field Sensor

26 12 2010

A few days ago, the HiTechnic Magnetic field sensor arrived at my doorstep. Ever since, I was thinking about what to use it for, and this is the result: an automatic binary encoder, sender, receiver and decoder used to synchronize two NXT motors. The video below shows the procedure:

HiTechnic Magnetic SensorSo, the robot starts by setting the bias for the magnetic sensor before it’s near the magnet. Once the user adjusts the red stick to an acceptable angle (between 0 and 255 degrees – program is paused if angle is wrong) for the motors to sync to, that angle is translated into an eight-bit binary code. Then, the third motor compares its own position to the way it’s supposed to be – if a bit (boolean variable) is true, the black stud has to be up (0 degrees), and when the bit is false, the red stud has to be up (180 degrees). If necessary, the motor adjusts the position. At the same time, the magnetic field sensor “reads” the magnet, getting either a positive or negative number. If the received number is positive, it makes a bit true; if it’s negative, it makes that same bit false. Once it has all eight bits, it translates it back into a target for the other motor to go to, thus synchronizing the motors. At the very end, the third motor checks its position and makes sure it ends up having the black pin (north of the magnet) up.

More information:

Thanks to:

  • Mightor for creating both a driver and example program for the magnetic field sensor
  • HiTechnic for creating the magnetic field sensor




Remote Control using HTIRL

17 10 2010

I just finished my 2nd experiment with the HiTechnic IR Link, which is used to control PF motors through IR signals. The setup is pretty simple:

The four power functions are controlled using the remote control (obviously). It starts of by telling the user to set the NXT servo to the default angle using a simple illustration. When it’s in the right position, the user simply clicks the button and starts controlling the PF motors. The remote switches between motor 1-4 when the NXT servo is turned ninety degrees in either direction, displaying the active motor’s number on the screen. Then, when the button is pressed, that motor will run until the sensor is released, looping forever. I want to thank mightor , Gary Samad and ivanseidel for helping me out with the programming for this!

Wanna know more about the remote control? Check out the following post(s):








Follow

Get every new post delivered to your Inbox.

Join 34 other followers