ROBOTC.net forums
http://www.robotc.net/forums/

HiTechnic Prototype board
http://www.robotc.net/forums/viewtopic.php?f=41&t=2428
Page 1 of 1

Author:  DRV47 [ Sat Jun 19, 2010 5:59 am ]
Post subject:  HiTechnic Prototype board

Hi,

I've just started using the HiTechnic Prototype board. I am using mightor's 3rd-party drivers and I've not been able to understand one thing: how to read the B inputs.

This is HTPB-exp7.c, the code for the 7th experiment of the HiTechnic Experimenters Kit A (magnetic sensor connected to B0 and LED to B4):

Code:
#include "drivers/common.h"
#include "drivers/HTPB-driver.h"

task main() {
  // The data to be written: 0x10 = 010000 binary,
  // makes B4 digital port an output.
  HTPBsetupIO(HTPB, 0x10);

  while(true) {
    if(HTPBreadIO(HTPB, 0xF3) == 0) {
      eraseDisplay();
      nxtDisplayTextLine(1, "Magnet present");
      HTPBwriteIO(HTPB, 0x10);
    } else {
      eraseDisplay();
      nxtDisplayTextLine(1, "Magnet absent");
      HTPBwriteIO(HTPB, 0x00);
    }
    wait1Msec(50);
  }
}


Here the mask used to read is 0xF3. Why is that? (bin 11110011 does not seem logical to me...) This code doesn't work for me by the way: it only works when I use 0x01 as the mask.

Could anybody explain what mask is to be used to read any B input? Is it possible to read simultaneously two or more inputs, or a combination of outputs (i.e if I want to check that B0, and B1 are true and B3, and B4 are false ignoring B5)?

Thanks in advance,

David

Author:  mightor [ Sat Jun 19, 2010 12:31 pm ]
Post subject:  Re: HiTechnic Prototype board

DRV47,

It's been a while since I wrote those programs. It does seem a little odd to use 0xF3 as a value for that. I'll look into it. If your magnet is connected to B0 then 0x01 is indeed the correct mask.

- Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/