Let's Make Robots!

LDR Cyclops - holding, scanning, seeking, recalling

Continuation from here.

Video straight from the camera to Youtube (Sorry Oddbot).

scans.gif

 Continued here.

AttachmentSize
ldr_eye_telescope_scanning.bas3.38 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Since someone asked about perl and serial communications, I tried the perl module designed to talk serial.

Here's the code that would receive characters from the Picaxe and then print them on the screen. Ad infinitum. Or rather ad CTRL-C.

#!/usr/bin/perl -w

# essential steps to get these modules to work
# start Perl Package Manager (click from the windows start menu)
# or be hardcore and run ppm-shell and type commands from the ppm> prompt
#  add repository http://www.bribes.org/perl/ppm/ (Options menu)
#   ppm> rep add bribes http://www.bribes.org/perl/ppm/
#  install modules Win32, Win32-API, Win32-SerialPort (search and click)
#   ppm> i Win32
#   ppm> i Win32-API
#   ppm> i Win32-SerialPort
#  quit ppm (you know: ctrl-alt-del and stuff)
#   ppm> q
# enjoy

use Win32;
require 5.003;
use Win32::SerialPort qw( :PARAM :STAT 0.19 );

my $PortName = "com1";

$PortObj = new Win32::SerialPort ($PortName) || die "Can't open $PortName: $^E\n";

$PortObj->baudrate(4800);
$PortObj->parity("none");
$PortObj->databits(8);
$PortObj->stopbits(1);
$PortObj->write_settings || undef $PortObj;

my $Configuration_File_Name = 'D:\data\perlcode\SerialPort_settings.txt';
$PortObj->save($Configuration_File_Name) || warn "Can't save $Configuration_File_Name: $^E\n";

while (1) {
   my $char = $PortObj->lookfor();
   print $char;
}

undef $PortObj;

Now the real data logging can begin!

 
 

ldr_scope_compare1_0.gif

[edit: corrected superimposed photo of window, it's now flipped left to right, as the scan would track]

..the ideas just keep on coming in. I am totally stealing the idea of a multi posistion switch for diferent modes! Great idea. I just checked Radio Shack and they have a 6 position rotary switch for just 3 bucks. Now all I gotta do is figure out some resistor values so I can use all 6 posistions on one ADC channel. Good stuff, great post.

Not counting your V+ and GND, you would only need to run a single wire to your switch. I am running a flat cable that brings a total of 16 pins from the picaxe board.

Resistor values: pick a low current, say 1 mA. At 5 V that would require a total R of 5 kOhm. Just put a resistor between the legs of the 6 position switch, 1 kOhm each. Each step of the switch is now coded as an additional 1/5 of V+ : 0/5, 1/5, 2/5, 3/5, 4/5, 5/5.

But how about easy coding? Could we make each voltage step 1/8? That would make reading the ADC value a lot easier. Instead of six if/thens, you would just read the first three (most magnificant) bits of the byte. Choose eight resistors of 625 Ohm, put one before the series and two in the back, whatever. Just make sure to use them all.

Off course, 625 Ohm is just as arbitrary as the choice for 1 mA. Go nuts on the numbers. Except on the number eight. That number is just too beautiful to ignore. Maybe even buy a different switch?

In order to divide a voltage eight ways, you only need seven resistors. Just wanted to get that off my chest/shoulder.

Either way: Many resistors in series that form a not-so-continuous voltage divider? That sounds a lot like a potentiometer! Except that a pot is fully continuous. But there are mechanical ways to remedy that. Polymorph anyone?!

The question is can you write more than one byte to one single address? The picaxe manual says that a word will be broken into 2 bytes and stored at address x and address x+1.

The question is... Why can't I write this:

Write address, byte1, byte2, byte3, byte4 etc.

-or-

write address, word1,word2,word3 etc...

I just don't get it rik! I read the same about the word thing that confused me... If indeed there is a one byte per address limit, why did they write the command like this?

WRITE location,data ,data, WORD wordvariable...

Data, data seems like two bytes to me! --Bastards!!

You can write words to memory. The command is written:

write location, word w1, word w2

 

 

Same is used for peeks and pokes. Here is a line of code from one of my programs that works fine.

peek 84,word position1,word position2

 

I get your point. I think that writing
WRITE location      , data0, data1, data2
will save you from writing
WRITE location      , data0
WRITE location + 1 , data1
WRITE location + 2 , data1

etc.

I might take a vacation from this project as my TJ parts have arrived. Three packages in one day. But more questions and suggestions are always welcome.

Boy those pulleys are tiny!