Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / General Electronics / Re: Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 21, 2012, 04:29:20 pm
Hi everybody!

I've managed to reduce the noise/interference and increase the range somewhat by fiddling around with all the above tips and tricks.
To recap what I've done (I'll post pictures later Iron Man 2 starts on tv soon and I'm a bit tired)
1. I've physically increased the distance between the LED and the RF Receiver.
2. I've decoupled the power rails on the breadboard that holds the RF Receiver, first with a 47 uF Capacitor and then two 1 uF Capacitor close on each GND/VCC pin of the receiver. Also I've added a Ferrite along the VCC power rail of the breadboard (it has a gap in the rails so thats where I put it).
3. On the LED side of the circuit I've shortened the leads of the LED and resistors and added 1 uF capacitors (as described before).

All this did help albeit very little. What actually helped the most was moving the GND source from one side of the Arduino, I originally had both in the GND sockets next to each other. Also changing the transmission speed from 2000 to 300 helped quite a bit.

Well that's it... I hope to improve this but right now I'm too tired. Pictures will come.

EDIT: Added pictures.
2  Using Arduino / General Electronics / Re: Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 19, 2012, 02:44:24 pm
Ok, my order came through pretty quickly but I didn't have the time to try it out until today.

So far I've tried 100pF, 470pF, 1nF, 4n7F and 10nF. None of them really gave me a flawless transmission but I'd say it was a little bit better than before. Not much change from changing caps values.

I've also tried placing three of the ferrites in series with each anode of the LED before the resistor. Also just one ferrite in series with the cathode of the LED to GND. Both of those gave me roughly the same result as the caps.

I've also tried a mix of caps and ferrites.

What else can I try to reduce the interference? Should I continue up in capacitor size until I hit it or are there other approaches?

 
3  Using Arduino / General Electronics / Re: Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 16, 2012, 01:56:11 pm
Ok thank you.

Regarding the ferrite beads. Is this what I'm looking for?
http://www.electrokit.com/en/ferrit-bl01rna62t5-murata-axiell-o3-6x5.43402
or is it one of these?
http://www.electrokit.com/en/thru-hole-mounted-rf-chokes.c370
4  Using Arduino / General Electronics / Re: Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 16, 2012, 11:59:35 am
Ok, thank you ever so much.

Just to make sure I understand you is this how I should connect them? Circuit Diagram

Next question:
Since I don't have any 100pF Caps lying around I need to order them so I thought I might aswell order a whole bunch of various caps while I'm at it. So what if 100pF won't work then what would you suggest I try next?  
The lowest value caps I have at home is 100nF, could I use those?

EDIT: Fixed broken link.
5  Using Arduino / General Electronics / Re: Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 15, 2012, 04:59:46 pm
Yup that worked. It's been running for over ten minutes now and seems to work fine, it does however cause some glitches but these are just momentary.

Is there anything I can do to reduce the interference?

I also added a small 0.1uF capacitor between the +5V and GND pins closest to the antenna on the RF receiver. Allthough I should add this didn't help anything before, but I just haven't removed it yet. I found it in a similar circuit in Tom Igoe's Making Things Talk so I hoped it might help.

6  Using Arduino / General Electronics / Possible bad circuit causing Arduino to hang alt. RF transmission to fail. on: December 15, 2012, 03:04:24 pm
I'm moving a thread from the Programming Questions part of the forum to here since it's starting to look more and more like a hardware issue. Most likely my not quite able circuit building skills.

The short story:
I want to control an RGB LED via a RF Transmitter/Receiver pair using VirtualWire. The transmitter sends 0-1023 from a potentiometer to the receiver that uses the incoming data to control the LED. Everything in this circuit works perfect as long as I don't try to analogWrite to the LED. Well it works for a couple of seconds but then fails. Seemingly no transmission gets through to the receiver.

For the long story check the thread in the link above.

This is what I've checked:
The transmitter is not the problem. It continues to send data after the "hang".
The LED is not the problem. It works just fine if I run the code "locally" on the receiver unit with a potentiometer hooked up.
If I just yank out the LED from the circuit the problems disappear. But I guess that comes from breaking the circuit this removing the issue that might be causing problems.

EDIT: Fixed broken links.
Circuit diagram
Breadboarded Circuit 1
Breadboarded Circuit 2
Breadboarded Circuit 3

Since it looks a bit messy I might aswell say, NO! There are no crossed leads touching.

Anyone able to spot anything that might cause the RF receiver to stop receiveing data or atleast disturb the transmission.

Code parts below for the curious.

Code for the receiver
Code:
/*
  RGB LED controller
*/

#include <VirtualWire.h>

// LED's
int ledPin = 13;

// Sensors
int Sensor1Data;
int potVal;

// RF Transmission container
// char Sensor1CharMsg[5]; // commented out not necessary

// set the ledPins
int ledRed = 6;
int ledGreen = 5;
int ledBlue = 3;

// LED Power variables
byte redPwr = 0;
byte greenPwr = 0;
byte bluePwr = 0;

void setup()
{
  
  // sets the digital pin as output
  pinMode(ledPin, OUTPUT);      
    
    // VirtualWire
    // Initialise the IO and ISR
    // Required for DR3100
    vw_set_ptt_inverted(true);
    // Bits per sec
    vw_setup(2000);
    
    // Start the receiver PLL running
    vw_rx_start();      

  pinMode(ledRed, OUTPUT);
  pinMode(ledGreen, OUTPUT);
  pinMode(ledBlue, OUTPUT);
    
  // serial for debugging purposes only
  Serial.begin(9600);
}

void loop()
{  
  dataRX();
  colorControl();
  
  // DEBUG
  Serial.print("Sensor 1: ");
  Serial.print(Sensor1Data);
  Serial.print(" potVal: ");
  Serial.print(potVal);
  
  
  Serial.print(" redPwr: ");
  Serial.print(redPwr, DEC);
  Serial.print(" greenPwr: ");
  Serial.print(greenPwr, DEC);
  Serial.print(" bluePwr: ");
  Serial.println(bluePwr, DEC);
  // END DEBUG
 

} // END loop()

void dataRX()
 {
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
    
    // Non-blocking
    if (vw_get_message(buf, &buflen))
    {
int i;
        // Turn on a light to show received good message
        digitalWrite(13, true);

        /* Commented out for buffer to integer directly
        
        // Message with a good checksum received, dump it.
        for (i = 0; i < buflen; i++)
{            
          // Fill Sensor1CharMsg Char array with corresponding
          // chars from buffer.  
          Sensor1CharMsg[i] = char(buf[i]);
}
        
        // Null terminate the char array
        // This needs to be done otherwise problems will occur
        // when the incoming messages has less digits than the
        // one before.
        Sensor1CharMsg[buflen] = '\0';
        
        // Convert Sensor1CharMsg Char array to integer
        Sensor1Data = atoi(Sensor1CharMsg);
        
        */
        // Convert buffer directly to Integer String
        Sensor1Data = atoi((const char*)buf);
        
        // Turn off light to and await next message
        digitalWrite(13, false);
  }
  // delay(200);
}

// lightMode 1
void colorControl() {
  
  // read the potentiometer position
  potVal = Sensor1Data;
  
  // RED > ORANGE > YELLOW
   if (potVal > 0 && potVal < 170) {
     redPwr = 255;
     bluePwr = 0;
     greenPwr = map(potVal, 0, 170, 0, 255);
   }
 
   // YELLOW > LIME?? > GREEN
   if (potVal > 170 && potVal < 341) {
     greenPwr = 255;
     bluePwr = 0;
     redPwr = map(potVal, 341, 170, 0, 255);
   }

    // GREEN > TURQOUISE
    if (potVal > 341 && potVal < 511) {
      greenPwr = 255;
      redPwr = 0;
      bluePwr = map(potVal, 341, 511, 0, 255);
    }
 
   // TURQOUISE > BLUE  
   if (potVal > 511 && potVal < 682) {
     bluePwr = 255;
     redPwr = 0;
     greenPwr = map(potVal, 682, 511, 0, 255);
   }
 
   // BLUE > PURPLE
   if (potVal > 682 && potVal < 852) {
     bluePwr = 255;
     greenPwr = 0;
     redPwr = map(potVal, 682, 852, 0, 255);
   }
 
   // PURPLE > RED
   if (potVal > 852 && potVal < 1023) {
     redPwr = 255;
     greenPwr = 0;
     bluePwr = map(potVal, 1023, 852, 0, 255);
   }
  
  // Display colors
  colorDisplay();
}        

// Displays the colors when called from other functions
void colorDisplay() {
  analogWrite(ledRed, redPwr);
  analogWrite(ledGreen, greenPwr);
  analogWrite(ledBlue, bluePwr);
}

Code for the transmitter
Code:
/*

Sensor Transmitter
By Markus Ulfberg 2012-07-06

Takes a sensor reading 0-1023
converts it to a char array and sends
to RF receiver unit via VirtualWire  

*/

#include <VirtualWire.h>

// LED's
const int ledPin = 13;

// Sensors
const int Sensor1Pin = A2;
// const int Sensor2Pin = 3;

int Sensor1Data;
char Sensor1CharMsg[5];


void setup() {

 // PinModes
 // LED
 pinMode(ledPin,OUTPUT);
 // Sensor(s)
 pinMode(Sensor1Pin,INPUT);
 
 // for debugging
 Serial.begin(9600);
 
 // VirtualWire setup
 vw_setup(2000); // Bits per sec


}

void loop() {
  
  // Read and store Sensor 1 data
  Sensor1Data = analogRead(Sensor1Pin);
  
  // Convert integer data to Char array directly
  itoa(Sensor1Data,Sensor1CharMsg,10);
  
  /*
  // DEBUG
  Serial.print("Sensor1 Integer: ");
  Serial.print(Sensor1Data);
  Serial.print(" Sensor1 CharMsg: ");
  Serial.print(Sensor1CharMsg);
  Serial.println(" ");

  // END DEBUG
  */
 
 digitalWrite(13, true); // Turn on a light to show transmitting
 vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));
 vw_wait_tx(); // Wait until the whole message is gone
 digitalWrite(13, false); // Turn off a light after transmission
 delay(200);
 
} // END void loop...
7  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 14, 2012, 01:14:32 am
Took a while but here we go:

Circuit diagram
Breadboarded Circuit 1
Breadboarded Circuit 2
Breadboarded Circuit 3

Since it looks a bit messy I might aswell say, NO! There are no crossed leads touching.

EDIT: Moving this to the General Electronics part forum.
8  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 13, 2012, 12:37:44 pm
That didn't do much but I noticed that if I disconnected the led everything worked. Could it be that the led disturbs the transmission?
9  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 13, 2012, 11:09:42 am
You appear to still have your LEDs connected to pins 9 and 10, which the VirtualWire class uses, unless you tell it to use other pins. Which you don't.

So, it's hardly surprising that as soon as you write to those pins VirtualWire quits working.

Nope, dc42 noted this a while back so I've changed to pins 3,5 and 6.

What happens if you just comment out the analogWrite calls?

That works, it's up and running hand still works after five minutes of continous running. So it seems to be analogWrite that causes trouble.
10  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 04:25:47 pm
It's the receiver that stops receiving.
And it seems it is colorControl() that somehow mixes things up. If I just comment that one out, I can go on for ages.
11  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 02:50:22 pm
Ok, so I've changed the ledpins to use pin 3, 5 and 6.
This actually stops Serial Monitor output from hanging. But it still seems to hang after a while when the Sensor1Data gets stuck with the same number.
12  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 11:17:22 am
Try:
Code:
Sensor1Data = atoi((const char*)buf);

Sorry to say I got the same problem as before. A couple of lines fly by in the Serial Monitor before it hangs. Commenting out the Serial.print lines does not help either.

Again if I don't include the colorControl(); function everything seems to work just fine.
13  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 04:07:29 am
Try:

Code:
Sensor1Data = atoi((const char*)buf);

That compiled, as I suspect you already knew. Unfortunately I will have to wait a couple of hours before I can try it live. However as I do like to know what I'm coding could you please tell me or point me in a good direction to find reading material as to what actually is done in that line. Am I just stating that buf is a const char* or does (const char*)buf perform some sort of change?
14  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 03:03:31 am
Code:
/*
  RGB LED controller
  4 modes: off, color select, color pulse and random cycle/pulse
  By Markus Ulfberg 2009-05-19
 
  Updated to Version 2 - 2010-01-13 (Not publicly released)
  Updated to Version 3 - 2011-12-14

  Thanks to: Ladyada, Tom Igoe and
  everyone at the Arduino forum for excellent
  tutorials and everyday help.

  TODO:
  1. Use millis for debounce instead of delay.

*/

#include <VirtualWire.h>

// LED's
int ledPin = 13;

// Sensors
int Sensor1Data;
int potVal;

// RF Transmission container
char Sensor1CharMsg[5];

// set the ledPins
int ledRed = 10;
int ledGreen = 9;
int ledBlue = 6;

// LED Power variables
byte redPwr = 0;
byte greenPwr = 0;
byte bluePwr = 0;

void setup()
{
 
  // sets the digital pin as output
  pinMode(ledPin, OUTPUT);     
   
    // VirtualWire
    // Initialise the IO and ISR
    // Required for DR3100
    vw_set_ptt_inverted(true);
    // Bits per sec
    vw_setup(2000);
   
    // Start the receiver PLL running
    vw_rx_start();       

  pinMode(ledRed, OUTPUT);
  pinMode(ledGreen, OUTPUT);
  pinMode(ledBlue, OUTPUT);
   
  // serial for debugging purposes only
  Serial.begin(9600);
}

void loop()

  dataRX();
  colorControl();
 
  // DEBUG
  Serial.print("Sensor 1: ");
  Serial.print(Sensor1Data);
  Serial.print(" potVal: ");
  Serial.print(potVal);
 
  Serial.print(" redPwr: ");
  Serial.print(redPwr, DEC);
  Serial.print(" greenPwr: ");
  Serial.print(greenPwr, DEC);
  Serial.print(" bluePwr: ");
  Serial.println(bluePwr, DEC);
 
  // End debug     
  // END DEBUG

} // END loop()

void dataRX()
 {
   uint8_t buf[VW_MAX_MESSAGE_LEN];
   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
    // Non-blocking
    if (vw_get_message(buf, &buflen))
    {
int i;
        // Turn on a light to show received good message
        digitalWrite(13, true);

        /* Commented out for buffer to integer directly
       
        // Message with a good checksum received, dump it.
        for (i = 0; i < buflen; i++)
{           
          // Fill Sensor1CharMsg Char array with corresponding
          // chars from buffer.   
          Sensor1CharMsg[i] = char(buf[i]);
}
       
        // Null terminate the char array
        // This needs to be done otherwise problems will occur
        // when the incoming messages has less digits than the
        // one before.
        Sensor1CharMsg[buflen] = '\0';
       
        // Convert Sensor1CharMsg Char array to integer
        Sensor1Data = atoi(Sensor1CharMsg);
        */
       
        // Convert buffer directly to Integer String
        Sensor1Data = atoi(buf);
       
        // Turn off light to and await next message
        digitalWrite(13, false);
  }
  // delay(500);
}

// lightMode 1
void colorControl() {
 
  // read the potentiometer position
  potVal = Sensor1Data;
 
  // RED > ORANGE > YELLOW
   if (potVal > 0 && potVal < 170) {
     redPwr = 255;
     bluePwr = 0;
     greenPwr = map(potVal, 0, 170, 0, 255);
   }
 
   // YELLOW > LIME?? > GREEN
   if (potVal > 170 && potVal < 341) {
     greenPwr = 255;
     bluePwr = 0;
     redPwr = map(potVal, 341, 170, 0, 255);
   }

    // GREEN > TURQOUISE
    if (potVal > 341 && potVal < 511) {
      greenPwr = 255;
      redPwr = 0;
      bluePwr = map(potVal, 341, 511, 0, 255);
    }
 
   // TURQOUISE > BLUE 
   if (potVal > 511 && potVal < 682) {
     bluePwr = 255;
     redPwr = 0;
     greenPwr = map(potVal, 682, 511, 0, 255);
   }
 
   // BLUE > PURPLE
   if (potVal > 682 && potVal < 852) {
     bluePwr = 255;
     greenPwr = 0;
     redPwr = map(potVal, 682, 852, 0, 255);
   }
 
   // PURPLE > RED
   if (Sensor1Data > 852 && potVal < 1023) {
     redPwr = 255;
     greenPwr = 0;
     bluePwr = map(potVal, 1023, 852, 0, 255);
   }
   
  // Display colors
  colorDisplay();
}       

// Displays the colors when called from other functions
void colorDisplay() {
  analogWrite(ledRed, redPwr);
  analogWrite(ledGreen, greenPwr);
  analogWrite(ledBlue, bluePwr);
}
15  Using Arduino / Programming Questions / Re: VirtualWire or String causes arduino to hang on: December 12, 2012, 01:05:47 am
Thanks for all the suggestions but I'm afraid I'm still going nowhere here.

What about the Serial.print lines? If you remove all those, does the program work?

Nope that didn't work.

Oh yes I see. That loop is the issue. Maybe a memcpy would be simpler. And choose the length as the destination length, not the source length.

This I have to research more if I should go ahead and do. So I'll put this on hold if the next one is simpler.

...or convert the data directly from 'buf' instead of copying it to Sensor1CharMsg.

I tried this but that didn't work. Allthough I doubt I did it right. Am I looking for a char to integer converter or something else?
Code:
Sensor1Data = atoi(buf);

Error Message
Code:
conversion from 'uint8_t*' to 'const char*'
rgb_mixer_RF_controlled_pulse_makkan_v4_ino:115: error: initializing argument 1 of 'int atoi(const char*)'

Pages: [1] 2 3 ... 7