Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Earendil

macrumors 68000
Original poster
Oct 27, 2003
1,599
89
Washington
Quite simply put, I'd like to explore and make sure of analog signals, by reading them into my Apple computer.
I'm a CS major, so have programmings knowledge (without the in-depth industry know-how), and am just now taking an intro electronics class (building simple circuits).

What I can't find using google, is the difficulty level of getting an analog signal into a computer, and how much such a venture would cost. I'm a curious student, not a business man with capital and an idea to sell :)
Are there Libraries built into Object-C to handle such a task? Or will devices come with an SDK to make that software to hardware mesh?

Could someone lay the general idea down for me?
Bonus points for sticking around to answer any specifics I might have.
Bonus points and a brownie if you tell me that it's as easy to interface an analog signal with a Mac, as it is with an iPhone ;-)

Cheers!
~Tyler
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
You need to be a bit more specific. Is this analog signal a sound? If so you could just record it via the mic, then do whatever you want with the resulting digital data. I am guessing this is not it, but you didn't mention at all, so who knows? Essentially the first "hard" part of this is getting the analog signal digital and getting the digital signal in to your machine. Do you know if there's already something like this for the device in question that converts the signal into a digital format? If so, what interface is available (USB, Firewire, serial, parallel, etc)? If not, are you going to have to construct your own?

Once you have a means of digital acquisition of the raw data, you'll need a "driver" to actually gather this up and make it available on the system. I don't know much about how one goes about writing such a thing, but i'm betting others do.

Once you have this done, i would guess that the easiest step would be to interact with the device via C and system calls of some sort. Since Objective-C can call into C, C is Objective-C, etc. that seems like the most straight-forward to me. Once you have a means of pulling data from the device into a C routine, it should be pretty easy to manipulate in Objective-C from that point on.

Give some more information, and maybe someone will be able to point you in the right direction.

-Lee
 

Earendil

macrumors 68000
Original poster
Oct 27, 2003
1,599
89
Washington
I would love to give more details!
I have a couple analog signals I want to record. One is something like 0-5v and powers a gauge, the other is something more like 0-1v and can be thought of as something similar to a temperature sensor.

You are correct, it isn't sound. I'm aware of those kinds of input devices ;-)
But hey, if I could take the signal down to a safe voltage/amperage, and put it through the Mic jack and get the information I wanted from that, I suppose that could work...
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
I would love to give more details!
I have a couple analog signals I want to record. One is something like 0-5v and powers a gauge, the other is something more like 0-1v and can be thought of as something similar to a temperature sensor.

You are correct, it isn't sound. I'm aware of those kinds of input devices ;-)
But hey, if I could take the signal down to a safe voltage/amperage, and put it through the Mic jack and get the information I wanted from that, I suppose that could work...

You might be able to do something using a microcontroller with a USB port and an ADC (Analogue to Digital Converter). Could be quite a fun project actually.
 

Berlepsch

macrumors 6502
Oct 22, 2007
303
48
As lee said, for a real advice, we'd need to know more about the type of measurements you want to take - especially accuracy and sample rate.

One thing that I could suggest for near-static signals is buying a multimeter with RS232 interface plus a RS232 to USB adapter (all together $100 or less). If you are serious about playing with electronics, you'll need a good multimeter anyway, and communicating over the serial port is straightforward. Just make sure that you have documentation for the commands needed to control the instrument (and not only some Windows software).

For measurements of dynamic signals, you should probably first read up on data acquisition and A/D conversion; then you can look more specifically for suitable solutions. National Instruments (http://www.ni.com) offers a range of USB multifunction acquisition devices with OS X support; the cheapest is at $170 without academic rebate. Other than that, Google is your friend :)
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
How about one of these little things:-

http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove

I've a friend who's been playing around with one and he's been hooking it up to do all sorts of things on his Mac. It's got 6 analogues inputs 0 - 5v. The board is very cheap, Around £20 I think. It's well supported in Processing (the Java based IDE) on the Mac so is easy to program. Not sure about controlling one in Objective-C though.

b e n
 

trule

macrumors 6502
Mar 16, 2007
310
0
http://www.velleman.be/

They have a few kits. Basically you need something with a USB/Serial interface that your computer can 'talk' too, this something then takes care of the ADC tasks. There are plenty of kits that do this, but normally they are DOS/Windows focused so you may need to find Mac drivers or write your own.

http://www.vellemanprojects.com/ot/en/product/view/?id=351980
http://www.vellemanprojects.com/ot/en/product/view/?id=351346
http://www.vellemanprojects.com/ot/en/product/view/?id=364910

Linux driver that could work under mac
http://linuxk8055.free.fr/
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
How about one of these little things:-

http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove

I've a friend who's been playing around with one and he's been hooking it up to do all sorts of things on his Mac. It's got 6 analogues inputs 0 - 5v. The board is very cheap, Around £20 I think. It's well supported in Processing (the Java based IDE) on the Mac so is easy to program. Not sure about controlling one in Objective-C though.

b e n

My Dad has got one of those. They are pretty damn slick, and have an AVR microcontroller so technically you should be able to use them in the same way. They also come with their own Mac OS X IDE which actually works and uses a very C like language.
 

Martster

macrumors newbie
Feb 9, 2008
28
1
Van Diemen's Land
another vote for Arduino

I agree that the arduino boards seem like the best solution. Processing is easy to use and from what I've seen with a friends project the boards are well made too.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
My Dad has got one of those. They are pretty damn slick, and have an AVR microcontroller so technically you should be able to use them in the same way. They also come with their own Mac OS X IDE which actually works and uses a very C like language.

Sounds like you've got a pretty cool dad Cromulent!

Yeah the Arduino looks good. Think I'm going to get one myself.

b e n
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
Ugh... Arduino's...

I'm kind of an elitist when it comes to microcontrollers/microprocessors. What I don't understand is why don't you hook the circuit up to a Logic Analyzer or Oscilloscope with a USB attached to it?

From what I am reading it seems like you are just testing to see the data from a PWM (Pulse Width Modulator) and a temperature transducer...

Trust me on this one, being an ECE student (and in his senior year) you'd be better off using a Logic Analyzer, saving it as raw data onto a jump drive then analyzing that on your Mac. It's not a good idea to be using your Mac for grabbing signals without the proper system between the two to make sure your Mac or your circuit to be destroyed. Plus, once you understand how the data is working from a raw point, you can then develop a system to translate it for you to your Mac.

On a side note, it sounds really familiar to my senior design project... Hmmm... :rolleyes:
 

craig1410

macrumors 65816
Mar 22, 2007
1,130
911
Scotland
That little board above looks good but just in case you can't get hold of one, how about taking apart an old game controller and using the analogue axis controls for your own purposes? I would expect that the axes will simply be controlled by potentiometers which will "wipe" from +5v to 0v. You should be able to just connect the wiper to your 0-5 volt source and connect your ground to the game controller ground. Same with the 0-1v signal.

If you then use the drivers which came with the game controller then you should be able to use the OS X game controller API's to read the values. Note, I don't know anything about OS X game controller API's by the way... Maybe someone else can help with that. :)

I would suggest that you be very careful when interfacing to your Mac to avoid damage. Ideally use zener diodes or clamping diodes and current limiting resistors to prevent your inputs from going beyond the working voltage of the interface. Something like a 5v1 reverse biased zener across the input with a 100 ohm resistor in series with your input signal.

I hope this helps,
Craig.
 

Earendil

macrumors 68000
Original poster
Oct 27, 2003
1,599
89
Washington
Ugh... Arduino's...

I'm kind of an elitist when it comes to microcontrollers/microprocessors. What I don't understand is why don't you hook the circuit up to a Logic Analyzer or Oscilloscope with a USB attached to it?

Cost? Don't Oscilloscopes and Logic Analyzers at least $100, with good ones being $500-$1000?
I'm all for being elitist (I'm on a Apple forum, right? ;) ) but cost is a prohibiting factor.

Besides, as long as I'm using a common board like the Arduino, shouldn't that be adequate protection for my computer? Assuming the signals going into the board are already pretty docile, the output can't get too out of wack.

On a side note, it sounds really familiar to my senior design project... Hmmm... :rolleyes:

I'm in an Electronics class for my senior year in CS, so I'm getting my feet wet with this type of stuff. But there is still a our knowledge base that I lack when it comes to getting instrument signals into a computer where I can access them with my code :)
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
Your university should have Oscilloscopes and Logic Analyzers for you to use. Also, yes the Arduino has sufficient protection against weird signals to your Mac, but the Arduino has a different C syntax than what most microcontrollers use, which in my opinion is bad.

The Arduino is a great dev board for a hobbyist, but if you want to learn things properly, you should be doing it the hard way of programming, and learn straight up C, not this hybrid BS for people who don't know how to program.

To help you out understanding signals, look into getting a couple of my professor's text books.

http://wwweng.uwyo.edu/electrical/faculty/barrett/68hc12/

His book mainly focuses on the Motorola Freescale line, but a lot of subsystems are in all the other controllers. Plus, there are timing diagrams for you to look at!

BTW, what kind of Electronics class is this? A Microprocessor's class, basic transistor/VLSI class? Etc...
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
Your university should have Oscilloscopes and Logic Analyzers for you to use. Also, yes the Arduino has sufficient protection against weird signals to your Mac, but the Arduino has a different C syntax than what most microcontrollers use, which in my opinion is bad.

The Arduino is a great dev board for a hobbyist, but if you want to learn things properly, you should be doing it the hard way of programming, and learn straight up C, not this hybrid BS for people who don't know how to program.

There is nothing stopping you from dropping down into ASM as far as I know. The Arduino is after all an AVR microcontroller.
 

autorelease

macrumors regular
Oct 13, 2008
144
0
Achewood, CA
I haven't used it, but the Teensy USB (http://www.pjrc.com/teensy/) is a $20 board with an AVR microcontroller, a full-speed USB interface, and Mac software. Code can be uploaded via the USB cable, so no expensive programming cable is required.

You'll probably want to read the AT90USB162 datasheet to find out how to use the analog-to-digital converter (ADC). If you find the datasheet too scary, you might be better off with an Arduino :p
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
There is nothing stopping you from dropping down into ASM as far as I know. The Arduino is after all an AVR microcontroller.

Very true. All I'm saying is that to learn things properly, it's better to know exactly how and why it's working rather than have a board handed to you with a few pages of documentation.

Doing it in ASM would definitely be awesome to do on the board, but you might run into an issue with ADC (Analog-to-Digital Converter) processing. Mainly if you want to have the thing interrupt based rather than polling.
 

Gruffalo

macrumors newbie
Jan 27, 2006
13
0
http://www.velleman.be/

They have a few kits. Basically you need something with a USB/Serial interface that your computer can 'talk' too, this something then takes care of the ADC tasks. There are plenty of kits that do this, but normally they are DOS/Windows focused so you may need to find Mac drivers or write your own.

http://www.vellemanprojects.com/ot/en/product/view/?id=351980
http://www.vellemanprojects.com/ot/en/product/view/?id=351346
http://www.vellemanprojects.com/ot/en/product/view/?id=364910

Linux driver that could work under mac
http://linuxk8055.free.fr/

Or alternatively, you could use this one along with its nifty looking test UI application. The 8055 board only has 2 analog inputs though and they aren't terribly sensitive as the device only has an 8-bit DAC.
 

mcmadhatter

macrumors 6502
Sep 6, 2005
338
2
Bath, UK
I'm an arduino as a model railway controller, I use the analog pins to detect and measure the back emf of a locomotive. It even sends/recieves UDP packets with data to/from my macbook via my network using an ethernet shield.


The Arduino is a great dev board for a hobbyist, but if you want to learn things properly, you should be doing it the hard way of programming, and learn straight up C, not this hybrid BS for people who don't know how to program.

It's not hybrid BS, you can use normal C with arduino. Personally I don't like the arduino IDE, and prefer working in straight normal C or ASM. I use a plug in for textmate and a modified makefile to compile my C/C++/ASM code from the command line. It is also possilbe to use the eclipse IDE as well. At the end of the day you can code and program it as you would any AVR chip using avr-gcc and avr-dude.

I would recommend getting the seeeduino variant of the arduino , as it has two extra ADC pins. I'd download the arduino software, at least it has example code for reading in analog values from things like temprature sensors amongst other things.

PM me if you want a copy of the makefile, or a hand getting started with arduino
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
It's not hybrid BS, you can use normal C with arduino.

If you use the Arduino IDE with default, it is hybrid. It uses a hybrid C and their language to do the job, but that's getting into symantics. Besides, why use one of those when you can get your own microcontroller/microprocessor for like 20 bucks and make a customized layout/board for it? You'll have better known and more appreciation for doing it that way.
 

Earendil

macrumors 68000
Original poster
Oct 27, 2003
1,599
89
Washington
Besides, why use one of those when you can get your own microcontroller/microprocessor for like 20 bucks and make a customized layout/board for it? You'll have better known and more appreciation for doing it that way.

Well to name one of millions... I want to learn more than I have time and resouces for. So, my options are to not mess around with the electronics world for fear I won't "fully appreciate it", or that I won't understand it "fully". Or I can get a general understanding, and use electronic devices as additions to MY world and choice of education, computer science/software engineering.

I understand where you're coming from, as I feel the same about visual basic vs c++ etc. How ever I would be happy if every human new visual basic than what the current situation is(that is one of worse that no knowledge, but misconception). Any, that is mho, take it or leave it :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.