Loading...
  Show Posts
Pages: 1 2 [3] 4 5 ... 11
31  Using Arduino / Programming Questions / Re: Need help with a Math problem on: March 20, 2013, 07:55:07 am
@Rob, following your advise i have changed the routine to this.
Code:
void _xyConvert(float az, float el)  {

  double azFloat = az /100*DegreeToRadian;
  double elFloat = el /100*DegreeToRadian;

 _XX =  (asin(sin(-azFloat) * cos(-elFloat) )*RadianToDegree) + 90.0;
  if(el < 0.1) {
    el = 0.1;
  }
  else {
    _YY = (atan(cos(-azFloat) / tan(-elFloat) )*RadianToDegree) + 90.0;
  }
}
According to the theoritical guys there are some differences between there results on a sacel-ruler en this routine.
How i can i prefent/tactle the divisions by 0?
32  Using Arduino / Programming Questions / Re: Need help with a Math problem on: March 19, 2013, 01:58:33 pm
After postin i figured that out as wel en started to output every line of calculation.
This is the result of that:
    az(RAD) = 23000(4.01) and el(RAD) = 5100(0.89)
     Calculate Azimuth >> X
    cos(-azFloat) = -0.64
    tan(-azFloat) = -1.23
    cos(-azFloat)/tan(-azFloat) = 0.52
    atan(cos(-azFloat)/tan(-azFloat)) = 0.48
    atan(cos(-azFloat)/tan(-azFloat))*RadianToDegree = 27.50
    (atan(cos(-azFloat)/tan(-azFloat))*RadianToDegree)+90.0 = 117.50
     Calculate Elevation >> Y
    sin(-azFloat) = 0.77
    cos(-elFloat) = 0.63
    sin(-azFloat)*cos(-elFloat) = 0.48
    asin(sin(-azFloat)*cos(-elFloat)) = 0.50
    (asin(sin(-azFloat)*cos(-elFloat)))*RadianToDegree = 28.82
    ((asin(sin(-azFloat)*cos(-elFloat)))*RadianToDegree)+90 = 118.82
Made by this code and gives the corect values.
Code:
void _xyConvert(long az, long el)
{
  double azFloat = az;
  azFloat = azFloat /100*DegreeToRadian;
  double elFloat = el;
  elFloat = elFloat /100*DegreeToRadian;

    _XX = (atan(cos(-azFloat) / tan(-elFloat) )*RadianToDegree) + 90.0;
    _YY = (asin(sin(-azFloat) * cos(-elFloat) )*RadianToDegree) + 90.0;
}
But your code example gives a different answer _XX =75 and _YY=117
33  Using Arduino / Programming Questions / Re: Need help with a Math problem on: March 19, 2013, 12:23:56 pm
I now have changed the code by including the radians to degrees conversion by declaring a static
Code:
  static const double DegreeToRadian = 0.0174532925;  // PI/180
and included in the two calculations
Code:
    _XX = DegreeToRadian * ( atan(cos(-az) / tan(-el) ) ) + 90.0;
    _YY = DegreeToRadian * ( asin(sin(-az) * cos(-el) ) ) + 90.0;
But now the result is in both 90.0
34  Using Arduino / Programming Questions / Need help with a Math problem on: March 19, 2013, 09:42:29 am
I have to turn a AZ/EL rotor system into a XY system.

For the X part this is the formula where az and el are the Azimuth and Elevation values.

Y = Degrees ( ArcSin ( Sin ( Radians ( -az ) * Cos ( Radians ( -el )))) + 90.0

In arduino code this would look like:
Code:
#include "Arduino.h"
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <math.h>

  long _XX;
  long _YY;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(1000);
  _xyConvert(36000, 19700);
}

void loop() {
  
}

void _xyConvert(long el, long az)
{
  double azFloat = az;
  azFloat = azFloat /100;
  double elFloat = el;
  elFloat = elFloat /100;

    _XX = atan(cos(-az) / tan(-el)) + 90;
    
    _YY = asin(sin(-az) * cos(-el) ) + 90;
  
      Serial << _FLOAT(_XX,2) << " - " << _FLOAT(_YY,2) << endl;
}
But the result in both equals zero. Any help would be wolcome.


Moderator edit: Tags hopefully corrected
35  Using Arduino / Installation & Troubleshooting / Re: I have a #$^$%&% Leonardo for free, just pick it up on: March 17, 2013, 11:38:05 am
This is the error message i get
  • avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "C:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf"

             Using Port                    : \\.\COM4
             Using Programmer              : avr109
             Overriding Baud Rate          : 57600
             AVR Part                      : ATmega32U4
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PA0
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    10     8    0 no       1024    8      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : butterfly
             Description     : Atmel AppNote AVR109 Boot Loader

    Connecting to programmer: .avrdude: Send: . [1b]
    avrdude: Send: S [53]
    avrdude: Recv: S [53]

    avrdude: Recv:
    avrdude: Send: V [56]
    avrdude: Recv: V [56]
    avrdude: Send: v [76]
    avrdude: Recv: v [76]
    avrdude: Recv:
    avrdude: Send: p [70]
    avrdude: Recv: p [70]
    Found programmer: Id = "Sÿ("; type = p
        Software Version = V.
Is there a way to get the orgional USB drivers and not the ones supplied with Leonardo?
36  Using Arduino / Installation & Troubleshooting / I have a #$^$%&% Leonardo for free, just pick it up on: March 15, 2013, 05:35:16 am
A few days ago i got a Leonardo becourse i wanted to use it for my new project.

But its now for pickup for free, or i wil trow it out of my car window.

Dispiet all the good advices on the forum and website i gant get it to work.

It wont accept a sketch be uploaded, it says i have com4:, but it tryes to use com3: for programming.
Reading the facts and trying to hold the reset until the upload message apears, nothing works.
This is a waisted $25
37  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 14, 2013, 07:05:31 am
Moving the structure definition out of the function gets rid of that error message.
According to this http://arduino.cc/forum/index.php/topic,153823.msg1154610.html#msg1154610 schould is be possible.
38  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 14, 2013, 06:22:46 am
The only thing i dit was chancing EEPROM_value in EEPROM_Value and nothing else.
I now do it the old fasioned way
Code:
void dumpConfig()  {
struct EEPROM_Struct{
  long _azAdZeroOffset; // azAdZeroOffset value
  long _elAdZeroOffset; // elAdZeroOffset value
  long _azScaleFactor; // azimuth encoder scale factor
  long _elScaleFactor; // elevation encoder scale factor
  int _closeEnough; // value for catcing position
  long _azimuthPark; // Position where the antenna is parked after a timeout
  long _elevationPark; //
  byte _rotationSpeed; // Actual rotation speed
  byte _rotationSpeed4; // Rotator speed High
  byte _rotationSpeed3; //
  byte _rotationSpeed2; //
  byte _rotationSpeed1; // Rotator speed Low
  unsigned long _rotorParkInterval; // Duration after wich the rotors are parked
  char softwareVersion[4]; // contains version number
}  
EEPROM_Value;

  Serial << "Show EEPROM" << endl;
    for (unsigned int t=0; t<sizeof(EEPROM_Value); t++) {
      *((char*)&EEPROM_Value + t) = EEPROM.read(t);
    }
  
  Serial << EEPROM_Value._azAdZeroOffset << endl; // azAdZeroOffset value
  Serial << EEPROM_Value._elAdZeroOffset << endl; // elAdZeroOffset value
  Serial << EEPROM_Value._azScaleFactor << endl; // azimuth encoder scale factor
  Serial << EEPROM_Value._elScaleFactor << endl; // elevation encoder scale factor
  Serial << EEPROM_Value._closeEnough << endl; // value for catcing position
  Serial << EEPROM_Value._azimuthPark << endl; // Position where the antenna is parked after a timeout
  Serial << EEPROM_Value._elevationPark << endl; //
  Serial << EEPROM_Value._rotationSpeed << endl; // Actual rotation speed
  Serial << EEPROM_Value._rotationSpeed4 << endl; // Rotator speed High
  Serial << EEPROM_Value._rotationSpeed3 << endl; //
  Serial << EEPROM_Value._rotationSpeed2 << endl; //
  Serial << EEPROM_Value._rotationSpeed1 << endl; // Rotator speed Low
  Serial << EEPROM_Value._rotorParkInterval << endl; // Duration after wich the rotors are parked
  Serial << EEPROM_Value.softwareVersion << endl; // contains version number
}
39  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 14, 2013, 03:55:47 am
Its hopeles with me, now got a different error:
EEPROM:127: error: no matching function for call to 'EEPROM_readAnything(int, dumpConfig()::EEPROM_Struct&)'
40  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 13, 2013, 05:28:36 pm
Sometimes i feel stupid becourse i cant figure out what is wrong here:
Code:
void dumpConfig()  {
struct EEPROMStruct{
  long _azAdZeroOffset; // azAdZeroOffset value
  long _elAdZeroOffset; // elAdZeroOffset value
  long _azScaleFactor; // azimuth encoder scale factor
  long _elScaleFactor; // elevation encoder scale factor
  int _closeEnough; // value for catcing position
  long _azimuthPark; // Position where the antenna is parked after a timeout
  long _elevationPark; //
  byte _rotationSpeed; // Actual rotation speed
  byte _rotationSpeed4; // Rotator speed High
  byte _rotationSpeed3; //
  byte _rotationSpeed2; //
  byte _rotationSpeed1; // Rotator speed Low
  unsigned long _rotorParkInterval; // Duration after wich the rotors are parked
  char softwareVersion[4]; // contains version number

EEPROM_Value;

EEPROM_readAnything(0, EEPROM_value);
}
I get a 'EEPROM_value' was not declared in this scope error.
Maybe its to late and i should go to sleep.
41  Using Arduino / Programming Questions / Re: EEPROMEx library not behaiving as expected on: March 13, 2013, 03:15:41 pm
Now i am puzzled. The example shows :
Code:
void setup() {
OK = loadConfig;
}

void loop() { }

bool loadConfig() {
  EEPROM.readBlock(configAdress, confValue);
  return (confValue.softwareVersion == SOFTWARE_VERSION);
}
So  the result of loadConfig() could be false or true but if i understand you correct this isnt so.
42  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 13, 2013, 06:53:32 am
Oeps thats a lot of information for me as a newbie C++ programmer.
Could you give a example. Thnx
43  Using Arduino / Programming Questions / Re: EEPROMEx library not behaiving as expected on: March 13, 2013, 06:44:29 am
Ok will try that later. If correct the example is wrong.
44  Using Arduino / Programming Questions / Re: How to dump data from EEPROM more clearly on: March 13, 2013, 06:38:41 am
OK, final question, can one delete the struct afterwards to clear RAM?
45  Using Arduino / Programming Questions / EEPROMEx library not behaiving as expected on: March 13, 2013, 04:37:38 am
I am trying to implement the EEPROMEx libray and run into a problem.
(http://playground.arduino.cc/Code/EEPROMLoadAndSaveSettings)
In my setup() if want to see if there is a software change:
Code:
#include <Streaming.h>
#include <SoftwareSerial.h>
#define SOFTWARE_VERSION "0.1"
const int maxAllowedWrites = 200;
const int memBase = 0;
const int memCeiling = EEPROMSizeATmega328;
boolean OK = true;
int configAdress = 0;

void setup() {
  configAdress  = EEPROM.getAddress(sizeof(StoreStruct)); // Size of config object
  OK = loadConfig();    // Try to load config
  if(OK) {
           Serial << "Config load" << endl;
           }  // If version are same resume
  else   {
          saveConfig();
          Serial << "Config save" << endl;
          }  // else save defaults and use them

}
And the two routines from that example adjusted to my enviroment:
Code:
bool loadConfig() {
  EEPROM.readBlock(configAdress, confValue);
// for debug only
  Serial << SOFTWARE_VERSION << endl;
  Serial << confValue.softwareVersion << endl;
//
  return (confValue.softwareVersion == SOFTWARE_VERSION);
}

void saveConfig() {
   EEPROM.writeBlock(configAdress, confValue);
}

Althoug both version are the same, saveConfig() is called always.
Pages: 1 2 [3] 4 5 ... 11