News:

SMF for DIYStompboxes.com!

Main Menu

Arduino and PICs

Started by spargo, August 26, 2011, 03:12:14 AM

Previous topic - Next topic

spargo

I recently got a PIC programmer to dive into a bit of digital stuff.  Then, I discovered Arduino.  I do have a programming background but I'm unfamiliar with programming hardware and ASM.  Correct me if I'm wrong: my PIC programmer can burn data to PIC chips, and the Arduino can't.  The Arduino board itself is programmed and used as a controller.

Is that right?  The Arduino environment seems more friendly than what I've seen so far of PICs, but when it comes to sticking a chip in a pedal (like the tap tempo tremolo for example), what is the best way to go?  Is it easy to program with Arduino and somehow burn to a PIC?

Any links to resources you've personally used are appreciated as well.

Hides-His-Eyes

I think the main reason to use PICs over arduino is the cost. But then they make some amazing tiny arduino boards for not too much money.

Seljer

The Arduino is an Atmel AVR microcontroller with some basic circuitry included (regulated power supply and a clock crystal + a serial interface) and a bootloader already loaded onto the chip which takes up some space but allows enough basic communication for you to load your programs onto the chip directly via serial/USB with no need for a separate programmer.
If you bought a bare ATmega chip you'd be in the same situation as if you had a PIC chip, you'd need a programmer (can be had for like $25) and you can get the thing working in a breadboard with less then half a dozen components. If you buy an Arduino, if you were later to progress to using just AVR chips you can actually use the Arduino as a programmer.

You generally don't need any assembler knowledge unless you're really trying to squeeze down for speed/size restrictions (and the latter isn't that much of a problem, just buy a chip with enough space).

derevaun

Another way to think about the Arduino is that it's a breakout board for an Atmel chip (with the bootloader programmed onto the chip). You could program the chip, pull it out of the Arduino's socket and place it in a circuit that mimics the situation on the Arduino board (like Seljer said, power and a crystal mainly).

PIC might be a good choice if you're planning for eventual production. Arduinos seem to be more useful when the prototype is the final product. It's pretty quick to get working, and as soon as it works, it works. If it's socketed, you can always bring it back to the Arduino board to update the program.

iccaros

An Arduino is to Amtel as Basic Stamps are to PIC's
they allow easy programming and most of the electronics you would need, and in  alot of cases more than you will need.

There are boot-loaders for PIC's that allow you to use C and C++ directly on the PIC as you do with the Arduino.

You can do the same job with both, in my experience PIC's have many more types so you can pic the one you need, down to very small 8 pin versions, that still have PWM and other features that normally come in the bigger Amtel packages.
We use PIC's at work, but once we get the functionality of several we program a FPGA to do production.

Either is a good starting point, and I built a programmer that works for both, just a matter of the socket board you use.

MoltenVoltage

Quote from: iccaros on September 09, 2011, 11:09:54 PM

We use PIC's at work, but once we get the functionality of several we program a FPGA to do production.


Why do you use FPGA's for production?

Are you saying you can compile multiple PIC programs into a single FPGA?
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

iccaros

I can make a FPGA act like mutiple PIC ..

Why speed.

its not the program but the funtionality. The PIC is for development

PRR

PIC is a naked chip. You need other stuff.

Arduino is a PIC(-like) chip plus "other stuff". Power system, clock, RS232/USB program/terminal interface, in/out on headers.

Naked PIC is $3 (or less). PLUS the other stuff. Day(s) of busywork before any fun can start.

Arduino is $30. You can poke a Hello World into it 10 minutes after you open the box.

Play with the Arduino. It can go right into a cash-register etc... prototype is the product. Sure, tap-tempo in a pedal, just an Arduino.

When you discover that it is too expensive or too big, then reduce the board to a PIC and the bare minimum other-stuff you need. Until Banjo World offers you a contract, you might never need to use a naked PIC.

> unfamiliar with programming hardware and ASM

Machines only run machine code. To humans, this is gibberish. Coding a dozen insructions in machine language will grow hair on your eyeballs.

As soon as you have a computer that will parse TLA text, you make-up TLAs like ADD MOV STO. Code just enough parser (on this or another computer) to eat the TLAs and output straight machine langue. Now you are cooking with ASM.

They really can't sell any CPU without an ASM assembler.

ASM is not that easy. Write a formula parser, table database, and fancy print statements. Now you have FORTRAN or BASIC or COBOL. These compilers can show you ASM if you want, but usually output machine code.

Keep going. With enough computer and programmer time, you can translate anything to machine code. When you have a big machine (PC) and a little machine (PIC) you typically write Pascal or BASIC or C or even Java on the big machine, compile to little-machine machine code, then put that code where the PIC will find and run it.

Nearly any "hobbyist" platform will have an integrated environment to write the program, do basic checks, find the PIC/Stamp/Arduino on a PC port, and put the code to the PIC.

Writing the code to the PIC is just a bit different than writing pictures to a thumb-drive. Obviously it only makes sense to write to the right PIC and in the right place; the PIC IDE handles that. Formerly we connected via serial port; today USB is common.

Arduino seems to have grown its own programming language, "Processing". Seems to be Java-like. Which means sorta-C-like. Seems to try to be easy to start with. Seems to be "visual". There's probably more direct ways to get to working code. Ah... it seems that "Processing" outputs C for an Arduino C compiler, you can skip the frills.
  • SUPPORTER

armstrom

look at the TI launchpad. It is only $4.30 for a usb programmer and two msp430 value line microcontrollers. tough to beat that deal!
-Matt

Gurner

I'm unfeasibly tight, I baulked at the cost of Arduino, which kind of forced my hand to go the PIC route...I'm pleased I did, cos at the end of the day, I'm a techie type that likes getting deep down and dirty with the 'interfacing' to the outside world anyway.

I still find it gobsmacking the amount of features/flexibility a $1 pic can provide.

iccaros

Quote from: Gurner on September 11, 2011, 06:41:43 AM
I'm unfeasibly tight, I baulked at the cost of Arduino, which kind of forced my hand to go the PIC route...I'm pleased I did, cos at the end of the day, I'm a techie type that likes getting deep down and dirty with the 'interfacing' to the outside world anyway.

I still find it gobsmacking the amount of features/flexibility a $1 pic can provide.

Same reason I did not use basic stamps.

but you can get the Amtel chip and do the same as with a PIC, use an external oscillator, and power your ready to go, just need to program it.
Either way they can be useful in replacing many logic chips, I remember in high school, This was way before the internet... For our final school project we built a controller out of 7400 series logic and a robotic  Arm out of an old Xerox. Nothing more than turn left right, one elbow, up and down and grab.
The controller tool an entire table worth of bread boards,  and to program you had to enter number codes that was really the binary equivalent of which motors to turn on.
now you can do that with one PIC, or Amtel what ever.
Great class, so glad I picked skill center over "advanced courses"

thedefog

Quote from: Gurner on September 11, 2011, 06:41:43 AM
I'm unfeasibly tight, I baulked at the cost of Arduino, which kind of forced my hand to go the PIC route...I'm pleased I did, cos at the end of the day, I'm a techie type that likes getting deep down and dirty with the 'interfacing' to the outside world anyway.

I still find it gobsmacking the amount of features/flexibility a $1 pic can provide.

Sorry to bump sn old thread, but you can build a Freeduino for around $20 ( whick comes with a bootloaded atmega328) and just use the arduino for burning and testing your programs. Then just buy a bunch of pre-boot loaded Atmega328s off ebay for like $4 a pop with some xtals and 5v regulators, and you can perf your own custom boards for projects. Works great for me and is cheap.

nexekho

I recently bought a starter pack off eBay - a simple programmer, leads, pin headers, crystals, capacitors, LEDs, resistors and 3 ATMegas - for about £16.  If you're starting out with controllers this might be a good way to do it.
I made the transistor angry.

cloudscapes

I've started experimenting with PIC32's. That means finally learning C.

The 8-bit AVRs I had been using are too slow for the crazy stuff I have in mind!  ;D
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

nexekho

Quote from: cloudscapes on January 19, 2012, 07:17:26 PM
The 8-bit AVRs I had been using are too slow for the crazy stuff I have in mind!  ;D

What kind of crazy stuff?  I've been doing chorus/flanger/phaser/tremolos with mine and recently synthesizery stuff doing rough monophonic pitch tracking.

I look forward to it :]
I made the transistor angry.

cloudscapes

Quote from: nexekho on January 19, 2012, 08:15:06 PM
Quote from: cloudscapes on January 19, 2012, 07:17:26 PM
The 8-bit AVRs I had been using are too slow for the crazy stuff I have in mind!  ;D

What kind of crazy stuff?  I've been doing chorus/flanger/phaser/tremolos with mine and recently synthesizery stuff doing rough monophonic pitch tracking.

I look forward to it :]

granular sampling/looping stuff, mostly. and some synth stuff, multiple DCOs in one chip. and eventually building the multitrack looper of my dreams.

but if all I need are LFOs, ADSRs, a single DCO or simple synth, presets and automation, an AVR will usually do just fine.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

thedefog

#16
I absolutely love the simplicity of the arduino platform. And Processing makes coding a breeze for not-so-great coders like myself. There are so many examples out there and the resource base is so vast that you can do pretty much anything you can dream up on them within reason.

I only recently ran into a non-audio project that requires a lot more pinouts. I'm building my own Pitch and Bat pinball machine into a coffee table. I'm controlling an LCD screen for scoring and whatnot along with a vast array of momentary switches connected to plexi cut-outs to trigger scoring and LEDs where I didn't want to deal with logic circuits for multiplexing, so I ordered an Sanguino kit, which uses the ATMega644 as its microcontroller. The code is pretty much identical for the most part, and can be compiled within AVRdude. Also it is very much affordable and a lot nicer for prototyping your more complex designs without having to rig up a good deal of external CMOS chips. I've got the preliminary code for all of the Leds, some cheesy audio, switch detection with bounce code, flipper timing code between the solenoids for the pitcher's mound (solenoid pops up a plexi plate, then another solenoid shoots the ball) and the batt with the solenoids rigged up to TIP102s through a power supply I yanked out of a dead Laser Printer (regulated 50vDC out for the solenoids and 5vDC regulated for the microcontroller) . I got the flipper assembly off eBay from an old pinball machine and I'm in the process of molding plexi for the pitching mound and home-run ramp. The hardest part is figuring out the angles and spacing of the board, along with the assembly to send the pinballs back to the pitcher from the strike zone. Still working that out. I know it's not really something meant for this forum, but if anyone is interested, I'll post code along with pictures so far. I'm basing it off of this Virtual Pinball design:

thedefog

BTW, the arduino is TOPS for adding in midi to non-midi devices. I've successfully rigged up a few old drum machines with triggers using them (TR-606, Sound Master Rhythm SM-8, Old Kimball Organ Drum section, cheesy mini switch controlled midi controller).

For audio related stuff, Beavis Audio has an awesome page with some wonderful LFOs to control a wah effect. Take that code, and add in some gating into other voltage controllable sources, and the possibilities are endless. I've messed around with his code running into Tim Escobedo's Simple VCF and it sounds ridiculous. I just never got around to housing the thing up, but I definitely want to use it. http://beavisaudio.com/projects/DSWF/

Beo

#18
I'm thinking of diving into digital programming as well. It seems to me that the evolution of the PICs and AVRs is a moving target. As I research these two technologies online, it seems the chip versions, and the coding languages / IDEs are constantly changing/updating.

I've done Basic/Fortran/C coding in college and some VB scripting at work, so I'm not too concerned about the learning curve. Also I'm not too concerned about startup cost (i.e. don't mind building or buying prototype development setup). I do however want to avoid re-inventing the wheel, and would like to re-use a lot of what's out there in terms of projects and coding examples. Also, I'd like to not have to constantly be re-learning and updating to ever-changing technology. My applications will be for my own use, basic logic chips in pedals, tap, sync, selection, LED/LCD display, etc... not audio processing or synth.

So now that it's March 2012, what the latest lay of the land... is there a trend towards PIC or AVR or do they both have thriving futures? Which seems to be a better starting path, given my thoughts above? Thanks! Travis

Update: to answer my own question, looks like PIC and AVR are both thriving and will be around a long while with avid followers. I think I am leaning towards AVR. Is getting a development board, perhaps with on-chip debugging capability helpful and recommended? It seems like you can get started just with a breadboard and some components, using an ISP interface cable to program the chip.

harmless

I'm really new to this stuff, too, but I started with an Arduino Uno and it's been fine so far. I'm a confident programmer, so the built in serial output monitor in the IDE was enough for me to get by with, debugging-wise.  My notions of what is expensive are probably out of whack, but $25 for the Uno is dirt cheap.  For my first project I ended up buying a Pro Mini for $20 to put in the pedal.  For my next one, I'm going to try to use the Uno as a programmer for an ATTiny of some sort (only a few bucks each and smaller/easier to include in a layout).