How can I control the arduino interface using lua - lua

I have an arduino galileo board, which I'm running using Intel's image on a micro-sd card.
I already manage to run basic Lua scripts on it.
I want to run a Lua script on the board (Intel's image) and interact with the arduino interface - for example be able to turn on a led or read sensor data. This is very simple to do when using sketch directly, where you have straight forward API to turn on specific pin that is connected to a led. Same goes for reading input from a pin (check if sensor is sending data).
Is there a Lua library that has such access to the pins? or should I somehow connect the Lua script to the Arduino API?
The script will already run on the board.
Thanks.

what you want to do is similar to the Firmdata; it is a processing and arduino sketch that will use arduino as a mere "executor" of a pseudo language over serial.
That means many arduino command are mapped to a specific serial command, for example 'aX' may means do a digitalRead, where X is the pin number, 'bX' do an analogRead and so, obviusly arduino will then send back the reading to your host.
Drawback are that you are limited by serial (or any other bus) throughput. That means, if you want to just fast-prototipe something, it it a good solution, but when you need to code time-sensistive (or specialized) code, then you need to create your own function, called by your own command, witch probabily as a custom response.. pratically you are writing a custom program, and the ardiuno (and LUA) sketch become a mere string parser.
On galileo, the arduino is connected by serial port, as it is needed for sketch upload, so as long as LUA give you some library to manipulate serial port, you are good to go for this solution.

Related

Two TCL scripts that use the same conection

I am working with two tcl files. One is a program that connects to a thermal scanner to get information from it via ethernet. I have integrated the other tcl GUI that can reflash the scanner via ethernet. How do I use the connection from the first one to use the flash utility on the second GUI? At first, the two GUI's were separate but I had to combine them for customers.
-let me know if you need any code, the programs are about 4000 lines long so I didnt want to put them on here.
A single TCP connection can only really be used by one process (at each end) at a time; trying to do otherwise causes confusion. Can you just get each program to talk to the thermal scanner directly? At least theoretically, it ought be able to support multiple simultaneous connections, and that'd be a simple way to work.
But if the device won't work that way, the easiest way to multiplex the communications is to have a single process that actually talks to the device and for the other programs to talk to that multiplexer process (probably via a local socket). The multiplexer doesn't need to have a GUI, but would be told to do things like “flash this file to the scanner” or “stream values out of the scanner”. The details of how to do all this will depend very much on what's actually going on with the communications, but the fcopy command is highly likely to be useful in this, as it can be used to efficiently stream data from one Tcl channel to another.

Gnuradio streaming between two computers?

Is there a simple way to implement communication between two computers running GNUradio using the standard blocks set?
What I am have now is this:
On a Linux computer, GNUradio is running and receiving input from a Radio peripheral. On that computer I can see the received waveform on a WX scope. I can also use sliders and input boxes to change things like the receiver frequency.
What I'd like to do is this:
On a Windows computer, I have the WX scope and sliders. When I move the a slider or change an input box, that data gets sent to the Linux, which is still running the radio receiver on Gnuradio. The received signal goes through a stream back to the windows, and gets displayed on the WX scope on Windows.
Someone elsewhere suggested using the ZMQ blocks, however, when I tried setting up a PUSH/PULL to transmit a sine wave from the Linux to the Windows, nothing went through. The guy who recommended that approach tried the same and also could not get it working, so I think that block might be broken?
So is there any alternative blocks that can do what I'm trying to do? Preferably something well documented, and available on GNUradio-companion.
Depending on the data rate from the receiver, it's possible to encounter performance issues attempting to send raw waveform data using e.g. the UDP blocks, where the sender may print an error similar to the following:
gr::log :WARN: udp_source0 - Too much data; dropping packet.
Because the scope widgets usually only display a portion of the input data, a more ideal way of remotely visualizing the waveform might be to only send the rendered scope widget (e.g. using a remote desktop such as VNC or X2Go). Although this solution reaches beyond your original problem, it is probably easier to use in the long run for cases involving two-way GUI interaction.
For the scope widget data, the UDP sink and source blocks seem to be native to GNU Radio, and are either sufficiently documented solution or simple enough for this problem, again taking firewall configuration into consideration as #Zephyr mentioned.
From GRC, specify in the UDP blocks:
the hostname or IP address of the display computer, and
a choose port number that isn't already in use (and were you using Linux, OS X, or anything UNIX-like, not any port below 1024).
For setting variables over the network, you might try the XMLRPC blocks, as described in another answer. These were recently deprecated, however.
See my other answer for discussion of alternative if performance issues arise.
Both Linux and Windows should have firewalls which might be blocking the connections.
You need to post the error messages displayed in gnuradio-companion.

Is a network shield required to do POSTGET requests with arduino?

By means of being thorough i was wondering if someone could tell me if I need an ethernet/wifi shield to be able to use POSTGET requests using my arduino.
I've got an NFC shield and I need to send the data stored on the tag to my web server.
You can't do it directly, but if you're planning to use USB, you can
send data using the various serial commands to the PC you're connected
to. You'll need a program written in your language of choice on the PC
listening to the arduino and that program can submit your GET request
for you.
Or in other words, you can fake it, but an ethernet capability would
probably be better & easier.
Copied from a post I found in the Arduino forums

Need help using Arduino R3 as serial-to-usb converter (to program something)

I have researched (and learnt quite a bit), but I have little experience in programming and only really understand basic sketches so far. I would like to use the Arduino R3 (more specifically, the usb to serial converter chip) to program a full-size hobby radio.
I have connected my radio to the Arduino appropriately (5V, Rx, Tx, Gnd) and put the Arduino into Tristate mode (apparently you have to do this..), but I seem to be lacking appropriate drivers. I basically want my Arduino R3 to function exactly like this: CP2102 . Please note that I am not being super cheap. To get something like that where I live would take at the very least a month. Some people also say that I should remove the Atmega chip. The ultimate goal is that I have a device, with drivers, on a com port and not just an "unknown device".
So, my questions are: leave the Atmega on, or remove it? and which drivers do I need?
Thanks!
EDIT: I found almost exactly what I need just after I posted. For some reason I couldn't get it to work, but maybe you could help me understand? Here's the link LINK If anyone is keen to help me out!
Just to make it clear: it has been done before, but I get the feeling people leave out things which they think are obvious, but to the not-yet-professional tinkerer like me aren't :/
Thanks so much!
It seems like the links you reference are for older Arduinos with an FTDI chip. The Arduino Uno doesn't use that. Here's a link for using the Uno
So! All of the older Arduinos (NG, Diecimila and Duemilanove) have
used an FTDI chip (the FT232RL) to convert the TTL serial from the
Arduino chip (Atmel ATmega). This allows for printable debugging,
connecting to software like PureData/Max, Processing, Python, etc.
etc. It also allows updating the firmware via the serial bootloader.
The good news about the FT232RL has royalty-free drivers and pretty
much just works. The bad news is that it can -only- act as a
USB/Serial port. It can't act like a keyboard, mouse, disk drive, MIDI
device, etc.
and
The Arduino Uno has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega328
provides UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels
this serial communication over USB and appears as a virtual com port
to software on the computer. The '16U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, a
.inf file is required. The Arduino software includes a serial monitor
which allows simple textual data to be sent to and from the Arduino
board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the
computer (but not for serial communication on pins 0 and 1).
Basically the LINK you provided, shows the user HACKING the Arduino. Using the USB/Serial(TTL) converter(what ever chip that is on your Arduino) to link to the Radio's Mini Din connector, in place of connecting to the Arduino's CPU.
As stated in other answer the Arduino uses a CHIP (of some flavor) to bridge the USB(Virtual Serial Port) to the Serial Port of the ATmega328 micro. These pins are available on the Shields connector 0(RX) and 1(TX). Hence you see the picture wiring those pins to the Radio's DIN connector.
Where I would expect in addition the RESET of the Arduino's CPU would be held to GND, this would force the pins into Hi. Simply with an extra wire jump the RESET pin to a GND.
It's working! Somewhere along the line the drivers for my arduino seem to have been deleted, so I reinstalled them, did what you said, and learnt something.
So to clarify for others: pretty much plug and play (as the link I posted suggests), but make sure to install the arduino drivers properly.
Thanks a lot for the help!

iOS virtual button to Arduino

What would be the best way of sending a signal from an iPad to an Arduino?
I am trying to use XBee, with iPad and Arduino to send a wireless signal.
I want to make a big red virtual button on an iPad that, when pressed, turns on an LED on the Arduino.
I am a total newbie when it comes to iOS, but OK with Arduino and XBee.
So I'm not sure if I understood correctly, but in my meaning there is only one simple way to solve the problem:
Connect an XBee to a Computer and another to the Arduino. On the computer you launch a webserver, which will be accesible from the iPad over Safari. This server handles the clickes and writes to the XBee Com Port, for communication.
Here are some examples, people already made:
http://www.projectallusion.com/1/post/2009/11/iphone-controlled-solar-powered-arduino-tank.html
http://www.sparkfun.com/tutorials/152 (not with xbee, but you can implement that by yourself)
I know it's been a while but I just came across to this question and yesterday I was doing the exact same thing so I'll share the method I used and the source of it.
In order to set a LED on or off in an Arduino board from the iPad you really don't need anything more than a browser. This is of course if you have a way to connect that Arduino to the local network.
Today you have at least two options. The WiFi and the Ethernet shields. Once you have your Arduino board inside the network you can send the instructions (HIGH or LOW) to the board form the browser.
These are my two boards connected waiting to be plugged to the local network:
Of course, you'll have to code the board to process those instructions. There are many examples on how to configure network settings and state instructions:
If you have a bit of time and want to do something more elaborated you could create a simple app to graphically control the state of those LED(s).
Inside you'll basically do the same thing, create the URL command and send it to the Arduino IP but it'd look much nicer. If you integrate later more controls the sky in the limit.
My experiment is a combination of what I learned from this nice tutorial and some tips I've read here and there.
I hope it becomes also useful to someone else.
Cheers,
Since you need to use a network connection from the iPad, a possibly simpler way to do this would be to use a WiFi module on the Arduino to poll a web script, and have the iPad write a state (button press) to that web script.
There's a handy WiFi module called the RN-XV that's designed like an XBee. I wrote up two tutorials on it:
http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js
http://log.liminastudio.com/itp/physical-computing/using-the-rn-xv-wifi-module-as-a-remote-switch

Resources