Shop OBEX P1 Docs P2 Docs Learn Events
New guy is lost ~~ Simple program doesn't execute correctly — Parallax Forums

New guy is lost ~~ Simple program doesn't execute correctly

JetManJetMan Posts: 39
edited 2010-04-11 01:23 in Propeller 1
I have created an extremely simple program that fires one output on and off yet all i get is one quick high pulse on the pin then nothing !!!!

Every download produces one quick pulse on the pin , yet never executes any commands after the first outa

[noparse][[/noparse]code]
CON
_clkmode = RCFAST


PUB MotorOnOff

dira[noparse][[/noparse]14..12] := %101

repeat

!outa[noparse][[/noparse]12]
waitcnt (500 + cnt)
!outa[noparse][[/noparse]14]
/[noparse][[/noparse]code]

Comments

  • JetManJetMan Posts: 39
    edited 2010-04-10 02:50
    ok code objects didn't work , proper indentation is used in the actual program
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 03:08
    Try changing the waitcnt to

    waitcnt(clkfreq/2 + cnt)

    Also the "/" goes inside the brackets.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-10 03:12
    The slash ("/") has to be inside the brackets as in "/code".

    If the indenting is indeed correct, what you posted should work ... toggle pin 12, then toggle again every 50us or so. Pin 14 will toggle roughly opposite to pin 12, again roughly every 50us or so depending on the actual clock speed with the RCFAST clock (8 to 20MHz).

    You might slow this down by increasing the "500" in the waitcnt so you can more easily see what the program is doing.
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:12
    yeah already tried that and again still no dice , it's almost like only the first line executes for a brief second then everything halts . Is it necessary to do anything with the external resonator pins when not using them ?? tie to ground or okay to leave floating ? Power supply is good at 3.3vdc dead on communication with pc is flawless I don't understand why such a simple program will not execute correctly ?!

    CON
      _clkmode = RCFAST
    
    
    PUB MotorOnOff
    
      dira[noparse][[/noparse]14..12] := %101
    
       repeat
    
          !outa[noparse][[/noparse]12]
          waitcnt (clkfreq/2 + cnt)
          !outa[noparse][[/noparse]14]
    
    
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:14
    well than I quit !!!!!!!!!!!!! I have played with the timing just to see if it made any change in noticeable performance and nothing 50 , 500 , 5_000 , 50_000 all the nsame one quick burst from p12 and nota out of p14
  • kuronekokuroneko Posts: 3,623
    edited 2010-04-10 03:24
    What happens if you toggle only pin 12, i.e.

    PUB MotorOnOff
    
      dira[noparse][[/noparse]12]~~
    
       repeat
          !outa[noparse][[/noparse]12]
          waitcnt (clkfreq/2 + cnt)
    
    


    I could be wrong but it looks like setting pin 14 to HIGH kills your setup, a short maybe?

    BTW, your code clearly works, I just tested it (using different pins).
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:28
    Nope no shorts did that already as well , this is something beyond basic code structure or shorts. I have two n-Chanel mosfet pairs switched through two separate opto's that control my motors and when I apply 3.3vdc to the input side of the opto with out the prop attached i get a good strong solid motor on on both channels. Is it possible that there is some erroneous data in the prop that is not cleared when the unit is programmed ?
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-04-10 03:34
    f you go back to this code...

    CON
    ··_clkmode·=·RCFAST


    PUB·MotorOnOff

    ··dira[noparse][[/noparse]14..12]·:=·%101

    ···repeat

    ······!outa[noparse][[/noparse]12]
    ······waitcnt·(clkfreq/2·+·cnt)
    ······!outa[noparse][[/noparse]14]

    And add a waitcnt delay line after '!outa[noparse][[/noparse]14]', does it change? Could it be the sample rate?
    J-

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent!
    Send $1 to CannibalRobotics.com.
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:39
    no change , tried that as well . what i am noticing is that no matter what i do it seems to igonore every command except for high on whatever pin i designate then executes a very quick high and stops running. doesn't matter how i assemble the code or what form or function i use .

    I've tried everything from outa[noparse][[/noparse]12] := 1 to out[noparse][[/noparse]14] := 1 , to the old !outa[noparse][[/noparse]12] all produce the same results , one quick pulse on whatever pin i have specified and then dead.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-10 03:40
    Nope. I tried your program using LEDs on the I/O pins and it works fine

    There's something in how you have things wired that's probably causing the Propeller to reset ... some kind of short.
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:46
    Ok I've humored myself and put the prop on a solder-less board connected only to 3.3vdc and laptop. fluke 87 v attached to p12 and same thing happens quick pulse after download then back to low condition permanently . Is there such thing as a bad chip ?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-10 03:54
    Sure, there's always the possibility of a bad chip, but the Propeller is normally very robust.

    Have you connected all of the Vdd pins to 3.3V and all of the Vss pins to ground? Have you used bypass capacitors (0.1uF ceramic) on all of the Vdd/Vss pairs?

    Have you grounded the BOEn pin?
  • JetManJetMan Posts: 39
    edited 2010-04-10 03:58
    Yes to everything minus the bypass caps , I suppose i can throw a couple on quick and just see what happens . although my 3.3 vreg has same on its pins just a block or so away ? It's worth a shot .
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 04:00
    Does it behave the same way if you download the program to EEPROM?

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • JetManJetMan Posts: 39
    edited 2010-04-10 04:05
    I aint got no eeprom , just ram on prop.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 04:07
    Are you absolutely sure that it is not a power problem? Try fresh batteries just to eliminate the possibility.

    Rich h

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • JetManJetMan Posts: 39
    edited 2010-04-10 04:22
    There's no place for batteries ?
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 04:39
    No batteries eh? And you are sure that there are no shorts?

    Okay then, is there any more to your program that what you posted? If so, that could be the problem. Otherwise I think the next step is to show us some pictures of your setup and post the code you are running as an attachment.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • JetManJetMan Posts: 39
    edited 2010-04-10 05:41
    www.gstsllc.com/prototype_pics

    site to view and download pics , two with comments

    .spin files are attached.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 05:59
    Holy Toledo! You got a lot going on there! Unfortunately, we can't see the details of how you have it wired up.

    Can you remove the Propeller chip and put it in a breadboard with a LED just to test it? That would be the simplest way I think to determine if the chip is defective.

    You could also remove the chip then measure the resistance from pin 14 to ground to see if there are any hidden shorts.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • JetManJetMan Posts: 39
    edited 2010-04-10 06:04
    1.) How'd you know i was in Toledo ?? Must be an armature radio thing ?

    2.) Already did both of the above I truly believe ram is damaged on chip it acts the same even on the old solderless breadboard with only a simple red led connected.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-10 06:47
    JetMan said...
    1.) How'd you know i was in Toledo ?? Must be an armature radio thing ?

    2.) Already did both of the above I truly believe ram is damaged on chip it acts the same even on the old solderless breadboard with only a simple red led connected.

    1.) It was your accent. smile.gif

    2.) I don't know what would be wrong with it but if it doesn't work to toggle a simple LED then I would agree that something is fried on the chip.

    Note that if you are using Spin.2 2.spin to test it with an LED that it will be toggling much too fast to see. That's where the waitcnt(clkfreq/2 + cnt) comes in.
    CON
      _clkmode = RCFAST
      
    
    
    PUB MotorOnOff
    
      dira[noparse][[/noparse]14] := 1
    
       repeat 
      
          !outa[noparse][[/noparse]14]
          waitcnt (clkfreq/2 + cnt)
    



    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 4/10/2010 5:49:43 PM GMT
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-04-10 07:51
    Jet, the fact that your program loaded successfully into the chip means that it's good. I don't know what your were doing with spin.1 but that would leave the outputs on. Bear in mind that RCFAST is around 12MHz or around 83ns and you have set a delay for 500 times that which is only 42us. Even if you set that to 50,000 it is still too fast at 4.2ms. Try 5_000_000 instead.

    BTW, I just noticed that clkfreq/2 which should work as well but a constant is a constant.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*

    Post Edited (Peter Jakacki) : 4/10/2010 8:04:23 AM GMT
  • JetManJetMan Posts: 39
    edited 2010-04-10 14:05
    Again though I must reiterate that even if I skip the whole toggle portion and skip the repeat command and simply execute a high on p12 or any output designated by dira to be such, it only goes high for a fraction of a second and then stops. so it's not a timing issue because it does it whether i try to toggle the pin or not and i have tried everything from 500_000_000 to 50 and also tried clkfreq/2 , clkfreq/4 .

    What interests me is that the last two posts referred to what are apparently two different versions of spin ? spin1 and spin2 please explain as maybe this is my issue ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Landon Leigh
  • Shawn LoweShawn Lowe Posts: 635
    edited 2010-04-10 15:24
    1.spin and 2.spin are your versions of programs. Rich just reversed the names

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • mikedivmikediv Posts: 825
    edited 2010-04-11 01:23
    jetman tried your code it works fine I just have a prop chip with a prop plug connected to oscilloscope on bread board I would have to say it has to be something in the way you have it wired or a bad chip I had a prop stick usb that had 5 bad pins the rest of the thing worked fine just not those 5 pins
Sign In or Register to comment.