Show Posts
Pages: 1 ... 44 45 [46] 47 48 ... 87
676  Community / Bar Sport / Re: Curiosity - way too cool. Sunday. on: August 06, 2012, 04:04:39 pm
I piped the HD TV (Ustream) from NASA on my TV screen and enjoyed the show. If it wasnt for webcasting I would have seen nothing. (not interesting enough for the general public)

AFAIK no Arduino was involved in this mission ... ?  smiley
677  Community / Bar Sport / Re: Raspberry Pi launch farce on: July 30, 2012, 06:20:09 am
By the time it arrives I'll have misplaced my marbles.
I've bookmarked this thread - lots of things to remember in another 8 weeks
It arrived today. I promptly have put it on shelf. If I have to wait so long for it, it now it's turn to wait until I have time!   smiley-twist
678  Community / Website and Forum / Re: Chatroom on the Arduino Website? on: July 26, 2012, 02:49:50 pm
Interesting JamesC4D; would you say you are part of the minority that uses both sites?

I was not saying "limiting" - I was saying "not expanding".

But, you have a point. The Chat-oholics fret at the pedastrian pace of the forum, and the forum-nerds get disturbed by the chats going off -topic... smiley I am not anti-chat per se; althogh I only rarly use them (IRC in this case)

If there already is a well functioning chat channel, then there is no need for another one to be created here.
679  Using Arduino / Programming Questions / Re: debouncing a switch during 'while' loop on: July 26, 2012, 02:10:23 pm
I'm with PaulS.

But I actually think your first attempt was better. It should be sufficient for the scenario you describe.

The debounce, even when implemented correctly, would not help. I think something else is causing the switch sensing to change. For example that you power the motor directly from the Arduino, or it is insufficently decoupled (capacitors) - the Arduino resets, and your program starts from the beginning, or just plain malfunctions.
680  Using Arduino / Programming Questions / Re: Showing year as three digits! on: July 26, 2012, 01:02:30 pm
You MUST enclose your code in the code tags (use the "#" icon when entering the code). For example: I see a smiley with sunglasses suddenly in the code instead of a digit and closing bracket. I can guess this is a 8. Also some subscript brackets get "swallowed". Note you can edit the post you have submitted.The above was edited, so now legible.

You're also missing the "#include" of the libraries you are using.
681  Community / Website and Forum / Re: Chatroom on the Arduino Website? on: July 26, 2012, 04:36:34 am
-1

Ie. no chat room. More channels just dilutes - less people see and potentialy answer a given question.
682  Using Arduino / Programming Questions / Re: Analog In / PWM on: July 22, 2012, 01:11:36 pm
Lets make the confusion complete smiley-wink  it does not matter if you call analogRead(A3) or analogRead(3) or analogRead(17) - they all go to the same pin. (There is code in the core to cope with analog pins having "three names" - thus helping the newcommer to get stuff working)

On the digitalRead there is not much choice. It is only the number - 13. Any alias/constants you do on your own.

Meanwhile, back to the original question and confusion of the thread.

You can set "any" pin with pinMode to input or output. "Any" is in quotes as restrictions apply.(Usually you stay away from pin 0 and 1 as they are used by Serial)
You can do digitalRead, analogRead, digitalWrite, analogWrite on "any" pin. ... and there are restrictions - analogWrite will only work on the pins marked with "PWM"; analogRead will only work on analog pins.
683  Using Arduino / Programming Questions / Re: Running two loops at once (at the same time) on: July 22, 2012, 12:27:08 pm
also on http://arduino.cc/forum/index.php/topic,76140.html dicsussed and shown in depth
684  Using Arduino / Programming Questions / Re: leds are repeating top and bottom in pattern on: July 22, 2012, 12:25:59 pm
johnwassers expression (1<<(11-i)) is the mask - it is computed on the fly.

On a side note: It would be a long and heated debate to determine what is "more efficient" (in terms of code, memory and CPU use); shifting your mask or computing it on the fly. It does not matter. One writes the code that most clearly states what the purpose is (unless one is in a very time critical section when one possibly has to write things in a "confusing" way to get it faster).
685  Using Arduino / Programming Questions / Re: leds are repeating top and bottom in pattern on: July 21, 2012, 02:25:32 pm
Not sure what you mean by "repeats the bottom/last".

So if the pattern is LED 3 and 5 of 5 LEDs would you expect it to blink 3, 5, (going forward) and then 5, 3 (going backward) which is what the code does very well. but you want 3, 5, 3 because the 5 is at the end, you do not want it twice?

As you write, reducing your loops would not work if the numbers are 2,3 4 in the 5 Lights as it would do 2, 3, 4, 4, 3, 2 and you want to avoid doing the 4 double?.

It requires more code: you have to remember the last LED number you blinked, and then ignore it if the same number comes up again. You can code that test & skip inside your Ledpattern function.

Lastly I am worried about your construct
Code:
if ( test ) { /* empty */ } else { /*actual code*/ }
If it is temporary construct due to some debugging code now left out, OK, but change it to
Code:
if ( opposite-test ) { /*actual code*/ }
686  Using Arduino / Programming Questions / Re: Simple-yet-powerfull - Serial Command input with numbers on: July 21, 2012, 01:17:10 pm
Hi GoForSmoke - thanks for the comment, but you are reading the test the wrong way round: the while is ONLY busy while there ARE characters in the buffer. No characters, it will return at once. Likewise if the number/command is complete. At least that is the intention. And as far as I have tested, it seems to work that way. Here is my little test.
Code:
/* Test the nnnC library */

#include "nnnC.h"

void setup() {
  Serial.begin(9600);
  Serial.println("nnnC test");
}
void loop() {
   static char C ; static int V ; static float F ;                               
   if ( nnnC( &C, &V) ) {                           
     Serial.print("Command ");Serial.print(C);     
     Serial.print(" : ");Serial.println(V,DEC);       
     }                               

// An idle LED blink-without-delay to verify nonbloking
   static unsigned long Timer = 0 ;
   static boolean OnOff = true ;
   if ( millis() - Timer > 333 ) {
     Timer = millis() ;
     digitalWrite(13,(OnOff=!OnOff)?HIGH:LOW) ;
   }
}

Graynomad: thanks for the comment about brackets. Using atoi/atof and those require using a buffer (precious RAM bytes) and suddenly there is maximum inputsize (nnnC accepts a 100 digit number - it wont fit in an integer smiley but no parser or memory overflow). I have not exactly measured it, but have experienced that including the atoi/f will appreciably increase the code size.

Any/Everybody: The design is "minimalistic": It is not foolproof (like "7-5" is legal interpreted as -75) but functional enough.
687  Using Arduino / Motors, Mechanics, and Power / Re: MC433 on: July 21, 2012, 12:45:48 pm
Hi Chagrin, no problem with doing the LPT ports, with direct connection from the Arduino. According to the schematics they go directly to the motor-controller (an ATmega48) so no problems with levels/currents there. The schematic shows a pullup on the limit switches and the doc says it only needs a pulldown to ground, so they should be OK to float (of course, simple enough to set up a pullup...)

My question is about using the TWI/I2C interface. On this interface you get to talk to motor controller to set some scaling factors, which it stores in its EEPROM and retrieves/uses on powerup.

If the only purpose is to drive the steppers I would use something else - got plenty of modern stepper-drivers. But the fun-of-the-game is this MC433 board (until it gets too difficult)
688  Using Arduino / Programming Questions / Simple-yet-powerfull - Serial Command input with numbers on: July 20, 2012, 03:58:33 pm
This is an invitation for comments by the those who feel experienced enough (you know who you are smiley )

Sometime(often) people ask here how to use the Serial input to give simple commands, possibly with some numeric argument to their sketch. The thread then revolves around ASCII <-> Integer conversion and what a "terminator" is. For my own use I have evolved the simple syntax: first the number is entered (ASCIIwise) in the Serial input and then terminated by a command character. The code accumulates so it does not block. Sending the ASCII sequence "67x3yp" would be interpreted as three commands: Command X with argument 67, command Y with argument 3 and Command P with argument 0.

Until recently I usually cut-n-paste this codesnippet in my various sketches, I have now rewritten it as a very small library for the community.

The nnnC.h module
Code:
/*--------------------------------------------------------------------------------*\
|   nnnC - Number Command input                                                    |
|                                                                                  |
|  Read serial input of simple argument values in format "nnnC"                    |
|   nnn is a series of (ASCII) digits, with optional sign (& decimalpoint for nnnF)|
|   C is a single character that is the command or argument name terminates string |
|   C is converted to uppercase.                                                   |
| Call "fffC" instead of "nnnC" for float value (See prototype declaration below)  |
|                                                                                  |
| The call is non-blocking, so command interpretation is done in its own "thread", |
| meaning : You can call it as often as you want in the loop()                     |
| Only when it returns true will the the arguments C and V contain valid values.   |
|                                                                                  |
| Example use:                                                                     |
|   static char C ; static int V ;                                                 |
|   if ( nnnC( &C, &V) ) {                                                         |
|     Serial.print("Command ");Serial.print(C);                                    |
|     Serial.print(" : ");Serial.print(V,DEC);                                     |
|     }                                                                            |
\*--------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------*\
| Not-a-bug; known limitations:                                             |
| Illegal numeric syntax, how the "-", "+" and "." are placed, are accepted |
| If you use both nnnC and fffC only "switch" between them after a command  |
| Note the parameters must be global or static                              |
| the nnnC only takes int - maximum is +/-32767 as usual                    |
| (But it is easy - just change "int" to "long" and you can do longs :-) )  |
\*-------------------------------------------------------------------------*/

#ifndef _nnnC
#define _nnnC

#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif

boolean nnnC( char *, int * ) ;
boolean fffC( char *, float * ) ;

#endif


The nnnC.cpp module
Code:
/*--------------------------------------------------------------------------------*\
|   nnnC - Number Command input                                                    |
|                                                                                  |
|  Read serial input of simple argument values in format "nnnC"                    |
|   nnn is a series of (ASCII) digits, with optional sign                          |
|   C is a single character that is the command or argument name terminates string |
|   C is converted to uppercase.                                                   |
|                                                                                  |
| The call is non-blocking, so command interpretation is done in its own "thread", |
| meaning : You can call it as often as you want in the loop()                     |
| Only when it returns true will the the arguments C and V contain valid values.   |
|                                                                                  |
| Example use:                                                                     |
|   static char C ; static int V ;                                                 |
|   if ( nnnC( &C, &V) ) {                                                         |
|     Serial.print("Command ");Serial.print(C);                                    |
|     Serial.print(" : ");Serial.print(V,DEC);                                     |
|     }                                                                            |
| Use "fffC" instead of "nnnC" for float value                                     |
\*--------------------------------------------------------------------------------*/

#include "nnnC.h"

// Integer version
// NB: The "." acts a command character, not part of a number.
boolean nnnC (char * Cmd, int * Val) {
  static boolean Done = true ;
  static boolean Negative = false ;
  if ( Done ) {                        // if a valid value has been returned before
    Negative = Done = false ;          //   reset for new command
    *Val = 0 ;
    }
  while ( Serial.available()>0 ) {     // interpret all serial bytes ...
    *Cmd = Serial.read() ;
  if (*Cmd == '-')                     // negative value
    Negative = true  ;                 //    set flag
    else if ('0' <= *Cmd && *Cmd <= '9') // valid digit
          *Val = (*Val) * 10 + (*Cmd) - '0' ; //    accumulate input
  else if (*Cmd == '+')                // A "+" sign
      ;                                  // ignore
    else {                              // It is a non-numeric character, i.e. the command.
      if ('a' <= *Cmd && *Cmd <= 'z') *Cmd &= B01011111 ; // forces uppercase (for 7bit ASCII)
      if ( Negative ) *Val = -*Val ;     // Adjust for negative value
      Done = true ;                      // note we are done
    return true ;                      // and exit
     }
   }
  return false ;
}

 // Float version
boolean fffC (char * Cmd, float * Val) {
  static boolean Done = true ;
  static boolean Negative  ;
  static byte Fraction ;
  if ( Done ) {                         // reset for new interpretation.
    Negative = Done = false ;
    *Val = 0 ; Fraction = 0 ;
    }
  while ( Serial.available()>0 ) {      // interpret all serial bytes ...
    *Cmd = Serial.read() ;
if (*Cmd == '-') {                  // negative value
  Negative = true ;                 //    set flag
  return false ;                    //    and exit
  }
if (*Cmd == '.') {                  // decimal point
  Fraction = 1 ;                    //    start counting, and thus flag decimal seen.
  return false ;                    //    and exit
  }
    if ('0' <= *Cmd && *Cmd <= '9') {   // valid digit
      *Val = *Val * 10 + *Cmd - '0' ;   // accumulate input
  if ( Fraction > 0 ) Fraction++ ;  // adjusting for after decimal
      return false ;                    // and exit
  }
if (*Cmd == '+')                    // Accept and ignore a "+" sign
  return false ;
// It is a non-numeric character - treated as command character
    if ('a' <= *Cmd && *Cmd <= 'z') *Cmd &= B01011111 ; // forces uppercase (for 7bit ASCII)
    if ( Negative ) *Val = -*Val ;      //adjust for negive value
for( ; Fraction > 0 ; Fraction-- ) *Val /= 10.0 ;  // divide down decimal
    Done = true ;                       // note we are done
return true ;
   }
 }

Note: This is intended as a very lightweight routine, when a simple input commandparser is needed.

(Edit: fixed a bug on float fractions, cleaned up some comments, added some brackets for clarity)
689  Using Arduino / Motors, Mechanics, and Power / Re: MC433 on: July 20, 2012, 02:43:56 pm
Update: SOC Robotics have been kind enough to send me some info - they never got round to write the doc. So I got some source to look at to work it out  smiley-eek ... this is going to take some time. smiley-neutral
690  Using Arduino / Motors, Mechanics, and Power / Re: MC433 on: July 20, 2012, 12:44:24 pm
try to reverse-engineer
Bit too much for me, I am afraid. It also uses a .dll to get at the LPT port - so the program refuses to start on a pc without a LPT.
Pages: 1 ... 44 45 [46] 47 48 ... 87