Show Posts
Pages: 1 ... 157 158 [159] 160 161 ... 360
2371  Using Arduino / Programming Questions / Re: Compile errors with Progmem on: May 09, 2013, 12:56:28 pm
Did/were you able to check that it didn't put the table in RAM?
I ask because I've never seen PROGMEM as the first thing on the line.
2372  Using Arduino / Programming Questions / Re: Compile errors with Progmem on: May 09, 2013, 11:13:07 am
Code:
static PROGMEM prog_uint32_t crc_table[16] = {

I wouldn't use static to declare a PROGMEM table. Static is for RAM.
Maybe
Code:
uint32_t PROGMEM table[16] = { etc etc etc


Using an old method, this worked with char arrays and still runs:

Code:
#include <avr/io.h>
#include <avr/pgmspace.h>

const char PROGMEM namesTable[] = { // all this text stored in flash
  "MARK\0FRANCIS\0JOHN\0ANDREW\0ROBERT\0SEAN\0HAYES\0LUDWIG\0HARRISON\0GRAND\0SALTER\0BOND\0"
};

PGM_P nT; // will point into namesTable

#define  FIRSTNAMES    6
#define  LASTNAMES     6
PGM_P    firstName[ FIRSTNAMES ];
PGM_P    lastName[ LASTNAMES ];

void  printProgstring( PGM_P FM )
{
  char fb;
  do
  {
    fb = pgm_read_byte( FM++ );   
    if ( fb )  Serial.print( fb );
  }
  while ( fb );
}

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

  nT = namesTable;
  firstName[ 0 ] = nT;
 
  byte i; // only counting to 6 so 1 byte is enough
  for ( i = 1; i < FIRSTNAMES; i++ )
  {
    while ( pgm_read_byte( nT++ ));
    firstName[ i ] = nT++;   
  }
 
  for ( i = 0; i < LASTNAMES; i++ )
  {
    while ( pgm_read_byte( nT++ )); // find the \0 at the end of name[ i-1 ]
    lastName[ i ] = nT++;   
  }

  for ( i = 0; i < FIRSTNAMES; i++ )
  {
    printProgstring( firstName[ i ] );
    Serial.println( );   
  }
  Serial.println( );   
  for ( i = 0; i < LASTNAMES; i++ )
  {
    printProgstring( lastName[ i ] );
    Serial.println( );   
  }

}

void loop(void)
{
}
2373  Using Arduino / Programming Questions / Re: Serial monitor output to text file on: May 09, 2013, 10:55:04 am
Actually it was the trying to rt-click and get a menu. Ctrl-C does work but I never tried that till now.

And Serial Monitor does allow scrolling too. But Hyper Terminal allows saving incoming data to file and sending file data out. And what I can do with my own code goes beyond either.

2374  Using Arduino / Programming Questions / Re: PWM Water distiller on: May 09, 2013, 06:44:17 am
Quote
I suspect i have a 110v element labeled as a 240v.

Have you tried a step-down transformer?

2375  Using Arduino / Programming Questions / Re: Removing delay and averaging analog input help needed on: May 09, 2013, 06:32:44 am
Last time I played with using a led to control the brightness of the led, I started with this:

http://playground.arduino.cc//Learning/LEDSensor

and I ended up with slightly different code. It does flicker in low light.

Code:
//
// This example shows one way of using an LED as a light sensor.
// You will need to wire up your components as such:
//
//           + digital2
//           |
//           <
//           > 100 ohm resistor
//           <
//           |
//           |
//         -----
//          / \  LED, maybe a 5mm, clear plastic is good
//         -----
//           |
//           |
//           + digital3
//
// What we are going to do is apply a positive voltage at digital2 and
// a low voltage at digital3. This is backwards for the LED, current will
// not flow and light will not come out, but we will charge up the
// capacitance of the LED junction and the Arduino pin.
//
// Then we are going to disconnect the output drivers from digital2 and
// count how long it takes the stored charge to bleed off through the
// the LED. The brighter the light, the faster it will bleed away to
// digital3.
//
// Then just to be perverse we will display the brightness back on the
// same LED by turning it on for a millisecond. This happens more often
// with brighter lighting, so the LED is dim in a dim room and brighter
// in a bright room. Quite nice.
//
// (Though a nice idea, this implementation is flawed because the refresh
// rate gets too long in the dark and it flickers disturbingly.)


// just a few changes then....

#define LED_N_SIDE 7
#define LED_P_SIDE 6

unsigned long  now, mark, interval;
unsigned long checkUSecs = 2UL, ledOnTime = 100UL, senseMaxUSecs = 5000UL;

char  state = 0; // -128 <--> 127

void setup()
{
  //  now = micros();
}

void loop()
{
  static  unsigned int j = 0U;

  switch ( state )
  {
  case  0:
    {
      // Apply reverse voltage, charge up the pin and led capacitance
      pinMode(LED_N_SIDE,OUTPUT);
      pinMode(LED_P_SIDE,OUTPUT);
      digitalWrite(LED_N_SIDE,HIGH);
      digitalWrite(LED_P_SIDE,LOW);

      // Isolate the pin 2 end of the diode
      pinMode(LED_N_SIDE,INPUT);
      digitalWrite(LED_N_SIDE,LOW);  // turn off internal pull-up resistor

      now = mark = micros();
      state = 1;
      j = 0U;
      break;
    }

  case  1:
    {
//      if ( micros() != mark )
//      {
//        mark = micros();
        if ( digitalRead(LED_N_SIDE))
        {
          if (( micros() - now ) >= senseMaxUSecs )
          {
            state = 2; // quit reading
          }
        }
        else
        {
          state = 2;
        }
//      }
      break;
    }

  case  2:
    {
      // Turn the light on

      digitalWrite(LED_P_SIDE,HIGH);
      digitalWrite(LED_N_SIDE,LOW);
      pinMode(LED_P_SIDE,OUTPUT);
      pinMode(LED_N_SIDE,OUTPUT);
      mark = micros();
      state = 3;
      break;
    } 

  case  3:
    {
      // Turn the light off after ledOnTime microseconds
      if ( micros() - mark >= ledOnTime )
      {
        digitalWrite(LED_P_SIDE,LOW);
        //      delayMicroseconds(1000);
        // we could turn it off, but we know that is about to happen at the loop() start
        state = 0;
        break;
      }
    }
    break;
  }
}

2376  Using Arduino / Programming Questions / Re: PWM Water distiller on: May 09, 2013, 06:14:05 am
Hi Jason. I have a nice Black and Decker rice cooker (ran me $13 at Walmart) that shuts itself off when the water is steamed off. It does it either by weight or temperature rise but smaller or larger amount works the same.

Perhaps if you put a load sensor under the distiller and have it cut off during the last liter being distilled then you can avoid both the burn and the extra energy cost of distilling the last water that has the concentrated impurities from all the water you started with. After all, those impurities raise the boiling point so why not dump that water and start new?

Does your heater burn impurities to the bottom even when there's more than a little water in the pot or is that something you get after you let the thing boil dry or near dry?

2377  Using Arduino / Programming Questions / Re: Serial monitor output to text file on: May 09, 2013, 05:55:39 am
You can copy from the Serial monitor window easily enough.  No need to use yet another program.  Select what you want to copy using the mouse and Control/C will do the copy for you.

Running XP here and I was never able to do that which is why I tried Hyper Terminal for the first time in over 15 years.
2378  Community / Bar Sport / Re: the Ardu-cake on: May 09, 2013, 04:16:17 am
Amazing detail! Was it 3D printed?
2379  Community / Bar Sport / Re: arduino help blind see! on: May 09, 2013, 04:13:23 am
https://www.youtube.com/watch?v=Z_E3zxx2l9g

2380  Community / Bar Sport / Re: how to impress a girl with arduino! on: May 09, 2013, 04:04:23 am
She liked you in the first place. Otherwise you'd be "a creep".
2381  Community / Bar Sport / Re: Arduino based replicator on: May 09, 2013, 04:02:13 am
Yep, I was the one being political.   smiley-roll-blue

Yes, that changes -everything- you wrote.

2382  Using Arduino / Programming Questions / Re: Decimal Point Problems. How to make a variable value of 1.35? on: May 09, 2013, 03:59:12 am
You can use floats, fixed-point math, or smaller units and print the decimal place only in output.

I was a math and science head since the 60's so to me it's no problem choosing units to use integers with. Maybe it's an outcome of using pencil and paper for so many years but the decimal point is just a reference to me.

If I want to measure meters down to 4 decimal places then I make my unit micrometers. I take care to do my divisions last and have two places that can round before the 4th place digit is compromised.
For me, two thirds of a 123456 is 123456 * 3 / 2 and if I want to chase it then the remainder is 123456 * 3 % 2. If 123456 is 'really' 123.456 and I need 2 place accuracy then I don't need to chase the remainder.

I can go with floats but on an AVR they will be teeth-grinding slow and in the process of doing much math with them I can count on errors that I won't get using integers. But... they will be small errors. When .9999999 really is 1 and process speed is not critical then go ahead and use floats.

2383  Using Arduino / Programming Questions / Re: Serial monitor output to text file on: May 09, 2013, 03:25:14 am
It's less of a learning curve if you already know code, files and what you need to do.

Never mind anyway, I just went to the File IO examples and wouldn't you know, the directory list example doesn't even compile. I won't send a newbie into that mess.

Using DOS Command Line isn't going to work on all Winblows versions but for you and me, it does. XP here.
I have done that kind of thing not long ago but the results were not so good. One thing to know is that you may need to use the DOS MODE command to set up the serial protocol (rate, parity, bits) before communicating. Of course there's a default so you don't always have to set MODE.

See if Hyper Terminal doesn't have save to file options. I've used that instead of Serial Monitor when I wanted to cut&paste Arduino output.
.........
Yup. Just checked. You can receive and send files through Hyper Terminal, look in the Transfer menu.
 


2384  Community / Bar Sport / Re: Arduino based replicator on: May 09, 2013, 02:37:40 am
According to John Schnatter, after hiring a PR firm over the matter:

Quote
Reporter: "Do you think your -- you know -- franchise owners... are going to cut people hours back to make them part time instead of full time?"

Me: "Well, in Hawaii there is a form of the same kind of health insurance and that's what you do, you find loopholes to get around it. That's what they're going to do."

Reporter: "My understanding is that if you're a full time employee, which is 35 hours or over, you'd be covered. Or if you're part time then you wouldn't be. So wouldn't some business owners just cut people down like 34 hours a week so they wouldn't have to pay for health insurance?"

Me: "It's common sense. It's what I call lose-lose."

The reporter asked what I believed Papa John's franchisees would do in response to Obamacare, not what Papa John's would do. In fact, her question was "wouldn't some business owners just cut people down like 34 hours a week so they wouldn't have to pay for health insurance?"

My answer: "It's common sense."

Companies like Papa John's are largely a collection of small independent businesses. The average Papa John's franchisee owns three to four stores. Since our franchisees own the restaurants they operate, who they hire, how many hours they give each employee and what they pay each employee is up to them, not me or Papa John's. Like any small business in these economic times, our franchisees are under a tremendous amount of pressure on costs.

During that same interview, talking about Obamacare I said, though it wasn't widely reported:

    "The good news is 100% of the population (full-time workers) is going to get health insurance. I'm cool with that."
    "We're all going to pay for it. There's nothing for free."
    "And this way I get to provide health insurance and I'm not at a competitive disadvantage ... our competitors are going to have to do the same thing."

Papa John's, like most businesses, is still researching what the Affordable Care Act means to our operations. Regardless of the conclusion of our analysis, we will honor this law, as we do all laws, and continue to offer 100% of Papa John's corporate employees and workers in company-owned stores health insurance as we have since the company was founded in 1984.

"All I said was...." doesn't include what he actually said for damn good reason. The goal of an excuse is to shift minds away from the bleeding give-away he made.

1) At the time, 1/3rd of the Papa John employees had health insurance.
2) He did say the cost of a pizza would have to go up 10 to 14 cents to cover all of them.
3) He did say it's common sense to cut hours to avoid raising prices.

Duh and no crap he's reversed after the feedback he's gotten. Those remarks were made when Mitt Romney was going to be the next president and showing your teeth was okay. Now it's time to backpedal from that position and pretend you really care for the people who actually earn the money you get.

There's more people and less resources all the time. One small group is profiting like never before and the other 90% are steadily losing ground. Do the math unless you're too stupid or mental to figure it out.

When a bunch of sheep and a wolf sit down to lunch, wolf is not on the menu. And for some reason, the wolf sees no advantage in having green pastures. That's a sheep problem.

There's a libertarian Youtube out on WHY sweatshops in 3rd world countries are good. It uses the same basic argument I've seen on why slavery was good; you're really being kind to the slaves by feeding them and giving them a place to live. They would die otherwise.

Never mind that the wannabe-slavers... errrrr, Job Creators only have their freedom because others did kill and or die protecting that freedom. That video has a virtual puppet do the speaking. Guess why? Oh yeah... because the media would "take it wrong and twist it". And besides, the puppet has as much conscience as the ones that scripted it, ie none.

2385  Using Arduino / Programming Questions / Re: Serial monitor output to text file on: May 08, 2013, 06:51:41 pm
BTW, after I typed "copy com5 textfile.txt" at the DOS prompt my Arduino's serial monitor screen will not change size (can't be resized). Does anyone know how to fix this?

You could write a better terminal program using the Processing language that the Arduino IDE is derived from. You will need to use the Serial library which is in the Very Helpful Examples.

www.processing.org

Pages: 1 ... 157 158 [159] 160 161 ... 360