Show Posts
|
|
Pages: 1 ... 10 11 [12] 13
|
|
169
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Program a GUI in C/C++ for arduino and mouse cursor control
|
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 } }
|
|
|
|
|
170
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Program a GUI in C/C++ for arduino and mouse cursor control
|
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.
|
|
|
|
|
171
|
Using Arduino / Programming Questions / Re: RF12.h: Why is there not definition of 315MHz
|
on: July 27, 2012, 03:55:38 am
|
Hello. I have read the datasheet and looked into the corresponding position in the sourcecode of "RF12.cpp". Additionally, and the really helpful source!!!, I received great help from a electronic engineer. More detailed: Look the definition of "uint8_t rf12_initialize (uint8_t id, uint8_t band, uint8_t g)" in RF12.cpp, this function is used to initialize teh RFM12(B) module. Then, I want to know what paramter has to be changed, of course it was "band" (uint8_t), it was only used once in the function rf12_initialize. That means that this position is the corresponding one to be examined: rf12_xfer(0x80C7 | (band << 4)); (RF12.cpp, l.404) Look here: "|" is the logical AND operator, << is a bitshift operator (shifts 4 to the left, that means a hexadecimal unit (2^4=16)) Now consider binary: 1000 0000 1100 0111 Now I need the datasheet ( hoperf : RFM12.pdf ) , see the bottom left table on page 12. Back to the binary code: I said << is the bitshift operator, lets apply it on the code, e.g. we use "2" as given in the definition (#define RF12_868MHZ 2) for 868MHz band. Then it is 0000 0010 << 4 ("shift" the 10 ,which is 2 in binary, 4 bits left) = 0010 0000 . Now do the addition: 0000 0000 0010 0000 + 1000 0000 1100 0111 = 1000 0000 1110 0111 The important binary parts were highlighted. In the datasheet's table there is written: 315MHz band: b0=0; b1=0. That means we need a zero for both b0 and b1. That is 1000 0000 11 00 0111 . And it is a lot of fun! Feel free to ask if there are any questions (maybe explanation was unclear because quickly written). Regards.
|
|
|
|
|
173
|
Using Arduino / Programming Questions / Re: RF12.h: Why is there not definition of 315MHz
|
on: July 26, 2012, 09:50:11 am
|
|
That would be useless, I think. These definitions are used in the library to help the user. So, Ican simply write "RF12_433MHZ" instead of the "1". That is more logic for the user but the program translates it into "1" that is understood by the RFM12 module.
But I want the module to understand 315MHz!
|
|
|
|
|
175
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Sniffing RAW wireless data (433MHz, 868MHz; FSK/ASK)
|
on: July 26, 2012, 07:02:58 am
|
Perhaps I'm wrong, but I'd expect a FSK receiver to only operate with a FSK transmitter, and a ASK receiver to only operate with a ASK transmitter.
No, that's what I meant, too. Knowing the modulation meant for me to have the ability to demodulate the signal modulated with this type of modulation. It seems to me that you are looking for receiver that can receiver transmissions from either type of transmitter. No idea whether such a critter exists. Concerning this, I thought too. And I finally decided to use two devices for this issue. That means one receiver only works with FSK, the other one with ASK. So, I think you're right. It's difficult to find one. The only one, I found, is the ATA5811 - however it seems to be very sophisticated. That doesn't mean I have decided not to want to work with it. So I will look for one ASK receiver and a FSK receiver separately. Can you recommend one that supports (only)one of these modulations? They should be as simple as possible, the received data should be given directly at a pin output without trying to decode it.
|
|
|
|
|
176
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Sniffing RAW wireless data (433MHz, 868MHz; FSK/ASK)
|
on: July 26, 2012, 06:14:22 am
|
|
Thank you for the fast answer. As far as I know, the receiver has to "know" in what type of modulation the signal was sent. And I know that the data can be sent via different types of modulation. At home, I have many devices that work with this properties (frequency and modulation type). For me, it is important to get the data they sent, at first the data, not necessarily the actual information. Then, I will try to work with it (what will get the harder part). If there are any questions left, feel free to ask.
|
|
|
|
|
178
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Program a GUI in C/C++ for arduino and mouse cursor control
|
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 ...
|
|
|
|
|
179
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Program a GUI in C/C++ for arduino and mouse cursor control
|
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
|
|
|
|
|