Arduino microcontroller interface with Revolution

Interested adding compiled externals from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Arduino microcontroller interface with Revolution

Post by hamlynart » Wed Nov 26, 2008 7:51 pm

Hi,

Is it possible to interface with an Arduino microcontroller through Revolution? I can do it through Flash but to be honest I hate Flash and Rev would be so much better for the type of projects I'd like to do.

Many Thanks in Advance.

Jim H

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed Nov 26, 2008 8:29 pm

If this is a USB device, you may be able to connect to it; and if there's a .DLL to communicate with it, you could wrap that with an external.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Thu Nov 27, 2008 9:06 pm

It's certainly possible to do. I wrote a rev interface for the Make board from makingthings.com earlier this year. If you haven't bought the Arduino board yet, you might want to check this out first. You'll find my interface in revOnline under my namespace.

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

RE: Arduino microcontroller interface with Revolution

Post by hamlynart » Wed Dec 03, 2008 11:39 pm

Nice Make interface. I have some Teleo microcontrollers from Making Things (who make the Make controller) but they're obsolete and don't work with my Intel Mac so I decided to switch to the much cheaper Arduino. Like the old Teleos the Arduino uses serial Proxy to communicate with Flash etc because it's actually a serial device. I think it's way too complicated for me to work out how to code anything to allow Rev to interface with the Arduino but I hoped someone else might have?

Thanks

Jim H

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Thu Dec 04, 2008 4:26 am

Thanks. I picked up the Make board for about $100 at the Maker Faire earlier this year. I had the rev ethernet interface running in a week, but got stumped on the USB port until I realized their driver wants a trailing cr. And then ignores it...

My understanding of the Arduino board is that you write a program for it to run and then download it to the board over the usb port. So the rev interface might just be a script editor and and a downloading section. Unless you wanted to write an emulator, which would be way cool...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Thu Dec 04, 2008 9:12 pm

Mark, I looked at your Make interface and it's pretty cool. But I didn't find where it actually communicates with the external device. Did I miss something obvious, or is there a DLL or some other component that it's dependent on.

I'm totally ignorant about this sort of stuff, so please be patient if I missed something that would be obvious to anyone who knows what they're doing. That's not me, at least not yet, but lately I've found myself itching to play with robotics so this may be something I'll be using down the road.

As a side note, I just want to say: Damn! You have some fun stuff in your RevOnline collection. At the last RevCon I was impressed by the goodies you showed me, but looking through your stuff in RO it's even clearer how much great stuff you do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Fri Dec 05, 2008 1:25 am

Um... thanks... now I have to go look at what kind of stuff I put in my revOnline folder...

anyway, there's no special dll or driver or anything like that. The Make board registers itself as a COM port on Windows and as a usbmodem type on OSX. In the libOSC substack you'll find a command called OSC.Open that figures out whether to use ethernet or usb and then treats the usb port as a serial device. I hardcoded COM3 into the library since that's what came up for me, but it's easily changeable and will only be different if COM3 is already in use for some other usb device.

...and if you need to do any usb network troubleshooting on Windows (sorry - I can't find an OSX equivalent) there's an absolutely wonderful one that solved my usb problems in ten minutes at AGGSoft

http://www.aggsoft.com/usb-port-monitor.htm

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Fri Dec 05, 2008 10:24 am

I've controlled Arduino many times from Revolution in MacOS X environments. Even if it's a USB device, it register itself as a serial port using a driver. This way you don't need serial hardware add-ons.

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Post by hamlynart » Fri Dec 05, 2008 12:59 pm

mmiele, that's amazing news - what do I need to do to get the arduino and Mac OSX working together too?

Cheers

Jim H

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Fri Dec 05, 2008 4:59 pm

Yes, that's great to hear. Any chance you could post some sample code on revOnline for the rest of us to see?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Sat Dec 06, 2008 2:22 am

Jim H- I suppose I should ask a few questions:

what OS are you working with?
have you tried communicating with the Arduino board as a serial device?

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Post by hamlynart » Sat Dec 06, 2008 11:10 am

Mwieder, Thanks for the reply.

OSX 10.5.5 Intel Macbook Pro using RunRev Studio 2.8.1.

I've got the Arduino working nicely with Flash using Kasper Kamperman's arduino_flash.pde and Serial Proxy.

I just don't have the slightest idea what script to use in RunRev to communicate via Serial Proxy. Presumably a different config file is necessary for Serial Proxy also?

Best

Jim H

mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

Post by mmiele » Sat Dec 06, 2008 11:25 am

I used MacOS Tiger and then Leopard.

What you need is:

1 - download and install from the Arduino site (http://www.arduino.cc) the Arduino SDK.

2 - download and install from the Arduino site or the FTDI site (http://www.ftdichip.com) the driver to see the Arduino USB as a serial port.

3 - connect the arduino board to an USB port of your Mac.

You will see is a new entry in the list of serial devices.
You can get the list reading the "driverNames" property: ex.

put the driverNames into field "serialPorts".

You can get a useful stack to test serial communication at

http://www.troz.net/Rev/tutorials.php

The stack is SerialTest.rev

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

Post by hamlynart » Sat Dec 06, 2008 2:54 pm

Very good so far. there is certainly something is happening, which is encouraging. Serial Test says that the Port is open and if I send data the RX light flickers on the Arduino.

What next?

How do I read data coming in from sensors connected to the Arduino?

Many Thanks

Jim H

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Sat Dec 06, 2008 5:59 pm

From what I can gather from http://arduino.cc/en/Guide/MacOSX you simply download a program to the Arduino and turn it loose.

Now that you've got the serial communications part working, I don't think anything else in my Make board controller is going to help you much - the Arduino is a more autonomous board, while the Make board can be controlled from a program running in an outside source. And the Make board uses OSC as its programming language while the Arduino's language is based on Wiring.

I'd try sending the sample LED flasher program to the board and see what happens. I've found a great USB port traffic watcher for Windows but don't have an equivalent program for OSX.

Post Reply