Show Posts
Pages: 1 2 [3] 4 5 ... 360
31  Community / Bar Sport / Very interesting video on cap sensor design. on: August 04, 2014, 02:09:02 pm
https://www.youtube.com/watch?v=ZHzaVzYEZbw

He has a sense plate and a ground plate that are separated horizontally so the plate fields spread out.
Then he makes the ground plate much bigger than the sense plate, concentrating potential on the sense plate.

There is also this:
https://www.youtube.com/watch?v=ZHzaVzYEZbw
 
I am liking the lack of resistors, etc, in the second approach, the 1-wire cap sense.

I don't like bare metal touch because of static and accidents. Touch paper over metal is better but I want plastic sheet over the paper. The button labels print on the paper, the cover sheet wipes off.


32  Using Arduino / Project Guidance / Re: program to find rpm on: August 02, 2014, 06:38:23 pm
You could get more samples by counting slots or spokes in a wheel than by just one point per revolution.
A gear tooth counter reads metal going by without needing attached magnets.
The counter has a field that metal moving through interacts with and there's the signal.

Can you put a light, small wheel against the wheel being measured?

If you're okay with IR sensors, office store printed transparency sheet is IR transparent.
It's a lot easier and cheaper to print a wheel with 1024 timing holes and a hub than it is to cut one from metal..



33  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: August 01, 2014, 02:20:25 am
My question was and is about what you seem to think some of the code is doing.
I don't know how that affects the whole but one good wrong assumption usually makes major problems.

I saw that and stopped right there and asked a question that you haven't bothered to answer at all.
I don't have your hardware setup to be able to find the answers myself either.

How much of that did you write before testing the first time?
34  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: August 01, 2014, 01:46:59 am
You might be safe to feed it to amplified speakers but it would need resistors to feed as Line In to an amp.
35  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 05:56:44 pm
You get serial by checking Serial.available().

How would you get a button? That may be trickier than just checking a pin, depending on the button but still the principle is the same.

The important part is to not let doing one thing hold everything else up, which is called blocking code.



36  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: July 31, 2014, 04:03:18 pm
I thought for sure that a led has a minimum trigger voltage by color and a maximum voltage not much more.
Red led needs > 1V doesn't it?
37  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 03:59:58 pm
If you map something to degrees and then degrees to servo value not degrees then you set up for 2 round offs.
 
38  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 03:22:01 pm
The whole page of Nick's blog covers the whole subject.
The second part is state machine showing exactly what you want and it does not need atoi().

When digits are received, as they arrive an unsigned int is 'moved up' 1 digit then the new digit is added.
This is because text numbers arrive high-value to low-value order.
123 is 1x100 + 2x10 + 3. So you read the 2 then x10 and add the 1, then x10 and add the 3 all as they come.

Code:
void processIncomingByte (const byte c)
{
  if (isdigit (c))
  {
    currentValue *= 10;
    currentValue += c - '0';
  }  // end of digit
  else
  {

    // The end of the number signals a state change
    handlePreviousState ();

    // set the new state, if we recognize it
    switch (c)
    {
    case 'R':
      state = GOT_R;
      break;
    case 'S':
      state = GOT_S;
      break;
    case 'G':
      state = GOT_G;
      break;
    default:
      state = NONE;
      break;
    }  // end of switch on incoming byte
  } // end of not digit  
  
}

If all you do is grab the code, you won't learn half of the tutorial there.
if you learn it all, this kind of thing will not be a problem again.

39  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: July 31, 2014, 01:39:33 pm
the 4 LEDs are turned on for 500 ms using PMW for a value of 10mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 250mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 50mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 0mv.

Unless you have a circuit to turn PWM into analog, it doesn't work that way.
PWM is full VCC for value/256 time out of each duty cycle.
Default duty cycle is about (just over) 2 ms. PWM 127 should get just over 1 ms ON, 1 ms OFF at 5V pattern.
40  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 01:28:04 pm
Simple letter + value code is exactly what Nick Gammon addresses with example in this tutorial blog:
 http://gammon.com.au/serial

41  Using Arduino / Programming Questions / Updated SMlib code on: July 30, 2014, 10:24:47 am
I've reached the 9500 char post limit.
GitHub doesn't like XP.
Verizon is taking my web space in 2 months.
I won't be posting updated code though the code is updated.
42  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: July 30, 2014, 09:09:21 am
Yeah but still, if the temperature is used to directly determine something else (formula of temperature and constants) then table the something else and save needing those steps and constants as well.

IE, don't table factors if results or partial results are more useful.

PS I could go farther.
Suppose you have 2 factors and a number of constants used in a complex formula, what do you do?
You use a 2 dimensional table as Jiggy-Ninja did. The formula reduces to lookups and interpolation if any is needed.
43  Using Arduino / Programming Questions / Re: How to share code? on: July 30, 2014, 07:54:17 am
I saw your code from github. to make your code easy for beginner like us to use. you need to write simple examples using your code. still, if you think your code is great. write a book about it.

That takes a lot. The book is likely more effort than the code.
But if 2 or more were to collaborate successfully, a group project of shared skills might go easier or devolve into a mess and fights, it's hard to say.  smiley-eek-blue

44  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: July 30, 2014, 06:28:57 am
You can make a linear based table easily enough. Question is would you have room to store it? And does it need to cover how many kinds of refrigerant?

You can get more flash and RAM with a bigger chip. You can build or buy that. Just keep in mind that you're not stuck with one set of limits when you're looking at approaches to solutions. A $7 (if you're just buying one) ATmega1284P chip has 128K flash, 16K RAM and 2 serial ports. A less than $3 ATmega328P (the UNO chip) has 32K flash, 2K RAM and 1 serial port (software serial can be used for more). Both are covered in build your own tutorials, both are covered in kits and sold on assembled and tested boards. And those are just 2 choices out of a very wide range.

What you explore for techniques now can likely be taken farther through easy choices down the road.
So definitely explore before you choose!

You can use an external flash chip or EEPROM as easily as an SD adapter and get away with a smaller AVR.

Half a second is a long time to Arduino, 8 million CPU cycles. But with the wrong code that spends most of the time waiting for things to finish it can be hardly any time at all, 500 milliseconds to fritter and waste. The right code can run a small circus of devices smoothly simultaneously.

Lookup tables are a great way to save computation. If the pressure you look up in the table is going to be used to calculate PWM values to run a servo or motor and nothing else, store those instead of pressure! PWM is only 8 bits!

Here's an example of using a lookup table of integer sine x 10000 (Y = radius x value / 10000) vs using sin() to generate floats. It does the process many times for each (adding every value and printing it to keep the compiler from optimizing the calculations away and providing result checks in the process) to take long enough to notice  smiley-mr-green then shows that calculating just the sines with floats takes 100x as long. Tables work.
It runs on a bare UNO just fine and it is not the fastest or most efficient code for what it does.

Code:
// Getting 16 bit unsigned vars in and out of PROGMEM (flash)
// Written for public domain by GoForSmoke 2014


// this program also compares the time to do table lookup vs using floats and sin()
// sorry about having to add and print the totals but otherwise the compiler optimizes the test to nothing

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <math.h>

const word PROGMEM PROGTBL[ 91 ] = { // sine * 10000 by degree 0 to 90
  0U,  175U,  349U,  523U,  698U,  872U, 1045U, 1219U, 1392U, 1564U,
  1736U, 1908U, 2079U, 2250U, 2419U, 2588U, 2756U, 2924U, 3090U, 3256U,
  3420U, 3584U, 3746U, 3907U, 4067U, 4226U, 4384U, 4540U, 4695U, 4848U,
  5000U, 5150U, 5299U, 5446U, 5592U, 5736U, 5878U, 6018U, 6157U, 6293U,
  6428U, 6561U, 6691U, 6820U, 6947U, 7071U, 7193U, 7314U, 7431U, 7547U,
  7660U, 7771U, 7880U, 7986U, 8090U, 8192U, 8290U, 8387U, 8480U, 8572U,
  8660U, 8746U, 8829U, 8910U, 8988U, 9063U, 9135U, 9205U, 9272U, 9336U,
  9397U, 9455U, 9511U, 9563U, 9613U, 9659U, 9703U, 9744U, 9781U, 9816U,
  9848U, 9877U, 9903U, 9925U, 9945U, 9962U, 9976U, 9986U, 9994U, 9998U,
  10000U, };

void setup( void )
{
  Serial.begin( 115200 );

  char  formatted[ 8 ];

  word  W;

  PGM_P  Addr; // define a const prog_char pointer named Addr
  Addr = (const prog_char *) PROGTBL; // cast the table address to fit Addr

  for ( byte i = 0; i < 91; i++ )
  {
    W = pgm_read_word( Addr + 2 * i ); // read unsigned 16 bits at Addr
    sprintf( formatted, "%6u", W );
    Serial.print( formatted );
    if ( i < 90 ) Serial.print( ", " );
    if (( i % 5 ) == 4 ) Serial.println( );
  }
  Serial.println( "\n\n Timed test" );
 
  Serial.flush(); // getting serial interrupts out before time test
  delay( 1000 );  // making sure of it

  unsigned long accum = 0UL; // to make the compiler use all the lines below

  unsigned long mics = micros();
  for ( byte i = 0; i < 91; i++ )
  {
    W = pgm_read_word( Addr + i * 2 );
    accum += (unsigned long) W;
  }
  unsigned long tookMics = micros() - mics;
 
  Serial.print( "\n accum = " );
  Serial.print( accum );
  Serial.print( " took " );
  Serial.print( tookMics );
  Serial.print( " micros to add up" );
  Serial.println( );
 
  Serial.flush(); // getting serial interrupts out before time test
  delay( 1000 );  // making sure of it
 
  float fAccum = 0.0;
 
  mics = micros();
  float T = sin( M_PI * 30.0 / 180.0 );
  for ( byte i = 0; i < 91; i++ )
  {
    T = sin( M_PI * (float) i / 180.0 );
    fAccum += T;
  }
  tookMics = micros() - mics;
 
  Serial.print( "\n float accum = " );
  Serial.print( fAccum );
  Serial.print( " took " );
  Serial.print( tookMics );
  Serial.print( " micros to add up" );
  Serial.println( );
 
}

void loop( void )
{
}

45  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: July 29, 2014, 11:14:17 pm
If your table goes by linear temperature, you only need to store pressure for each and use temperature to get the index.
You may have room for 1/10th degree steps for integer values in Pa instead of kPa.

Another route from flash is to use data store in an SD card. It's slower but still fast and the limits are sky high.


Pages: 1 2 [3] 4 5 ... 360