Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 114
61  Using Arduino / General Electronics / Re: DAC in arduino DUE on: May 06, 2013, 09:11:39 am
Yes, but be very careful what you connect it to, a lot of us have accidentally burned ours.

The opamp suggestion from tmd3 is a good suggestion, without this or a similar buffer between the DAC and your load, your DAC might not last very long - mine didn't

Duane B
rcarduino.blogspot.com

62  Using Arduino / Audio / Re: How to make speaker louder. on: May 05, 2013, 12:34:20 am
Same chip, different circuit -

http://rcarduino.blogspot.com/2012/08/adding-audio-to-arduino-projects.html

Duane B

rcarduino.blogspot.com
63  Using Arduino / Motors, Mechanics, and Power / Re: Changing Servo library frequency? on: May 05, 2013, 12:31:24 am
Although your servo should work just fine with the standard servo library, you can also take advantage of the higher refersh rate with this alternative library -

http://rcarduino.blogspot.ae/2012/11/how-to-read-rc-channels-rcarduinofastlib.html

Duane B

rcarduino.blogspot.com
64  Using Arduino / General Electronics / Re: IR Beam Interrupt on: April 30, 2013, 09:55:33 am
Quote
Seems to be the wrong link?  It's about controlling multiple servos from a RC transmitter.

Sorry, see below -
http://rcarduino.blogspot.ae/2012/07/lap-timer-build-along-part-one.html

http://rcarduino.blogspot.com/2012/08/lap-timer-build-along-part-2-transponder.html

Duane B
rcarduino.blogspot.com




65  Using Arduino / Audio / Re: Timers for audio on: April 30, 2013, 04:22:46 am
for cli and sei you should use nointerrupts and interrupts instead, these globally disable or enable interrupts and are available on all Arduino platforms

Duane B

rcarduino.blogspot.com
66  Using Arduino / Programming Questions / Re: RISING and FALLING ISR on same pin? on: April 30, 2013, 04:20:11 am
simple example of reading a pulse using CHANGE and digitalRead for the pin state

http://rcarduino.blogspot.ae/2012/01/how-to-read-rc-receiver-with.html

Duane B

rcarduino.blogspot.com
67  Community / Products and Services / Re: Analog bass synthesizer shield on: April 30, 2013, 12:44:32 am
Demo ?

Duane B

rcarduino.blogspot.com
68  Using Arduino / General Electronics / Re: IR Beam Interrupt on: April 30, 2013, 12:25:21 am
This project does something similar, It has an IR Transmitter fitted and the Arduino looks for the presence of the IR to count a lap, you want to look for the abscense of the IR to indicate a person, but the principle is the same -

http://rcarduino.blogspot.ae/2012/01/can-i-control-more-than-x-servos-with.html

Duane B

rcarduino.blogspot.com

69  Using Arduino / Motors, Mechanics, and Power / Re: Software Servo Library with Digital/Analog Servos on: April 30, 2013, 12:11:18 am
You do not want to use the software servo library, at one time the standard servo library that comes with Arduino was limited to a small number of servos, but for years now it has been able to support 12, it is very well known, very well supported and very reliable. Best of all the standard library does not require you to call refersh every 50ms.

Here is an example you can use right now that drives 12 servos with the standard library -

http://rcarduino.blogspot.ae/2012/01/can-i-control-more-than-x-servos-with.html

Duane B

rcarduino.blogspot.com
70  Using Arduino / Motors, Mechanics, and Power / Re: Software Servo Library with Digital/Analog Servos on: April 29, 2013, 07:01:20 am
Yes, most servos are designed to work with the standard RC Pulse range of 1000 to 2000 microseconds as provided by the Arduino Servo library - I assume that you mean the standard Arduino Servo library when you refer to 'Software Servo' ?

Duane B

rcarduino.blogspot.com
71  Products / Arduino Due / Re: 4 channel RC reading jitter on: April 27, 2013, 01:25:11 pm
8 Channel RC Reading/writing/loopback code now up here -

http://rcarduino.blogspot.ae/2013/04/reading-rc-channels-with-arduino-due.html

Duane B

rcarduino.blogspot.com
72  Products / Arduino Due / Re: Suspected Bug - Micros or Interrupts on: April 27, 2013, 01:23:07 pm
Hi,
   Thanks Stimmer for your work on the confirmation and resolution.

Duane B

rcarduino.blogspot.com
73  Products / Arduino Due / Re: 4 channel RC reading jitter on: April 26, 2013, 01:44:44 am
Hi,
   It looks as if the error comes from a combination of interrupts and the way in which micros is implemented, you can find more information and a suggested fix to the Due cores here -

http://arduino.cc/forum/index.php/topic,162787.0.html

Try the code in the post above with the fix to the micros function and let us know how you get on by posting in the topic linked above

Once you have this fix in place, the 4 channel code should also be fine

Duane B

rcarduino.blogspot.com
74  Using Arduino / Project Guidance / Re: RC Traction control - accurately measuring wheel speed on: April 25, 2013, 01:21:46 pm
As far as i know timer capture only works on the single timer capture pin - great for a single wheel, not much use for four wheels though.

Duane B

rcarduino.blogspot.com
75  Products / Arduino Due / Suspected Bug - Micros or Interrupts on: April 25, 2013, 12:47:50 pm
Hi,
   The following sketch reproduces a bug whereby interrupts are reporting the time as measured using micros to be either 1,000 micros too soon or 1,000 micros too late.

The code is a lightly modified version of a pattern used man times to measure RC Channels on the AVR Platforms. I have stripped the sketch down, changed the data types and added some additional tracking variables to assist with debug.

The sketch implements a loop back where a servo signal is output on pin 8 and read back in on pin 2. Over a period of time, the signal read back in will alternate between periods of being correct, 1,000 micros too short and 1,000 micros too long, each of these conditions can be seen repeatedly for short periods while the sketch is running - sample output below -
The columns are

Pulse Width, start time in micros, end time in micros, pulse width, Time since last rising edge, time since last falling edge

Code:
1102 12823887 12824989 1102 20001 20002
1102 12843888 12844990 1102 20001 20001
1102 12863889 12864991 1102 20001 20001
1102 12883890 12884992 1102 20001 20001
1102 12903891 12904993 1102 20001 20001
1102 12923892 12924994 1102 20001 20001
1101 12943894 12944995 1101 20002 20001
1102 12963895 12964997 1102 20001 20002
1102 12983896 12984998 1102 20001 20001
1102 13003897 13004999 1102 20001 20001
102 13023898 13024000 102 20001 19001    // we lost 1,000 micros on the falling edge here ?
102 13043899 13044001 102 20001 20001
102 13063900 13064002 102 20001 20001
101 13083902 13084003 101 20002 20001
102 13103903 13104005 102 20001 20002
102 13123904 13124006 102 20001 20001
102 13143905 13144007 102 20001 20001
102 13163906 13164008 102 20001 20001
102 13183907 13184009 102 20001 20001
102 13203908 13204010 102 20001 20001
101 13223910 13224011 101 20002 20001
102 13243911 13244013 102 20001 20002
102 13263912 13264014 102 20001 20001
1102 13283913 13285015 1102 20001 21001 // we gained 1,000 micros on the rising edge here ?
1102 13303914 13305016 1102 20001 20001
1102 13323915 13325017 1102 20001 20001


This pattern continues with the measured pulse being reported as 100,1000 or 2000

Anyone seen something similar with interrupts or micros ?

Loop back test code -
Code:
//
// rcarduino.blogspot.com
//
// A simple approach for reading RC Channels using interrupts
//
// See related posts -
// http://rcarduino.blogspot.co.uk/2012/01/how-to-read-rc-receiver-with.html
// http://rcarduino.blogspot.co.uk/2012/03/need-more-interrupts-to-read-more.html
// http://rcarduino.blogspot.co.uk/2012/01/can-i-control-more-than-x-servos-with.html
//
// rcarduino.blogspot.com
//

#include "Servo.h"

// Assign your channel in pins
#define THROTTLE_IN_PIN 2

// Assign your channel out pins
#define THROTTLE_OUT_PIN 8

// Servo objects generate the signals expected by Electronic Speed Controllers and Servos
// We will use the objects to output the signals we read in
// this example code provides a straight pass through of the signal with no custom processing
Servo servoThrottle;

// These bit flags are set in bUpdateFlagsShared to indicate which
// channels have new signals
#define THROTTLE_FLAG 1

// holds the update flags defined above
volatile uint32_t bUpdateFlagsShared;

// shared variables are updated by the ISR and read by loop.
// In loop we immediatley take local copies so that the ISR can keep ownership of the
// shared ones. To access these in loop
// we first turn interrupts off with noInterrupts
// we take a copy to use in loop and the turn interrupts back on
// as quickly as possible, this ensures that we are always able to receive new signals
volatile uint32_t ulThrottleStartShared;
volatile uint32_t ulThrottleEndShared;
volatile uint32_t ulThrottleInShared;

void setup()
{
  Serial.begin(115200);
 
  Serial.println("multiChannels");

  // attach servo objects, these will generate the correct
  // pulses for driving Electronic speed controllers, servos or other devices
  // designed to interface directly with RC Receivers
  servoThrottle.attach(THROTTLE_OUT_PIN);

  // using the PinChangeInt library, attach the interrupts
  // used to read the channels
  attachInterrupt(THROTTLE_IN_PIN, calcThrottle,CHANGE);

  // for loop back test only, lets set each channel to a known value
  servoThrottle.writeMicroseconds(1500);
}

void loop()
{
  // create local variables to hold a local copies of the channel inputs
  // these are declared static so that thier values will be retained
  // between calls to loop.
  static uint32_t ulThrottleIn;
  static uint32_t ulThrottleStart;
  static uint32_t ulThrottleEnd;

  // local copy of update flags
  static uint32_t bUpdateFlags;

  // check shared update flags to see if any channels have a new signal
  if(bUpdateFlagsShared)
  {
    noInterrupts(); // turn interrupts off quickly while we take local copies of the shared variables

    // take a local copy of which channels were updated in case we need to use this in the rest of loop
    bUpdateFlags = bUpdateFlagsShared;
   
    // in the current code, the shared values are always populated
    // so we could copy them without testing the flags
    // however in the future this could change, so lets
    // only copy when the flags tell us we can.
   
    if(bUpdateFlags & THROTTLE_FLAG)
    {
      ulThrottleIn = ulThrottleInShared;
      ulThrottleStart = ulThrottleStartShared;
      ulThrottleEnd = ulThrottleEndShared;
    }

    bUpdateFlagsShared = 0;
   
    interrupts(); // we have local copies of the inputs, so now we can turn interrupts back on
    // as soon as interrupts are back on, we can no longer use the shared copies, the interrupt
    // service routines own these and could update them at any time. During the update, the
    // shared copies may contain junk. Luckily we have our local copies to work with :-)
  }
 
  // do any processing from here onwards
  // only use the local values unAuxIn, unThrottleIn and unSteeringIn, the shared
  // variables unAuxInShared, unThrottleInShared, unSteeringInShared are always owned by
  // the interrupt routines and should not be used in loop

  if(bUpdateFlags & THROTTLE_FLAG)
  {
    Serial.print(ulThrottleIn);
    Serial.print(",");
    Serial.print(ulThrottleStart);
    Serial.print(",");
    Serial.println(ulThrottleEnd);
  }
  bUpdateFlags = 0;
}


// simple interrupt service routine
void calcThrottle()
{
  // if the pin is high, its a rising edge of the signal pulse, so lets record its value
  if(digitalRead(THROTTLE_IN_PIN))
  {
    ulThrottleStartShared = micros();
  }
  else
  {
    // else it must be a falling edge, so lets get the time and subtract the time of the rising edge
    // this gives use the time between the rising and falling edges i.e. the pulse duration.
    ulThrottleEndShared = micros();
    ulThrottleInShared = ulThrottleEndShared - ulThrottleStartShared;
    // use set the throttle flag to indicate that a new throttle signal has been received
    bUpdateFlagsShared |= THROTTLE_FLAG;
  }
}

Duane B



rcarduino.blogspot.com
Pages: 1 ... 3 4 [5] 6 7 ... 114