Show Posts
Pages: 1 [2] 3 4 ... 53
16  Community / Bar Sport / Re: Why don't CPUs and microcontrollers operate on 24v? on: October 05, 2012, 12:18:06 pm
Modern high speed processors have another problem to deal with as well, electromagnetic interference.

Every conductor has some inductance rating, even if it's in the range of nano or pico henries.  While that may not sound like much, it does result in the generation of electromagnetic fields around those conductors as high speed signals run through them, and as internal traces on processors get smaller and smaller (the latest Intel i processors are built using 32nanometer traces), these miniscule electromagnetic fields can generate currents in neighboring paths, thus requiring the processors to run on increasingly lower and lower voltages to keep these fields small enough to mitigate such interference.
17  Using Arduino / Programming Questions / Re: problem with SoftwareSerial and servo libraries on: October 05, 2012, 12:09:31 pm
18  Using Arduino / Programming Questions / Re: Flushing Arduino on: October 05, 2012, 12:06:41 pm
Ummm... drop it in the toilet and hit the lever?

You need to clarify what you mean by 'flush the Arduino.'
19  Using Arduino / Programming Questions / Re: Reading a packet of data in one call on: October 05, 2012, 12:05:37 pm
Output the BytesToRead and you're going to find that there aren't any to read, even with a proper connection.

Your processor operates many many times faster than serial communications, even through the overhead of the .NET runtime engine.  Not only are you not going to receive a result in the time it takes your code to get from the Write() operation to the Read() operation, but it's likely your command still hasn't even been sent by that point.

The recommended method of receiving serial data in C# is through the DataReceived event.  This is because you can't really predict when the data is going to arrive.
20  Using Arduino / Programming Questions / Re: Reading a packet of data in one call on: October 04, 2012, 09:47:46 am
There are a number of things your code is trying to do that just is NOT going to work.
You are trying to transmit multiple types of data between the two systems, and you have no reliable identification of the types of data that are being transmitted.  Not only that, but you want all these things to be handled in one call, which is still possible, but only magnifies the need to uniquely identify all the different types of data being transmitted.

For example:  You have a request for analog read data that immediately reads what comes back from the Arduino and assumes it's your result from that request.  Bad assumption.

In general, you have 4 different commands of varying lengths.  2 are expected results back also of varying lengths.  Your serial comms need to include a few things in order to make such a scenario reliable.

1.  Unique start and end of packet markers.  It is essential they be unique.  In other words, these start and end of packet markers cannot be used anywhere within the packet itself.
2.  Unique headers for each of the command types and response types.  The uniqueness is the same as for the start and end markers.
3.  A processing framework that either does not expect the result to be the very next packet of data received after the command is sent (flexible, but a bit more complicated to code), or strictly enforces a rigid command/response ordering for all commands (not as complicated to code, but introduces a lot of blocking and waiting, and isn't very efficient, responsive in general).

You are currently using binary serial comms, which makes a lot of the above more difficult (unique markers/headers in particular, since writing out an int value can generate any byte value output).  Switching to human readable transmission makes most of the above easier, but introduces a layer of conversion/parsing.  Both the Arduino Serial object and C# serial object provide provisions for converting, and both the Arduino and C# environment provide additional libraries for parsing.  As a result, it's generally easier to get human readable Serial comms functional than it is to get binary Serial comms functional.  It's also easier to debug human readable Serial comms since it's, well, human readable.
21  Using Arduino / Motors, Mechanics, and Power / Re: Communicating with Peter Norburg Stepper Board on: October 03, 2012, 05:30:23 pm
FYI. I tried taking out the delay here and the while loop just runs through. There needs to be a slight delay in order for the buffer to load in a character, it seems.
Serial.available() returns the number of characters currently in the buffer.  If it returns a value greater than zero, then there are that many characters in the buffer right then and there.  If removing the delay() caused your code not to work the way you want, then that's symptomatic of another problem.

You recommend dealing with collecting the incoming characters in an array rather than the string object?

Like how I loaded all my command strings into the char* stepCommand[ ] array?
Sorta.  Working with C strings requires more effort than working with String objects, which is why most people are so fond of using Strings.  If you aren't very familiar with manipulating C strings, googling C string tutorial should provide plenty of guidance.  There are a lot of C library functions for handling all the heavy lifting, so it's not all that much more effort than using a String class.  It's just not all wrapped up in a nice package for you.

If I move the stepperboard IO to two other pins, will that send all Serial.println commands ONLY to the serial monitor and my Serial.write commands ONLY to my stepperboard? I'm trying to figure how I can print debug data to the serial monitor without freaking out the stepperboard.
If you use the software serial class to communicate with the stepperboard, you'll create a new serial object associated with those pins and use that object to communicate with the board, not Serial.  Something like...

SoftwareSerial StepperSerial(RXpin, TXpin);

//Send command to stepper board

//Send message to Serial Monitor
Serial.println("Message out.");

There are plenty of examples out there using the SoftwareSerial library as well.
22  Using Arduino / Motors, Mechanics, and Power / Re: Communicating with Peter Norburg Stepper Board on: October 03, 2012, 12:05:28 pm
const int numCommands = (sizeof(stepCommand)/sizeof(char*));
This line of code gives me a value of 12, which seems to be right to me. Maybe even though I have 12 commands, this isn't the correct array size? I'm going to try your method, just trying to figure out why this doesn't work so I can understand what going on here.

Hmm, apparently I have misunderstood how sizeof() works in that situation.  If it's returning the correct array size, then ignore my comments, they're apparently incorrect.

On the String objects though, your commands are stored in C strings, which are just arrays of chars.  The String objects I'm referring to are
String readString;
String writeString;
Those are String objects.  The String class isn't working properly in the current version of Arduino and causes memory leaks over time.  Switch them to C strings as well.

As for your other questions...

1:  You cannot have multiple devices connected to the serial port at the same time.  If your stepper controller is connected to the serial port, then you can't connect to it with your PC (the usb port ties into that serial port.  The Uno only has the 1 hardware uart).  You could move the stepper controller to a softwareserial port on any of the other pins, allowing you to communicate with the Uno with the computer via USB while it's connected to the stepper controller.

2:  Serial.print(100) will send the string "100" out the serial port as 3 bytes of data corresponding the characters 1, 0, and 0.  It converts data to human readable ascii.  Serial.write(100) sends the numeric value of 100 out the serial port as a single byte of data.  When transmitting char data the output is the same either way.  In general though, if the intent is to transmit human readable text, use print/println.
23  Using Arduino / Motors, Mechanics, and Power / Re: Communicating with Peter Norburg Stepper Board on: October 03, 2012, 10:47:53 am
Your primary problem is with your calculation of the size of your Command array.

stepCommand is essentially a 2d array (and a jagged one at that).
char* stepCommand[]
is the same as this:
char stepCommand[][]
Your calculation of the number of elements in this array is incorrect.  It's basically returning the total number of characters in the array, not the number of full command strings.  The way you're defining the array, there's no easy way to calculate the number of commands in the array.  Best to just handle that semi-manually, either with a #define or a const param.  I would include this value in the declaration of your array as well, like:
char* stepCommand[numCommands]
Doing so will cause a compile error if your param does not agree with your array (if you add another command to the array and forget to update numCommands value, it won't compile)

Beyond that, you'll likely run into problems with your String objects as well.  Best just not to use them.  They thrash memory pretty hard.
And while this probably isn't exhibiting itself as any sort of problem, there's no reason to have a delay between Serial.available() and
24  Using Arduino / Motors, Mechanics, and Power / Re: Forward/reverse motor control with stops - advice please on: October 03, 2012, 10:32:58 am
The only 'boards' you should need would be a motor controller board and the Arduino.

You explicitly call the drawer heavy, so you may need a motor controller with more oomph than the readily available shields for Arduino.  That all depends on the specs of the motors you plan on using.

Other than that, all the other hardware will be the same (drive rail, stop switches, power supply, etc.)
25  Using Arduino / Programming Questions / Re: Noob Programming Question on: October 03, 2012, 09:43:18 am
Grumpy Mike put together a decent guide to merging code:

It's not nearly as simple/trivial as web based scripts, but it can be done.
26  Using Arduino / Programming Questions / Re: A Better Fade? on: October 02, 2012, 03:04:41 pm
A logarithmic or exponential formula would probably provide a visibly smooth enough fade on/off.  It may not be a perfectly accurate method, but likely close enough that the human eye won't perceive any inconsistencies.
27  Community / Products and Services / Re: Highly Anticipated 32-bit "Due" due When? on: October 02, 2012, 09:36:21 am
Where is this so-called announcement on  Yes, it was evidently 'announced' at Maker Faire, but until they actually get around to listing in their hardware pages as an official product (, or at least having an entry on the main page that gives the specifications and pictures, it is still vapour-ware IMHO.

Quoted for emphasis (although I don't personally consider it vapor-ware).

I only consider an announcement official if it's made to the general public through a direct company associated medium.  Maker Faire is neither a general public announcement or a direct company associated medium.

Otherwise, I give it marginally better credibility, at best, than rumor.
28  Community / Bar Sport / Re: WAY OFF TOPIC, but I would like some help getting my head around this. on: September 28, 2012, 09:16:13 am
As Graynomad mentioned, this is the biggest hurdle in converting requirements into code.  Requirements can be of varying levels of ambiguity.  There is zero ambiguity in code.

In this case, the phrase 'into the forest' needs to be more specifically defined.  Without that definition,  any answer is just an interpretation that may or may not be correct.  It could be half way, it could be all the way.  It could be something else entirely if 'into the forest' has some non-intuitive meaning.  For example, it could just as easily mean a single step if 'into the forest' is simply a binary state.
29  Community / Bar Sport / Re: The ARMs race on: September 28, 2012, 09:00:38 am
I havn't even got into v1 of the ide yet, I am waiting for someone to do a version of Gavin Smiths wonderful  " arduino cheat sheet" for the changes that are needed for v1.

I only spent a minute perusing that cheat sheet, but I didn't see anything that needed to be changed for v1.  At most there may be 1 or 2 very minor tweaks necessary to be 100% accurate.
30  Community / Bar Sport / Re: do you use android? on: September 28, 2012, 08:49:01 am
I used to have a cell phone, mp3 player, gps unit, and PDA.

Now, I have an Android.

Multitaskers >>>> Unitaskers.
Pages: 1 [2] 3 4 ... 53