Show Posts
Pages: 1 ... 383 384 [385] 386 387 ... 542
5761  Using Arduino / Project Guidance / Re: Using ATMega328 on breadboard on: January 27, 2012, 12:08:24 pm
As far as the Arduino knows it's power is 0 and +5.  If you feed your 'Ground' wire to an analog input it should get a value around 512 (1/2 full scale or +2.5V)
5762  Using Arduino / Programming Questions / Re: SPI specs on: January 27, 2012, 12:05:22 pm
Think of SPI as two 8-bit shift registers.  The serial output of one is the serial input of the other and vice-versa. The "Slave Select" line goes to the output latch of the shift register.  The "Master" loads a value into its shift register and clocks out 8 bits.  While those 8 go out, 8 bits come in from the shift register in the peripheral.  On the rising edge of the latch, the peripheral acts on the data.
5763  Using Arduino / Programming Questions / Re: Serial temp data read? on: January 27, 2012, 11:54:33 am
Assuming the stream of characters always has a digit after the decimal point:

Code:
float Temperature(String temperature)
    {
    bool negative = false;
    int temp = 0;

    for (int i=0; i< temperature.length(); i++)
        {
        char c = temperature[i];
        if (c == '-')
               negative = true;
        if (c >= '0' && c <= '9')
            temp = temp * 10 + (c - '0');
        }

   if (negative)
       temp *= -1;

   return temp/10.0;
   }
5764  Using Arduino / Project Guidance / Re: Using ATMega328 on breadboard on: January 27, 2012, 11:43:51 am
As long as the +2.5 and -2.5 rails have a common Ground and you DO NOT CONNECT THAT GROUND TO ANYTHING CONNECTED TO THE ATmega you can use the -2.5 rail as Ground and the +2.5 rail as +5.
5765  Using Arduino / Project Guidance / Re: Read recorded sensor data sequentially from CSV on: January 27, 2012, 11:40:19 am
is there a way to do this so that it reads the data at the same speed etc as it was recorded?

Depends on what speed the data was written.

Hopefully it was written at a fixed rate that is reasonably slow, like less than 100 per second.

Use the "Blink without delay" example to see how you schedule thing to happen at regular time intervals.

In loop():
    if you have a parsed value ready:
        if it's time to send the next value:
            analogWrite()
            set the value to 0
            mark the value as 'not ready'
     else
         if there is a character available in the file:
             read the character
              if the character is a comma:
                    mark the value as available
              else
              if the character is a digit:
                  multiply the value by 10 and add character - '0'
    end of loop()
                 
5766  Using Arduino / Installation & Troubleshooting / Re: arduino bootloader on: January 27, 2012, 11:26:57 am
Try turning on "verbose output during upload" in Preferences.  That might give more information.  It should allow you to see what value came back from the chip.  Is it possible you got a 328 instead of a 328P?
5767  Using Arduino / Project Guidance / Re: Streaming Serial Data into Arduino on: January 27, 2012, 10:41:54 am
First thing I would suggest is to only send data when it changes.  That way you get better responsiveness because you don't have to wait for data that isn't needed.

Second thing is to send binary rather than text so it doesn't have to be converted back.

If each data byte contains address information then you don't need to provide framing.

You have 43 bits you want to send:  4*8 for joysticks and 11 for buttons.  You can break those into blocks of 4 bits and use the other 4 bits in the byte to specify which block of data:

0X: Joystick axis 1 High Four Bits
1X: Joystick axis 1 Low Four Bits
2X: Joystick axis 2 High Four Bits
3X: Joystick axis 2 Low Four Bits
4X: Joystick axis 3 High Four Bits
5X: Joystick axis 3 Low Four Bits
6X: Joystick axis 4 High Four Bits
7X: Joystick axis 4 Low Four Bits
8X: Buttons 0-3
9X: Buttons 4-7
AX: Buttons 8-11
BX: Spare
CX: Spare
DX: Spare
EX: Spare
FX: Spare

As each byte arrives the Arduino places the low four bits in the correct location based on the high four bits and then calls whatever function handles that data item.

One problem is that sending a joystick axis as two parts might cause glitches as the joystick moves since it might be acting on the left half of a new value combined with the right half of the old value.  Fix this by having the sending program always send the low half if the high half changes and have the Arduino only act when the low half arrives.  Small changes that only change the low half will remain efficient and large changes are likely to change both halves anyway so little efficiency is lost by sending both.

If the data might get lost along the way you can have the sending program send out the un-changed values periodically.  Say one joystick value or set of 4 buttons every tenth of a second or so.  That would help assure that both sides have the same current values.
5768  Using Arduino / Programming Questions / Re: SPI specs on: January 27, 2012, 10:00:32 am
In the IDE select Reference from the Help menu.

At the top of the Reference page, click on the Libraries link.

On the Libraries page, click on the SPI link.
5769  Using Arduino / Installation & Troubleshooting / Re: Problem uploading - stk500_getsync(): not in sync: resp=0xe0 on: January 27, 2012, 09:58:33 am
Is it possible that someone burned an optiboot (UNO) bootloader on your chips?  Try selecting the Arduino UNO board to see if that works.
5770  Using Arduino / General Electronics / Re: Rotary Encoder Tutorial port to Arduino Uno on: January 26, 2012, 11:41:43 pm
http://arduino.cc/it/Tutorial/Button
5771  Using Arduino / Programming Questions / Re: Akting a motor and a relais simultaniously on: January 26, 2012, 11:19:52 pm
If you want to minimize changes you could split the long delays into several smaller delays.

For example if you wanted to have the valve open for 2 second starting half a second after the motor starts down:

Code:
    digitalWrite(dirPin,directionMovementR);  // Motor direction down
    analogWrite(pwmPin,powerOnR);  // Motor start

    delay(500);  // Run motor for 1/2 second before opening valve

    digitalWrite(6,HIGH);  // Valve open
    delay(2000);  // For two seconds
    digitalWrite(6,LOW);  // and then closed

    delay(durationMovementR - 2500);  // The rest of the motor down time
    analogWrite(pwmPin,powerOff); // Stop the motor
5772  Using Arduino / LEDs and Multiplexing / Re: Control red-green led (inverted?) on: January 26, 2012, 11:11:32 pm
If you have a "Common Anode" style of LED cluster, connect the common anode to +5.  Then connect the separate cathodes to I/O pins through the same size resistor you would use if the LED was connected to Ground.  Then when the pin is HIGH, no power will flow (both ends of the LED are at +5V).  When the pin is LOW the LED will light up (power will flow from +5V through the LED and resistor to the LOW I/O pin.

If you use PWM outputs, 0 will be full on and 255 will be full off.  Exactly the inverse of a Common Cathode cluster.

No, you can't use a single resistor on the common pin.  Each LED needs a separate current limiting resistor.
5773  Using Arduino / General Electronics / Re: SPI Programmer and how to isolate from ATtiny..... on: January 26, 2012, 06:31:52 pm
Have you tried just setting the programming outputs from the UNO to inputs?  That should prevent them from interfering with the operation of the ATtiny.
5774  Using Arduino / General Electronics / Re: SPI Programmer and how to isolate from ATtiny..... on: January 26, 2012, 04:37:09 pm
Typically you would put an ICSP header on the board to be programmed.  Plug in the programmer to program.  Unplug it to run your program.

An alternative, if you are using a DIP processor, is to unplug it from your board and plug it into a socket/board set up for programming.
5775  General Category / General Discussion / Re: coin validator programming (ie cctalk) on: January 26, 2012, 03:57:55 pm
SR5 Serial Protocol Manual:
http://www.moneycontrols.com/en/productfiles/file/80/980a69a501a532cd15e328d813dfe1be

Generic cctalk protocol manual:
http://www.money-controls.de/manuals/cctalk/(84)cctalk_Part_1_v4_5.pdf

I think you want the "Teach Mode Control" command (202).  You will want 8 or more samples of the coin to be programmed.
Pages: 1 ... 383 384 [385] 386 387 ... 542