View unanswered posts | View active topics It is currently Thu Jul 31, 2014 3:30 am






Reply to topic  [ 2 posts ] 
HiTechnic Prototype board 
Author Message
Rookie

Joined: Sat Dec 19, 2009 5:46 am
Posts: 22
Post 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


Sat Jun 19, 2010 5:59 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post 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

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


Sat Jun 19, 2010 12:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.