|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 336
Posts: 36476
Seattle, WA USA
|
 |
« Reply #1 on: July 20, 2012, 12:31:34 pm » |
I would love to hear if you have experience in this area and how you accomplished this task.
I used C#. It is trivially easy to define user interfaces and to read from/write to the serial port. The only remotely challenging part is that the user interface runs one thread and serial data processing is done in another. But, a little understanding of threads and how to communicate between threads solves that issue (which will be present in C++, too). C# threading is easy. C++ threading is not as easy.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 0
Posts: 184
|
 |
« Reply #2 on: July 23, 2012, 10:22:51 am » |
Hello, for those issues, I use Lazarus. Lazarus is the IDE, FreePascal its language which is like Delphi. There is a library called Synapse and you need the synaser unit and its TBlockSerial. http://synapse.ararat.cz/doc/help/synaser.TBlockSerial.htmlThen, if you are able to program with Delphi like languages, you can use Mouse.CursorPos.X and Mouse.CursorPos.Y ... If you need help, I think I can help you. Additionally, to be mentioned, that I already controlled my DC motor (connected to my Arduino) via this method. I also wrote a GUI (graphical user interface) for it ! Good luck ! Greetings
|
|
|
|
« Last Edit: July 23, 2012, 10:25:13 am by karlok »
|
Logged
|
using Arduino Uno Rev 3
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #3 on: July 24, 2012, 05:52:02 am » |
hi all.. shp loop and karlok i need your help regarding this issues for my project.
your help will be highly appreciated thanks.
|
|
|
|
« Last Edit: July 24, 2012, 05:53:46 am by fazalnasir »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 336
Posts: 36476
Seattle, WA USA
|
 |
« Reply #4 on: July 24, 2012, 05:55:13 am » |
i need your help regarding this issues for my project. What issues?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #5 on: July 24, 2012, 02:31:11 pm » |
i have to control two DC motors each for X & Y direction motion. The control will be through Serial comm-- between Arduino and PC through rs232 port by following methods:
a. From mouse courser motion like that in Games or b. From keyboard arrow keys
the motors used for motion of paint Gun base. So, issue is how to control both the motors at a time i-e X and Y motion and
Secondly i want to create GUI for different action to perform: e.g 1. Reloading (GUI should have Reload button) 2. magazine changing (GUI should have magazine change button) etc..
please give me the solution in each case ( mouse control and keyboard control) and also want to know which programming software can i use to create GUI that can communicate with Arduino.
thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 0
Posts: 184
|
 |
« Reply #6 on: July 26, 2012, 05:46:30 am » |
I think you already succeeded in controlling the motors from your Arduino board? If you did that, the rest will be easy. If not, I think I cannot help you. Can you show the source code for it? Zhis might help. i have to control two DC motors each for X & Y direction motion. You mean both can move in x and y direction? Or do you mean one motor for x direction, the other one for y? and also want to know which programming software can i use to create GUI that can communicate with Arduino.
for those issues, I use Lazarus. Lazarus is the IDE, FreePascal its language which is like Delphi. There is a library called Synapse and you need the synaser unit and its TBlockSerial. http://synapse.ararat.cz/doc/help/synaser.TBlockSerial.htmlThen, if you are able to program with Delphi like languages, you can use Mouse.CursorPos.X and Mouse.CursorPos.Y ...
|
|
|
|
|
Logged
|
using Arduino Uno Rev 3
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 336
Posts: 36476
Seattle, WA USA
|
 |
« Reply #7 on: July 26, 2012, 05:52:49 am » |
The control will be through Serial comm-- between Arduino and PC through rs232 port by following methods:
a. From mouse courser motion like that in Games or b. From keyboard arrow keys Neither is appropriate. The Arduino understands bytes, like letters. Send 'f' to move along the x axis in the positive direction. Send 'b' to move along the x axis in the negative direction. Send 'u' to move along the y axis in the positive direction. Send 'd' to move along the y axis in the negative direction. Secondly i want to create GUI for different action to perform: e.g 1. Reloading (GUI should have Reload button) 2. magazine changing (GUI should have magazine change button) etc.. Go right ahead. How, exactly, is the GUI supposed to reload the weapon? How, exactly, is the GUI supposed to change the magazine? How, exactly, does changing the magazine differ from reloading? please give me the solution in each case Why? Neither is appropriate. and also want to know which programming software can i use to create GUI that can communicate with Arduino. Any one that you are familiar with that can write to the serial port.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #8 on: July 27, 2012, 04:28:10 pm » |
Answers to karlok:
1) yes i know well how to control motors
2) yes one motor for x direction, the other one for y.
Let say the control is from keyboard: control means, if i press right arrow key from keyboard the motors should rotate in one direction and vice virsa... the responce of motor should like this: by pressing arrow key once... the motor should responce (jerk) by holding arrow key .... the motor should keep rotaion unless the key is release my Question is (is this control is possible through Serial communication..? if yes, how i can control by CODE or somthig else)
3) i think it will take so much time to understand Lazarus. So, if you have any such code or stuff made by you. Can you mail me? in this way i will make focus on my requirements.
thanks
Answer to paulS:
1) i know Arduino understands byte, i want to explian this problem like
by pressing arrow key once... the motor should responce (jerk) by holding arrow key .... the motor should keep rotaion unless the key is release. if we send continously 'F' Serially to Arduino(by holding F key from keyboard) and then reading that byte(containing 'F') and then make condition accordingly in code for rotating motors.
2) GUI will have Buttons each will send info (byte) to Arduino serially and check that byte for respective actions that will be perform by Arduino by sending signal to actuators( Servos, steppers etc) to perform 1) loading bullet from magzin 2) cahnging magzine etc that is what i suppose, mr. paulS and requested for help.
thanks
|
|
|
|
« Last Edit: July 27, 2012, 04:35:10 pm by fazalnasir »
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 0
Posts: 184
|
 |
« Reply #9 on: July 27, 2012, 05:10:10 pm » |
Hello. control means, if i press right arrow key from keyboard the motors should rotate in one direction and vice virsa [...] by holding arrow key the motor should keep rotaion unless the key is release Hint: First) define a time how long the motor should move when pressed a key once (e.g. 1sec). Then the code is like the following (pseude code): rightarrowkey_onkeydown: if (Gettickcount-a) > 1000 { send_command(); a=gettickcount; } Otherwise the command would be always sent if the rightarrowkey is pressed, that would result in a buffer overflow, I guess. So avoid it. With this code you also include your wish that the signal is sent once when you press short on rightarrowkey . a is a Dword variable, you could also use integer for it, both are working. --- second) you have to write the Arduino sketch, As far as I understood, you already have one working. Then it will be simple. Just use Serial.begin(9600); at the beginning or some arbitrary other baud rate for initialization. Then with Serial.read(); you read the data sent to your Arduino via serial communication (datatype should be byte because it's 256bit and thats a char, and chars are sent via serial comm.). --- third) finish your computer code that controls your arduino "robot motor". I will post an example later... ------- IMPORTANT question: What programming language are you familiar with? You need one to conrol your Arduino.
|
|
|
|
|
Logged
|
using Arduino Uno Rev 3
|
|
|
|
Germany
Offline
Full Member
Karma: 0
Posts: 184
|
 |
« Reply #10 on: July 27, 2012, 05:19:25 pm » |
Some example code (untested) /* KARLOK, 28/7/2012 */
void setup() { Serial.begin(9600); Serial.println("\n[Arduino-Motor] started with 9600 baud ..."); }
void loop() { byte rx_data;
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255): rx_data = Serial.read();
Serial.print("Received command: "); Serial.println(rx_data, DEC);
switch(rx_data){ // intentionally omitted 0 because it should be the "set idle mode" command, see below case 1: // move motor left case 2: // move motor right case 3: // move blablabla case 4: // move whatever case 5: // arbitrary commands... } // Clean up last received command. // Otherwise you would have a non-stop run of your command after sent once! rx_data = 0; // 0 (zero) is the "set idle mode" command } }
|
|
|
|
|
Logged
|
using Arduino Uno Rev 3
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 336
Posts: 36476
Seattle, WA USA
|
 |
« Reply #11 on: July 27, 2012, 06:22:25 pm » |
by pressing arrow key once... the motor should responce (jerk) by holding arrow key .... the motor should keep rotaion unless the key is release. There is no difference between these two actions. Send a value when the key is pressed. Send another value when the key is released. In the two cases, the only difference is the time between when the two values are sent. The easiest thing to do is send 'F' on press and 'f' on release, for one key. 2) GUI will have Buttons each will send info (byte) to Arduino serially and check that byte for respective actions that will be perform by Arduino by sending signal to actuators( Servos, steppers etc) to perform 1) loading bullet from magzin 2) cahnging magzine etc So, what is the problem? The sending and receiving of serial data is the same, The action to be performed is different. Although, how a solenoid can load a bullet or change a magazine escapes me. Not that it matters, since that is up to you to arrange for the hardware to manage.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #12 on: July 28, 2012, 02:08:18 pm » |
i use C language for controlling Arduino.
thanks karlok
the hardware is another problem i will do that, but my question is " what are the guidelines (program in which i create GUI easily, any Links) that would help me to create GUI for above requirements that i explained, easily. karlok told me about Lazarus but i have know idea and will take so much time for understanding Lazarus. i have idea of C/C++ thanks paulS
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 0
Posts: 184
|
 |
« Reply #13 on: July 28, 2012, 05:05:06 pm » |
I don't know much about C++ expect of that I use for Arduino language, however I think there can be created GUI applications, too. Have you never created a GUI with C++? You better ask in some C++ forums because this is not Arduino concerning directly even if there might be many members who know C++ programming, if your question is just how to make a GUI with C++ then here is not the right place, I guess.
|
|
|
|
|
Logged
|
using Arduino Uno Rev 3
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #14 on: July 28, 2012, 05:55:21 pm » |
no never use C++ for creating GUI, i am going to do this. i am trying to search but if you have any best links of forums regarding this problem..?
thanks for your help, karlok
|
|
|
|
|
Logged
|
|
|
|
|
|