Sunday, September 28, 2008

Sidewinder Force Feedback Pro Windows XP

For those looking for a solution to getting the force feedback 2 joystick working in XP take a look here:

Force Feedback Article

However this brief reminder is that he old Force Feedback Pro joysticks do work under XP and they work pretty well. Only problem is that the forces are too strong. This makes them pretty hard to use under most situations except if you are doing the programming yourself. In which case, download the newest version of Visual C# Express Edition, or for that matter any of the visual languages and download the newest Microsoft DirectX SDK. I used 2006.

Go down a few levels and you'll find a cool utility that allows you to test out all the forces on the joystick.
EX:
C:\Program Files\Microsoft DirectX SDK (February 2006)\Samples\Managed\DirectInput\Bin\x86\csFeedback

You can also go up and edit the programs to your hearts desire. If you are using anything other than a joystick, you may have problems and will have to set the number of axes to 1 instead of two, but this is a well known problem.

Tuesday, July 29, 2008

SHARP 2Y3A001 F Arduino filtering

I'm using the Sharp 5 beam sensor in a project of mine and I was having trouble with the measurements varying a lot. Stupid me, after checking it out with my Parallax USB Oscilloscope I realized that the input voltage to the sensor wasn't right, I simply didn't have it plugged in right. That stabilized the output and my mean analog readings were close, but I felt that taking the mean wasn't necessarily the best way to go about it, because if you look at the output of the sensor under an oscilloscope it spikes then oscillates, so if you simply do an average of a lot of readings that initial spike will affect your output. I figured that the best value would come from the mode and not from the mean. A mean of the top two frequencies would also work, but for simplicity, I"m just using one. Here is the code I used on the arduino platform. (Essentially just C)

I took 50 samples, put them in an array, applied an insertion sort, and then searched through the list once finding the highest mode. Then I printed out the average mode and min and max to the screen. I also made use of a printFloat function I found floating on the net. Notice I'm also only reading one out of the 5 beams at the moment, I wanted to get the algorithm to work first before changing, but its just a matter of uncommenting a few lines and making some changes. The output from the sensor is not rock solid when you place it down and aim it at an object.


// printFloat prints out the float 'value' rounded to 'places' places after the decimal point
void printFloat(float value, int places) {
// this is used to cast digits
int digit;
float tens = 0.1;
int tenscount = 0;
int i;
float tempfloat = value;

// make sure we round properly. this could use pow from , but doesn't seem worth the import
// if this rounding step isn't here, the value 54.321 prints as 54.3209

// calculate rounding term d: 0.5/pow(10,places)
float d = 0.5;
if (value < 0)
d *= -1.0;
// divide by ten for each decimal place
for (i = 0; i < places; i++)
d/= 10.0;
// this small addition, combined with truncation will round our values properly
tempfloat += d;

// first get value tens to be the large power of ten less than value
// tenscount isn't necessary but it would be useful if you wanted to know after this how many chars the number will take

if (value < 0)
tempfloat *= -1.0;
while ((tens * 10.0) <= tempfloat) {
tens *= 10.0;
tenscount += 1;
}


// write out the negative if needed
if (value < 0)
Serial.print('-');

if (tenscount == 0)
Serial.print(0, DEC);

for (i=0; i< tenscount; i++) {
digit = (int) (tempfloat/tens);
Serial.print(digit, DEC);
tempfloat = tempfloat - ((float)digit * tens);
tens /= 10.0;
}

// if no places after decimal, stop now and return
if (places <= 0)
return;

// otherwise, write the point and continue on
Serial.print('.');

// now write out each decimal place by shifting digits one by one into the ones place and writing the truncated value
for (i = 0; i < places; i++) {
tempfloat *= 10.0;
digit = (int) tempfloat;
Serial.print(digit,DEC);
// once written, subtract off that digit
tempfloat = tempfloat - (float) digit;
}
}





float rawData = 0;
float distance =0;
float alpha[5] = {7545.2,7522,7860.2,8373.9,8093.6};
float beta[5] = {-1.3297,-1.3272,-1.3341,-1.3445,-1.339};
//will be used in equations for different LEDs example : LED1 = 9009x^-1.3591
int iterations = 50;
byte measurements[50];
int mode, TempModeValue;
byte HighestFrequency, TempFrequency;
int i,j,z;
byte key;

void setup(){
Serial.begin(9600); // set up Serial library at 9600 bps
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
digitalWrite(18,LOW);
for(i=5;i<=9;i++)
digitalWrite(i,HIGH);



}
void loop(){

//distance = rawData;
//Serial.println((int)rawData);
//delay(500);
//Serial.print("?f");//clear screen
rawData =0;
//for(i=4;i<=8;i++)
i=4;
{

///TIME CRITICAL READINGS
digitalWrite(i,LOW);//10cm sensor is inverted
digitalWrite(9,HIGH);
delay(20);
for(z =0;z {
measurements[z] = analogRead(0);
rawData += measurements[z];
}
digitalWrite(i,HIGH);
digitalWrite(9,LOW);
///TIME CRITICAL READINGS OVER


//sort list
for(j=1;j {
key=measurements[j];
i=j-1;
while(measurements[i]>key && i>=0)
{
measurements[i+1]=measurements[i];
i--;
}
measurements[i+1]=key;
}
//take first value as highest
mode = TempModeValue = measurements[0];
HighestFrequency = TempFrequency = 0;

for(i=1;i {
if (measurements[i] == TempModeValue)
TempFrequency++;//represents highest frequency
else
{
TempModeValue = measurements[i];
TempFrequency = 1;
}

if(TempFrequency > HighestFrequency)
{
mode = TempModeValue;
HighestFrequency = TempFrequency;
}
}




rawData /= iterations;
//distance = 1148*pow(rawData,-1.0

//measurements[i-4]= pow(rawData,-1.3591);
//rawData = alpha[i-4]*pow(rawData,beta[i-4]);
for(z=0;z {
printFloat(rawData,2);
Serial.print(',');
Serial.print(measurements[0],DEC);
Serial.print(',');
Serial.print(measurements[49],DEC);
Serial.println();
}

//printFloat(rawData,6);
if(i<8)
//Serial.print(',');
//measurements[i-4] = rawData;
delay(5);
}
// Serial.println();
delay(250);




/*if(Serial.available() > 0)
{
temp = Serial.read();
if( temp == 'r')
{
//printFloat(distance,2);
for(i=0;i<4;i++)
{
printFloat(measurements[i],6);
Serial.print(',');
}
printFloat(measurements[4],6);//so we don't have an extra comma
Serial.println();
/* }
}*/
}

Monday, July 28, 2008

Saturday, July 26, 2008

Saturday, July 19, 2008

compiling issues

I found a site that illustrates the proper order for directives when using g++ as a compiler. I was having the problem that I could make a program compile using relative pathname in the -I option but not when using an absolute path name.

The following worked with relative pathnames


$(CXX) main.cpp -o test -I./.. -L. -lsmile

But i wanted to use absolute path names and i tried this:


$(CXX) main.cpp -o test -I/home/santiago/thesis/SmileHeaderfiles -L -lsmile

which didn't work.
This did work


g++ -I/home/santiago/thesis/SmileHeaderfiles main.cpp -o test -L. -lsmile

Friday, July 18, 2008

Player/Stage Ubuntu 7.10 update

I got player version 2.1.1 and stage 3.0.0 working, player was not too difficult, I just needed to install libglu1-mesa-dev to get rid of some of the dependency issues I was having.

Stage was more difficult, For some reason the program needed me to manually export
export LD_LIBRARY_PATH=/usr/local/lib
for stage to work.

I was getting this error before for google reference:

stage: error while loading shared libraries: libstage.so.3.0.0: cannot open shared object file: No such file or directory


So I added:
export LD_LIBRARY_PATH=/usr/local/lib
to .bashrc and called it a day.

Wednesday, July 16, 2008

two usb webcams same hub, ubuntu 7.04

Well, I know how I got two cameras working on the same hub in Ubuntu 7.04, but apparently it doesn't work in 7.10. If I can get it working again, I'll provide better instructions. The key step is to download the source code for gspca for linux. Then open up gspca_core.c and search for he section where the author says he doesn't know how to set the bandwidth budget so he allows the maximum. Here is the section:


/**
* Endpoint management we assume one isoc endpoint per device
* that is not true some Zoran 0x0572:0x0001 have two
* assume ep adresse is static know
* FIXME as I don't know how to set the bandwith budget
* we allow the maximum
**/
static struct usb_host_endpoint *
gspca_set_isoc_ep(struct usb_spca50x *spca50x, int nbalt)
{
int i, j;
struct usb_interface *intf;
struct usb_host_endpoint *ep;
struct usb_device *dev = spca50x->dev;
struct usb_host_interface *altsetting = NULL;
int error = 0;
PDEBUG(3, "enter get iso ep ");
intf = usb_ifnum_to_if(dev, spca50x->iface);
/* bandwith budget can be set here */
for (i = 4; i; i--) {//changed nbalt to 4
altsetting = &intf->altsetting[i];
for (j = 0; j < altsetting->desc.bNumEndpoints; ++j) {
ep = &altsetting->endpoint[j];
PDEBUG(3, "test ISO EndPoint %d",ep->desc.bEndpointAddress);
if ((ep->desc.bEndpointAddress ==
(spca50x->epadr | USB_DIR_IN))
&&
((ep->desc.
bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_ISOC)) {
PDEBUG(0, "ISO EndPoint found 0x%02X AlternateSet %d",
ep->desc.bEndpointAddress,i);
if ((error =
usb_set_interface(dev, spca50x->iface,
i)) < 0) {
PDEBUG(0, "Set interface err %d",
error);
return NULL;
}
spca50x->alt = i;
return ep;
}
}
}
PDEBUG(0, "FATAL ISO EndPoint not found ");
return NULL;
}

Well as you can see the outer for loop was i = nbalt. I changed that to 4 since it seemed like a nice number. It was really arbitrary. Then do make and make install, and you should be good, then download some program like spcaview and have at it.

Friday, July 11, 2008

Player/Stage Ubuntu 7.10

After several hours struggling with trying to compile from source and having problems, I got Player/Stage to work. I should have known better, Ubuntu always makes things easy.

To install stage:
$sudo apt-get install stage

To run a demo
$stest /usr/share/stage/worlds/simple.world robot1

And if you want other tests look through /usr/share/stage/worlds for other worlds to try.

Wednesday, June 4, 2008

Using two routers on a home network

I recently got two routers to talk to each other and actually had my home network of two computers separated into two subnets. The key to it was to set up one router as a gateway, and have the second router setup with a static ip address as if it were to receive one from the ISP, but instead, set up the static IP to be one within the network of the first router. For example, the first router was setup with DHCP, so its external address would change, but its LAN address was set to 192.168.1.1 and was the gateway. The second router's WAN address was static and set to 192.168.1.2. The second router's LAN address was 192.168.2.0. Then the important part setting up static routing. The first router, 192.168.1.1, had the following static routing entry.
ID Destination IP Address Subnet Mask Default Gateway
1 192.168.2.0 255.255.255.0 192.168.1.2

and on the second router, 192.168.2.0
ID Destination IP Address Subnet Mask Default Gateway
1 192.168.1.0 255.255.255.0 192.168.1.1

The rest was taken care of automatically. Remember, pinging is your friend

Thursday, April 10, 2008

90s

Just as a personal note, when attempting to do 90s, stand should width apart and keep legs locked, swing the upper body, swing right hand down toward left foot, in the same motion lift left leg up behind you and up, keep legs locked and keep them at should width apart even in the air, go towards a hand stand and reach to place left hand where right foot was. Keep legs apart in air. Now shift weight from right hand to left and pick up right hand at this time, twist hips slightly and pull legs in, rotation should have been maintained til this point and conservation of momentum will increase spin. This is probably the worst explanation on how to do this skill, but its a reminder to myself.

Thursday, April 3, 2008

WRTSL54GS i-force joystick

I was able to get my WRTSL54GS to read my Saitek ST290 joystick as well as a mouse. I had problems at first getting it to read, and I think it was a conflict with USB 2.0

First download the newest bleeding edge version of OpenWRT. How to do this has been posted many times but for completion,

make a folder with


$mkdir Kamikaze
$cd Kamikaze
$svn co svn://svn.openwrt.org/openwrt/trunk/
$make menuconfig


Well, I can't upload the code for the moment so I'll just save it away and post it later.

4/18/09

Well, its been a damn long time, and this has taught me the valuable lesson of writing down the steps I take to make something happen, or else I might forget as I have this time and it has forced me to re-figure out how I got this to work in the first place. The main problem I had, and have, is that I don't think I'm entirely sure how the OpenWRT makefile system works.

Well, assuming you have directory named trunk where all of your openwrt stuff is type

make menuconfig


make sure the following settings are set

Target System (Broadcom BCM947xx/953xx [2.6])
Target Profile (Linksys WRTSL54GS)

Kernel modules --->
Other modules --->
kmod-hid
kmod-input-core
kmod-input-evdev
USB Support --->
kmod-usb-core
kmod-usb-ohci
kmod-usb-storage
kmod-usb2


Then press escape key twice
Now type

make kernel_menuconfig


Then make sure the following are selected


[*] Enable lodable module support --->
[*] Enable the block layer --->
[*] Networking support --->

Device Drivers--->
Input device support--->
Generic input layer (needed for keyboard, mouse, ...)
Polled input device skeleton
Mouse interface
Joystick interface
Event interface
<*>Joysticks/Gamepads--->
I-force devices
[*]HID devices
[*]USB support


If I didn't mention something then it may have been set by default, or if I did and it was already set, no harm done.

Then press esc esc. It will then start to do some basic writing of configurations through the makefile process. (I think) Then it will say
I-Force devices (JOYSTICK_IFORCE) [M/n/?] m
I-Force USB joysticks and wheels (JOYSTICK_IFORCE_USB) [N/y/?] (NEW)

type yes. I'm not sure why this comes up. As I do more research with this project, I'll try and figure more of how it actually works.

It will then finish.

then type

make V=99


The V=99 is very important as it will prompt you for different things during the make process.

such as the joystick thing mentioned above, type yes again. It will do this twice during the make process.

once its done, we're going to upload the new firmware to the WRTSL54GS. If you don't already have it make sure you have atftp. If you're running a system with apt-get use the following.


sudo apt-get install atftp


Then pull up two terminals. Connect the WRTSL54GS to the same router or switch or hub that your computer is connected to. You can do it directly but its more a pain in the butt as you have to set your computer to a static IP address. Also, change your router's ipaddress to something other than 192.168.1.1 as that is what the WRTSL54GS defaults to during loading and during a hard reset if its is necessary to do so.

so in one window

ping 192.168.1.1


And in the other window

$cd bin
$atftp
tftp> connect 192.168.1.1
tftp> mode octet
tftp> trace
Trace mode on.
tftp> put openwrt-wrtsl54gs-squashfs.bin


Now wait and don't press enter. Disconnect the WRT and you should see no response in the window that is pinging the device. Click on the terminal that is running atftp, so you are ready to press enter. Plug the device in and as soon as you get a response from 192.168.1.1 in 1 window, press enter and write the new firmware to the device. If for some reason you are having troubles, try pushing in a small pin in the hole next to the power supply hole on the WRT as you are pushing in the power, this will put the WRT into a type of safe mode that may help with the loading. Now assuming all went well you should get this

.
.
.
sent DATA
received ACK
.
.
.
sent DATA
received ACK
tftp>


I'm assuming it should end in about the same block size.

type quit in the atftp window to exit that program and go to the terminal that was pinging, press
ctrl-c to stop it and then try telnet 192.168.1.1

you should be greeted by the OpenWrt prompt.

type passwd to set your password as we have to move some files over using scp.

so


root@OpenWrt:/# passwd
Changing password for root
New password:
Bad password: too weak
Retype password:
Password for root changed by root
root@OpenWrt:/# exit



ssh root@192.168.1.1
$ ssh root@192.168.1.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
59:b6:61:9b:88:60:d0:af:c1:16:9a:02:f2:bb:76:82.
Please contact your system administrator.
Add correct host key in /home/santiago/.ssh/known_hosts to get rid of this message.
Offending key in /home/santiago/.ssh/known_hosts:1
RSA host key for 192.168.1.1 has changed and you have requested strict checking.
Host key verification failed.

If you get the above, just do

$rm /home/santiago/.ssh/known_hosts
$ssh root@192.168.1.1
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is 59:b6:61:9b:88:60:d0:af:c1:16:9a:02:f2:bb:76:82.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.1' (RSA) to the list of known hosts.
root@192.168.1.1's password:

After typing in your password you should be back to OpenWRT prompt.

Now go back to your directory where you just uploaded OpenWRT
should be
~/Kamikaze/trunk/bin$
now

$cd packages/target-mipsel_uClibc-0.9.29/
scp kmod-usb-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-hid_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-evdev_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-ohci_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-hid_2.6.28.9-brcm47xx-1_mipsel.ipk root@192.168.1.1:/home

By the time you try this OpenWRT may have moved on to a different kernel version, so don't worry if the numbers don't match, just type in scp followed by the first part of the module and use tab completion to finish it. In other words use the same modules for your version of the kernel.

Now in the terminal that has OpenWRT open,

root@OpenWrt:/home# opkg install kmod-usb-core_2.6.28.9-brcm47xx-1_mipsel.ipk km
od-input-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-evdev_2.6.28.9-brcm47xx-
1_mipsel.ipk kmod-hid_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-ohci_2.6.28.9-brcm
47xx-1_mipsel.ipk kmod-usb-hid_2.6.28.9-brcm47xx-1_mipsel.ipk

They have to be installed in that order as some depend on others.
Now in openWRT

root@OpenWrt:/home#cd /lib/modules/2.6.28.9

Then back on your own machine, on the

$cd ~/Kamikaze/trunk/build_dir/linux-brcm47xx/linux-2.6.28.9/drivers/input
$scp joydev.ko root@192.168.1.1:/lib/modules/2.6.28.9/
$cd joystick/iforce
$scp iforce.ko root@192.168.1.1:/lib/modules/2.6.28.9/

Now back in the terminal with openWRT

$cd /lib/modules/2.6.28.9/
$insmod joydev.ko
$insmod iforce.ko

Now plug in the joystick and type in dmesg

$dmesg
.
.
.
usbcore: registered new interface driver iforce
usb 1-1: new full speed USB device using ohci_hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff01, data = 43
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff03, data = 45 00 01
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff01, data = 4f
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff04, data = 56 02 05 00
input: AVB Top Shot Pegasus as /devices/pci0000:00/0000:00:02.0/usb1/1-1/input/input0

Now lets give it a quick test. Still in OpenWRT


$cd /dev
root@OpenWrt:/dev# ls
1-1 mtd3ro shm
console mtd4 tty
cpu_dma_latency mtd4ro ttyS0
event0 mtdblock0 ttyS1
full mtdblock1 urandom
input mtdblock2 usb1
js0 mtdblock3 usb2
kmsg mtdblock4 usbdev1.1_ep00
log network_latency usbdev1.1_ep81
mem network_throughput usbdev1.2_ep00
mtd0 null usbdev1.2_ep01
mtd0ro port usbdev1.2_ep82
mtd1 ppp usbdev2.1_ep00
mtd1ro ptmx usbdev2.1_ep81
mtd2 pts zero
mtd2ro random
mtd3 root
root@OpenWrt:/dev#cat js0
|��|��|��|��|��|��|��|��|�|��|����|��|��|��|��|��|�������������������
���$�,���D�L���T�\���|�����������������������������������
����L��T���d��l���t�|������������������������������
����$���L�T���d�l������������������������
���$��,���^C

The ^c at the end if me pressing ctrl-c to stop the output. Obviously this isn't the way you want it to use the device. but it shows that it is being recognized and is working. In order to get more than that you need to have a test program such as jscal installed. I'll put details for that later, as I already know how to do it and it won't take long to put that one up.

command line search

to interactively search your history of commands press ctrl-r in linux from the shell

Sunday, March 30, 2008

linux kernel module problems

make -C /lib/modules/2.6.20-15-generic/build M=/home/santiago/pctxDriver/helloTest modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.20-15-generic'
scripts/Makefile.build:17: /home/santiago/pctxDriver/helloTest/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/santiago/pctxDriver/helloTest/Makefile'. Stop.
make[1]: *** [_module_/home/santiago/pctxDriver/helloTest] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.20-15-generic'
make: *** [all] Error 2

The problem with this is that although Ubuntu Makefiles maybe named makefile, the kernel subsystem is looking for a makefile by the name of Makefile. In other words capitalization does matter.

Wednesday, March 26, 2008

Sonar update

Well I'm working on multi-plexing the sonars and I have it working to some extent. I can't send a signal to both and read the results separately without adding some transistors. What was happening was I had everything connected to a bus, so even though I was trying to read one sensor, the signal was being transferred through the bus to the other sensors. This information is only useful to me as a reminder.

Tuesday, March 18, 2008

SRF02 arduino address confusion

Well, I've been looking over the code from Tom Igoe for the Devantech SRF02 sonar based on arduino

http://www.tigoe.net/pcomp/code/category/code/arduinowiring/39

Well even though it worked right off the bat, I was terribly confused why the address for the SRF02 sensor was 0x70 instead of 0xE0 as it was in the Basic Stamp example I used.

Well aparently the I2C address standard only works from 0 to 127 the LSB is used for read / write so the 0xE0 becomes 0x70 for the address of the chip. I found the answer here

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205634009/3

Sunday, March 16, 2008

more sonar

I've realized that only the SDA pins are messed up on my "green" and "orange" sonars. So I was able to reuse the same SCL pin and just have the SDA pins connected to different pins. So instead of the original 2 pins used up I now have 3. Better than having to get new sonar. Unfortunately, I think they can still only transmit. Have to also re-solder green one.

Saturday, March 15, 2008

own sonar

I'm using this site as an example

http://www.micro-examples.com/public/microex-navig/doc/090-ultrasonic-ranger.html

while testing it I'm reminding myself that I have to use a 33k resistor

SRF02

I found out the problem with the SRF02 modules. Somehow during my dealings with them, the boards seem to have shorted. They won't turn on if the SDA and SCL on the green and orange ones are plugged in. I found this out by using software I2C and changing the SDA and SCL pins for them. The orange and green modules can both ping but not receive data. I'm going to try and create my own sonar modules as I only have to calculate time in microseconds between them.

Friday, March 14, 2008

ATTINY13 DAPA cable half duplex uart

I've been recently messing around with learning to code in AVR, or more specifically learn why serial isn't working. I think I have it down to the fact that the default mode for the ATTINY13 is 9.6 MHz and that the frequency is off somehow compared to the half duplex software serial offered by Atmel, I'm going to order an 8Mhz oscillator and see if that fixes it, I"ll also order some 16Mhz oscillators for my arduino projects. Sometimes I like things to work easily.

While I was trying to get the serial to work right, my chip seemed to stop working, like I couldn't reprogram it with the DAPA cable. I went back and downloaded a new Makefile from a tutorial and I made the necessary changes I had previously made. The one that got it to work again was to uncomment
AVRDUDE_FLAGS += -E noreset
this allowed the program to run with the DAPA cable still attached

Wednesday, March 12, 2008

Player stage

I had problems installing player stage on Ubuntu, specifically stage, the solution was to include a few extra libraries, mainly


>$sudo apt-get install libgtk2.0-dev libltdl3-dev libboost-dev libboost-signals-dev libboost-thread-dev libssl0.9.7

Tuesday, February 19, 2008

Ubuntu utime error

I haven't quite figure this one out, but if you happen to run into a utime error. Check if its on a shared partition. Like a FAT32 partition shared between Windows and Linux. I was trying to compile BLAS today and it wouldn't work. I kept getting utime errors. Well I ended up copying everything over to my home directory under root and it worked from there.

Wednesday, February 13, 2008

Printer update

I had to reinstall my printer as a part of some testing...

Well, anyways, I made an update to the previous post I made, you also have to change the enabled state of the printer. I also found out that when using uci, its very particular. The following line was missing


root@OpenWrt:~# uci set p910nd.cfg1.enabled=1
root@OpenWrt:~# uci commit p910nd
root@OpenWrt:~# /etc/init.d/p910nd enable


That first line was the most important, the second line makes it permanent between reboots, and the last line makes it so that it loads the p910nd daemon on boot. Notice how there is no space in the pnd.cfg1.enabled=1 This is required and it won't work otherwise.

Tuesday, February 12, 2008

Ubuntu dual screen, multiple monitors, R52

UPDATE:
I have since updated to Gutsy Gibbon, don't necessarily recommend it other than being able to read Windows files. Well, today I was trying to show a friend how to use aticonfig to setup two screens and I went to System->Administration->Restricted Drivers Manager and selected and unchecked the Enabled block for the ATI driver. I tried re-installing it but aticonfig simply wouldn't work. I had plenty of xorg backups as aticonfig does this on every change, but it simply wouldn't work, here is the solution:

First, download the newest driver from ati and store it in a folder I stored it in

/home/santiago/ATIDRIVERS

the file was

ati-driver-installer-8-8-x86.x86_64.run

I changed to that folder after downloading the file and ran

sudo sh ./ati-driver-installer-8-8-x86.x86_64.run

I used automatic and default settings. Afterwards I ran
sudo aticonfig --initial -f

After this, restart the computer, don't just press ctrl-alt-backspace.

After restarting run:
sudo aticonfig --dtop=horizontal

And now press ctrl-alt-backspace

and if you have a second monitor plugged in it should come to life!



If you happen to have a version of Ubuntu before Gutsy Gibbon, you know there isn't a GUI for setting up multiple monitors, and if you have ever been unlucky enough to try configuring your own xorg.conf file, you know that one little mistake can leave you with a terminal on startup until you manage to reload the backup. Anyways, if you're lucky enough to have an ati video card driver, the command in Ubuntu to setup a dual head system is


$sudo aticonfig --initial=dual-head


At this point press ctrl-alt-backspace which restarts X, log back in and you'll have a two head setup. This is also only temporary, so when you restart you'll have your normal settings back.

Sunday, February 10, 2008

Linux frame grabber

For some of my robotics research, I have been trying to implement a vision based system using webcams. I got the webcams working with spca5xx, I'll put up a post later how I managed to get it to work with multiple cameras off the same root hub. But if you need to do video analysis and need a simple linux frame grabber, I high recommend
http://www.mjmwired.net/kernel/Documentation/video4linux/v4lgrab.c
It was relatively simple to use. The only thing I recommend is to not use the READ_VIDEO_PIXEL function, just address the pointer as an array and use indexing, its faster, and also,

leave out the call to

int get_brightness_adj(unsigned char *image, long size, int *brightness) {
long i, tot = 0;
for (i=0;i tot += image[i];
*brightness = (128 - tot/(size*3))/3;
return !((tot/(size*3)) >= 126 && (tot/(size*3)) <= 130);
}


as in the code it results in a very long lag, and I rather control the brightness on my own.

OpenWRT Kamikaze 7.09 image loading

IMPORTANT: Before doing any of the following be sure you have boot wait turned on. You should already, but atftp won't load an image to the router without it.

Loading a new image of OpenWRT does not seem to be supported via webif in Kamikaze 7.09. I found that atftp works well. There are plenty of examples on how to do this, but I find that the procedure that works best is to cd to the directory with the image you want to load, then open up to terminals.
In the first terminal

$ping 192.168.1.1

Assuming that the router address is set to 192.168.1.1.
It will continously ping the router
In the second terminal, cd to the directory and then

$atftp

Then the atftp terminal pops up

tftp> connect 192.168.1.1
tftp> mode octet
tftp> trace
tftp> put openwrt-wrtsl54gs-squash.bin

NOTE: don't press enter on the last line just yet
Where you will substitute the image you want to upload for openwrt-wrtsl54gs-squash.bin
At this point you should have the put line typed in on one window and the router responding to pings in the first window. At this point unplug the router's power, watch for the pings to stop and plug the router back in. As soon as the router responds, press enter on the last line and several lines like the following should appear:

sent DAT
received ACK


Then wait at least 2 minutes and the router light should stop blinking.

Saturday, February 9, 2008

USB drive on WRTSL54GS

Made some more progress tricking out my router. I managed to get my 160GB external to show up. I hope to set this router up as a print server and as a webcam/recorder server.

Well, after some fiddling and some searching on OpenWRT forums, I found that the command that allowed me to mount the drive was

mount -t vfat /dev/sda1 /mnt

Friday, February 8, 2008

OpenWRT Kamikaze Printer Sharing Windows XP update

If you follow the guide on printer sharing I mentioned yesterday about how my usb printer showed up as /dev/lp0. Well, another helpful hint is that if one of the client computers you're setting the print service up on has a printer already installed, uninstall it. Simply adding a TCP port after the fact doesn't allow windows to recognize that the printer is ready to print. If the printer was installed as a local USB printer, Windows will continue to look for a USB connection in order for it to believe that the printer is ready to print. So just delete your printer and follow the guide and you'll be alright.

Thursday, February 7, 2008

WRTSL54GS printing Kamikaze 7.09 and HP 5550

So I've had my share of luck with getting things to work under embedded systems such as the WRTSL54GS. Its often times hit and miss, and unless you're willing to go through code, sometimes you're just stuck. Nevertheless I've been a big fan of the work people have been doing at X-WRT and OpenWRT. Here are the steps I followed to get the WRTSL54GS to work as a print server with my older HP 5550. I also tried it with my newer HP PSC 1350, but I didn't actually test printing to it, but it did show up.

NOTE:
Make sure you connect to your WRTSL54GS using a wired connection as you may have problems getting wireless to work. I have another router working as my wireless router, so that wasn't an issue with me

Step 1.
Install the newest version of x-wrt it can be found here.

Go to your WRTSL54GS website, type in 192.168.1.1 if you haven't changed any settings on your browser. Go to the last page and click update, browse for the place where you stored the file and take a break. It takes 5-10 minutes to install and reboot. Be patient.

Step 2
Configure your router.
type in 192.168.1.1 It will reset to this IP address regardless of what it was before. Use the web interface to set up your router to your hearts desire. When you first log in it will ask for a new password. Remember this as you will need this password to ssh into the router.

Step 3
SSH into router
Use your favorite program to ssh into the router. In linux the command would be

$ssh root@192.168.1.1

It will then ask for the password you set earlier. Now you have to ensure you have a connection to the internet, if you. I always try pinging google as a test


root@OpenWrt:/# ping www.google.com


Now, you actually don't need all these packages, but since you're already in the router, might as well install all the packages you need related to usb.


root@OpenWrt:/# ipkg install kmod-usb-core kmod-usb-ohci kmod-usb-uhci kmod-usb2 p910nd kmod-usb-printer


I know thats a bit long, but if you're not pressed for memory, it just works, and installs printer support.

Step 4
Configuration

Plug in your printer into the usb port. type

root@OpenWrt:/# dmesg

It should reply with something along these lines

usb 3-1.4: new full speed USB device using ehci_hcd and address 4
usb 3-1.4: configuration #1 chosen from 1 choice
drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x03F0 pid 0x6004


Next we will check for the printer. Until this point I was following the excellent instructions located at the OpenWRT site

Here's where I differ, for some reason, my printer did not show up as

/dev/usb/lp0 but rather /dev/lp0
uci show p910nd

p910nd.cfg1=p910nd
p910nd.cfg1.device=/dev/usb/lp0
p910nd.cfg1.port=0
p910nd.cfg1.bidirectional=1
p910nd.cfg1.enabled=0

I simply used the command



root@OpenWrt:/# uci set p910nd.cfg1.device=/dev/lp0
root@OpenWrt:/# uci set p910nd.cfg1.enable=1
root@OpenWrt:/# uci commit p910nd
root@OpenWrt:/# /etc/init.d/p910nd enable


And I followed the instructions on adding a printer shown on the same site, under Ubuntu:

  • Start kprinter
  • Select 'Add printer'
  • Select Network printer (TCP)
  • Use 192.168.1.1 (the router's IP address) as the printer's IP
  • Fill in the port you want to use (normally defaults to 9100)
  • Pick manufacturer and model
  • Pick the recommended driver
  • Then you can new print a test page or change the settings of the printer further
After this I clicked print test page and I heard the wonderful sound of the printer spooling. Hope this is helpful to you, it was to me.

IP release in Ubuntu

I have recently been having problems in Ubuntu with it having an extreme preference to connect to my wireless network rather than connect via eth0. I found out that the command to release the IP address an


$ sudo dhclient -r


To renew the address its the same command but without the r


$ sudo dhclient -r

If things get really bad, you can always restart the networking service.

$ /etc/init.d/networking restart

C++ errors

g++ -c -o Symmetric.o Symmetric.cpp
Symmetric.cpp:30: error: declaration of ‘virtual int Symmetric::position(int, int)’ outside of class is not definition
Symmetric.cpp:31: error: expected unqualified-id before ‘{’ token
make: *** [Symmetric.o] Error 1

This is pretty obvious to most people, but if you happen to run into this error, try taking a look at the definition of the function, it may be as simple as a out of place semicolon. In this case, the problem was in this line of Symmetric.cpp.

I just placed a semicolon on the definition of that class function.

int Symmetric::position(int i,int j);
{
...
};

This was one heck of a project this file came from. It was an exercise in inheritance. I'll post some more info on it later, as I think it was a very informative programming assignment.

Saturday, February 2, 2008

CCTV lenses

The CCTV lenses just arrived today. I'm doing some research, trying to determine the best conditions to create a laser webcam rangefinder The reason I'm modifying it is that in my lighting conditions, unless I have most of the lights off, and do some filtering, I the red dot is never the brightest pixel. I've found that because of the IR filter used on cameras, the brightness of the laser point is greatly reduced. To remedy this, I bought a set of 6 lenses in sizes 2.8,3.6,6,8,12, and 16mm, with an F2.0. I'm currently using these on a labtec webcam pro. I bought a whole slew of them off of ebay for my CS department. I've found that the 3.6mm F2.0 lens creates an image most like the one I originally used. The reason I'm doing this is that these lenses come without an ir-filter, which basically allows you to see infrared. So if you're interested in doing the FreeTrack webcam mod for the Labtec Webcam Pro, I suggest you order the 3.6 lens. It will avoid you the problem of having to polish off the IR filter which isn't pretty. Only problem is that the original tube that allows the camera to screw on has a large space without threading, which means that although the lens will work for the camera, I had to cut the tube to make it fit. Which in my mind is much better than polishing off the filter, but if I figure out anything new I'll post it.