Show Posts
Pages: 1 2 [3] 4 5 ... 451
31  Community / Website and Forum / Re: Drop the boolean data type, its broken. (or fix it) on: June 30, 2014, 06:20:40 am
C and C++ agree on false==0.   I think I'd prefer to see
#define true (!false)
If thats still acceptable.
32  Using Arduino / Installation & Troubleshooting / Re: No /dev/tty.usbmodem on OS X 10.9.3 on: June 30, 2014, 03:06:57 am
Vendor ID 0x1a86 is apparently NOT an FTDI device (you have a Nano "clone", rather than a genuine article.)
Checking around, it seems that it is a "ch341" USB/Serial driver, and doesn't have a MacOS driver.
 https://discussions.apple.com/message/10802537
http://wch-ic.com/product/usb/ch341.asp
33  General Category / General Discussion / Re: Double Micro Push Buttons on: June 30, 2014, 02:51:55 am
http://www.mouser.com/ProductDetail/Grayhill/32-02/?qs=sGAEpiMZZMvxtGF7dlGNpqffYO%252bJL0u23FEtaBLkZew%3d

DPDT switches are a lot more common, but they'll tend to be bigger as well.
34  Development / Other Hardware Development / Re: Restrict user of certain pin/peripheral? on: June 30, 2014, 02:38:04 am
You could use your own pins_arduino.h file to mark the relevant digial pins as "NOT_A_PORT" in the digital_pin_to_port_PGM array.  This would only protect against a particular class of users, and it would cause programs to fail "silently" in mysterious manner if they tried to use the pins, but it might be better than nothing.
35  Using Arduino / General Electronics / Re: Reasonable: 167 ohm from micro speaker? on: June 30, 2014, 02:30:50 am
Quote
167 ohms is surprisingly high - most "bud" earphones are 30 ohms.
I agree.  Could this be a magnetic non-speaker transducer?  Some (many?) phones are designed to "work with hearing aids", which means that they somehow simulate the old-style phone earphones WRT magnetics.  (or it could be a special speaker specifically designed for such compatibility.)
http://transition.fcc.gov/Bureaus/Common_Carrier/FAQ/faq_hac.html
36  Using Arduino / Programming Questions / Re: T1 timer counter sketch on: June 30, 2014, 02:14:08 am
Arduino Digital pin 8 is chip pin portB0, which is "ICP1 (Timer/Counter1 Input Capture Input)" according to the datasheet.
37  Using Arduino / Microcontrollers / Re: Help with making a "cheat sheet" for Arduinos. on: June 30, 2014, 01:10:22 am
Quote
Pins 0 - 7 are grouped together but 0 and 1 are the RX and TX pins.
Pins 8 - 13 (and two more pins) are grouped together.
Be careful about "grouped together", because that changes from board to board.  For example, one a MEGA, the "grouping" is quite different.

Quote
2 - 7 are PWN pins.
Pins 8 - 11 are also PWM.
This is incorrect for an Uno.  PWM pins are 3,5,6, 9,10,11.

Quote
Pins 15 - 20 are the analogue input pins, but also there are sub-sets:
Two are the SPI bus.
This is wrong.  SPI does not share pins with analog.

Quote
Pins 2 - 7 (from memory) allow you to activate internal pullup resistors if you use them as inputs.
ALL the pins allow you to activate internal pullups.

You might like: https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZckNXSnNQa0FiWldNMFhWcHV1ODFzR0E&usp=sharing
and https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZcm9YOUQ1cEdVclM0bXVTQkp5c3oxUVE&usp=sharing
They are set up as spreadsheets so that you can sort by different columns, which I've found useful.  Potentially, anyway.
(not updated for R3
38  Using Arduino / Programming Questions / Re: I need a code explanation on: June 29, 2014, 05:38:53 pm
Quote
So the port 8888 is for clients using UDP or TCP and the port 123...
Internet connections (UDP or TCP) have two port numbers involved.  The "destination port" of a client usually defines the service being requested.  TCP port 25 is SMTP Email, 123 is Network Time Protocol.  The "source port" is supposed to be random and unique on the client, and should not conflict with any service that the client might be offering at the same time.  In this case, it looks like the programmer has chosen 8888 as the initial "random" port.
39  Using Arduino / Microcontrollers / Re: [Solved] ATMEGA8L with External Interrupts won't wake from sleep on: June 29, 2014, 05:31:17 pm
Note that ATmega8 and ATmega328 are different "families" of chips, not just members of the same family with different amounts of memory (like m168 vs m328)  The m8 is quite  a bit older, and is probably "primitive" in various ways.
40  Using Arduino / Microcontrollers / Re: PROGRAM A PIC WITH ARDUINO 2009 on: June 29, 2014, 05:28:25 pm
Do you have a higher voltage supply (~12V) and a HV switch?  While some of the newer PIC have a "low voltage programming mode" that is 5V only, the 16F84 is an old chip that will need HV on its Vpp pin to be programmed.
41  Community / Website and Forum / Re: Drop the boolean data type, its broken. (or fix it) on: June 29, 2014, 05:25:21 pm
Does the C++ spec mean that
if (Serial.available()) {  // blah }
is now slower (in C++) than
if (Serial.available() > 0) { // blah }
because it first has to convert the paren contents to "bool" for the sake of "if", and then check for "true"?  (As opposed to C, where it would just check for non-zero...
Or does the optimizer fix all that for us?

I'm not sure I understand the advantages of forcing bools to be only 0 or 1, aside from a sort of intellectual purity...
42  Community / Website and Forum / Re: Drop the boolean data type, its broken. on: June 29, 2014, 06:15:12 am
In C, the rule was that you should never compare a Boolean to true.
"if ((Boolean)57) print("true");" works fine.
43  Using Arduino / Programming Questions / Re: boolean doesn't response on: June 29, 2014, 05:01:31 am
Code:
   if (GoToServo); //if the rule is true - go to this part of the code
    {
In this case, the problem may be the ";"  That ENDS the "if" statement.
(disregard if that's a transcription error rather than how the code actually reads.)
44  Using Arduino / Programming Questions / Re: Data types and arithmetics on: June 29, 2014, 04:58:43 am
Quote
I don't really understand why though (why didn't I have to type cast MC_ also?), since X2 being a 32bit integer should be able to store it?
C has simple but counter-intuitive rules for doing math.  Given an expression like
Code:
long X2 = MC * (1 << 11) / (X1 + MD);
, it calculates results of sub-expressions "in order."  So in 1<<11, both numbers are "int" (short) (all constants are
"int" unless you indicate otherwise), leading to a short result.  Then we multiply by MC, which is another short, and expect another short result (which is now getting questionable.)  X1 is a long, so X1+MD gets calculated using longs (MD is first "promoted" to a long), and produces a long result.  The final division has the short result divided by a long, so again the short is convert to a long, the calculations are long, and you get a long result.  ONLY THEN does it notice that the X2 is also a long, so it can directly assign the result of the calculations.  The fact that the final destination is a long has NO EFFECT on calculating the value of the expression on the right hand side.

You can google "C promotion rules" and find out more.  Note that this is a lot less obvious in many C compilers (desktop computers, for instance), because the default type for constants (int) is 32bits on those machines, and you don't do math that overflows 32bits nearly as often as you do math that overflows 16bits.
45  Using Arduino / Programming Questions / Re: Data types and arithmetics on: June 28, 2014, 08:51:40 pm
Code:
long UT = 27898;
unsigned short AC5 = 32757;
unsigned short AC6 = 23153;
short MC = -8711;
short MD = 2868;
You'll save yourself a lot of uncertainty by using the same data type (long) for all your constants.  The calculations all have at least one long, so all of the ints will need promoted to longs anyway.
Both 2^11 and 2^15 are wrong.
Code:
X1 = ((UT - AC6) * AC5) / (1<<16);  // Right shift "undefined" for signed numbers :-(
  X2 = ((long)MC<<12) /  (X1 + MD);
I assume that these calculations are from datasheets, so the bits discarded in making X1 are known irrelevant.
Pages: 1 2 [3] 4 5 ... 451