Shop OBEX P1 Docs P2 Docs Learn Events
MCP3208 Obejct? — Parallax Forums

MCP3208 Obejct?

Jim FouchJim Fouch Posts: 395
edited 2007-02-12 20:00 in Propeller 1
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

Comments

  • RytonMikeRytonMike Posts: 12
    edited 2007-02-12 08:50
    This may just be my incompetence…
    Where exactly was the original 3208 object posted? I can’t find it in the exchange.
  • Jim FouchJim Fouch Posts: 395
    edited 2007-02-12 14:36
    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 StablerGraham Stabler Posts: 2,510
    edited 2007-02-12 14:40
    Do you need to lock it? Will the other code actually write to that data rather than just read it?

    Graham
  • Jim FouchJim Fouch Posts: 395
    edited 2007-02-12 14:42
    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?
  • RytonMikeRytonMike Posts: 12
    edited 2007-02-12 16:27
    Excuse my persistence, Jim, but could you tell me where can I find the original mcp3208.spin object?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-02-12 19:35
    It is in the distribution of the Propeller Tool along with the other example objects.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • RytonMikeRytonMike Posts: 12
    edited 2007-02-12 19:49
    Thanks Paul.
    Jim pointed this out to me privately.
    My eyes must be growing dim with old age!

    Mike
  • Jim FouchJim Fouch Posts: 395
    edited 2007-02-12 19:54
    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 BakerPaul Baker Posts: 6,351
    edited 2007-02-12 20:00
    Feel free to modify, just make mention of your source.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.