Show Posts
Pages: 1 ... 96 97 [98] 99 100 ... 114
1456  Using Arduino / Programming Questions / Re: A case of RTFM - bitSet on: March 22, 2012, 02:13:02 pm
Hi,
   Cut a long story short, I was using bit flags like so

#define CHANNEL_ONE 1
#define CHANNEL_TWO 2
#define CHANNEL_THREE 4
#define CHANNEL_FOUR 8

   Without paying enough attention to the function I was calling bitSet(n,CHANNEL_FOUR) which instead being equivalent to -

n |= 8

 was actually equivalent to

n |= (1<<8)

which overflows my byte.

Moderator edit: eliminated smileys

That was the first time I have used the Arduino bit functions, I am going back to bitwise operators.

Duane B

rcarduino.blogspot.com
1457  Using Arduino / Programming Questions / A case of RTFM - bitSet on: March 22, 2012, 10:51:22 am
Hi,
   This might save someone some time.

   I am using bit flags to control access to shared variables between the loop function and interrupt service routines. To make my code as beginner friendly as possible I used the bit functions (bitSet,bitRead,bitWrite,bitClear).

   Everything works fine for my first 3 variables, but the 4th is never accessible.

   The reason is very simple and if I had been paying attention I would have spotted it hours ago. The Arduino bit functions quite reasonably regard the bits in a byte as numbered 0-7, so there is no bit 8 to set.

   Its obvious enough, but if you are used to using bits directly through powers of 2, you like me will have a problem.

   RTFM

Duane B

rcarduino.blogspot.com

1458  Using Arduino / Project Guidance / Re: Measuring Pulse Width on: March 22, 2012, 07:08:16 am
Hi,
    Just to be clear, I am referring to the input capture functionality of the timer, this is a timer configuration which will copy the exact timer count into a dedicated register when the pin state changes, you can then read this captured hardware timer value from your code. As this is using the hardware timer directly, its not reliant on or effected by any code that may be running.

Not sure if thats what you understood.

Duane B

rcarduino.blogspot.com
1459  Using Arduino / Project Guidance / Re: Measuring Pulse Width on: March 22, 2012, 06:48:39 am
Hi,
    I keep meaning to look into it myself and never get the time, but isn't the input capture feature of hardware timer1 exactly what you need to measure these small intervals ?

Duane B

rcarduino.blogspot.com
1460  Using Arduino / Programming Questions / Re: Servo and Analog Question on: March 21, 2012, 11:51:54 pm
Hi,
   The Servo library is very good and allows you to control a large number of servos on more or less any pin.

Here is some background -

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

There are some aliases in Arduino which allow you to refer to the analog pins in digital functions, I haven't tried this myself, but the following may work for you

myServo.attach(A1); // A1 is the alias for analog pin 1, use An for whichever analog pin you want where n = 0 to 5

Duane B

rcarduino.blogspot.com
1461  Using Arduino / Project Guidance / Re: How to attach a Futaba FP-R114H to an Arduino Mega? on: March 21, 2012, 11:44:27 pm
Hi,
   Reading the receiver is easy, you can find all you need on my blog starting here -

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

   Controlling the motors may or may not be as easy.

   If the motors are RC Hobby quality, they are probably powerful and will require a lot more power than Arduino can deliver, in this case you might want to use RC Electronic Speed Controllers, the good news is these can easily be driven by an Arduino.

   If the motors are less powerful toy type motors you can drive these from an Arduino with a few cheap and easy to use components. Two common options are 1) Using transistors to switch larger currents from the Arduino or 2) Using a ready build motor driver chip.

   If you come back with the type of motor, we can give you a better idea of what you will need.

Duane B

rcarduino.blogspot.com
1462  Using Arduino / Motors, Mechanics, and Power / Re: Detailed How To Posts - Reading From An RC Receiver on: March 21, 2012, 10:14:39 am
Hi,
   I have finally overcome my resistance to spending money and bought a 2.4Ghz radio partly due to the results posted by Erni, partly due to a new race track opening in Dubai and finally down to getting a good price.

   I have posted an update here -

http://rcarduino.blogspot.com/2012/03/reading-from-rc-reveiver-do-you-need.html

   In the next few days I plan to post some options for interfacing with multiple inputs, in my case I need to read three channels and four RPM sensors, 7 sensors in total, the sensors update 50 times a second for the RC Channels and upto 70 Times a second for the RPM Sensors.

Duane B.

rcarduino.blogspot.com

1463  Using Arduino / Sensors / Re: IR leds and 38KHz receivers as a optoencoder or similiar on: March 16, 2012, 09:46:20 am
Hi

That's useful to know, it's handy to have the 38khz detection but the additional signal rules that most receivers come with are a real pain to live with in lots of applications, including my lap timer and the OPs traffic counter.

Thanks

Duane B

rcarduino.blogspot.com

1464  Using Arduino / Motors, Mechanics, and Power / Re: Servo motors for spider on: March 15, 2012, 06:17:54 am
Hi,
   Check the same page you found the price of the Hitec servo, cheap servos start at less than 10 dollars and can be found for a lot less if you are buying in bulk which I assume you will be.

   Looking at the spider, most of the servos are acting against quite a lot of leverage, you should consider this as you might need reasonable power to deal with the leverage.

Duane B

rcarduino.blogspot.com
1465  Using Arduino / Motors, Mechanics, and Power / Re: Mechanical issue, mounting sprocket to stepper on: March 15, 2012, 06:15:31 am
Hi,
    Take it to a hobby shop, they have lots of pinions, RC Racers like to change their gear ratios from time to time. If none of the car sized pinions fit, heli pinions might. You should also be able to pick up a few other gears and bearings that will help you along the way.

Duane B

rcarduino.blogspot.com
1466  Using Arduino / Programming Questions / Re: Speed of Arduino compared to PC... on: March 15, 2012, 04:51:59 am
Hi,
   Interesting, unless my maths is wrong, taking clock speed alone, you would expect around 175 times slower. Is my maths wrong or is there a lot of floating point or multi byte maths in your algorithm ?

Duane B

rcarduino.blogspot.com
1467  Using Arduino / Programming Questions / Re: Code conversion - button to radio button on: March 13, 2012, 03:04:29 pm
Hi,
   Might not be the wrong forum, just not used to seeing HTML Around here, are you using it with an Arduino ?

Duane B
1468  Using Arduino / Programming Questions / Re: Code conversion - button to radio button on: March 13, 2012, 02:57:16 pm
Hi,
   Wrong forum ?

   Here you go anyway

http://www.w3schools.com/html/html_forms.asp

Duane B

rcarduino.blogspot.com
1469  Using Arduino / Audio / Re: Auduino v5 on uno only pot 4 works on: March 13, 2012, 02:00:45 pm
Hi,
   Glad to see you have come back to it, still busy myself, I have been to six, maybe seven countries since I replied. I really want to build an Auduino myself so hope this is the fix for it, if not I will have another look when I get home.

Duane B

rcarduino.blogspot.com
1470  Using Arduino / Programming Questions / Re: Abstract base class on: March 13, 2012, 08:01:05 am
Hi,

Unfortunately I suspect that none of this is very encouraging to the OP.

I would suggest that if the behavior and the code to implement this behavior is largely the same across devices, you can create a base class that provides a full solution for the most common device but which includes virtual functions for the behavior which is different in other devices.

If the code to implement the largely similar behavior is actually quite different between devices then you would be better creating an abstract base class rather than the suggestion above - of a base class, because the base class code would be irrelevant in many cases.

The decision is really down to the extent of the device specifics -

1) Everything about the devices is different, I just want to provide users with a class that hides this

Go with an abstract base class and create full implementations of classes for each device

2) Mostly the devices are very similar, but there are some minor differences in how they are accessed and what they return

In this case there is an opportunity to provide a base class which provides a full implementation of the most common device and derived classes which implement/hide the differences through virtual functions.

These are often qualitative decisions, If I were you I would start with a base class that implements the most common device, then try and add additional devices through derived classes, if this starts to get awkward then its telling you that you would be better of with an abstract base class and individual implementations in the derived classes.

Duane B

rcarduino.blogspot.com
Pages: 1 ... 96 97 [98] 99 100 ... 114