Show Posts
Pages: [1]
1  Development / Suggestions for the Arduino Project / Problem with rxtxSerial serial_test.c Patch on: January 27, 2013, 10:39:27 pm
Hello,

I am using the wonderful patch that Erwin Ried developed for rxtxSerial that fixes the delays associated with bluetooth and serial ports.  The patch works well and the delays experienced when using the Arduino IDE with bluetooth enabled go away.  However, I have run into a slight change in behavior when using the Serial Monitor adn the patched rxtxSerial.dll and wanted to know if other people are seeing it.

With the version of rxtxSerial.dll that comes with the Arduino IDE when I reset the speed at the bottom of the Serial Monitor the sketch running on the Arduino resets.  By resetting the speed what I am referring to is selecting the drop down with speed selections and then releasing on the speed that was being used before.

Using the patched version of rxtxSerial.dll this no longer happens.

I find this useful when debugging sketches.

Any ideas?

Thanks,

digitalhack
2  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Mystery Solved Again) on: December 28, 2011, 12:26:11 am
I got the parts in for the new design last week and determined I hadn't solved the mystery.  The waves formed by the sets of peaks and valleys were not due to the wheel being untrue.  

I hooked up a QRD1114 and when I plotted the data it looked the same as in the original post.  Unfortunately,  there were valleys that were higher than some of the peaks and this meant there wasn't one voltage that I could set for the comparator.

After some trial and error I determined that I needed to:

1) Move the sensor closer to the encoding disk.  It is now about 1mm to 2mm away from the disk.
2) Decreased the number of stripes on the encoder disk to 32.  

It appears that when the width of the white and black stripes is too narrow you get a higher low reflectance as the sensor gets reflection from a mix of white and black and not just black.  This results in a lower voltage difference between the peaks and valleys.

More to follow...
3  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) (Mystery Solved) on: December 18, 2011, 10:27:15 pm

Understood and thanks much for the help.  I will order the parts and give it a try.
4  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) (Mystery Solved) on: December 18, 2011, 10:20:33 pm
Something like this?



I replaced the QRB114 with a QRD114 which appears to be the replacement.  The parts list would look like this.

2 - FAIRCHILD SEMICONDUCTOR QRD1114
1 - FAIRCHILD SEMICONDUCTOR LM339AN
2 - TRIMMER, POTENTIOMETER 5KOHM 23TURN THD VISHAY SFERNICE T93XB-5K-10-D06
2 - 220 Ohm Resistors
2 - 10K Ohm Resistors

5  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) (Mystery Solved) on: December 18, 2011, 10:40:49 am
Understood, any recommendations on a replacement?
6  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) (Mystery Solved) on: December 17, 2011, 07:57:31 pm
Quote
I am pretty sure this issue would exist no matter if analog or digital versions of this sensor were used
No with the digital version of he sensor you would not see the changes due to distance.

I am using the digital version of this sensor.  I think the reason why it exists with the digital version is that the digital version just allows the analog value to be determined using a capacitor discharge circuit that allows a digital I/O line on a microcontroller to take an analog reading of reflected IR by measuring the discharge time of the capacitor. Shorter capacitor discharge time is an indication of greater reflection.

Digital: QTR-1RC (http://www.pololu.com/catalog/product/959)
Analog: QTR-1A (http://www.pololu.com/catalog/product/958)
7  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) on: December 17, 2011, 12:35:54 pm

Success!

This morning I figured out what was causing the second wave.  The wheel is not completely true and  as it rotates the distance between the sensor and the encode disk varies slightly.  This variation impacts the reflectance of the white and black lines in a consistent fashion.  When the distance between the sensor and the encoder disk is smaller the reflectance is higher for both the white and black and therefore both discharge times are lower.

I am pretty sure this issue would exist no matter if analog or digital versions of this sensor were used and therefore I will account for it in the software reading the sensor.

Thanks for the suggestions and help!

digitalhack
8  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) on: December 16, 2011, 03:25:21 pm
Sorry, I noticed I had the sensor part number incorrectly typed in the subject and several other places.  It is a QTR-1RC and can be found at http://www.pololu.com/catalog/product/959.

Thanks, for the tip on the decoupling capacitors I will look to include them in the design.

9  Using Arduino / Sensors / Re: Wheel Encoder using Digital Reflectance Sensor (Pololu QTR-1RC) on: December 15, 2011, 09:27:30 pm
Grumpy_Mike and dharmiso thanks for the feedback.

Here is a picture and a schematic for the test setup.  In the picture the QTR-1RC (1) is over the wheel.  The power, ground and signal wires are connected to the breadboard (2) and the signal is finally jumpered to pin D2 on the boarduino (3).





I will follow up the pointer on "signal aliasing".  This setup doesn't lend itself to putting an analog filter before the input pin as that would require modifying the QTR-1RC as the output from the sensor is digital and not analog.
10  Using Arduino / Sensors / Wheel Encoder using Digital Reflectance Sensor (Mystery Solved Again) on: December 13, 2011, 12:20:32 pm
Hello,

I am working to implement a wheel  encoder using a Pololu QTR-1RC sensors and an encoder disk glued to the back of the wheel.   I have come across a situation that I cannot explain and wonder if someone else has an idea what is causing it.

The encoder disks on the wheels have 64 black lines and 64 while lines.  Based on this I would expect the discharge times from the sensor to be high 64 times during one rotation of the wheel.  I would also expect the amount of time that it takes to get 64 highs / lows to decrease with increased servo rotation speed.

Based on a graph of the data from the sensor I see what is expected and more.  It turns out that the entire series of highs / lows caused by the black / white lines fluctuates in a wave pattern as well.  This wave pattern, which I cannot explain, exhibits narrower intervals the higher the rotation speed of the servo.

In the graph below the red line represents data when the servo is set to writeMicroseconds 1600 while the blue line is writeMicroseconds 2000.

 

I have posted more detail, including code, of what I am doing at http://digitalhacksblog.blogspot.com/2011/12/abot-wheel-encoders.html if additional information would help.

Thanks,

digitalhack
11  Using Arduino / Installation & Troubleshooting / Re: Arduino 0022 and 1.0 super slow on: December 10, 2011, 10:08:10 am
I am running on Windows 7 Professional 64 bit with Java version 1.7.0 and was having performance problems.  Based on CrossRoads' post I removed my bluetooth dongle and the IDE performance improved significantly.

Thanks!



12  Forum 2005-2010 (read only) / Interfacing / SPI Arduino Master to Arduino Slave on: January 09, 2011, 01:02:07 pm
Folks,

I am working on emulating an SPI slave with a second arduino to ease the process of troubleshooting accessing multiple SPI devices on the same bus.

I have successfully setup several simple examples transferring data from one Ardunio serving as a Master to second one serving as a Slave and from the Slave to the Master.  Where I am having problems is implementing a more sophisticated interface where the Master sends commands to the Slave and the Slave responds with Results.

My hardware setup has the following pin mappings:

Master      Slave
A1 D2 to A2 D5
A1 D10 to A2 D10
A1 D11 to A2 D11
A1 D12 to A2 D12
A1 D13 to A2 D13

Both Ardunio A1 and Ardunio A2 share a common ground.

The goal is:

1) When the Slave has data to send the Master it initiates interrupt 0 via pin 5/pin 2.
2) The Master sends a byte with the value of 17 to the Slave letting it know it is ready to read data.
3) The Slave on getting 17 sends the Mater a byte of value 19.  Eventually this will be more sophisticated data.

The problem is that the Slave hangs after sending 19 to the Master.  It looks like this is Slave is not seeing the SPIF bit set when the bit shift completes.  I have read the documentation for SPI on the ATmega328 and it looks to me like the SPIF bit should be getting set.  

I have come up with several work arounds but I would like to see if there is a way to make it work as it would appear the documentation says it should.

Any help would be much appreciated.

Thanks,

digitalhack

Master Code

Code:
// Master

#define SCK_PIN   13
#define MISO_PIN  12
#define MOSI_PIN  11
#define SS_PIN    10

void MasterInit(void) {  
  // initialize the SPI pins
  pinMode(SCK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  pinMode(SS_PIN, OUTPUT);

  // Enable SPI, set as Master
  SPCR = B00000000;
  SPCR = (1<<SPE)|(1<<MSTR);
}

byte ReadByte(void) {
  while(!(SPSR & (1<<SPIF))) ;
  return SPDR;
}

void WriteByte(byte value) {
  SPDR = value;
  while (!(SPSR & (1<<SPIF))) ;
  return;
}

volatile boolean SlaveDataFlag = false;

void isr(void) {
  SlaveDataFlag = true;
}

void setup() {
  Serial.begin(57600);
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  attachInterrupt(0, isr, LOW);
  MasterInit();
  digitalWrite(SS_PIN, HIGH);
}

void loop() {
  byte txData;
  byte rxData;
  while (true) {
    if (SlaveDataFlag) {
      Serial.println("Slave has data...");

      Serial.println("Writing data to slave...");

      digitalWrite(SS_PIN, LOW);
      WriteByte(17);
      Serial.println("Done Writing data...");

      Serial.println("Reading data from slave...");
      rxData = ReadByte();
      digitalWrite(SS_PIN, HIGH);

      Serial.println("Done Reading data...");

      Serial.print("From Slave: ");
      Serial.println(rxData, DEC);
      SlaveDataFlag = false;
    }
  }
}

Slave Code

Code:
// Slave

#define SCK_PIN   13
#define MISO_PIN  12
#define MOSI_PIN  11
#define SS_PIN    10

void SlaveInit(void) {
  // Set MISO output, all others input
  pinMode(SCK_PIN, INPUT);
  pinMode(MOSI_PIN, INPUT);
  pinMode(MISO_PIN, OUTPUT);
  pinMode(SS_PIN, INPUT);

  // Enable SPI
  SPCR = B00000000;
  SPCR = (1<<SPE);
}

byte ReadByte(void) {
  while(!(SPSR & (1<<SPIF))) ;
  return SPDR;
}

void WriteByte(byte value) {
  SPDR = value;
  while (!(SPSR & (1<<SPIF))) ;
  return;
}

unsigned long lastSent;

void setup() {
  Serial.begin(57600);
  digitalWrite(5, HIGH);
  SlaveInit();
  lastSent = millis();
  pinMode(5, OUTPUT);
}

void loop() {
  if (digitalRead(10) == LOW) {
    Serial.println("Pin 10 low...");
    byte rxData;
    rxData = ReadByte();
    Serial.print("Command: ");
    Serial.println(rxData, DEC);
    if (rxData == 17) {
      Serial.println("Sending data to master...");
      WriteByte(19);
      Serial.println("Done Sending data...");
    }
  }
  if (millis() > lastSent + 2000) {
    Serial.println("Pin 5 low...");
    digitalWrite(5, LOW);
    delay(10);
    digitalWrite(5, HIGH);
    lastSent = millis();
  }
}

Output from Master

Code:
Slave has data...
Writing data to slave...
Done Writing data...
Reading data from slave...
Done Reading data...
From Slave: 19

 
Output from Slave

Code:
Pin 5 low...
Pin 10 low...
Command: 17
Sending data to master...
13  Forum 2005-2010 (read only) / Interfacing / Re: Arduino + Bicycle + Rollers = Headache on: March 02, 2010, 04:24:11 pm
Thanks for all the feedback.  I got things working.  

It doesn't appear to matter if I use 10K or 1K resistors.  What does matter is that I have resistor between the Ardunio pin, the switch leg and ground and another one between the common switch leg and +5v.  If I don't both interrupts fire when either switch closes.

As for all the other problems they appear to have been static.

My breakthrough was that I found out that things worked fine as long as I was holding on to the wall which I do to get up to speed where I can balance the bike.  I could ride all day as long as I had one hand on the wall.

It tried a bunch of things to ground the bike, myself and the rollers but nothing worked.  Finally I put the whole setup on a rubber exercise mat and this solved the problem.  I no longer get strange readings or Arduino lockups.  

Googling information on Bicycle Rollers did come up with a fair amount of talk about static.

Thanks again for all the pointers.

digitalhack
14  Forum 2005-2010 (read only) / Interfacing / Arduino + Bicycle + Rollers = Headache on: February 27, 2010, 02:15:09 pm
Hello,

I am an avid bicyclist and an avid tinkerer.  I figured that one way to make it through the indoor riding season was to combine the two areas.

I figured to start easy and just interface and old Cateye bicycle computer sensor with an Arduino.  Unfortunately, so far it hasn't been anything but easy.

The Cateye sensor consists of two switches and two magnets.  The switches are mounted on the rear chainstay and one magnet is mounted to a spoke and the other to a pedal.  My plan was to hook it up the switches to pins 2 & 3 and then setup a simple interrupt routine to count revolutions.

Problem #1 - Connecting the switches (Solved). smiley  I cut the cable to the two switches and had a devil of a time connecting anything to it so I could connect it to the Arduino.  I couldn't solder it and ended up having to crimp pins to the end of it.

Problem #2 - Extending the cables from the sensor (Solved).  smiley  I wanted to extend the sensor leads so that I could work with the Arduino on my bench while the bike was in the stand.  With my initial setup both interrupts would trigger when either switch closed.  I fixed this by putting 10K ohm resistors between the 5v from the Arduino and the common pin and then 10K resistors between the two switch leads and ground.

Here is what is giving me the headache:  smiley-sad

Problem #3 - Everything works with the bike in the bike stand but not on the rollers.  I setup the Arduino to print out the interrupt counter for the wheel and pedals every five seconds.  In the stand you get a nice consistent set of number.  Start riding on the rollers and you will jump from 150 rpm to 600 rpm between samples.

My current line of troubleshooting is that it has something to do with static electricity being generated between the bicycle tires and the rollers but so far I haven't been able to solve the problem.

If anyone has any ideas I would love to hear them.

Thanks,

digitalhack
Pages: [1]