HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Feb 19, 2013, 11:18 AM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
300 Posts
The arduino on which the NRF24L01 is connected didn't like i2c in my setup. Tried that road, couldnt'get it to work. Let me know if you can figure out how to get it working, NRF24L01 and i2c together. I would advice to first try it outside the boat.

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Sign up now
to remove ads between posts
Old Feb 19, 2013, 12:39 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,603 Posts
Accordig to the spec sheet, the nRLF24L01 is designed for SPI, as evidenced by the MOSI/MISO pins. The sheet doesn't mention I2C at all and I don't see any SDA/SCL pins on the schematic.

But that wouldn't stop you from communicating between Arduino's via I2C, if you wanted to, and still talk to the nRLS2401 via SPI, as the Arduino supports both protocols.
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 21, 2013, 01:08 PM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
Today I did some more testing after having written a new program.
I still didn't manage to get transmission from the laptop through the USB cable and the comm Arduino to the executing Arduino.
At some point it came to mind that serial communications require a common - wire which I at first did not have.
After having fixed that it still didn't work.
Then I started to realise that the USB cable might be the cause for these failures as the - wire in the USb cable is most likely used as - for the comm Arduino whilst the executing Arduino has it's - connected to the battery.
That means that the only way to check if this program works is by removing the USB cable from the scene and going wireless...
That will make it harder to find problems if something doesn't work but it would still be much easier then when the lack of a common - wire leaves the system unable to work at all...

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Feb 21, 2013, 01:32 PM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
300 Posts
Softserial is the answer, or you have to wait for the Mega's. Then you can use RXTX 1-3 for the executing arduino's. The code I send you might also be usefull for others. It's a little demo program for two arduino's working seperate from a computer. The code is a+number for selecting a function group (a and A are now the same group). The number is the execution value. In this case a potentiometer is read, a letter is added to the command and send through the serial to the other arduino. The second arduino receives the command. Splits the group letter and value and executes the command. In this case, make 1 led brighter and one led dimmer by turning the pot.

The code to Tweety was in Dutch. Ledwaarde mean LedValue.

Danny


RX part:
Code:
char buffer[64]; 
const int LedPin1 = 9;
const int LedPin2 = 10;

void setup() 
//Setup for communication
{ 
  Serial.begin(9600); 
  Serial.flush();
}

//start reading
void loop() 
{ 

  if (Serial.available() > 0) { 
    int index=0; 
    delay(10); // take some time to fill the buffer 
    int numChar = Serial.available(); 
    if (numChar>64) { 
      numChar=64; 
    } 
    while (numChar--) { 
      buffer[index++] = Serial.read(); 
    } 
    splitString(buffer); 
  } 
} 

// function for receiving serial data up to 64 characters
void splitString(char* data) { 
  char* parameter; 
  parameter = strtok (data, " ,"); 
  while (parameter != NULL) { 
    setFunction(parameter); 
    parameter = strtok (NULL, " ,"); 
  } 
  // clear buffer 
  for (int x=0; x<64; x++) { 
    buffer[x]='\0'; 
  } 
  Serial.flush(); 
}

void setFunction(char* data) { 
    if ((data[0] == 'a') || (data[0] == 'A')) { 
    int Ledwaarde = strtol(data+1, NULL, 10); 
    analogWrite(LedPin1,Ledwaarde);
    Ledwaarde = map(Ledwaarde,0,255,255,0); // reverse numbers
    analogWrite(LedPin2,Ledwaarde);
    }
   }

TX part
Code:
int analogValue1; char msga[140] = ""; int var1old = 0; int val1 = 550;

void setup(){
Serial.begin(9600);

}
void loop(){
// read analog 1 pin
analogValue1 = analogRead(A1);
val1 = map(analogValue1, 0, 1023, 0, 255);
delay(20);

// read the analog pin and put an A in front of the value
 char msga[140] = "";
 char a[17];
 int v = val1;
 if (v != var1old) {
 itoa(v, a, 10);
 strcat(msga, "a");
 strcat(msga, a);
 Serial.write(msga);
Serial.flush();
}

//new value becomes the new old value so it only send when the value changes 
  var1old = v;  
}

The Schematic (export from Fritzing):

Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Old Feb 21, 2013, 04:46 PM
Registered User
Deckie's Avatar
Australia, WA, Garden Island
Joined Nov 2010
464 Posts
Once you replace the current boards with the megas, all you need to use is the builtin jumpers to switch both to battery power, which turns the usb into a pure data cable, no grounding. You will then have the common ground between the boards that i2c and it now seems, serial, require to work.
Deckie is offline Find More Posts by Deckie
Reply With Quote
Old Feb 22, 2013, 05:36 AM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
I already have 1 Mega acting as comm Arduino (to which the USB cable is attached during these tests) so it's certainly NOT the case that the USB cable is interfering on the used RX and TX port.
As this tends to be missed I'll mention then type of Arduino every time I mention any Arduino...

I will try to find a way to stop the power from the USB cable or else I'll try wireless control.
When checking Danny's program I see another reason for not getting it to work like I want: the executing Arduino Uno has no code telling it what the command is all about and what to do with it.
I'll need to combine the earlier program with this newer program to get it to work.

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Feb 23, 2013, 01:39 AM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
As Danny's code is designed for 2 Arduinos which are to communicate with each other using the pot meter as input this code will need to be expanded for use the way I want to use it.
Besides, I also need to add the existing code for executing the commands to the program for the executing Arduino Uno (and soon to be Mega as well...).
I think that that last point should not be all to hard for me now, expanding the code to listen to the USB and then send that through might be more difficult.
Any help in this would be appreciated.

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Feb 25, 2013, 06:02 AM
Registered User
Deckie's Avatar
Australia, WA, Garden Island
Joined Nov 2010
464 Posts
Quote:
Originally Posted by tweety777 View Post
I already have 1 Mega acting as comm Arduino (to which the USB cable is attached during these tests) so it's certainly NOT the case that the USB cable is interfering on the used RX and TX port.
As this tends to be missed I'll mention then type of Arduino every time I mention any Arduino...

I will try to find a way to stop the power from the USB cable or else I'll try wireless control.
When checking Danny's program I see another reason for not getting it to work like I want: the executing Arduino Uno has no code telling it what the command is all about and what to do with it.
I'll need to combine the earlier program with this newer program to get it to work.

Greetings Josse
Uno's were meant to auto-select. That is, if you have the USB cable and the DC supply cable plugged in at the same time, it will preferentially use power from the latter, and not from the former. If it OR the mega is using the USB and not the DC, then you won't have a common ground and I2C will not work. Both must be running off USB ports from the same hub/computer or both off the same DC power supply. Anything else and I2C will not work. But you won't know until you have the code on the Uno for it to action, to give you diagnosis info to work from. I have the SHIP-TECT test bed with the bow Uno and the Main Mega working over I2C. It absolutely refuses to work if they are running in any power supply combination other than USB (Uno) + USB (Mega) or common DC (Uno) + common DC (Mega).

Of course, if it still won't work after that, then it get's even more interesting!
Deckie is offline Find More Posts by Deckie
Last edited by Deckie; Feb 25, 2013 at 06:08 AM.
Reply With Quote
Old Mar 06, 2013, 01:09 PM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
Finally I got my order in, weird thing is that an order from 2 weeks ago arrived last Monday whilst the order from 4 weeks ago (including the Arduinos and water pumps and stepper motors) arrived last Tuesday...
I already replaced the Uno by the newly arrived Mega so I now only have Arduino MEGA'S in my boat.

I tested the water pump at 6V and it seems to give enough water for 1 fire monitor though proper testing would be required, I only tested in a small sink in the kitchen.
I also received 9 small relays which will be used to power the pumps and LED's in larger amounts.

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Mar 07, 2013, 10:56 AM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
Does anyone know how to connect the stepper motor to an Arduino?
I got +, - and 4 other connections, presumably to control the motor.
Do I need to connect all of them?
And to what sort of pin?
A PWM pin or will an I/O pin do?
I would think at least 1 PWM pin would be required.

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Mar 07, 2013, 05:18 PM
Registered User
Ariel WA
Joined Apr 2005
339 Posts
Josse

I'm no expert. I believe you need a stepper controller that out puts the steps you need. Stepper motor have 2 sets of coils a+ a- and b+ b- . You Arduino is programed to put out setp and directiion to the controller.

Others will have more and better information

Dave
Phoneman2005 is offline Find More Posts by Phoneman2005
Reply With Quote
Old Mar 07, 2013, 09:34 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,603 Posts
Josse,

You will need a stepper controller, something like one of these. Also, you need to know if your stepper is unipolar or bipolar to get the right one.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Mar 08, 2013, 12:22 AM
Registered User
tweety777's Avatar
Vlaardingen, The Netherlands
Joined Nov 2008
1,342 Posts
The stepper controller is included, the wires I was talking about are those for which the controller has pins.

Greetings Josse
tweety777 is offline Find More Posts by tweety777
Reply With Quote
Old Mar 08, 2013, 08:54 AM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,603 Posts
Sorry Josse,

Misunderstood the question. Try this link. It explains how to wire steppers with 4 or 6 wires.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Mar 08, 2013, 09:28 AM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
300 Posts
Josse,
try google search Arduino ULN2003.

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Build Log Diving supportvessel Well Enhancer 1:75 tweety777 Scale Boats 1667 Yesterday 01:37 PM
Discussion KK Plus 5.5d/e Best value Enhanced KK Controller And MEMS/ACC Module dt8666 Multirotor Electronics 3396 Aug 27, 2014 12:07 PM
Discussion High Tech High Senior Project - Looking for Help & Suggestions! hth.uav Electric Plane Talk 13 May 16, 2012 07:32 AM
Discussion General rules for control surfaces ratios for aircraft? As well as CG's? GreenAce92 3D Flying 27 Feb 07, 2010 02:15 PM
My obscenely low tech, yet somehow high tech, camera mount eBird Aerial Photography 29 Dec 31, 2004 06:49 PM