Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Re: Include file location on: May 01, 2012, 12:04:57 pm
You could store all you settings in one 'library' and then include only what you need. You have to make it a library because of the way Arduino handles paths - that's why you have to include all used libraries in the sketch even when you don't use them directly in the sketch but in another file included in the sketch.

You could make a library called MyLibrary located in a subdirectory named MyLibrary (in the user libraries path) containing all your header files. Importing this library includes all header files in the sketch making them usable in other files, too. Just remove the not needed from the sketch.
2  Using Arduino / Programming Questions / Re: Copying a float into a uint8_t array efficiently on: May 01, 2012, 11:30:05 am
For binary copying you could use memcpy (http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html#ga5f60008005ea7557430149926cf583d7). Another idea for building your payload is a struct and union combination.
3  Using Arduino / Programming Questions / Re: Include file location on: May 01, 2012, 11:24:36 am
Put it in your sketch directory. If you need it in more than a single sketch you have to make it a library.
4  Using Arduino / Programming Questions / Re: Mistakes with shift operation on: May 01, 2012, 11:21:39 am
Code:
value = uint32_t(1) << i;
Try this one in your loop. Looks like the compiler uses int for the 1 and int is only 16 bit. If you shift 16 times the 1 gets lost...
5  Using Arduino / Programming Questions / Re: Anybody ever use WITS (Wellsite Information Transfer Specification) on: April 22, 2012, 04:49:48 pm
Lot of links in Google
http://www.control.com/thread/1026197007
http://home.sprynet.com/~carob/index.htm
No idea if you'll find the binary format specification of WITS, but then it should be no problem of implementing it into Arduino. Again here the question if you want do use the hardware in a production environment (reliability and safety concerns). If so you really should think about other hardware to use.
6  Using Arduino / Programming Questions / Re: Code problem with LED on: April 22, 2012, 04:19:56 pm
Code:
val = digitalRead(pirState); //read input and store it

//check whether the input is HIGH
if (val ==HIGH) {
  digitalWrite(ledPin, HIGH);  // Turns the LED on
  if (pirState == HIGH) {
   
} else {
  digitalWrite(ledPin, LOW);   // turns the LED off
  if (pirState == LOW) {

  }
This part of loop() is bogus. digitalRead expects an input pin as parameter - you use pirState, which is HIGH/LOW instead of inputPin. What you want is to read the state of the sensor and then set the LED accordingly. Just write the read state of the sensor to the LED:
Code:
pirState= digitalRead(inputPin);
digitalWrite(ledPin, pirState);
7  Using Arduino / Programming Questions / Re: Request for help modifying program on: April 22, 2012, 04:07:24 pm
I now have a functional pump stroke counter for oil drilling rigs, yay.
May I propose the use of safety PLCs for your oil platform  smiley-evil
8  Using Arduino / Programming Questions / Re: Request for help modifying program on: April 22, 2012, 03:19:08 pm
Assuming you use an Arduino Uno you should first connect buttonPin1 to another input then 1. Inputs 0 and 1 are used for serial communication. For the ledPin you have to connect another LED or for instance use the sum of your button counters to change the state of the onboard LED:
Code:
  if ((buttonPushCounter1 + buttonPushCounter2) % 2 == 0) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
And: Modulo 1 always returns 0. Modulo 2 returns 0 or 1...
9  Using Arduino / Programming Questions / Re: An easy-to-use code flow diagramming tool? on: April 22, 2012, 03:01:20 pm
Here is a short video tutorial http://www.yworks.com/en/products_yed_videos.html
and the manual http://yed.yworks.com/support/manual/index.html
10  Using Arduino / Programming Questions / Re: An easy-to-use code flow diagramming tool? on: April 22, 2012, 01:41:09 pm
Here is another alternative: yEd - http://www.yworks.com/en/products_yed_about.html - free and works on all pc platforms.
11  Using Arduino / Programming Questions / Re: error inside Serial.<init>() what do I do? on: April 19, 2012, 03:00:12 pm
Good question. This looks very strange. Is it a sketch? If yes then you should check your C/C++ syntax. Esp. the import lines. Then you declare a variable of type Arduino and in setup you assign a new object to the variable and so on. Seems like the Arduino software is not able to handle all the strange syntax and fails with an internal error. With only this excerpt of your code it his hard to guess what really happens.
12  International / Deutsch / Re: Servo.h Frequenz ändern on: April 16, 2012, 02:35:44 pm
Noch ein Hinweis, was hier passiert. Folgendes macht die Servo-Lib: für jeden Servo wird der Ausgangspin auf HIGH gesetzt, dann das Auslösen des Interrupts neu gesetzt, so daß er nach der Länge des HIGH-Signals wieder zuschlägt, um dann LOW zu setzen. Danach wird das gleiche mit dem nächsten Servo durchgeführt bis alle abgearbeitet sind. Jetzt wird das Auslösen des Interrupts auf REFRESH_INTERVAL gesetzt und beim nächsten Interrupt neu gestartet.

Daraus ergibt sich folgendes: hat man vier Servos und alle sind bei 1500µs, dann vergehen von den 20000µs REFRESH_INTERVAL schon 6000µs für das Erzeugen der Signale (+ die Verabeitungszeit). Sind alle vier bei den maximal erlaubten 2400µs, dann braucht man bereits den halben REFRESH_INTERVAL. Daraus ergibt sich ein Limit für die maximale Wiederholrate in Abhängigkeit der Anzahl der Servos. Andersum gibt der 16-Bit-Counter ein oberes Limit für REFRESH_INTERVAL vor. Beim 16MHz ATmega wird der Wert von REFRESH_INTERVAL mit 2 multipliziert in das Counter-Register geschrieben, welches meiner Meinung nach ja nur 16 Bit groß ist und damit nur Werte bis 65535 aufnehmen kann. Also wird bei etwas mehr als 32000 der REFRESH_INTERVAL nicht mehr das tun, was man erwarten würde.
13  International / Deutsch / Re: Servo.h Frequenz ändern on: April 16, 2012, 01:12:27 pm
Hast du mal versucht, die Frequenz auf 40Hz oder 30Hz zu senken? Es geht erstmal darum festzustellen, ob der Parameter seinen Zweck erfüllt. Langsamer sollte kein Problem sein, schneller könnte an die Grenzen der gewählten Timereinstellungen stoßen.
14  Using Arduino / Programming Questions / Re: LCD code help on: April 15, 2012, 02:25:50 pm
You declared B[7] (running from 0 to 6) instead of B[8] (from 0 to 7). Then in your loop y started at 0 and counted to 6 (y < 7). So even if the loop would be corrected you still would access the 8th element of B which was not declared thus you would overwrite something else in memory with strange effects as a result. Hope that is somehow understandable - or in other words: do not access an array beyond its bounds.
15  Using Arduino / Programming Questions / Re: LCD code help on: April 15, 2012, 01:50:44 pm
Your B array has only 7 entries and not 8 but you access the 8th (B[7]) when using digitalWrite().

Code:
for(byte nBitNo= 0; nBitNo < 8; nBitNo++)
  digitalWrite(A[nBitNo], bitRead((byte)myChar, nBitNo));
This does the same without the intermediate array B. HIGH is defined as 0x01 and LOW as 0x00.

Additionally I think you have to reverse array A, because in your example D0 is the most significant bit and you set it at A[0] / bitRead(..., 0) which handles the least significant bit.
Pages: [1] 2 3 ... 6