Show Posts
Pages: 1 ... 102 103 [104] 105 106 ... 114
1546  Using Arduino / Programming Questions / Re: Button Function - Call throughout when button action needed on: February 25, 2012, 09:06:26 am
Hi,
   Your are right, reading through an unrelated thread, someone mentioned 20ms as more than sufficient to debounce a switch, I will update accordingly.

Thanks

Duane B.

rcarduino.blogspot.com

1547  Using Arduino / Motors, Mechanics, and Power / Re: ESC arming problem on: February 25, 2012, 08:56:48 am
Hi,
    Is it a car, marine or air ESC ?

    If its a car ESC I would expect that it should be armed with 90 and for longer at least 2 seconds.

    Duane B

rcarduino.blogspot.com
1548  Using Arduino / Programming Questions / Re: Button Function - Call throughout when button action needed on: February 25, 2012, 08:34:12 am
Hi,
   In my RC Car/Go Kart lap timer project I have 4 keys to drive a user interface - scroll up, scroll down, ok, cancel.

The following very simple functions drive this -

getKeys -
Very simply poles the pins to see which buttons are pressed - non blocking

waitForKeyPress -
This one loops until one of the keys passed when the function is called gets pressed, for example if I am looking for OK or Cancel and I am not interested in up and down I call waitForKeyPress(KEY_OK|KEY_CANCEL) this will ignore up and down but will return with ok or cancel if one of these two gets pressed

waitForKeyRelease -
This one waits until all keys are released, its important when cancel might mean 'get me out of this mode' but then means 'delete' in the next mode - we need to wait until no keys are pressed before assuming a cancel press
means the user wants us to delete something.

Its simple stuff, I don't see much to gain from classes and arrays for four buttons so here it is, as used in my lap timer project, feel free to use it, you may of course want to add or change buttons.

Project Intro Here - http://rcarduino.blogspot.com/2012/02/rc-lap-timer-go-kart-lap-timer-part-2.html

Code:
//////////////////////////////////////////////////////////////////////////////////
//
// Key related helpers
//
// getKeys - pole keys
// waitForKeyPress - block waiting for keys based on a mask
// waitForKeyRelease - block waiting until no keys are pressed - used between menu contexts
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
// getKeys
//
// read the inputs and create a bit mask based on the buttons pressed
// this does not block, need to review whether we should make this block, in most
// cases we loop waiting for a key, sometimes we also loop waiting for no key
// could put both options here with an input parameter.
//
//////////////////////////////////////////////////////////////////////////////////
short getKeys()
{
 // Use bit flags for keys, we may have a future use for
 // combined key presses

 short sKeys = KEY_NONE;
 if(digitalRead(KEY_UP_PIN) == LOW)
 {
  sKeys |= KEY_UP;
 }
 if(digitalRead(KEY_DOWN_PIN) == LOW)
 {
  sKeys |= KEY_DOWN;
 }
 if(digitalRead(KEY_OK_PIN) == LOW)
 {
  sKeys |= KEY_OK;
 }
 if(digitalRead(KEY_CANCEL_PIN) == LOW)
 {
  sKeys |= KEY_CANCEL;
 }
 
 // absorb any switch bounce here
 delay(200);
 
 return sKeys;
}

//////////////////////////////////////////////////////////////////////////////////
//
// waitForKeyRelease
//
// we can enter a function while the activating key is still pressed, in the new
// context the key can have a different purpose, so lets wait until it is released
// before reading it as pressed in the new context
//
//////////////////////////////////////////////////////////////////////////////////
void waitForKeyRelease()
{
  do
  {
    // do nothing
  }
  while(getKeys() != KEY_NONE);
}

//////////////////////////////////////////////////////////////////////////////////
//
// waitForKeyPress
//
// convenience function, loop doing nothing until one of the sKeyMask keys is
// pressed
//
//////////////////////////////////////////////////////////////////////////////////
uint8_t waitForKeyPress(uint8_t sKeyMask)
{
  uint8_t sKey = KEY_NONE;
 
  do
  {
    sKey = getKeys() & sKeyMask;   
  }
  while(sKey == KEY_NONE);
 
  return sKey;
}

Duane B

rcarduino.blogspot.com
1549  Using Arduino / Sensors / Re: Suggestions on IR communication on: February 25, 2012, 08:12:41 am
Hi,
   The approach I suggested does not involve the IRRemote library. If all you want to do is send a signal to a servo and a motor through Infra red, then just  use the servo library to generate a servo signal, but connect it to an IR Emitter instead of a servo. On the other end you can read the signal and send it straight out to a servo with no additional coding or decoding on either end.

   What IR Receiver are you using, if its one that expects a signal in a given frequency range, you can build a small circuit with a 555 Timer to create this signal and then switch it using a PIN driven by the servo library. I can point you to some good online resources for building this part if your receiver needs it, but let me know what type it is first.

   Once you have one channel up and running its easy enough to add some more to the signal.

Duane B

rcarduino.blogspot.com


1550  Using Arduino / Project Guidance / Re: Slotcar speed controller with display and electronic memory project on: February 24, 2012, 10:06:52 am
Hi,
   I searched for 'meat board' after reading your post the first time, couldn't find anything that wasn't related to livestock !

   Duane B

rcarduino.blogspot.com
1551  Using Arduino / Sensors / Re: Problems with pulseIn and servo.h on: February 24, 2012, 06:30:39 am
Hi,
    I have checked the source for pulseIn and as far as I can see, it does not use any of the hardware timers.

    The problem could be in your hardware design or code, what are you using for power and are you using current limit resistors on your inputs and outputs ?

    For an example of using interrupts to measure and incoming pulse, see a post on my blog here -

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

Duane B
1552  Using Arduino / Sensors / Re: Problems with pulseIn and servo.h on: February 24, 2012, 06:00:18 am
Hi,
I don't have access to the Arduino files to check right now, but it is possible they are using the same timer. why don't you switch to using interrupts for the incoming pulses instead ?

Duane B
rcarduino.blogspot.com
1553  Using Arduino / Project Guidance / Re: Help! I can't even begin my project. on: February 24, 2012, 05:48:37 am
Hi,

Dubai has an electronics souk where you can buy ATMega8 chips and everything else you need to make a standalone board. I am sure Saudi has the same shops, in Dubai they are all around the satellite Market and my guess is that they would be in a similar area in Saudi.

for your first board it is much easier to buy a Ready built UNO, it will make programming any boards you later build so much easier.

Your nearest distributor is in Jordan, you can find the details if you search around the main Arduino site.

Duane B
rcarduino.blogspot.com


1554  Using Arduino / Project Guidance / Re: list of shaft hub bushing sources on: February 24, 2012, 05:36:52 am
Hi,

These are RC car wheel hubs, I think they are 11mm at the hex and the shaft is 4mm, will check a set later today. you will see that they fix to the shaft using a pin, if your shaft does not accept a pin, there are similar types where the pin is held within the hex in which case you could probably cut a thread and use a grub screw in place of the pin. Assuming no one suggests a simpler off the shelf solution.

http://m.rcmart.com/mobile_product_info.php?cPath=1389&products_id=14465

Duane b
rcarduino.blogspot.com




1555  Using Arduino / Project Guidance / Re: Slotcar speed controller with display and electronic memory project on: February 24, 2012, 05:25:08 am
Hi,
    I used to build resin slot cars, what's the material the controller is made from, it looks like something you could make model parts from ?

Duane B


1556  Using Arduino / Sensors / Re: Suggestions on IR communication on: February 23, 2012, 11:46:58 pm
Hi,
   The servo needs this type of a signal which is easily generated by the servo library -



If you generate this on a pin with an ir transmitter connected, you can send it directly. I am not sure where you see the difficulty ?

is it that you haven't sent anything through ir yet ?

Duane b
1557  Using Arduino / Sensors / Re: Suggestions on IR communication on: February 23, 2012, 10:38:08 am
Hi,
   Still not on the plane yet.

   If you look on my blog there is a post on using interrupts to read a signal from an RC receiver, this will work for you, but you will be taking the interrupt from an ir receiver instead.

Prove the concept with the code from my blog and then I can give you some pointers on adding a second channel to the signal.

Rcarduino.blogspot.com look in the most popular posts.

Duane b

1558  Using Arduino / Sensors / Re: Suggestions on IR communication on: February 23, 2012, 09:01:06 am
Hi,

I don't know anything about the library you are using, but if I was trying to implement a proportional ir remote system, I would use an ir emitter driven directly from the servo library.

I would try something like three servos, on for throttle, one set at a fixed signal just to act as a separator, then the steering servo.

The servo library already implements the type of pulse width encoding used to drive servos and electronic speed controllers, so why invent something else less efficient when you can transmit this directly ?

I am about to get on a plane some will have to leave it at that for now, if your interested in this approach I can help out tomorrow

Duane B


1559  Using Arduino / Programming Questions / Re: Counting the impulses between two signals on: February 22, 2012, 01:47:48 pm
Hi,
   You can do this with interrupts, you have two of them available on the UNO. These links should help you give you some background, once you have read through them come back for more help if you need it.

http://arduino.cc/playground/Code/Interrupts

http://arduino.cc/en/Reference/AttachInterrupt

Duane B

rcarduino.blogspot.com
1560  Using Arduino / Programming Questions / Re: wave moving down line of servos on: February 22, 2012, 01:37:37 pm
Hi,
  The function map takes a long as its input so it is rounding your value p to either 1 or 0, easy to fix, multiply p by 100 and change the following -1,1 to -100,100.

Duane B

rcarduino.blogspot.com

Pages: 1 ... 102 103 [104] 105 106 ... 114