Skip to content

Panopticon Tower With Sharp Sensor

January 23, 2015

15-01-23 panopticon car15-01-23 panopticon 2 15-01-23 panopticon 1

After most of a day’s soldering I have the sharp short range IR sensor mounted facing forward on the carbot. The ultrasonic sensor is also there for calibration. The MCP3002 analog-digital-converter chip is mounted on the main driver board and wired to the SPI signals back to the olduino.

I buzzed all the connections and plugged it in, to my delight it worked right off. I ran a little program in the olduino to compare the two sensors. It had the code from my earlier experiments with the sharp long range sensor so it is reading the sharp sensor twice and taking the lower reading – looking at these values i don’t think that will be necessary with this sensor. It’s fairly sensitive in the 12″(30 cm) distance range that I use to trigger a turn which is good too. At 13″ from the bumper it’s reading 160(.775V) which grows to 200(1V) at 10″. The noise in the sensor reading is only a few mv, unlike the long range sensor.

15-01-23 panopticon 3

15-01-23 sharpy sez

//14-11-20 sharpping.c drive the sharp 2Y0A02 ir distance sensor
#include <nstdlib.h> //for printf etc.
#include <cpu1802spd4port7.h> //4mhz 1802 with host on port 7
#include <olduino.h> //for digitalRead, digitalWrite, delay
#include <hspi2.h> //hardware spi header
#include "..\carbot\pingBN.h"
unsigned int sharpy(){
	asm("	dec	sp\n" //make a work area
		"	sex 3\n"	//set x to pc
		"	out 6\n	db 0x68\n"	//send 68 to read channel 0
		"	sex sp\n	inp 6\n" //pick up top bits
		"	ani 3\n	phi 15\n"	//put bits 8&9 of result into return register

		"	sex 3\n"	//set x to pc
		"	out 6\n	db 0xAA\n"	//send pattern to read low bits
		"	sex sp\n	inp 6\n	plo 15\n" //pick up low bits to return register
		"	inc	sp\n"	//restore stack pointer
		"	cretn\n");	//actual return
	return 0;	//dummy return for compiler
}
void main(){// exercise the sharp sensor
unsigned char c00,c01,c10,c11;
unsigned int tenbits,nextbits, thebits,dist;
float voltage,v2;
	//printf("Sharp Mule here\n");
	out(4,0x80); PIN4=0x80; //make sure slave select is high

	while(1){
		delay(500);
		digitalWrite(7,LOW); //lower slave select
		tenbits=sharpy();
		digitalWrite(7,HIGH); //raise slave select
		digitalWrite(7,LOW); //lower slave select
		nextbits=sharpy();
		digitalWrite(7,HIGH); //raise slave select
		thebits=min(tenbits,nextbits);
		voltage=(float)thebits/1024.0*5.0;
		dist=pingq();
		printf("@%d,\t Sharpy sez %d %d %f Volts\n",dist,tenbits, nextbits,voltage);

	}
}
#include "olduino.c" //pick up revised delay
#include <nstdlib.c>
#include <hspi2.c>
#include "..\carbot\pingBN.c"
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: