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

EV3 with HiTechnic SuperPro using RC4.28B w driversuite 3.3
http://robotc.net/forums/viewtopic.php?f=1&t=10470
Page 1 of 1

Author:  OliviliK [ Wed Feb 04, 2015 11:45 pm ]
Post subject:  EV3 with HiTechnic SuperPro using RC4.28B w driversuite 3.3

I am new FTC coach and new user of RobotC, but quite experienced in MCU control in general. I had difficulties to get the HTSPB examples in the driversuite to work. After some trials and errors, everything is working OK.

The solution was to
  • View-> Preferences > Detailed Preferences ..., Compiler Tab, Include Directories Tab
    Set include directory path to
    E:\My Projects\Robotics\RobotC\robotcdriversuite-master\include\
    Note: The "drivers" is not part of the path name in the downloaded driversuite
  • Change the #include "drivers/HTSPB-driver.h" into #include "hitechnic-superpro.h"
  • Change the configuration pragma
    from #pragma config(Sensor, S1, HTSPB, sensorI2CCustom9V)
    to #pragma config(Sensor, S1, HTSPB, sensorEV3_GenericI2C)
  • Change the display commands
    from nxtDisplayTextLine
    to displayString

For example the HTSPB-exp2.c in the driversuite is (and as such not working with EV3)
Code:
#pragma config(Sensor, S1,     HTSPB,                sensorI2CCustom9V)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*   HiTechnic Experimenter's Kit for the SuperPro

Experiment - 2 Six LEDs and a Potentiometer

This program reads the analog value of a potentiometer and outputs a
digital value to one of six LEDs.

*/

#include "drivers/HTSPB-driver.h"

task main() {
  int inputdata;
  ubyte outputdata;
  int bit;

  // Set B0 as output
  HTSPBsetupIO(HTSPB, 0x1);

  while(true) {
    // Read a 10bit wide analogue value from A0
    inputdata = HTSPBreadADC(HTSPB, 0, 10);

    nxtDisplayTextLine(1, "A0: %d", inputdata);

    // Set the output bit based on the analogue input value
    bit = (inputdata/128);
    if (bit > 5) bit = 5;
    outputdata = 1 << bit;

    HTSPBwriteIO(HTSPB, outputdata);
    wait1Msec(50);
  }
}


After the modifications, the following code works with EV3.
Code:
#pragma config(Sensor, S1,     HTSPB,          sensorEV3_GenericI2C)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*   HiTechnic Experimenter's Kit for the SuperPro

Experiment - 2 Six LEDs and a Potentiometer

This program reads the analog value of a potentiometer and outputs a
digital value to one of six LEDs.

*/

#include "hitechnic-superpro.h"

task main() {
  int inputdata;
  ubyte outputdata;
  int bit;

  // Set B0 as output
  HTSPBsetupIO(HTSPB, 0x1);

  while(true) {
    // Read a 10bit wide analogue value from A0
    inputdata = HTSPBreadADC(HTSPB, 0, 10);

    displayString(1, "A0: %d", inputdata);

    // Set the output bit based on the analogue input value
    bit = (inputdata/128);
    if (bit > 5) bit = 5;
    outputdata = 1 << bit;

    HTSPBwriteIO(HTSPB, outputdata);
    wait1Msec(50);
  }
}


Cheers, Ollie

Author:  mightor [ Thu Feb 05, 2015 1:50 am ]
Post subject:  Re: EV3 with HiTechnic SuperPro using RC4.28B w driversuite

The 9V pin on the I2C port is currently not trivial to enable. Setting the sensor port to sensorI2CCustom9V does not work and sensorEV3_GenericI2C does not enable that pin. I'll post a work-around on my blog in the next couple of days.

Also, you should not be using that particular version of the driver suite with ROBOTC 4.x, rather the one in Github, which you can download here: https://github.com/botbench/robotcdriversuite

= Xander

Author:  OliviliK [ Thu Feb 05, 2015 2:45 pm ]
Post subject:  Re: EV3 with HiTechnic SuperPro using RC4.28B w driversuite

Mightor,

Thanks for a rapid and relevant response. I did use the driver suite from your Github account. It could be obvious for the seasoned RobotC developers where to get the "3rd party" include files, but the instructions in RobotC web site are not quite clear about that.

I am looking forward for the work-around instructions in your blog. Could the similar ideas be used to get the Tetrix motor/servo controllers to be connected to EV3?

Best Regards, Ollie

Author:  mightor [ Thu Feb 05, 2015 2:56 pm ]
Post subject:  Re: EV3 with HiTechnic SuperPro using RC4.28B w driversuite

The work-around is for sensors that require 9V on pin1, not a motor controller :)

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