Show Posts
Pages: [1] 2 3 ... 10
1  Forum 2005-2010 (read only) / Interfacing / Re: Serial data to Visual Basic, Visual C++, Java on: April 30, 2008, 07:48:12 am
Aaah, ok. I just assumed VB6 as it is by far the most easy windows environment and language to get started with. Also, people whine constantly about the performance and such of programs made with VB6. Up yours, people! When one is talking about small utility-applications and stuff like that, performance doesn't even come into play.  smiley-wink
2  Forum 2005-2010 (read only) / Interfacing / Re: Serial data to Visual Basic, Visual C++, Java on: April 30, 2008, 04:22:50 am
If you use Visual Basic, communicating with the Arduino is pretty simple stuff.

1. Add the object Microsoft Comm Control 6.0 to your project, and put it on the form.

2. Set the correct properties for MSComm1 (baud-rate, com-port, etc.) This depends on your Arduino-code and your computer setup.

3. Add the following code to the Form_Load() event (double click the form):
Private Sub Form_Load()
MSComm1.PortOpen = True
End Sub

4. Add a Timer to your form (the small clock-symbol-thingie) and set it's interval to something like 100ms (Interval: 100)

5. Add the following code to the timer (double click the timer-object on the form)
Private Sub Timer1_Timer()
If MSComm1.InBufferCount > 0 Then
    Dim buf as string
    buf = MSComm1.Input
End If
End Sub

6. To send data back to the Arduino, you place the following code in your program (in a button_Click() event or something like that)
MSComm1.Output "whatever you want to send"
3  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet Serial Proxy and Flash on: May 06, 2009, 06:09:14 am

EOF means End of File. What you usually do when reading from a file is read "until EOF(1)" which means you read until End of File == True.

Reading from a network socket is (in most languages) very much like reading from a file. A packet is often terminated with the same character as a file (ascii character 0) so when you read a socket you can read until EOF(1).

I'm guessing you do something like this for your main loop:
      //read incoming data

The above is all well and good, except that it seems either serproxy or your flash application ends each packet with the ascii character 0 which means, to your program, EOF is true and thus the loop is exited.

I have very little experience with serproxy myself, as the version I tried opened the serial connection every time a network connection (like from your flash app) was created, and closed it when the network connection was closed. This meant that Arduino restarted, complete with the 5 second bootloader delay, every time I needed to connect.

Ok, that was way more than I was planning to write, but if I were you I'd check to see if serproxy keeps the serial connection open at all times. Try to write a simple arduino sketch that simply returns any serial data it recieves, fire up serproxy and connect to it with telnet. If everything works you should see whatever you type echoing back to you from the arduino, via serproxy. If this works, you need to see if your flash application sends character 0 after each package.

Ah, also.. I seem to remeber something about serproxy (for linux) having different parameters with regards to network behaviour. Do a "serproxy --help" to see what the parameter for changing network behaviour is. I don't remember properly, sorry, but I know there is something there to make it just pass everything right through (including character 0).

Good luck! smiley-grin
4  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet Serial Proxy and Flash on: September 09, 2008, 04:35:07 am
Oh god, sorry about the nett/net thing. I am norwegian and apparently my brain found it fitting to insert a norwegian word into my otherwise fairly decent english post. :-? It is fairly decently written, right? I haven't been in school for a good few years so.. ehe :smiley

What tools you use of course depends on what you want to do, and I don't personally have much against Flash. It's more just me getting tired of seeing people missuse flash to make sites that are heavy to load, slow to run or don't really work good at all. =P

I tend to sometimes go a tiny bit overboard when sharing my opinions. Like when discussing Java with Prophets of Javas Ultimate Coolness.. Sure, Java can be a great tool but I still end up quoting "Saying that Java is great because it works on all operating systems is like saying an*l s*x is great because it works on all genders." =P Hehe
5  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet Serial Proxy and Flash on: September 09, 2008, 02:09:57 am
Sorry mate, no matter how cool controlling the Arduino form a slick webinterface is, nothing Flash-related is "a new era"! Every proffessional webdeveloper I know (including myself) loathe Flash for it's plugin-dependancy, slowness and the fact that only a very, very few people out there use Flash moderately and skillfully enough to actually make it remotely useful. smiley-wink

If you want a smooth webinterface, check out AJAX. Or.. since AJAX is "Asynchronous JavaScript and XML" it's kind of limiting. Check out javascript and XMLHttpRequest. Combine it with css (and if you wish php and a mysql-database) and do it well, and you have a slick-looking interface that works in virtually any browser on any system made after 1990. Including cellphones which I think is a much cooler application of having a webinterface than controlling stuff from your computer only.

On the topic, I'll finally be getting my internett-hookup tomorrow and I recently managed to get my computer make the Arduino send NEC ir-remote signals to control my tv. I'm going to add the codes for my dvd-player, and also a few hardware devices like lightbars, lamps, etc. It will be awesome! 8-)
6  Forum 2005-2010 (read only) / Interfacing / Re: interfacing with php on: November 13, 2008, 09:54:59 am
I tried using linux on a computer that will be a dedicated arduino/media computer, and had a pretty weird problem..

The arduino scetch waits for 2 bytes (device code and command) that it sends to my TV with an IR LED. It then responds over serial to confirm that the command was sent. This works flawlessly under windows with a self-written program that holds a continous serial connection with the arduino and accepts incoming connections from telnet/php-scripts/etc.

However, when I tried to connect this to my linux box, the arduino/computer seemd to go into an infinite send/recieve loop whenever I tried to read the port, whether I used php to open the port (/dev/ttyUSB0) as a file or I just read from/wrote to it from console.

tail -f /dev/ttyUSB0 should just passively output whatever the arduino sends. Instead it actually sent data to the arduino, causing the arduino to respond, upon which linux promptly sent more data, and so on.

Also tried the package ser2net, that does very much the same as serproxy. Tried with different settings but the program has one huge flaw. To send the data inputted from the network-connection, it requires a newline to be sent. Ok, good idea.. Type stuff, backspace if you misspell, then press Enter to send.. but ser2net should not actually transmit the newline along with the data I inputted! I needed to send 2 bytes to my arduino, not 4. >smiley-sad

Long story short: Don't use linux unless you are competent enough to write software that does the arduno-to-web interfacing the way you want, or are prepared to customize your scetch to deal with linux beeing weird and transmitting data to read the device. smiley-razz

Oh, P.S.: I think the problem with SerProxy is that it doesn't maintain the serial connection. Rather, it establishes it when it gets an incoming connection and closes it after. This is really no good if you take the arduino bootloader 5-second-pause into concideration. :-/
7  Forum 2005-2010 (read only) / Interfacing / Re: Controlling Arduino through PHP on: October 24, 2008, 05:47:02 am
Are you sure? From what I've seen researching this, you can open the serial device like a file, fread from/fwrite to it like a file.. If course you have no options for setting baud rate, stop-bit, flow control etc. but that can be done with shell commands.

I must say, I would be very surprised if something as basic as serial ports do not work 100% properly in Linux...
8  Forum 2005-2010 (read only) / Interfacing / Re: Controlling Arduino through PHP on: October 24, 2008, 04:17:34 am
Pulled the concole info out of the class. The diffrent commands you can run using php's exec or proc_open or whatever.

       stty -F /dev/ tty0 115200

       stty -F /dev/ tty0 -parenb

       stty -F /dev/ tty0 parenb parodd

       stty -F /dev/ tty0 parenb -parodd

Character length:
       stty -F /dev/ tty0 cs5
       stty -F /dev/ tty0 cs8

Stop bits:
       stty -F /dev/ tty0 -cstopb
       stty -F /dev/ tty0 cstopb

Flow control:
       stty -F /dev/ tty0 clocal -crtscts -ixon -ixoff
       stty -F /dev/ tty0 -clocal crtscts -ixon -ixoff
       stty -F /dev/ tty0 -clocal -crtscts ixon ixoff

I think you need to chmod the serial port though, so apache can access it.
9  Forum 2005-2010 (read only) / Interfacing / Re: Controlling Arduino through PHP on: October 24, 2008, 02:09:08 am
Allthough this pachube seems like a pretty cool thingiemadoey, it also seems like it would be overcomplicating things. Now, I absolutely adore Rube Goldberg as much as the next geek, but the golden rule of enginering is after all: KISS, Keep It Simple, Stupid!

If you are confident in your linux skills, could you not just make a php script that writes directly to a serial port (/dev/ttyUSB0) on the linux box where it is hosted? On windows you have to revert back to Windows 98 or earlier to get direct access to the hardware ports, NT-systems "protect" us poor, stupid users from doing this without drivers etc.

Am I wrong in thinking that Linux allows you to open and write to any device as if it were a file? I remember beeing rather impressed when I ran "tail /dev/mouse0" or somesuch and saw the values sent by moving my mouse fill up the screen. :smiley

If the COM-port device (or usb or whatever Arduino shows up as on Linux) can be handled like a file, all you need is a very, very simple php script and you're home safe!

Edit: Have a look at Not har at all to understand and cut down for a php programmer. smiley-grin
10  Forum 2005-2010 (read only) / Interfacing / Re: Arduino with Second Life on: October 24, 2008, 01:22:59 am
I'm not sure which version of VB you use but for VB 6 this would be very easy indeed.

First, you need to add the MSComm object and one "Microsoft Internet Controls" (WebBrowser1). Here is the code to set relevant settings and open the connection to the Arduino port.
Private Sub Form_Load()

MSComm1.Settings = "9600,N,8,1"
MSComm1.CommPort = 3
MSComm1.PortOpen = True

End Sub

Then you add a timer that checks if the InBuffer of the MSComm object is larger than 0 and if so, fetches the buffer. Then it uses the WebBrowser1 object to get the data to the online part of your project. You know how to use $_GET-variables in php (or the equivalent in Pearl/asp/whatever, right)?
Private Sub Timer1_Timer()

Dim Buf As String

If MSComm1.InBufferCount > 0 Then
    Buf = MSComm1.Input

    WebBrowser1.Navigate "http://youraddress/script.php?data=" & Buf

End If

End Sub

The "script.php" part would I guess just be something that stores the value of  $_GET['data'] in a database or whatever, for use by the other script that actually communicates with the SL object.

Does that even make any sense..? :smiley

If anything is unclear, ask! I am as usual turning on notification on the thread, so feel free to whine away! ^^

An old, simple project I dug up for ya:
11  Forum 2005-2010 (read only) / Interfacing / Re: Best way to control arduino via network? on: August 22, 2008, 07:49:17 am
Man, I hate people with mindsets like that.. Which, unfourtenately, leaves me hating a scary number of people. I mean, I NEED to know how stuff works! Even if I might never use the knowledge for anything usefull I still love just knowing and the more one knows, the easier it gets to understand something new. Imagine where we as a species would be if everyone had that kind of mindset...

If that is your goal, go freaggin' do it! Your garage door probably has an open/close button on the inside. Hook up a transistor, relay, opto-isolator, whatever you like (or rather, need) to that. Add a switch that gets pressed when the door is closed and 2 thermistors. The ones they have at Sparkfun seem good, and Sparkfun showing you how to convert the readings into degrees is an added bonus.

So part count for something really cool this far:
- Arduino
- wires
- transistor (and relay, if the voltage is above something a transistor can handle)
- 2xthermistor
- button

What are you waiting for, man? Any tinker with some self respect has a switch and some wire lying around. Go out and hook it up to your garage door and make a password protected webinterface for it! (I can help with the web-stuff if you need it smiley)

Yeah, I know about X10. There is even an Arduino library for controlling X10 devices, though I don't know what kind of hardware I'd need to send signals from the Arduino to the devices. Would be a pretty smooth solution if a bit pricey. There are even dimmers, and every device comes in versions that can tell the central control unit their state. But then, why not just buy a starter pack that contains the "computer signal to mains wireing signal"-device and use that instead of the Arduino? =P
12  Forum 2005-2010 (read only) / Interfacing / Re: Best way to control arduino via network? on: August 22, 2008, 06:39:38 am
Aaaahahaha, ballsy man! You just called your wife, and I quote: "..a stupid person.."! ;D But alás, I know your situation. Been lusting for the chance to build a home automation system for years now but first of all I'm only renting an apartment for now and second, my girlfriend (who I share the apartment with) wouldn't like anything fancy like that. Besides, I'd not like to have to pull out my cellphone every time I needed to switch a light or chance channels on the tv. I'd like to retain the physical light switches and such but also be able to control everything from a central comuter (and from there, a webinterface, a tiny webinterface for cellphones with GPRS, perhaps bluetooth, etc), and also keep the traditional tv/dvd/etc. remotes but at the same time have an IR interface on a computer to control it. Or perhaps just have a mediacenter pc that I stream music, tv, dvd/video and other media through so I can control it over the network without the need for the IR interface.

Anyways, hook something up to the net and set a webcam on it! Even if it's just a few leds beeing controlled from your website, I'm sure people would love to play around with it. ^-^
13  Forum 2005-2010 (read only) / Interfacing / Re: Best way to control arduino via network? on: August 22, 2008, 12:19:34 am
So.. have you got any progress for us yet? smiley-grin
14  Forum 2005-2010 (read only) / Interfacing / Re: Best way to control arduino via network? on: August 19, 2008, 03:44:48 am
No problem, man! Here's the simplest possible solution:

Step 1:
Download serproxy
You'll probably have to modify the serproxy.cfg but you'll figure it out. Most importantly the serial settings have to match those of your Arduino, and you have to know which port number the php script will connect to. The following line in serproxy.cfg will tell you the portnumber:

Step 2:
Do you have any experience using php? If not, then start learning! Got a webserver with php? If not, download and use PortableWebAp This is a very simple, tough rather complete webserver. You'll figure it out. smiley-wink

Step 3:
Build the website! I'll give you a very basic script to send data to your Arduino through serproxy.

//open a connection to your computer running serproxy, on the port you found in serproxy.cfg
$fp fsockopen('localhost'5331$errno$errstr) or die('Error('.$errno.'): '.$errstr);
$_GET['do'] == 1)
//send character code 2. Can be replaced with whatever you want
$_GET['do'] == 2)
//close the connection

<a href="?do=1">On</a><br />
<a href="?do=2">Off</a><br />

There you go, that should be it! Don't hesitate to ask further if you need more help. smiley

Oh, don't forget to replace 5331 in the script with whatever portnumber you have in your serproxy.cfg!
15  Forum 2005-2010 (read only) / Interfacing / Re: 433mhz wireless problems on: October 04, 2007, 08:13:52 am
If you are going to have multiple devices communicating with your computer, you either need some ingenius timing-routine, a system where device 1 transmits to device 2, which appends it's data and transmits to device 3 and so on (not very efficient), or 2-way-communication so the computer can push/poll information to/from the device it wants.

Like I said, sending continous bits was a retarded suggestion on my side. Just send jibberish, followed by an identifier telling the computer that data is starting.

I'm not sure how you plan to link together several devices.. If you need any-to-any communication I'm pretty much lost, but if you need many-to-one type communication, getting a tranciever for your devices is the only good way I can imagine.. The computer says "Hey, unit 3, what is your analog input status?" and device 3 answers.
Pages: [1] 2 3 ... 10