wheel chair controlled by brain... servo and key processing help

hi I need help with coding for 2 servos and that react to keys pressed on a key board
x=reverse
w=forward
a=left
d=right

my servo set up would kind of be like

-90 degree for x
+90 degree for w
-90 degree for a
+90 degree for d

ive tried finding suitable code for my project which would take dsmx spectrum transmitter to Arduino but I can not figure that out mostly because its proprietary stuff so I don't mind gluing servos to my tx for my project.

project is using an eeg headset that can map keys to certain brain waves to control a wheel chair.
ive got everything working except the processing code and the Arduino code. its really a major part of it.

thank you in advance for any help

armenvegas:
hi I need help with coding for 2 servos and that react to keys pressed on a key board
x=reverse
w=forward
a=left
d=right

my servo set up would kind of be like :-
-90 degree for x
+90 degree for w
-90 degree for a
+90 degree for d

ive tried finding suitable code for my project which would take dsmx spectrum transmitter to Arduino but I can not figure that out mostly because its proprietary stuff so I don't mind gluing servos to my tx for my project.

project is using an eeg headset that can map keys to certain brain waves to control a wheel chair.
ive got everything working except the processing code and the Arduino code. its really a major part of it.
thank you in advance for any help

Are these continuous-rotation servos or standard ones? This part is confusing. Please elaborate:-

x=reverse
w=forward
a=left
d=right

Are the servos controlling buttons or a joystick on the wheelchair?

You shouldn't need to "find suitable code". You should "write suitable code".
You'll very rarely find pre-existing code that does exactly what you want, or even close.

Which EEG headset are you using? Have you done any preliminary testing to see if you can accurately discriminate brainwaves? For multi-directional control like you want, you'd almost need to read 'thoughts', rather than brainwaves. I'd be interested to hear how you plan to do it.

thank you for replying

I have the Emotiv Insight which includes a key mapper that can run on the window in focus... so my goal is to map keys(already done) to w,a,d,x and I have not been able to crack the digital signal mixing stuff yet and its WAY beyond my expertise so as a simple solution I'm going to mount 2 servos to my tx.

let me start fresh to explain the whole pic...

wheelchair with sabertooth dimensionengineering.com to receiver

and

Emotiv sdk has a training exercise for a block that moves which records your brain electrical patterns for things like "push", "pull", "lift","right", "left", "lower", etc... which I want to use 4 of the samples for my application.

so laptop running with Arduino terminal up and listening for w,a,d,x with out a return button pressed to move the transmitter sticks.

its a rough and dirty way until I can afford an open source tx/rx

did that kind of make sense?

ive ben using my transmitter to drive my wheelchair for a year now, I'm just trying to incorporate my newest tech. the headgear.

thank you

armenvegas:
thank you for replying

I have the Emotiv Insight which includes a key mapper that can run on the window in focus… so my goal is to map keys(already done) to w,a,d,x and I have not been able to crack the digital signal mixing stuff yet and its WAY beyond my expertise so as a simple solution I’m going to mount 2 servos to my tx.

let me start fresh to explain the whole pic…

wheelchair with sabertooth dimensionengineering.com to receiver

and

Emotiv sdk has a training exercise for a block that moves which records your brain electrical patterns for things like “push”, “pull”, “lift”,“right”, “left”, “lower”, etc… which I want to use 4 of the samples for my application.

so laptop running with Arduino terminal up and listening for w,a,d,x with out a return button pressed to move the transmitter sticks.

its a rough and dirty way until I can afford an open source tx/rx

did that kind of make sense?

ive ben using my transmitter to drive my wheelchair for a year now, I’m just trying to incorporate my newest tech. the headgear.

thank you

Right, I’m beginning to get the picture now. So the servos are standard servos, operating the controls. I thought you might have been using large continuous-rotation servos to actually turn the wheels.

And rather than a custom TX/RX setup, you’re using a standard radio-control transmitter, much like those used for model planes, boats etc?

I’d personally use something like an APC220 433MHz transceiver module at each end, with the TX sending digital values to the chair’s RX module, which could be easily decoded to meaningful servo position signals.
I guess this is what you mean when you say “I have not been able to crack the digital signal mixing stuff yet and its WAY beyond my expertise so as a simple solution I’m going to mount 2 servos to my tx.”

This is a very interesting project to me. I’d never heard of the ‘Emotiv Insight’ headsets, but looking at the price, I couldn’t justify the cost for my hobby projects anyway. I’ve been playing around with the Mattel Mindflex headsets, but am not very satisfied with the results to date. Easy to hack and I have no problem getting the data from the headset, but the values aren’t consistent and the ‘Attention’ and ‘Meditation’ values don’t seem to correspond with my mental state.
I’ll be most interested to see how your project develops, and will help whenever I can.

I’m in the midst of a robot car project that uses a pair of continuous-rotation servos for wheel drive, and a standard servo for moving the ‘head’ back and forth, with an ultrasonic ‘ping’ sensor attached, to check for obstacles. As such, I’ve had a little experience with servo control and might be able to help a bit in this area.

A couple of questions:-
So, I assume you’ve had a go at servo control using the servo library?
Do you have much experience with Arduino yet?
Which Arduino model are you using?

The best approach is to make a start on the code for servo control, then post your code and ask for advice, and we’ll help along the way. When posting your code, be sure to place it between code tags, ( </> in the ‘Post’ window), add as many descriptive comments in the code as possible, and also include any other information that you feel is relevant.

As mentioned, I’m looking forward to seeing how this develops. Be sure to keep us updated as you progress.

can I send you a pvt message about the headset?

armenvegas:
can I send you a pvt message about the headset?

And cut the rest of us out? Post it here.

I apologize,
ive owned arduinos and many kinds of shields for years now but I just cant get past the code starting line.
I have used the examples for servo sweep and knob but I don't know how to adjust them for my need. also serial monitor.... ugh its just not something I even know if I'm explaining correctly or inserting verbage backwords...
I love my Arduino mega adk. it looks bad asss but I don't know how to make it do what I imagine it can do.
I own xbees I own a few electric wheelchair, I own drones, heck ive built and still own 2 rc lawnmowers...
but the programming isn't my strong suit. I'm a hardware guy I guess, the software is where the MAGIC happens. I need a magician...

I have all the equipment here just staring back at me. I want to complete the puzzle.

thanks for listening

armenvegas:
can I send you a pvt message about the headset?

Reply sent. :slight_smile:

Now you need to have a go at writing the basics of that code, however crude, then between us all we can try to knock it into shape.
At the moment, no one here can do much, because we have no info about the exact servo movements needed, or the data that will be sent from laptop to Arduino and it's format.

Edit: And those Emotiv headsets sound far better than the Mattel Mindflex headsets that I've been playing with. Pity they're so expensive. :frowning:

#include <Servo.h>

Servo servo1,

int pos = 0;

const unsigned int BAUD_RATE = 9600;

char key = 0;

void setup() {
servo1.attach(2);

Serial.begin(BAUD_RATE);
}

void loop() {
if (Serial.available()) {
key = Serial.read();
if (key == byte(37))
{ //left
for(pos = 0; pos < 180; pos += 1)
{
servo1.write(pos);
delay(15);
}
}
else if (key == byte(39))
{ // right
for(pos = 180; pos >=1; pos -= 1)
{
servo1.write(pos);
delay(15);
}
}

}
}

import processing.serial.*;
color fillVal = color(0,0,0); // set variable ‘fillVal’
Serial port;

void setup() {
size(100, 100);
println(“Available serial ports:”);
println(Serial.list());
port = new Serial(this, Serial.list()[1], 9600);
}

void draw() {
background(0,0,0);
if (keyPressed == true) { // if key is pressed
fill(fillVal);
ellipse(50, 50, 50, 50);
}
else {
keyReleased();
}
}

void keyPressed() {
if (key == CODED) {
if (keyCode == LEFT) {
fillVal = color(255,255,255);
}
else if (keyCode == RIGHT) {
fillVal = color(0,255,150);
}
} else {
fillVal = 0;
}
port.write(keyCode);
if (keyPressed == false) {
port.write(‘0’);
}
}

void keyReleased() {
port.write(‘0’);
}

hey i found something that kinda matches what i need… but i need to make it faster and with out the return having to be pressed

// This program demonstrates how to control a servo to move in either direction
// with the keyboard.
// Setup:
// - Input a series of ‘w’ and press ENTER.
// - Input a series of ‘d’ (or other char other than ‘w’) and press ENTER.
// - You should see the servo move in either direction depending if the char
// is ‘w’ or non-‘w’.

// Ref: http://arduino.cc/en/reference/servo
#include <Servo.h>

Servo servo;

int pos = 0; // Stores the position (angle) of the servo. Range is [0, 180].

void setup()
{
Serial.begin(9600);
servo.attach(9); // Attaches the servo on pin 9 to the servo object.
servo.write(0); // Resets the position.
}

void loop()
{
if (Serial.available()) { // Returns true if there is serial input.
char ch = Serial.read();

if (ch == ‘w’) {
// Make sure not to exceed the mechanical limitation.
if (pos < 180) {
pos += 1;
}
} else {
// Make sure not to exceed the mechanical limitation.
if (pos > 0) {
pos -= 1;
}
}

// Now ask the servo to move to that position.
servo.write(pos);
// Mechnical limitation to the frequency of commands given.
delay(50);
}
}

The "press enter" is a limitation of the Arduino serial monitor. Get any other terminal program and it will send keystrokes immediately.

I use Putty a lot because it's good enough for most things I need. There are better alternatives, some with quite specialised uses.

Hi,

armenvegas == armen_terabelian ? ? ?

Tom..... :slight_smile:

@MorganS thank you

@TomGeorge yes I was using another laptop to code and tried to log in but forgot password so reset and I guess I made an account a while back or something.

I'm sorry wasn't trying to double post or spam

What's the goal of this interface? Is it to eventually have PC software sending the commands, or is it to just interface the keyboard with the wheelchair as an exercise? It's not clear in my head. Pressing keyboard keys to operate a servo that moves the RC TX controls isn't really any easier than manually operating the RC controls directly.
I must be missing something. (I was up most of the night working on a project, so maybe I'm just too tired to see clearly. :slight_smile: )