PDA

View Full Version : MCP3208 Obejct?



Jim Fouch
02-12-2007, 11:27 AM
I was wondering if anyone has use the MCP3208 object that is in the samples?

I modified it to be used with a MCP3304 and it works great. However, I need to be able to access it's values (ADC Readings) from more than one cog. In my design I will start the MCP3304 object and have it run continuously. In my main cog I will set up an array and pass the pointer to the MCP3304. Other objects will be started that will also receive a pointer to this Array. This way the other objects will be able to see what values the MCP3304 is reading.

My only problem is I can't figure out where in the assembly of the MCP3304 code I should copy the new readings into the global array.

I have attached a copy of my current MCP3304 driver.

thanks,

Jim

RytonMike
02-12-2007, 04:50 PM
This may just be my incompetence…
Where exactly was the original 3208 object posted? I can’t find it in the exchange.

Jim Fouch
02-12-2007, 10:36 PM
I did find a way to make the driver work the way I wanted...

I just created the array for the readings in the Main cog, then sent the address to the MCP3304 driver and it uses that address to store it's readings in. I then also sent that same address to the other two cogs that needed to access the readings. This way they all share access to a common area of RAM. I will need to add code that will lock access to the readings while the MCP3304 driver is writing to it.

Graham Stabler
02-12-2007, 10:40 PM
Do you need to lock it? Will the other code actually write to that data rather than just read it?

Graham

Jim Fouch
02-12-2007, 10:42 PM
No other code will write it the shared memory, But couldn't I read in the middle of a write and get a partial (Invalid) reading?

RytonMike
02-13-2007, 12:27 AM
Excuse my persistence, Jim, but could you tell me where can I find the original mcp3208.spin object?

Paul Baker
02-13-2007, 03:35 AM
It is in the distribution of the Propeller Tool along with the other example objects.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

RytonMike
02-13-2007, 03:49 AM
Thanks Paul.
Jim pointed this out to me privately.
My eyes must be growing dim with old age!

Mike

Jim Fouch
02-13-2007, 03:54 AM
Paul,

What is Parallax's position with customers modifying existing examples and posting the code for other customer to use? I just ask because of the copyright notice at the top of the examples.

I'm not sure if others could use my modified version, but it would be nice to know I could post it.

Thanks,

Jim

Paul Baker
02-13-2007, 04:00 AM
Feel free to modify, just make mention of your source.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)