Anyone doing Arduino programming?

dwell

pics?
Oct 9, 1999
5,185
2
0
I ordered an Uno being it's so cheap. I know C very well so I am not so worried about the language aspect, but wonder what application there is for the platform.

I originally wanted to experiment with DSP but it seems like you need a daughterboard and external libraries. I might eventually do it but I would imaging there's cheaper options for DSP programming.

I am wondering what people are doing with the platform other than making LEDs blink.
 

PCTC2

Diamond Member
Feb 18, 2007
3,892
33
91
I used the Arduino (with XBee wireless and Ethernet Shields), along with other custom circuitry to create many things, including a web-based remote control. You can create anything that can operate in a single thread.

I know someone who used 2 Arduinos (in parallel) to create a remote control helicopter. Or with some custom boot loader hacking, you can create an HID device like Makey.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
I use it for process control applications. It has analog in/out (well, PWM out anyway) so it can read a sensor, do some calculations like those required for PID control, and set an output.
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
Not arduino as such, but 8bit AVRs (same..), with C (GCC). You can do this on the arduino too.

I made a few boards with ethernet some time ago - modified another guys NTP/http code to run on it (i had a different avr... and he has bloody gotos in the code, had to fix that :p). Had some other plans but I've been busy lately. It syncs time from an ntp server, optionally displays it on a local display, and also shows the time on a webpage if you go to it's IP. I modified it to display on a old russian VFD... I never seem to finish stuff though. Get it working and then lose interest / too busy / to polish it and get proper PCBs made..
(The guys site is here: http://tuxgraphics.org/electronics/200710/avr-ntp-clock.shtml,
he has some other AVR projects too ... probably a good example of some things you can do with it: http://tuxgraphics.org/electronics/ )

If you want to add ethernet you can run his code and a <$10 ENC28J60(?) ethernet chip board from china (ebay), as opposed to the arduino 'ethernet shields' which cost a fortune.. 40 or 50 bucks I think. (they use different IC/code, though. Not sure if there is an arduino library (or whatever they call it for arduino) for ENC28J60.



Also been playing with the 8bit AVRs that have hardware USB. (why the arduinos don't use this is beyond me - they use a USB<>serial chip and a non-usb AVR. The USB AVRs are the same price as non-usb (roughly), and make the USB-serial chip unnecessary. Even more ridiculous is that the USB-serial IC costs *more* alone. nuts.).
They're pretty bitchin', seem to support most any USB class.. so serial port to talk with it, or HID as a keyboard or mouse, sound, etc etc. Another nice feature with them is USB bootloader, so you don't need a programmer for them, even blank chips from the factory...
Not strictly related I guess, as your unit doesn't have this

also check here
http://www.avrfreaks.net/ (projects, forums, etc)

There's a bunch of arduino geared stuff but it always struck me as a lot of chaff and hurr durring.
 
Last edited:

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
You can do a lot of stuff, if you are willing to buy more hardware or improvise existing hardware.

I created a wireless sensor network to monitor temperatures and upload it to a website.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
I used the Arduino (with XBee wireless and Ethernet Shields), along with other custom circuitry to create many things, including a web-based remote control. You can create anything that can operate in a single thread.

FWIW, you can do multi-threaded programming on microcontrollers. Not sure if the Arduino libraries make it accessible to beginners, but it can be done.
 

Red Squirrel

No Lifer
May 24, 2003
71,306
14,082
126
www.anyf.ca
I've actually been wanting to play around with it. It's been a long time that I wanted to get into electronics and programming and this may just be the key. There's even a Canadian site that sells the stuff so I don't have to worry about ordering stuff from the States and paying border taxes.

http://www.canakit.com

One project I'd like to take on is making an enviromental monitoring device. Surprisingly there is not much out there as far as that goes.

Not Arduino, but I did recently buy this:

http://www.canakit.com/catalog/product/view/id/627/s/4-port-usb-relay-controller/

And built a hvac control system using C++ and interfacing with that. There's some posts on my blog about it.
 

PCTC2

Diamond Member
Feb 18, 2007
3,892
33
91
FWIW, you can do multi-threaded programming on microcontrollers. Not sure if the Arduino libraries make it accessible to beginners, but it can be done.

Yes, on micro controllers you can. I like some of the ARM boards now.

But the Arduino libraries are just single-threaded sketches. So, for example, you have a remote controlled vehicle. I have observed on an especially compute-heavy sketch a rather funny behavior.

We used PID control for some adjustments. So during the sketch loop, it would read in from the RC receiver channels, calculate the differences, and then output to the steering, throttles, and brakes.

So you would observe (during a single cycle) a steering adjustment THEN a throttle adjustment THEN a brake adjustment.

So we switched to something much more powerful. :p
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Yes, on micro controllers you can. I like some of the ARM boards now.

But the Arduino libraries are just single-threaded sketches. So, for example, you have a remote controlled vehicle. I have observed on an especially compute-heavy sketch a rather funny behavior.

We used PID control for some adjustments. So during the sketch loop, it would read in from the RC receiver channels, calculate the differences, and then output to the steering, throttles, and brakes.

So you would observe (during a single cycle) a steering adjustment THEN a throttle adjustment THEN a brake adjustment.

So we switched to something much more powerful. :p

You can do multi-threaded programming on any processor, including the AVR chip that is in the Arduino. The Arduino single loop style sketches might not support it, but the hardware certainly does.

I have a couple of boarduinos (Arduinos that pop into a breadboard) that I use as AVR development boards. I wrote a simple multi-tasking OS (< 200 lines of C), that lets me run up to 10 threads (hard coded for laziness and for memory restrictions).

Did a quick google search. There appear to be some beginner friendly tools for the Ardunio: http://concurrency.cc/
 
Last edited:

dwell

pics?
Oct 9, 1999
5,185
2
0
Getting pretty much into this now. One thing I am hitting my head on the ceiling with is dealing with low power so I am spending more time with hardware than software at the moment. Most of my amplifier circuits work at 9v but I can't seem to get good clean, amplification @ 5v. I just ordered a bunch of low-powered op amps from Asia so hopefully that will go well.

Fun stuff though. The programming side is easy enough but didn't realize I was only dealing with 1K and hit my head a few times when using static lookup tables. Now I compute at setup to a buffer.

I really want to get into DSP but have not been able to get a clean signal input amplifying ~100mV (guitar) to 5v for the Arduino DAC. Still wondering how 10-bit DSP is going to sound but could be cool for some lo-fi effects.
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
If you want to do DSP stuff, the arduino isn't for you, it doesn't have the memory or internal parts needed for the task.

Instead look at the pic32 , they were recently released in DIP format so easy to use on a breadboard and are designed with both codec interfaces and internal DSP functions.
http://www.microchip.com/pagehandler/en-us/family/32bit/

To get things going all you need is a pickit3 programmer and the chips. Microchip is very generous on free samples if you sign up for them .
One of my favorite chips:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en557409


If you really want to do DSP though look at the dspic line, they are a bit tougher to understand but are very powerful, they can do things like MP3 internally along with voice, audio, EQ type processing and include 16 bit DACs for audio .
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532310
 
Last edited:

dwell

pics?
Oct 9, 1999
5,185
2
0
Cool info, thanks! I am finding Arduino to be pretty anemic for DSP. I'm building more hardware to amplify, filter, etc than I am writing code and even then it's 10-bit, low-quality output.

Going to look into pic32 for starters. Seems like a good starting point. I'll check out microchip. Thanks again.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Cool info, thanks! I am finding Arduino to be pretty anemic for DSP. I'm building more hardware to amplify, filter, etc than I am writing code and even then it's 10-bit, low-quality output.

Going to look into pic32 for starters. Seems like a good starting point. I'll check out microchip. Thanks again.

Arduino is great for noobs and people doing simple projects. I would say DSP is beyond an Arduino.
 

Red Squirrel

No Lifer
May 24, 2003
71,306
14,082
126
www.anyf.ca
For those that have done arduino, is the USB port on the chips strictly for programming, or can your program be used to do data I/O through it? My understanding is that it probably shows up as a serial port?

I want to build an environmental monitoring device so I'd like to code a basic serial interface so a separate C++ program can take all the readings and do what it has to do with them. Can I do this with arduino? I would use the analog ports with voltage divider to measure battery voltages, as well as digital pins for on/off conditions on certain devices like door contacts, smoke alarms, etc.


I'm looking at buying this one:

http://www.canakit.com/arduino-uno.html

If I understand this correctly I have 14 digital inputs, so I can verify 14 separate on/off conditions and 6 analog inputs, which can measure a voltage between 1 and 5 volts, so using a voltage divider to "squeeze" 20 volts into say, 10 volts would allow me to then reverse the ratio and read a voltage. Am I correct on this?

My biggest issue is the ease of reading the data through a custom C++ app.
 

dwell

pics?
Oct 9, 1999
5,185
2
0
Very easy to do with Arduino. The USB is seen as a serial device on the PC side. On Linux it would be /dev/ttyAAAA where AAAA is random. Just open that port and read the data stream.

On the Arduino side it's dead simple. Just set up serial and read on a loop:

Code:
void setup() 
{
    Serial.begin(115200); 
}

void loop()
{
    byte value = analogRead(0);
    Serial.write(value);
}

You can obviously buffer and batch write but keep in mind you only have 1K to work with.

http://arduino.cc/en/Tutorial/AnalogReadSerial

http://arduino.cc/en/Serial/Write
 
Last edited:

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
I want to build an environmental monitoring device so I'd like to code a basic serial interface so a separate C++ program can take all the readings and do what it has to do with them. Can I do this with arduino? I would use the analog ports with voltage divider to measure battery voltages, as well as digital pins for on/off conditions on certain devices like door contacts, smoke alarms, etc.

Get the chipkit uno
http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,893&Prod=CHIPKIT-UNO32

It can run 95% of the arduino code unchanged and it has 128K Flash, 16K SRAM, 42 I/O. It programs just like the arudino, uses a modified version of the ide, and appears as a FTDI based serial port to the pc. If you own a pickit 3 programmer you can even switch between it being an arduino or a pic 32.
This is the chip used on that board:

http://www.microchip.com/wwwproducts/devices.aspx?ddocname=en532434

80MHz, 1.56 DMIPS/MHz, 32-bit MIPS M4K Core
5 Stage pipeline, Harvard architecture
MIPS16e mode for up to 40% smaller code size
Single cycle multiply and hardware divide unit
32 x 32-bit Core Registers
32 x 32-bit Shadow Registers
Fast context switch and interrupt response

128K Flash (plus 12K boot Flash)
16K RAM (can execute from RAM)
Flash prefetch module with 256 Byte cache
Lock instructions or data in cache for fast access
Programmable vector interrupt controller
Fast and Accurate 16 channel 10-bit ADC,
Max 1 Mega sample per second at +/- 1LSB, conversion available during SLEEP & IDLE
Fail-Safe Clock Monitor &#8211; allows safe shutdown if clock fails
2 Internal oscillators (8MHz & 31KHz)
Hardware RTCC (Real-Time Clock and Calendar with Alarms)
Watchdog Timer with separate RC oscillator




In case you couldn't tell I really like the pic32 chips, price/performance ratio is outstanding.
Comparison of speeds, pic32 running mmbasic, lower is better.
Code:
                           BM1    BM2     BM3    BM4    BM5    BM6    BM7    BM8 
ABC 800 single precision   0.9    1.8     6.0    5.9    6.3   11.6   19.6    2.9 
ABC 800 double precision   1.2    2.2    10.0   10.6   11.0   17.8   26.4   14.4 
IBM PC                     1.5    5.2    12.1   12.6   13.6   23.5   37.4    3.5 
Apple III                  1.7    7.2    13.5   14.5   16.0   27.0   42.5    7.5 
VIC-20                     1.4    8.3    15.5   17.1   18.3   27.2   42.7    9.9 
ZX81 in "fast mode"        4.5    6.9    16.4   15.8   18.6   49.7   68.5   22.9 

Maximite                   0.016  0.144  0.196  0.205  0.354  0.512  0.721  0.310
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
71,306
14,082
126
www.anyf.ca
Very easy to do with Arduino. The USB is seen as a serial device on the PC side. On Linux it would be /dev/ttyAAAA where AAAA is random. Just open that port and read the data stream.

On the Arduino side it's dead simple. Just set up serial and read on a loop:

Code:
void setup() 
{
    Serial.begin(115200); 
}

void loop()
{
    byte value = analogRead(0);
    Serial.write(value);
}

You can obviously buffer and batch write but keep in mind you only have 1K to work with.

http://arduino.cc/en/Tutorial/AnalogReadSerial

http://arduino.cc/en/Serial/Write

That's good to know, think I'll go ahead and buy one. The pic32 sounds nice too, but the nice thing with arduino is that I can get it from Canakit which is Canadian so I don't have to deal with customs or expensive shipping, so it ends up being cheaper. They send it Canada post and it's literally under 10 bucks to ship.
 

Red Squirrel

No Lifer
May 24, 2003
71,306
14,082
126
www.anyf.ca
So I just got my UNO and made my first program. Nothing fancy, just a very basic environmental check device. I made a basic command line interface that I can access via serial and get data out of it. An automated app I will write running on my environmental control server will actually interface with it to get readings of various sensors.




I'm hoping to tie this in with some smoke/CO detectors too. Not sure on how yet but I'll have to get a smoke detector so I can mess around with it. The "1st alert" ones seem popular and easily obtainable so I'll probably get one, and once I figure it out hopefully the circuitry of my existing ones will be similar enough so I can wire it the same way on others.

There's also a safety store that opened here, I'll have to check with them as they may even have something designed for this already.
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
I've been working on some ethernet enabled AVR stuff.

Gonna make a board soon, with PoE. Think maybe I'll put standard arduino headers on it so people can use it with shields or whatnot... not sure yet.
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
I'm hoping to tie this in with some smoke/CO detectors too. Not sure on how yet but I'll have to get a smoke detector so I can mess around with it.

Most of the smoke detectors for sale now use optical sensors. They have a component called a smoke chamber, really just a plastic container with an IR led and an IR phototransistor, when the smoke particles interfere with the IR light it causes the IR sensor to stop conducting for a split second and the smoke detector reads that as being smoke. The older smoke detectors used americium and a chamber where the voltage would change slightly when the smoke particles were present. Americium is radioactive so its use wasn't liked by some epa groups, the amount and type in smoke detectors is far from hazardous, but some people are so paranoid of anything radioactive.


For CO you can get sensors from lots of places. Parallax has one that is good quality but not the cheapest.
http://www.parallax.com/Store/Senso...ortField/0/Level/a/ProductID/547/Default.aspx
 
Last edited:

Colt45

Lifer
Apr 18, 2001
19,720
1
0
They still make both kinds of smoke detector. Am ones are cheaper. They're better for faster / cleaner burning fires iirc. Optical is better for smouldery heavy stuff, iirc also.