In earlier posts I said I wanted to free the robot from the desktop PC.
One logical next step might be to develop some code for a mobile device such as a phone or tablet. I think I will learn a lot by attempting this route first. I have made a Java media mobile app before, nearly 10 years ago. Just recently I made a dummy app for an android (2.0) device to find out how to upload and download apps to the Internet, using security keys.
Eventually I want to put this arm on my robot car, so an Arduino will come into this recipe at some point, but I'm going to take a step back and consider the bigger picture of how this might all fit together at the end.
When you install the new drivers for your USB robot arm (see below), the OWI software you loaded from the CD will stop working. This isn't a failure of the code or instructions, it's just that you need to install new drivers for the USB board that work with Java and the IDE.
To revert to the OWI software interface.
In device manager uninstall the libusb-win32 devices: ELAN USB device. Then re-install the OWI software. Restart the PC between each step of the un-install and re-install process.
----------------------------------------------------------------------------- ***Disclaimer***
Please remember this code is provided for free and AS IS.
There is no support and no guarantee. As a non-expert, I will answer
what questions I can, and respond to constructive comments / criticism.
-----------------------------------------------------------------------------
I've posted links below to get all the code and allied files (jars,wrappers, drivers and libraries) to control the OWI robot arm using a simple GUI interface. You can also make sequences in Netbeans which make the arm execute set moves - make it dance as I did in the video above, if you like! My code is based on Andrew Davison's OWI project: http://fivedots.coe.psu.ac.th/~ad/jg/nui06/index.html
Extract archive and run the \bin\inf-wizard application. Choose a device to create drivers for e.g. 0x1267 0x0000 ELAN USB Device
Copy and rename the relevant DLLs in e.g. bin\x86\.. over to the OS (x86 is windows example) libusb0_x86.dll --> Windows\system32\libusb0.dll libusb0.sys --> Windows\system32\drivers\libusb0.sys
LibusbJava_dll_0.2.4.0 (.zip) and ch.ntb.usb-0.5.9.jar
Download ch.ntb.usb-0.5.9.jar and LibusbJava_dll_0.2.4.0.zip move the JAR and unzipped DLL to your java project folder.
If using an IDE such as Netbeans, make sure these files are copied into your dist folder: [ch.ntb.usb-0.5.9.jar], [LibusbJava.dll] and [LibusbJava_dll_0.2.4.0.zip].
Project organisation in Netbeans looks like this:
Text file for a java project here in Rich Text format:
To use this class and it's methods you need to set the arm to a suitable position
so that when the sequences begin the arm doesn't overshoot it's working
limits. Failure to do so may cause the gears to grind and click. The bot
may hit things, fall over and generally cause havoc.
For these Java method calls in the ArmDance class:
dance1(1, 5, 2);
faceCamShowOff();
I used the GUI (RobotUserForm.java) to set the arm to fully vertical
before starting.
If you use any of Craig's code please mention his name
and the Blog :
http://gampageek.blogspot.co.uk/2013/01/java-working-beautifully-many-thanks-dr.html
Monday, 14 January 2013
Arduino Meets Yogic Arts
The Relaxino!
Grove Ear-clip Heart Monitor for Arduino
I just bought this item and got it working nicely with the Seeduino test-code. Beware
some peoples ear lobes are too thick (mine are) so play around with the
position. I had to put it on a thin flattish part of my ear.
I made a first attempt at a simple relaxation device. Enter the Relaxino :)
Explanation of how it works.
It
works by measuring your heart rate and taking an
average. Each heart beat is displayed on either a red or green LED. An
LED flashes at the approx frequency of your heart rate to give you
biofeedback. You set a target rate in the code, so a red LED flashes
when you are above target and a green one when you are at, or below the
target heart rate (set in code). This allows you to try to relax and get feedback on
how you are doing. Target achievement is assessed by averaging over 20 beats. Future versions will allow setting heart rate by external controls.
Set
the target initially close to your resting heart rate (mine is
typically 65). It needs 30 beats to get going so both LED's will flash
on startup / Arduino reset. The word "BEAT" will print in the monitor
for each heart beat detected, and an LED will flash on each heart beat.
You can check by feeling the pulse in your neck and watching the LED -
both should be approx. in sync.
Lie or sit down and try to relax,
taking long deep breaths in and out, empty your mind and gently focus
on the LED light (being in the dark helps so you can see the pulses
through closed eyelids).
Gradually increase the length of the
breaths, counting if you need to: 6-8 seconds for in, 6-8 seconds for
out (or do whatever you can manage). Build up to longer and longer ins
and outs. Don't rush it and get out of breath - your heart will beat
faster!
Attach the anodes of a green LED on digital pin 13, and a red LED on pin 12.
Current limiting resistors used for the LED's are 560 Ohm and connect cathodes via the resistor to ground pins
Geekery Recipe:
The
device uses a RISING interrupt on pin 2, so attach the output wire
(yellow) of the heart monitor to pin 2 of the Arduino.
Black wire goes
to ground and red to +5v.
Attach the ear clip to your left ear. Beware
some peoples ear lobes are too thick (mine are) so play around with the
position. I had to put it on a thin flattish part of my ear.
/* Program to measure and display heart beats on two led's (and on serial monitor for debug)
* Green led flashes at approx freq of your heart rate when you are at or below your target,
* if you go above this (eg 65 bpm) the red.
* led flashes at the approx freq of your heart rate
* You can check by feeling your pulse
* in your neck and looking at LED - both should be in sync
* C. Turner 16/01/2013.
* Seeed product wiki http://www.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit
* Avaialible in UK here: https://digitalmeans.co.uk/shop/sensors-category/sensors-medical-category/grove-ear_clip_heart_rate_sensor
* More detailed project write-up here: http://gampageek.blogspot.co.uk/2013/01/arduino-meets-yogic-arts-seeduino-ear.html
// Sketch is provided "As is" with no guarantees, or support from the Author.
// Help with Arduino and shields can be found by joining the forum on the Arduino website: http://arduino.cc/en/
*/
unsigned char HIpin = 13;//red led = over target & use 560 Ohm resitor in series
unsigned char LOpin = 12;// green = @target heart rate or below & use 560 Ohm resitor in series
// times
unsigned long t1 = 0;
unsigned long t2 = 0;
unsigned long counter = 0; // count interrupts = beats
unsigned long secsElapsed = 0; // time for 60 beats
unsigned long myCount = 0; // heart beat count so far
float heartRate = 0; // instantaneous rate
float averageHeartRate = 0;// ave over 30 beats
boolean beatDetect = false;
void setup()
{
pinMode(HIpin, OUTPUT);
pinMode(LOpin, OUTPUT);
Serial.begin(9600);
Serial.println("Please ready your ear clip.");
digitalWrite(HIpin, HIGH);// red led off
delay(2000);//time to place clip, note that some people's earlobes are too thick (mine are)
// I had to place it on the main ear. May need to play until you get sensible results.
// change to 5000 or more if need more time.
digitalWrite(HIpin, LOW);// leds off
digitalWrite(LOpin, LOW);
Serial.println("Heart rate test begin.");// debug
t1 = millis(); // set start time.
attachInterrupt(0, interrupt, RISING);//set interrupt 0, digital pin 2 -
//Seed / grove heart monitor out pin is attched here.
}
void loop()
{
if (beatDetect == true)// if interrupted on pin 2 ie beat was detected
{
//*****************************************************************************
Serial.println("BEAT");// debug: print BEAT on each interrupt
if (counter > 20 )// use heart rate when 20 beats averaged
{
Serial.println("Heart Rate is: ");// debug
averageHeartRate = heartRate;
Serial.print(averageHeartRate);// debug
Serial.println();// debug
}
//************************************************************************************
counter = counter + 1 ;
t2 = millis(); // check time
myCount = counter;// heart beats so far
secsElapsed = (t2 - t1 ) / 1000 ; // seconds elapsed
heartRate = (float(myCount) / float(secsElapsed) ) * 60;// beats per minute
beatDetect = false;// reset for next interrupt (beat)
if (counter == 61)
{
counter = 0; // reset counter after 30 beats
t1 = millis(); // reset t1 to millis()
}
//display the info **************************
if (averageHeartRate != 0)
{
// SET TARGET HEART BEAT HERE ++++++++++++++++++++++++++++++++++++++++++++++++
if (averageHeartRate > 63)// my average resting heart rate = 65 bpm - choose your own
{
//HIGH target RED led
digitalWrite(HIpin, HIGH);// red led on
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(HIpin, LOW);// red led off
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(LOpin, LOW);// green led off
}
if (averageHeartRate <= 63) // my average resting heart rate = 65bpm choose your own
{
//LOW target green led
digitalWrite(LOpin, HIGH);// green led on
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(LOpin, LOW);// gree led off
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(HIpin, LOW);// red led off
}
}
else if (averageHeartRate == 0)// when starting up flash both leds
{
digitalWrite(HIpin, HIGH);// red led on
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(HIpin, LOW);// red led off
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(LOpin, LOW);// green led off
digitalWrite(LOpin, HIGH);// green led on
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(LOpin, LOW);// gree led off
delay10thsOfSeconds (1);// flash at heart beat rate
digitalWrite(HIpin, LOW);// red led off
}
}// end of beat detected
}
void interrupt()
{
beatDetect = true;
}
void delay10thsOfSeconds (int multi){// delay multi x 0.1 sec
for (int i = 1; i < (multi * 10); i++) // wait 10 = 0.1 sec
{
delayMicroseconds(10000); // multi x 100 x 10000 us
}
}
END CODE-----------------------------------------------------------------------
Thursday, 10 January 2013
As well asswanning around the Internet looking for interesting stuff :), I made the OWI-535 robot arm and really enjoyed it. It's for big kids too so I'm going to hack it (see previous post for ideas).
It took me
about 2-3 hours to put it all together. No problems encountered during
construction. The instructions were clear and concise. The parts are
surprisingly good quality for the price, and build quality once assembled is
remarkably sturdy. It all worked fine with the PC software, once installed on Windows Vista.
Not being a student of mechanics, I learned quite a bit about how these things work by building a kit. The gearboxes are fascinating the way they work with the worm screw on the motors - I have always used ready made gearboxes before. I think young peoplewill learn lots from constructing these types of kits especiallywith a parent or mentor.
I am writingsome Java software for the arm, because I plan to
eventually make it mobile [Davison code].
I want to write my own Java interface
for the OWI-535. I started that today so should have some updates next week.
It should be easy to hack for Arduino / RaspberryPI (RPI) too, due to the
nice–n-easy pinouts. I'm still not sure whether to got Arduino, RPI, or both. One advantage of RPI is that Java can be installed on-board, this means it would be easier to port my Java code.
The kit (as supplied) has no way of sensing or communicating the position of any of it's parts. Don't get me wrong, I don't expect the vendors to provide solutions to the limitations at this price! But maybe I can improve it and have fun at the same time! That's Gampa's mantra.
OWI-535 Robot Arm with USB: taking
into account quality, fun, specification and price I give it 4/5.
Video of Arm Controlled by Java GUI
Note the wires hanging out the back. I didn't pack them all away and make neat because I plan to go on hacking and modifying. I replaced the big batteries with a 2C lipo too, which makes the power a bit juicier @ 7.4 and 3.7v (was 6 and 3v) and is much lighter.
JAVA working beautifully - many thanks Dr Davison.
Be Aware
When you install the new drivers (Lib32-usb and Java)for your USB robot arm, the OWI software you loaded from the CD will stop working.
The first test of the OWi USB Robot arm, using the Davison code and instructions, works fine. I just played with the USB board on my PC with only the motors and LED attached. Ok it's cheating, but I wanted to know if I could program it using my own Java code.
Now it's time to play with it and see if I can get a nice interface up and running.
(I am using Netbeans 7.2.1 on Windows Vista). I need to decide how I'm going to progress this so it can go mobile.
Do I stick with Arduino?
Do I move over to Raspberry PI and Linux open JDK Java JavaOne 2012?
Blue Tooth / RF RC control?
All of the Above?
I will list some limitations of the Robot Arm. Don't get me wrong, I don't expect the vendors to provide solutions to the limitations. At this price it is great value for money (~ £50). The next one up I found uses servos and an MCU for £150. But maybe I can improve it and have fun at the same time! That's Gampa's mantra.
The kit (as supplied) has no way of sensing or communicating the position of any of it's parts. This is risky for the mechanical parts of the arm and could cause wear, even failure. We don't want our 'bot to get a sprain do we? Some thoughts:
Gears just carry on grinding away when max-positions of motorised joints are reached
Gripper needs "touch" sensor
Motors and gears could wear out
Batteries are very heavy - replace with Li-Ion?
My idea is to suggest an Arduino and on-board sensors in conjunction with the Arm. The Arduino could sense the limit and stop the motor(s) when max-positions are sensed, overriding commands from the Java program. A bit like a reflex in mammals - no need to engage the brain (Java machine).
This may be a cheap and simple add-on implementation to the arm, irrespective of how it is being controlled, whether it's the vendor's software or a custom Java implementation.
Happy New Year! After the success of the firework firing device, I'm thinking about projects for 2013.
I want learn more about the USB interface and protocol, because It opens a door to hacking into all sorts of devices. Just about everything has a USB these days.
For my first attempt (started today) I am using USBlyzer - Windows USB sniffer 30 day trial to sniff the data sent from my robot arm software to it's controller board on the Arm.
I want to use the Arduino USB host shield to control the Arm, thus setting it free from the chains of the Microsoft Empire.The hard bit is working out the USB stuff, but initial sniffings are promising and show small packets containing simple data.
I've had some ideas about what to do with it once it's Arduino enabled. Here are some on a dream-list, please add some if you can.
Make it lighter and, attach it to my robot car
Put it on a jeenode RF network, so I can RC it.
Put a miniature video camera on the "hand"
Enhance it's strength and add "super powers"
Add a plasma rifle in the 500W range?! Aw OK, a BB gun or missile launcher
Well, I hope I haven't bitten off more than I can chew! But Gamps has still got all his own gnashers. Thankfully Dr. Andrew Davison has tackled this in Java. I know a bit of JAVA so I'll be studying his work .