Pages: 1 [2] 3   Go Down
Author Topic: Problems sending data with two eb301 bluetooth modules and two arduinos  (Read 2401 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

still nothing. im starting to think this is a bigger pain than it's worth...
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tested the servos work if they are sent values in the range 0-179, as in your receive code?

You are either not getting the joystick values to your receiver, or the receiver is getting the values, but isn't able to control the servos with those values.

A simple test sketch in place of the actual receive sketch would allow you to determine what's what.

[OK, finished editing.]

Try this in place of your receive sketch and see if your servos move progressively through their expected range.

Code:
void loop()
{
  delay(1000);

   newval1 += 2;
   if  ((newval1 > 179) ||  (newval1 < 0)) newval1 = 0;

   //newval1 = map(newval1, 0, 1023, 0, 179);
   if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
     myservo1.write(newval1);
     oldval1=newval1;
   }

   newval2 += 2;
   if  ((newval2 > 179) ||  (newval2 < 0)) newval2 = 0;

   //newval2 = map(newval2, 0, 1023, 0, 179);
   if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
     myservo2.write(newval2);
     oldval2=newval2;
   }
 
}
« Last Edit: October 30, 2013, 05:53:14 pm by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

im starting to think this is a bigger pain than it's worth...

Sod what you think, I want to get this going! ;-)
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the servos work, but just not with this code for some reason. i just checked the serial monitor again and now the transmit sketch is messed up because im not getting the same values i was to begin with. im getting random stuff like this


* Untitled.png (74.81 KB, 1920x1080 - viewed 26 times.)
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the servos work, but just not with this code for some reason. i just checked the serial monitor again and now the transmit sketch is messed up because im not getting the same values i was to begin with. im getting random stuff like this

That's to be expected. You are sending integer values now, not strings, so they will look like nonsense when you try to print them as strings.

Is your serial monitor attached to your transmit sketch or your receive sketch?

In any case, try the test loop() for the receive sketch to check your servos are working as expected with the range of values you are sending. DIvide and conquer, it's the only way.
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the serial monitor is connected to the tx code. im using one of my homemade arduinos for the rx side so i can't hook it to the serial monitor, that i know how anyway lol
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the serial monitor is connected to the tx code. im using one of my homemade arduinos for the rx side so i can't hook it to the serial monitor, that i know how anyway lol

Too bad, it would make it easier if you were hooked up to the rx side, but doesn't matter.

If that test loop() function for the receive sketch moves the servos through the expected range, it means the problem is with the reception of values, rather than controlling the servos. If it moves the servos, but through a limited range, then the inverse mapping will have to be fixed. If it doesn't move them at all, then it doesn't matter what the transmit side is doing... nothing is going to happen in any case until the basic servo control gets fixed.
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that test loop code did nothing for it :/ but the servos arent bad.
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

that test loop code did nothing for it :/ but the servos arent bad.

They may be OK, but the software isn't. The best hardware will do nothing until the software is correct.

Have you an example sketch using the "SoftwareServo" lib that moves the servos at all? Perhaps there is an initialisation step you need to include. (Sorry, I'm not familiar with the "SoftwareServo" lib.)

Post that and I'll see if I can spot something that might need to be included in your receive sketch.
Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i took that from the example code from the arduino lib that came with the downloaded software. so honestly im not even sure if it needs the softwareservo.lib
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i took that from the example code from the arduino lib that came with the downloaded software. so honestly im not even sure if it needs the softwareservo.lib

You'll certainly need a servo lib of some description to interface your servos to the Arduinos. You didn't get any of the test/example sketches working with your servos before you started your own sketches? Thats' usually the way to get started, so you know the hardware set-up is compatible with the software assumptions.
« Last Edit: October 30, 2013, 06:25:17 pm by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this one worked but it's using one arduino with the servos and joystick attached
Code:
#include <Servo.h>
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup()
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop()
{
  newval1 = analogRead(potpin1);          
  newval1 = map(newval1, 0, 1023, 0, 179);
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print("2- ");    
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50);
}
« Last Edit: October 30, 2013, 06:29:12 pm by jeremybgilbert » Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

this one worked but it's using one arduino with the servos and joystick attached
Code:
#include <Servo.h>
Well, the first thing that jumps out at me is you are USING A DIFFERENT LIBRARY!

Trying including
Code:
#include <Servo.h>

in your receive sketch rather than

Code:
#include <SoftwareServo.h>

Try the test sketch again, this time with with correct library included, and see if things move this time.

Edit: Just out of interest, where did the #include <SoftwareServo.h> come from?
« Last Edit: October 30, 2013, 06:35:54 pm by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes, i tried using that library first but it never worked so i replaced it with the softwareservo
i cannot remember where i saw the softwareservo at. some sample code online
ive tried both of them with the receiver code but neither works
« Last Edit: October 30, 2013, 06:37:32 pm by jeremybgilbert » Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 828
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes, i tried using that library first but it never worked so i replaced it with the softwareservo

You mean it didn't work with the original tx/rx sketches you wrote? Well, that's not surprising, given the problems that have been identified with it earlier. Let's get the servos working with the test sketch, then we'll get the proper version going.

Edit: BTW, the test sketch will take about 90 seconds to move the servos through their entire range. Deliberately slow, I wasn't sure what you are connected up to and I didn't want to potentially break or stress anything.
« Last Edit: October 30, 2013, 06:43:49 pm by pico » Logged

WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

Pages: 1 [2] 3   Go Up
Jump to: