Shop OBEX P1 Docs P2 Docs Learn Events
Multiple ADC's — Parallax Forums

Multiple ADC's

TJHJTJHJ Posts: 243
edited 2008-07-01 13:15 in Propeller 1
Hello again all,
So I am trying to get reading from 4 lt1298 - 12 bit adc's. I seem to be struggling trying to get them all to interface up with out burning up 4+ cogs in the process.

So here is the problem I think if I use the standard object for this adc, CD-LT1298 from the OBEX, each time I initialize a new adc it starts up a new Full duplex Serial set, taking up 2 cogs. I think.... Unless its not working that way and just changing the send receive pins each time I call the ADC to get the data. THis would be ideal and how I would treat it if going to re write the driver.


I just wanted to check before I tried to re write the drivers, is there a neat trick work around for this? Or would it be worth it to Start the adc, get data, stop it.. open next one repeat. it is not that speed critical, but I only have 2 free cogs in the app as of now.




It leaves to a side note question, there are many objects that call full duplex serial, each time one of these is called does it start up a new cog or 2 to run the communications? Or is full duplex serial smarter than me, and just looks for the send receive data for what ever set of pins that object wants it to?

Thanks again and as always,
TJ

Comments

  • TJHJTJHJ Posts: 243
    edited 2008-07-01 13:11
    Um wow, I have got to stop posting 1st thing after I wake up....

    So go ahead and disregard that adc's problem, they never call full duplex serial... Doh, all i need to do is change it slightly to change the com pins when I need to go to a different adc...

    Sorry
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-01 13:15
    The LT1298 does not use asynchronous serial I/O. It's an SPI protocol device so I don't see why it should use FullDuplexSerial. I haven't looked lately at the driver in the OBEX, but I suspect it does launch a cog to be able to overlap reading from the LT1298 with other work. If you don't need the overlap, there's no requirement that it be there. SPI is simple and should only take a few lines of Spin to do and there's no reason why your code can't read different ADCs in succession, all with the same cog.

    Each declaration (instance) of FullDuplexSerial starts up a new cog when you call the "start" method. The instance saves the cog number used and, if you call the "stop" method or if you call the "start" method again, it first stops the running cog before starting a new one. The reason for this is that there are shared variables and the buffers and it wouldn't work to have two cogs trying to change the same variables at the same time.

    You can have more than one instance of FullDuplexSerial (or any other driver) running at the same time. This works because there's a separate copy of the variables for each declared instance. They do have to be initialized to use different I/O pin numbers as you might expect.
Sign In or Register to comment.