Shop OBEX P1 Docs P2 Docs Learn Events
I give up - Need Help — Parallax Forums

I give up - Need Help

RubberduckRubberduck Posts: 11
edited 2008-01-12 11:43 in Propeller 1
Hello Forum

I need some help with the posted files. I try to explain my problem.·In the "Main",·I start a reading·of a·MCP3208 AD. "child" reads all 8 channels and store them. Then it should put the results back in a array in "main". The result of 5 channels is "transmitted" as it should. But 3 is not. And I can't figure out why. Just to test I write "123"·rather then·the·real value from AD.

I'am looking for speed in my application so if anyone find something that could be improved please let me know (probably a bunch of stuff smilewinkgrin.gif .


Thanks
Andreas

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-01-10 18:01
    This is no good:
    ...
    t4                      res     1
    adc                     word    8
    command                 res     1                       ' for 3208 routine
    ....
    


    You wanted
    adc RES 8
    I presume?
  • RubberduckRubberduck Posts: 11
    edited 2008-01-10 20:04
    Thx deSilva for the quick respons

    That solved the problem. Why did it work for the first·and 5-8th channel?

    But my idea was to store the values in 8 words. And then "transfer" 4 longs·to save some instr (I know that I'm not "transfering" longs at the moment but I want to in the future). Does that make sense? Is it possible?

    word 1-
    word 2 - long 1

    word 3 -
    word 4 - long 2

    word 5 -
    word 6 - long 3

    word 7 -
    word 8 - long 4

    /andreas
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-10 22:35
    Well it's not clear to me what all your timing constraints are:

    With words you can transfer 8 of them in:
    WRWORD adc,   dest
    ADD dest, #2
    WRWORD  adc+1, dest
    ADD dest, #2
    WRWORD adc+2,dest
    ADD dest, #2
    WRWORD adc+3, dest
    ADD dest, #2
    WRWORD adc+4, dest
    ADD dest, #2
    WRWORD adc+5, dest
    ADD dest, #2
    WRWORD adc+6, dest
    ADD dest, #2
    WRWORD adc+7, dest
    


    8*16 ticks =1.6 µs = 600 kHz

    This delays the sampling.. I have not counted what the sampling part takes..
    But there is little chance you can do ANYTHING at all in SPIN at this fast pace...

    Post Edited (deSilva) : 1/11/2008 12:37:24 AM GMT
  • bambinobambino Posts: 789
    edited 2008-01-10 23:52
    Andreas, Here is some code for spi using two cogs. It no doubt "is not" what you need, but will give you a concept of how to get more speed from an spi. I actually used three cogs, one to write, one to read, and one to validate my readings and stop the recording when I found what I wanted in the circular buffer.
    http://forums.parallax.com/forums/default.aspx?f=25&m=168330

    Again, it is not a general purpose spi, But maybe it will give you an idea or two!
  • mynet43mynet43 Posts: 644
    edited 2008-01-11 01:17
    Andreas,

    I see you modified my assembly code from the object exchange (MCP3208_fast).

    Enjoy!

    Jim
  • RubberduckRubberduck Posts: 11
    edited 2008-01-11 17:48
    deSilva:
    The program I posted is not all of it - it doesn't show what I really want to do. My goal is to fill a buffer (512 bytes) in child. And then in spin write that buffer to a SD-card. While the Main is writing the first buffer, child will fill a second buffer of 512 bytes. As you all have figured out I'am new to the propeller - but could this be a good way to do it? Or is there an better way to do that?

    bambino:
    Maybe I'am wrong but I don't think the AD can handle more speed. But maybe I can use it for the SD-card to speed things up...

    Jim:
    Yes, a big thanks - the object exchange is a life saver! Hopefully I can contribute in the future [noparse]:)[/noparse]

    Thanks to You all for your ideas and your time

    /Andreas
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-11 17:56
    Andreas, you have to get a more precise feeling of where time is spent... There are huge diferences between SPIN and machine code; a factor of 2 or 3 can be gained or lost be different instruction scheduling.

    But it needs that you exactly count and calculate the time needed for all steps...
  • mynet43mynet43 Posts: 644
    edited 2008-01-11 18:24
    Andreas,

    You said you think the A/D can handle more speed. The code that you're using (MCP3208_fast) has been tuned to sample the MCP3208 at the fastest speed allowed by the chip specifications.

    You can increase the adc sample speed by over-clocking it. I've experimented with this and the chip seems to handle a faster speed without a problem. However, I didn't want to release something to the object exchange that operated outside of the chip specs.

    Let me know if you need more help with this.

    Jim
  • RubberduckRubberduck Posts: 11
    edited 2008-01-12 11:43
    deSilva:
    Okej - I continue with the work and when I have a working program - I hopefully will be able to see where I have the bottlenecks.

    Jim:
    Actually I didn't think the AD could handle more speed. And as for the code MCP3208_fast I didn't that could be improved either (take that as a compliment). But that sounds great - I never thought about overclocking the AD. But as for now I need to get the rest of the code working as I want. And later on I may hold you to your word [noparse]:D[/noparse].
    How much did you overclock the AD?

    Thx
    Andreas
Sign In or Register to comment.