|
676
|
Community / Website and Forum / Re: Too many forum sections
|
on: April 26, 2011, 05:30:53 pm
|
|
I, too, was originally awed by the many forums, but if anyone can take the few seconds to read the excellent heading description, then I think the forum spread makes good sense. I'd also risk the opinion that it seems there are fewer badly placed posts, the choice appears to make (new'ish) members post more accuratly.
And then I browse everywhere, sometimes by forum group, sometimes by "most recent", sometimes by "all unread" ...
|
|
|
|
|
681
|
Using Arduino / Programming Questions / Re: How to Hold the Two Shafts of Servo Motor ?
|
on: April 21, 2011, 11:12:35 am
|
Interesting point, AWOL. I found that attach() followed shortly by a write() was sufficient for it not to go to the middle first. Your suggestion is more elegant. The "real" problem with Servo on power initialization (in this case, when you do attach) is that the Servo will go to the write()/middle position from whereever it was from its idle/non-powered state. You cant ask a Servo to stay where it happens to be on attach/power on. In a clumsy way I was hinting at this by pointing out default behavior. Anyhow, let us leave the thread for the OriginalPoster and his problem.  How is it going jack_lai?
|
|
|
|
|
682
|
Using Arduino / Project Guidance / Re: How to make an internal interruption by serial
|
on: April 21, 2011, 10:57:59 am
|
|
Hi,
This is in the "Project Guidance" forum, and my comment in that context is that I think that you have an ambitious but possible project, although voice recognition is a very tall order (I dont know how much intelligence the WaveShield you mention has, if it can do the wave-match voice-recognition trick). And you seem to have most pieces. Nice video. Is it showing anything that does not work as intended?
As far as the programming goes, the last example of your working code still contains the two hurdles you need to get over - avoid using delay() and do not store things with *char unless you have allocated a buffer (or use the String library). I have not studied your code in detail. (You could alse change the if ( command== ..) to a switch/case construct.
Feel free to start a new topic under Programming with a specific problem. (The original question "interrupt for Serial" should have been there)
|
|
|
|
|
683
|
Using Arduino / Programming Questions / Re: String from serial into an array?
|
on: April 20, 2011, 05:36:44 pm
|
The bit I focused on was array1[i]= Serial.read() and analogWrite(pwmPin3,array1[2]); which means there is no parsing or conversion of ASCII to number going on. What is happening is that if VVVV is sending "23456" then PWM 1 will start outputting a 19% duty cycle, the PWM 2 a 20% duty cycle .. The ASCII character "2" has the binary value 50, which is put out via analogWrite(), which causes the 50/255 = 19% .... Is that what you wanted? The current format allows for a single digit for each channel (you're not looking for any "," as indicated in the first post) but that might be fine. If you're happy with a single digit and "0" is 0% and "5" is 50% and "9" is 90%, then change the analogWrite(pwmPin3,array1[2] to analogWrite(pwmPin3,(array1[2]-48)*255) If it works for you without above suggestion, then the VVVV program is outputting a true binary byte so that you are getting a correct 0-255 value. But now you know why if you didn't already  . Lastly, as you know how to do arrays ... instead of using variables pwmpin1, pwmpin2, use an array int pwnpins[] = { 3, 5, 6, 11, 9 } ; and then your last code simplifies to for ( int p=0; p<5; p++) analogWrite( pwmpins[p], array1[p] ) ; You can do the same improvemnt in the setup() to set the pins to output. (Is there a reason why you do not set pwmins 4 & 5 to OUTPUT ?) Hope this gave some more inspiration for next weeks work...
|
|
|
|
|
684
|
Using Arduino / Programming Questions / Re: RGB LED and Servo Synchronization Issues
|
on: April 20, 2011, 05:05:38 pm
|
I've seen worse code on this forum,  your's isnt so bad, crashoverride61088. And I do love you giving us a whole video of everything.  You clearly are good at getting a good finish on things (my problem is the opposite - my code works, but my hardware isn't pretty) Still, a few general pointers on the software is what you're asking for. One possible flaw is you do not debounce the switch. As your events (state actions) usually involve lots of delay, this masks that fact, but I wonder (as I have not studied the code in detail) if you might skip between states? (which is why a Serial.print at each state beginning might help) Your slow colourfade is stuck doing that (and nothing else). Once started no other changes will happen. This may be intentional or not, but your button will be 100% unresponsive while a fade is progressing. I have not used Korman's VarSpeedServo library so I do not know if that has the same problem. (unrelated note: I have made my own "slow" servo move for a robot arm, works, but didn't realise a library might have saved me the hassle, will go and try that as soon as this post is done  ) Hope that gave some inspiration
|
|
|
|
|
685
|
Using Arduino / Programming Questions / Re: How to Hold the Two Shafts of Servo Motor ?
|
on: April 20, 2011, 04:47:39 pm
|
Hi jack_lai you missed robtillaart's excellent suggestion of moving the attach code into the setup() part. IF you change the Serial.begin(value) you must ALSO make the same change in the Serial Monitor (on the pc) - they must match. If you use another program to talk to the COM port, it, too, must be set to the same value as you put in Serial.begin. That is true of all boards. BTW, when I use several Servos like that, I give them usefull names, that reflect what they mechanically do. The beginning of my code would be along the lines of Servo Upper, Lower ; // Two servos. The name reflects what mechanic they power, rather than "1" or "2" void setup() { Lower.attach(pinx) ; // this will power (and thus hold position) of the servos at start. Upper.attach(piny) ; // unfortunatly they also will go the servo library default position (roughly mid position) at full power until they get a new write Serial.begin(9600) ; // if you set this to 14400 you ALSO need to set the SerialMonitor speed window or whatever terminal program you use } void loop() { if (.. decision value..) Upper.write(30) ; Lower.write(120) ; } else ...... Lastly, the read() function of Servo does not return the actual position, it only returns the last write() value you gave (which should be the position they are at, if no mechanical failure) so it can not be used to "measure" the position. There is no electrical signal from the servo back to the Arduino to do that.
|
|
|
|
|
686
|
Community / Website and Forum / Re: Please offer board model comparison chart / table on website!
|
on: April 20, 2011, 04:17:24 pm
|
|
The really really nice things about wikis is that anybody can make this chart! "Anybody" includes ---> you!
As you are most keen on it, find the current offering insufficient, know exactly which bit is missing, have probably already done the research to find the missing information - YOU are the most qualified person to improve the wikipedia page and/or create/modify such a page on the Arduino wiki (called the Playground).
Go for it. And thank you for putting the effort in it.
|
|
|
|
|
687
|
Community / Website and Forum / Re: I don't speak french, dutch, italian, scandanavian...
|
on: April 20, 2011, 04:12:36 pm
|
I do English, Scandinanvian and German. For the rest I use Google translate  . Man what a (not yet realized potential) for humankind! Still, I can resist - back to the other weighty issue of this thread - German also turns the tens and units around - three-and-twenty for twenty three, ditto Danish/Norwegian (but not Swedish). Whilst German/Swedish have distinct words for the decades 20,30, 40... the Danish have a system based on the twenties after 40, ie forty, 50 is three-(minus)half times twenty (tre-og-halv-treds) ending at 90 (minus half of five times) (halv-fems). Actually each word is just as distinct, there is just an ancient root/reason for the choice of the word Of course you'd go stupid if you try and do the maths every time you say, 77 (seven-plus-4-minus half(=3.5) times twenty) you just learn to say the simple phrase syvoghalvfjerds.  Even Swedes when they come here to work in shops in Copenhagen from Malmö quickly learn that detail. Oh - What was the original topic? - Ah, supression of the foreign forums. Nope. More user choices/settings are likely to cause more problems.
|
|
|
|
|
690
|
Using Arduino / Project Guidance / Re: How to make an internal interruption by serial
|
on: April 20, 2011, 03:43:59 pm
|
The short answer is that you can NOT get an interrupt from the Serial (AsFarAsIKnow) as it already uses it internally. The Serial buffers all incomming characters in a buffer, which you retrieve one at a time with the .read() function. That is why .available can return a number, ie how many characters are waiting in that buffer. Secondly, the *data = "" is not allocating a "buffer" for you, it points to some arbitary location where there is single nul-byte (the string terminator). So I suspect you overwrite random bytes when you put a char to it, but as it only is one byte, it seems luckly work out. You have to allocate a buffer with char data[5] or something like that. Alternativly look at the Strings library/datatype. So, we come to the "old" problem (you're not the first to ask  ) about doing something else while delay() is blocking execution. The answer is NOT TO USE DELAY(). There is the infamaous BlinkLEDWithoutDelay example in the tutorials, but it somehow explains it badly ( as so many ask ). Still, required reading. So you need to change your main loop so you call a routine to check&process for input from Serial, then it always calls movemotor(). This routine has a variable that was set to millis()+5000 at the start and starts the motors and if the current millis() is greater that value you do stop the motors. (We'll ignore the wrap around that will occur after 49 days, and DO make sure the timer variables use unsigned long and not int) As you can see this means your loop will constantly check for Serial input, and constantly check if the motors should stop turning, and they will stop after 5 seconds and we have not used any delay(). Ta-Da! Your code is nicely structured and well laid out, so I am sure you can do this with above hint(s).
|
|
|
|
|