View unanswered posts | View active topics It is currently Sat Sep 20, 2014 4:02 pm






Reply to topic  [ 2 posts ] 
Bitbanging Over SuperPro Board Too Slow 
Author Message
Rookie

Joined: Thu Feb 14, 2013 9:34 am
Posts: 1
Post Bitbanging Over SuperPro Board Too Slow
Hi all,

I am trying to use the SuperPro board to interface with the following sensor: http://www.parallax.com/StoreSearchResu ... fault.aspx , a breakout board for a part whose datasheet can be found here: http://pdf1.alldatasheet.com/datasheet- ... asheet.pdf .

I wrote up some very basic code to bitbang the reading of the sensor by toggling pins through Xander's third party RobotC library (code is attached at the bottom). This successfully reads from the sensor, but is too slow. The sensor is an op-amp integrator attached to a phototransistor, and the capacitors that hold the values for each integrator max out by the time the data is pulled.

What would be the best way to reduce overhead on the sensor reading?

One solution may be to use the square wave function of the DAC to toggle the CLK pin of the sensor much more quickly, but I don't think there is a way to check how many clocks have passed, which is necessary for knowing the state of the shift register.

Another solution may be to write SuperPro C code to read the sensor and and communicate the data to the NXT. This way, all the lower level reading would be done on the SuperPro MCU and there would be less overhead. However, it seems SuperPro C only works with NXC, and even then, I can't seem to find any documentation on it at all. Would such a method be reasonable and be compatible with RobotC?

I could also connect another microcontroller to the SuperPro board that interfaces with the sensor and communicates it to the board. This seems a bit convoluted, as I would have to send bidirectional serial data over the digital pins of the SuperPro board. I am also worried about power considerations with this method, as when I previously tried to attach a ATmega328P to the SuperPro, it browned-out due to insufficient current.

Thanks,
Hylian

RobotC Code Attached:

Code:
#pragma config(Sensor, S3,     HTSPB,          sensorI2CCustom)

#include "drivers/hitechnic-superpro.h"
task main()
{
   HTSPBsetupIO(HTSPB, 0x03);
   HTSPBsetSamplingTime(HTSPB, 1);
   char values[128];
   int max = 256;
   while(true)
   {
      HTSPBwriteIO(HTSPB, 0x01);
      HTSPBwriteIO(HTSPB, 0x03);
      HTSPBwriteIO(HTSPB, 0x02);
      HTSPBwriteIO(HTSPB, 0x00);
      for(int i = 0; i<128; i++)
      {
         HTSPBwriteIO(HTSPB,0x02);
         HTSPBwriteIO(HTSPB,0x00);
      }
      HTSPBwriteIO(HTSPB, 0x01);
      HTSPBwriteIO(HTSPB, 0x03);
      HTSPBwriteIO(HTSPB, 0x02);
      HTSPBwriteIO(HTSPB, 0x00);
      for(int i = 0; i<128; i++)
      {
         
         HTSPBwriteIO(HTSPB,0x02);
         values[i] = HTSPBreadADC(HTSPB, 1, 8);
         HTSPBwriteIO(HTSPB,0x00);
      }
      
      HTSPBwriteIO(HTSPB,0x02);
      HTSPBwriteIO(HTSPB,0x00);
      writeDebugStreamLine("");
      eraseDisplay();
      for(int i = 0; i<100; i++)
      {
         writeDebugStreamLine("%5u",values[i]);
         nxtDrawLine(i+1, 0, i+1, values[i+14]/4);
      }
   }
}


Thu Feb 14, 2013 9:37 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: Bitbanging Over SuperPro Board Too Slow
There is no way to shorten it through this way, so your next best bet would be to use the SuperPro C. There is a guide here: http://bricxcc.sourceforge.net/nbc/spcdoc/SPC_Guide.pdf
You can program it through BrixCC. I've only ever used it very briefly but it is quite nice.

= 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 Feb 15, 2013 11:52 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.