Shop OBEX P1 Docs P2 Docs Learn Events
Viewport Ultimate verifies I am passing values between cogs, yet values cannot — Parallax Forums

Viewport Ultimate verifies I am passing values between cogs, yet values cannot

scidogscidog Posts: 4
edited 2009-10-23 05:05 in Propeller 1
Hello,

In the attached SPIN files I use "BAX_POT2LTC12982MOTS_09.spin" to call "bax_LTC1298_getADC.spin" .

I used Viewport Ultimate to verify that the values for variables ADCX and ADCY are indeed being passed from the first cognew to the second cognew.

For some reason, any attempt to use the values of ADCX and ADCY in a waitcnt command just gags.

The SPIN file compiles an runs just fine, but if I use a line like

deltaTclicksMotX := clkfreq/ADCX

I simply get zeros for the Viewport monitired quantities "v1" and "v2".



On the other hand

deltaTclicksMotX := clkfreq/1000

works just fine, and my stepper motors turn correctly as the !outa[noparse]/noparse commands click off pin state changes at the rate dictated by the waitcnt commands.


My intent is to adjust the rate at which the !outa[noparse]/noparse statements execute via use of the value ADCX, but ADCX does neither seem to behave as a long.

I am new to this stuff, so my attached files should clear up any gaps in the above explanation.



Any help is appreciated in advance,

scidog

Comments

  • mparkmpark Posts: 1,305
    edited 2009-10-22 21:22
    What does "gags" mean here? What happens if you wait about 50 seconds?
  • scidogscidog Posts: 4
    edited 2009-10-22 22:01
    All I am saying is that the attached code indicates these things:

    1.) The values ADCX and ADCY are being passed from one cog to the other.

    2.) The values for ADCX and ADCY behave as numbers and can be divided, multiplied, etc. within the second cognew's called method.

    3.) Since ADCX and ADCY are indeed acting as numbers, one should (should) be able to use them in a waitcnt command to dictate the time between successive !outa[noparse]/noparse statements, and thus control the rate at which the pin changes state. (The rate of pin state change hi/lo dictates how fast my stepper motors turn because that's the kind of circuit I have hooked up.

    BUT...

    4.) When I try to use the values ADCX or ADCY in commands like those below, the motors do not turn and monitired values v1 and v2 show up as zero and stay at zero, the motors do not turn, but the program compiles and runs...it just does nothing.

    deltaTclicksMotX := clkfreq/ADCX (a typical value for ADCX is about 2200)
    waitcnt (TclicksMotX += deltaTclicksMotX)


    In short, I cannot use ADCX or ADCY in any waitcnt calculations and have the program work as intended.

    I hope that helps.

    scidog
  • mparkmpark Posts: 1,305
    edited 2009-10-22 22:16
    I'm just wondering if maybe the program starts behaving as expected if you wait about 50 seconds.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-23 05:05
    Normally one uses commands like this for waitcnt in SPIN:

    waitcnt(clkfreq*2 + cnt) ' 2 second delay
    waitcnt(clkfreq/1000 * milliseconds + cnt)    ' reasonably accurate
    waitcnt(clkfreq/1000000 * microseconds + cnt) ' less accurate because of spin overhead
    
    
Sign In or Register to comment.