Active Topics

 


Reply
Thread Tools
cmdowns's Avatar
Posts: 100 | Thanked: 13 times | Joined on Mar 2008
#21
I was wondering if it would be possible to use the nokia as a transmitter (via bluetooth) and the arduino bt as a receiver, and use that set up as a diy RC system.

I'm not sure what the best way to send info to the arduino, other than it needing it to be serial. I wonder what app on the nokia would be simplest to send out some serial instructions through the nokia's bt. And I don't really know how the arduino bt works.

From what I understand, the arduino IDE (running on a terminal on some machine) can send and receive info from the arduino bt. But something tells me that this is not the best way to set up controlling the arduino. It seems like it would require constant reprogramming in the IDE, which in turn would require the time involved in recompiling and reuploading to the uC.

It seems like most of the folks out there that have gotten the nokia to talk to the arduino have done so using Python. I don't know anything about Python, but I am willing to learn.

Is there any reason that setting up the serial communication through bt couldn't work with the nokia-as-super-robot-brain idea? Obviously, one would loose some of the functionality described before, such as the nokia's camera and voice synthesis capabilities (or lose them as a useful feature on the robot).

However, if one could use the bt to communicate between the nokia and the arduino, and retain the nokia's role as the superlogic that interprets the info it gets from the arduino, that might be interesting.
 
Posts: 155 | Thanked: 69 times | Joined on Apr 2008
#22
I think you have a nice idea. I don't see any reason why the superbrain wouldn't work over bluetooth. The only gotcha is that there is one more thing (bluetooth) to configure and get working before you see anything happen.

Here's some example code that opens a bluetooth serial connection:
http://wiki.bluez.org/wiki/HOWTO/SerialConnections

I think the "device" it mentions is going to be something like "/dev/rfcomm0" on the NIT. Once the example code has created that, then you need a program to use it. Probably a terminal program like minicom or something would be good to start with. Then you could try stuff out just by typing in the window and see any responses the arduino sends back.

Later you start writing your "brain" program that does commands automatically.

One thing to mention... I think it's very important to take baby steps in a project like this with a lot of unfamiliar stuff. For example... Hook up arduino and get the simplest thing to happen with the IDE. Make an LED flash with the arduino or something. Fiddle with bluetooth serial and make the simplest thing happen so you know it's working. etc...
 
cmdowns's Avatar
Posts: 100 | Thanked: 13 times | Joined on Mar 2008
#23
I think you have a very good point about baby steps, taking things slowly etc.

So, if one wished to hook up the tablet to the arduino and send the most basic serial info from the tablet to the arduino, where would on start? Does one need to do anything fancy to get the tablet to send serial info over the usb port?

It sound like maybe that was the inital subject of this thread. Does anyone know if any progress was made?
 
Posts: 6 | Thanked: 4 times | Joined on Nov 2007
#24
Originally Posted by cmdowns View Post
I think you have a very good point about baby steps, taking things slowly etc.

So, if one wished to hook up the tablet to the arduino and send the most basic serial info from the tablet to the arduino, where would on start? Does one need to do anything fancy to get the tablet to send serial info over the usb port?

It sound like maybe that was the inital subject of this thread. Does anyone know if any progress was made?
I was able to talk to my arduino over serial from my 770 (See my post on page 1). You'll need a USB power injector because the 770 wasn't meant to be used as a USB host. Then use the FTDI driver fanoush complied on the first page of this thread.

In my project I used vnc to connect to the 770 over wifi. Then when I pressed the up key in the vncviwer the 770 would send a command to the arduino over serial which would turn on 2 motor controllers.
Below is the simple python code that I used to talk to the ardino. It uses pygame to see when a key is pressed and pyserial to send commands to the arduino.
Code:
import serial
import time

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Pygame Caption')
pygame.mouse.set_visible(0)

done = False

ser = serial.Serial('/dev/tty.usbserial-A4001u0a', 9600, timeout = 1)
while not done:
   for event in pygame.event.get():
      if (event.type == KEYUP) or (event.type == KEYDOWN):
         print event
         if (event.key == K_ESCAPE):
            done = True
         
         elif (event.key == K_UP):
                if (event.type == KEYUP):
                        ser.write('1')
                else:
                        ser.write('0')

                        #print ser.readlines()
         
         elif (event.key == K_DOWN):
                if (event.type == KEYUP):
                        ser.write('3')
                else:
                        ser.write('2')
If you are new to python check out http://diveintopython.org/. It is a great free online book about the basics of python. Also check out the pygame and pyserial tutorials.

Here is the arduino sketch I used:
Code:
/*Messing around with pygame and motor controller  */

#define pwmPin 9
#define dirPin 10

#define forwardDown 48
#define forwardUp 49
#define backDown 50
#define backUp 51



void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  pinMode(pwmPin, OUTPUT);      // sets the digital pin as output
  pinMode(dirPin, OUTPUT);  

   
}

void loop()                     // run over and over again
{
  
  if (Serial.available() > 0) {
    
    // read the incoming byte:
    int incSerialByte = Serial.read();
    
    // say what you got:
    Serial.print("I received: ");
    Serial.print(incSerialByte, DEC);
    
    
    if(incSerialByte == forwardDown)
    {
      analogWrite(pwmPin, 255);  
      Serial.println(" forwardDown");
    }
    else if(incSerialByte == forwardUp)
    {
      analogWrite(pwmPin, 0);
      Serial.println(" forwardUp");
    }
    else if(incSerialByte == backDown)
    {
      digitalWrite(dirPin, HIGH);
      analogWrite(pwmPin, 255); 
      Serial.println(" backDown");
      
    }
    else if(incSerialByte == backUp)
    {
      digitalWrite(dirPin, LOW);
      analogWrite(pwmPin, 0); 
      
      Serial.println(" backUp");
    }

  
  }
}
A final note, I wouldn't try to get the arduino ide working on the 770. I think that is going to be a lot of work for nothing. You will need to get java and a bunch of c libraries working on the 770. Use your desktop to develop and send your sketches to the arduino. Then just talk to the the arduino over serial from the 770.
 

The Following 3 Users Say Thank You to D-rock For This Useful Post:
Posts: 155 | Thanked: 69 times | Joined on Apr 2008
#25
Great post! Very clear and useful.
 
cmdowns's Avatar
Posts: 100 | Thanked: 13 times | Joined on Mar 2008
#26
I promise I am making a good faith effort to figure this stuff out on my own. I appreciate all the assistance that I get from the various users on this forum.

I am trying to implement the instructions laid out in D-rock's post#24. Unfortunately, I'm not making much progress.

I have installed pySerial on my n800 (OS2008). I have copied and pasted D-rock's Python code into my pyGTKEditor and attempted to run it from there. This is what I get back:

Code:
/usr/bin/python_serial.py:4: RuntimeWarning: import cdrom: No module named cdrom

import pygame

/usr/bin/python_serial.py:4: RuntimeWarning: import joystick: No module named joystick

import pygame

Traceback (most recent call last):

File "/usr/bin/python_serial.py", line 14, in <module>

ser = serial.Serial('/dev/tty.usbserial-A4001u0a', 9600, timeout = 1)

File "/usr/bin/serial/serialutil.py", line 156, in __init__

self.open()

File "/usr/bin/serial/serialposix.py", line 141, in open

raise SerialException("Could not open port: %s" % msg)

serial.serialutil.SerialException: Could not open port: [Errno 2] No such file or directory: '/dev/tty.usbserial-A4001u0a'

Press ENTER to continue ...
Honestly, I don't even know what this means. But I get the impression that it means that the code isn't running correctly. Can any benevolent guru out there give me an idea what I am doing wrong and what I need to do in order to make this code run on my tablet? I will be eternally grateful.
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#27
Originally Posted by cmdowns View Post
Code:
ser = serial.Serial('/dev/tty.usbserial-A4001u0a', 9600, timeout = 1)
Honestly, I don't even know what this means. But I get the impression that it means that the code isn't running correctly.
Looks like D-rock's example directly references a serial port device under /dev. Unless you have the exactly same brand and model of USB-to-Serial adapter, the device name under /dev is different.

There are ways to find out which name the adapter has. I would look kernel messages after plugging in the device, i.e. typing dmesg on the shell prompt. There will be a lot of kernel output and the last few lines should mention something about a new USB device.
 

The Following User Says Thank You to For This Useful Post:
Posts: 20 | Thanked: 1 time | Joined on Apr 2008
#28
ok, so you`ve been able to send messages to arduino. but can you receive messages like voltage? at a high speed? my aim is to create a multi channel voltmeter api and use it in Adobe Flash (preferred). is it even possible to receive volt measurements over arduino-> NIT serial connection? I need the 4channel data at least at 5-10 frames per second.. sounds possible?
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#29
Originally Posted by valtersboze View Post
is it even possible to receive volt measurements over arduino-> NIT serial connection? I need the 4channel data at least at 5-10 frames per second.. sounds possible?
4 channels * 10 samples/s * 2 bytes/sample/channel = 80 bytes/s

That's a very low amount of data, well within the capabilities of Arduino and the USB-to-Serial connection.

Disclaimer: I've never used Arduino myself, but I deal with microcontrollers daily. Atmel AVRs too, sometimes (it's what the Arduino is based on).
 
cmdowns's Avatar
Posts: 100 | Thanked: 13 times | Joined on Mar 2008
#30
I'm really glad this thread is still active. I'm still tyring to replicate D-rock's project as described in post 24. With the somewhat minor exception that I am using an n800 as opposed to the 770 he refers to.

My question is, do I still need to use the power injector as he describes:
Originally Posted by D-rock View Post
I was able to talk to my arduino over serial from my 770 (See my post on page 1). You'll need a USB power injector because the 770 wasn't meant to be used as a USB host.
I've been reading up on the n8xx's USB host mode, and it seems it doesn't have too much problem supplying power to things like USB keys. Can anyone tell me if the n800 can supply enough power to run an Arduino?

Thanks in advance for the consideration.
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:46.