Show Posts
Pages: 1 2 [3] 4 5 ... 361
31  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: August 11, 2014, 01:08:18 am
Yes, it does take a small fraction of a second to calculate the polynomial, using Horner's rule.

Did I mention "when you need speed"?  Oh yes, I did.

The reason to use tables is when you need speed and simplicity in your code.

Table lookup takes a small fraction of a millisecond, including interpolation if you don't use floats.

Which is better if you are running a live machine with PID? And maybe running other concurrent processes?

Which can be calibrated?
32  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: August 10, 2014, 10:42:58 pm
There is a much simpler approach that does not involve a large table and interpolation. Those are very smooth curves that can be accurately fit with a simple polynomial, giving you a function P(T) or T(P).  For example, the pressure data for Refrigerant 12 can be fit over the range of 0-150 degrees with a simple cubic polynomial, accurate to about 0.2 PSI over that entire range.

I used MATLAB to calculate the fit, with the result that P(T) = 1.8586e-5*T3 + 0.003803*T2 + 0.51359*T + 9.1194 (see attached plot). So, you need to store only four numbers to calculate P for any T in that range (and outside of it as well). You could use a quartic polynomial for larger ranges.

Curve fits can be done with any spreadsheet, and there are also online services to do curve fits for you.

Edit: to fit T(P) for the range -10 to 150 takes a fourth order polynomial, and the result is accurate to about 2 degrees. However, as  you can see from the plot, the fit digresses outside of the temperature range used for the fit.

The reason to use tables is when you need speed and simplicity in your code. Speed factor goes up 100x just by not generating as simple as sine values.

This is especially true when it is running on a 16 MHz 8-bit processor with no FPU and completely lacks support for 64 bit or larger floats as opposed to a 2+ GHz 32 or 64-bit pipelined multi-core processor with FPU's and more L1 cache than any AVR has SRAM.  

When you don't need speed and don't care past 3 or 4 places on answers, then get that 2 degrees accuracy that a table would not have to be off by at all.

Oh yeah. Didn't I mention that tables can be calibrated?
33  Using Arduino / Programming Questions / Re: Combining Codes on: August 09, 2014, 09:56:22 pm
I saw code that is supposed to be Motor Code and I saw code that's supposed to be Servo Code.
Using the posted code, what happens when you run either with hardware connected?

Just curious and wondering how you get from there to dog feeder.
34  Using Arduino / Programming Questions / Re: Virtual shift register lacks the first bit... on: August 09, 2014, 11:52:07 am
the OP is trying to figure out how to get an Arduino to insert data onto the S88 bus that is already under control of his model railway controller.

That is hacking.

In principle this is perfectly feasible - when you know how.

When you have enough details to try something that might work.

And I think (?) the OP has in mind to use wireless to enable the master Arduino to collect data before it inserts it onto the bus.

What have you in mind?


I didn't catch what the radio is for.

With all the proprietary stuff what can you do but hack?
See if the company name doesn't translate to Tandy.
35  Using Arduino / Programming Questions / Re: Virtual shift register lacks the first bit... on: August 09, 2014, 03:53:57 am
If you could hack the bus then you might send data back on it, which is what you're trying to do isn't it?
36  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 08, 2014, 08:16:38 pm
Can the End Device talk back and if so, how? Because that is where you are having the problem, no?

37  Using Arduino / Programming Questions / Re: Virtual shift register lacks the first bit... on: August 07, 2014, 04:50:38 pm
If you could hack the S88 bus, you might not need the radio.
38  Using Arduino / Project Guidance / Re: program to find rpm on: August 07, 2014, 04:42:00 pm
Just created this on Excel!

That's cool. You can also make concentric circles with differing numbers of spokes.

With 2 sensors arranged so that when 1 has a spoke in the way, the other has between spokes it is possible to tell not just the turn but the direction.

Adding sensors can be used to raise the precision as well, but only as precise as the sensors are placed and there is another use of printing on transparency. A pattern of apertures (holes, make them bigger than pin holes!) in black can assure that light only gets through to the detector (back from the aperture, in a blackened inside tube even paper will do) from the carefully channeled path even if the emitter and detector bulbs are slightly off to one side -- the light path and if it is blocked or not is what matters.

Find out how verniers work and you have a key to a precise measuring technique.
39  Using Arduino / Project Guidance / Re: program to find rpm on: August 06, 2014, 08:21:44 am
where can i get such wheel printed ?

You make a graphic and take that to an office store and have them print a transparency.

You may or may not have trouble with scale X-Y, if a circle comes out ellipse but I did not.
Total scale, how big the printed is to the screen picture is pixels per centimeter or inch.

Finding a picture ready made, I dunno. A CAD package is your best bet to get everything

On the same transparency sheet, put all the things you will need, like apertures for detectors.
40  Using Arduino / Programming Questions / Re: Virtual shift register lacks the first bit... on: August 05, 2014, 11:38:29 pm
E) None of the Arduino's have to read the S88 bus. The master only have to send out the data.

The master sends the data out on the bus but the Arduino doesn't read that?
Arduino just sends data to the master through wireless?

41  Using Arduino / Sensors / Cap sense through a cap. Static safe now? on: August 04, 2014, 11:49:09 pm
There's a simple touch sensor that's just a conductor on a pin, it can tell if you touch it.
But that's open to static.

I got it working with a jumper wire, especially squeezed on.

So I took a 1 uF radial cap and straightened the legs out sideways and stuck one leg in the pin 7 hole of an UNO.
About the same results so I paper-clipped a folded piece of foil to the free lead and it knows touch the foil very well but well through a plastic card.

My guess though is that the capacitor should protect the Arduino from static up to some point. But personal static only carries so much total kick.
100 MFD electrolytic cap gave smaller numbers is all. Maybe it can absorb more spark?

Quick and dirty concept test. Tested, works. I used pin 7 for the sensor. No reason.

// readCapacitivePin
//  Input: Arduino pin number
//  Output: A number, from 0 to 17 expressing
//  how much capacitance is on the pin
//  When you touch the pin, or whatever you have
//  attached to it, the number will get higher
// #include "pins_arduino.h" // Arduino pre-1.0 needs this

const byte sensePin = 7;

uint8_t readCapacitivePin( byte pinToMeasure )
  // Variables used to translate from Arduino to AVR pin naming
  volatile uint8_t* port;
  volatile uint8_t* ddr;
  volatile uint8_t* pin;
  // Here we translate the input pin number from
  //  Arduino pin number to the AVR PORT, PIN, DDR,
  //  and which bit of those registers we care about.
  byte bitmask;
  port = portOutputRegister(digitalPinToPort(pinToMeasure));
  ddr = portModeRegister(digitalPinToPort(pinToMeasure));
  bitmask = digitalPinToBitMask(pinToMeasure);
  pin = portInputRegister(digitalPinToPort(pinToMeasure));
  // Discharge the pin first by setting it low and output
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  // Prevent the timer IRQ from disturbing our measurement
  // Make the pin an input with the internal pull-up on
  *ddr &= ~(bitmask);
  *port |= bitmask;

  // Now see how long the pin to get pulled up. This manual unrolling of the loop
  // decreases the number of hardware cycles between each read of the pin,
  // thus increasing sensitivity.
  uint8_t cycles = 17;
  if (*pin & bitmask) {
    cycles =  0;
  else if (*pin & bitmask) {
    cycles =  1;
  else if (*pin & bitmask) {
    cycles =  2;
  else if (*pin & bitmask) {
    cycles =  3;
  else if (*pin & bitmask) {
    cycles =  4;
  else if (*pin & bitmask) {
    cycles =  5;
  else if (*pin & bitmask) {
    cycles =  6;
  else if (*pin & bitmask) {
    cycles =  7;
  else if (*pin & bitmask) {
    cycles =  8;
  else if (*pin & bitmask) {
    cycles =  9;
  else if (*pin & bitmask) {
    cycles = 10;
  else if (*pin & bitmask) {
    cycles = 11;
  else if (*pin & bitmask) {
    cycles = 12;
  else if (*pin & bitmask) {
    cycles = 13;
  else if (*pin & bitmask) {
    cycles = 14;
  else if (*pin & bitmask) {
    cycles = 15;
  else if (*pin & bitmask) {
    cycles = 16;

  // End of timing-critical section

  // Discharge the pin again by setting it low and output
  //  It's important to leave the pins low if you want to
  //  be able to touch more than 1 sensor at a time - if
  //  the sensor is left pulled high, when you touch
  //  two sensors, your body will transfer the charge between
  //  sensors.
  *port &= ~(bitmask);
  *ddr  |= bitmask;

  return cycles;

void setup( )
  Serial.begin( 115200 );
  Serial.println( F( "\n\nStart sensing!\n" ));

void loop( )
  Serial.println( readCapacitivePin( sensePin ));
  delay( 100 );

42  Community / Bar Sport / Very interesting video on cap sensor design. on: August 04, 2014, 02:09:02 pm

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:
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.

43  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..

44  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?
45  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.
Pages: 1 2 [3] 4 5 ... 361