Show Posts
Pages: 1 ... 464 465 [466] 467 468 ... 850
6976  Using Arduino / Interfacing w/ Software on the Computer / Re: VB6 with Uno serialprint to text box on: March 12, 2012, 04:14:46 pm

goes in the right direction:

Code:
//send data to serial port for debugging/read data at the PC                       
      Serial.print("A,");
      Serial.println(sensorValue);
      Serial.print("B,");
      Serial.println(speedstartValue);
      Serial.print("C,");
      Serial.println(speedcurveValue);
      Serial.print("D,");
      Serial.println(brakeValue);
      Serial.print("E,");
      Serial.println(brakecurveValue);
      Serial.print("F,");
      Serial.println(sensorMin);
      Serial.print("G,");
      Serial.println(sensorMax);
      Serial.print("H,");
      Serial.println(modelName);

this generates something like

A,100
B,120
C,130
etc

Your VB application recognizes the char and map this to the right text field.

Something like this is needed to parse (VB is too long ago)
Code:
intPos = InStr(strBuffer, vbCrLf)
If intPos <> 0 Then
  Dim C as Char
  Dim Value as String

  C = strBuffer[0];  'or is it 1 in VB?
  Value = Right$(strBuffer, 2)   'skip the separator

  Select Case(C)
  case A: TextSensorValue.Text = Value
  case B: ...  etc
  End Select
EndIf

6977  Community / Gigs and Collaborations / Re: Looking for an author to write an Arduino book on: March 12, 2012, 03:56:33 pm
@John_S
Quote
I just use google... for free! smiley-lol
(no insult meant but: )
There is no such thing as a free lunch (sorry smiley-wink, maybe you don't pay for it or you pay for it in an unknown way. E.g. google converts your google behaviour into money.
6978  Using Arduino / Programming Questions / Re: Least Squares Approximation on: March 12, 2012, 03:46:48 pm
Hi Morris,

in that .c code you have a copyright statement, are you submitting this code under another license?
Is it free for us to use?

Think it could make a nice Arduino library !
6979  Using Arduino / Programming Questions / Re: help needed to speed up function on: March 12, 2012, 03:39:49 pm

There is a bug in the time measurement

Code:
  t = micros();
  for(int i=0; i<1000; i++)
    SplitTime();
  Serial.print("Time:");Serial.print((micros() - t)/1000);Serial.println("us");

should be

Code:
  t = micros();
  for(int i=0; i<1000; i++)
    SplitTime();
  t = micros() - t;  // <<<<<<<<<<<<<<<<<<
  Serial.print("Time:");Serial.print(float(t)/1000);Serial.println("us");
As you do not want to take the printing of "Time: " in the measurement

The fastest version sofar goes from 74 us to

Time:70.93us 
HH:23
MM:59
SS:59


6980  Using Arduino / Programming Questions / Re: help needed to speed up function on: March 12, 2012, 02:32:04 pm
variation on 3 with a bit of 4

Code:
void SplitTime5()
{
  int hm = GPS_Time/100000L;
  unsigned int rem = GPS_Time - hm*100000L;
  
  HH = hm/100;
  MM = hm - HH*100;
  SS = rem/1000;
}
Time:76us
HH:23
MM:59
SS:59

- update -
Code:
void SplitTime6()
{
  unsigned int hm = GPS_Time/100000UL;
  unsigned int rem = GPS_Time - hm*100000UL;
 
  HH = hm/100;
  MM = hm - HH*100;
  SS = rem/1000;
}
Time:74us
HH:23
MM:59
SS:59
6981  Using Arduino / Programming Questions / Re: help needed to speed up function on: March 12, 2012, 02:26:04 pm
Code:
void SplitTime4()
{
        unsigned long S = GPS_Time / 1000;
        HH = S/10000; // 23
        unsigned int T = S-HH*10000; //5959
        // MM = (T *5243L >> 19);    // 95us but unclear
        MM = T/100;   // 96us
        SS = T - MM*100;
}
Time:96us
HH:23
MM:59
SS:59
6982  Using Arduino / Programming Questions / Re: Least Squares Approximation on: March 12, 2012, 01:21:53 pm

Try this one: - http://ceee.rice.edu/Books/LA/leastsq/index.html -
6983  Topics / Science and Measurement / Re: pulseIn(), photogate, time measurement on: March 11, 2012, 04:38:59 pm

you can post code between [ code] (without space) tags by using the #button above the edit field
Code:
unsigned long time;
void setup ()
{
  Serial.begin(9600); 
  pinMode(7,INPUT);
}

void loop ()
{
  time = pulseIn(7,LOW);
  if (time > 0)
  {
    Serial.println(time);
  }
}

Which version of the IDE are you using ? 1.0 or 0.22 ?
How did you connect the photogate ? Please post schematics?


6984  Development / Other Software Development / Re: Complex numbers library on: March 11, 2012, 02:20:41 pm
Just tested proposed code:
Code:
 unsigned long start = micros();
  for (int i = 0; i< 10000; i++)
  {
    c5 = c3 * c4;
  }
  unsigned long stop = micros();
  Serial.println(stop - start);
  Serial.println("\n.. Complex done");  

traditional code: 667180 for 10K multiplications
proposed code: 784068 for 10K multiplications
diff: 116888 = 17.5% slower smiley-sad

I still have to try some variations

- update -
improved the complex division by 9%  smiley - new code -

Code:
Complex Complex::operator / (Complex c)
{
double f = 1/(c.re*c.re + c.im*c.im);
double r = re * c.re + im * c.im;
double i = re * c.im - im * c.re;
return Complex(r * f, -i * f);
}

- update -
* improved upon other divisions too,
* other optimizations costs a lot of memory
  e.g. c_tan() = c_sin()/c_cos() which can be rewritten in 11 lines (steps) so that no new object is created => -44% but price is 358 bytes!!

6985  Using Arduino / Sensors / Re: Interfacing with Vernier pH probe on: March 11, 2012, 01:52:03 pm

You must divide by 1023 as that is the max value of the analog read. (effect using 1024 = -0.1%)

Furthermore refactored some code including printing the floating point value as that can be done simpler

including the tips of John wasser

(not tested)
Code:
int potPin = 0;
float phSense = 0;
float refvoltage = 1.1;

void setup()
{
  Serial.begin(9600);
  Serial.println("PH sensor ");
  analogReference(INTERNAL);
}

void loop()
{
  int samples = 20;
  int aRead = 0; 
 
  for (int i = 0; i < samples ; i++)
  {
    aRead += analogRead(potPin);
  }
  float voltage = 5.0 * aRead/ (1023 * samples);  // assuming 5V reference
 
  phSense = 14 - voltage/0.25;
 
  // convert voltage to pH
  Serial.print("Analog in reading: ");
  Serial.print(aRead);
 
  // print pH value on serial monitor
  Serial.print(" - Calculated pH Level: ");
  Serial.println(phSense, 1); // 1 = one decimal, 2 = two decimals (default),etc   // removed the /10
  delay(500);
 }
6986  Using Arduino / Sensors / Re: SDI-12 HELP on: March 11, 2012, 01:30:09 pm

Found this one myself - http://en.wikipedia.org/wiki/SDI-12 -

"all SDI-12 communications are transmitted in ASCII at 1200 baud with 7 data bits and an even parity bit."


if you use Serial.begin(1200) you should be able to get data in, you need to strip off the parity bit and then you can strat interpret the bytes...

not tested but this could be the starter
Code:
NewSoftSerial nss(3,4);  // use software serial so hardware serial is free for PC

void Setup()
{
  Serial.begin(9600);
  nss.begin(1200);
}

void loop()
{
  if (nss.available() > 0)
  {
    int val = nss.read();
    val = val & 0x7F; // strip of one byte
    Serial.print(val, DEC);
  }
}

6987  Using Arduino / Sensors / Re: SDI-12 HELP on: March 11, 2012, 01:24:20 pm
Do you have more information about the SDI-12 protocol?
or a datasheet of the sensors maybe?

Most sensors can be connected to Arduinbo although some of them are not so easy
6988  Topics / Science and Measurement / Re: Bacteria Incubator on: March 11, 2012, 01:09:46 pm

A good sensor might be the DHT22 which can do temperature and humidity  - http://arduino.cc/playground/Main/DHTLib -
6989  Using Arduino / Project Guidance / Re: PS2 to Arduino on: March 11, 2012, 01:08:11 pm

Ther is an email address at the bottom - bill at billporter.info - ... maybe ask the person directly?
6990  Development / Other Software Development / Re: Complex numbers library on: March 11, 2012, 01:03:23 pm

Thanks stimmer,

I did no performance tests/tuning yet but this is definitely one to remember.
Pages: 1 ... 464 465 [466] 467 468 ... 850