
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); } } }
|  |
 |  |  |